[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: open - resource temporarily unavailable



 <tomas <at> tuxteam.de> writes:

> 
> 
> On Fri, Jun 17, 2016 at 11:06:15AM +0000, Andrey wrote:
> >  <tomas <at> tuxteam.de> writes:
> 
> [...]
> 
> > > If the problem is somehow repeatable [...]
> 
> > It happens very rare and rather unpredictable 
> > sometimes when a lot of files are created
> > and sometimes without such obvious signs.
> 
> Darn. This makes the problem "interesting".
> 
> > > Other things to check: does that happen on any files? On a
> > > specific file system? If yes: how is that one mounted?
> > > 
> > 
> > It happens to any file on any ext4 partition which are locally mounted.
> > 
> > Is there a way to find out at least which part of the system is responsible
> > for 'resource temporarily unavailable'.
> 
> OK. I've got one more hint. Reading through the open(2) man page
> (assuming it is really open what's failing on you -- what evidence
> do you have?),

well, although it may be not convincing to you:
in Tcl it's return from -
'open $fname w'
from man open(3tcl):
'w  Open  the  file  for  writing only.  Truncate it if it exists.  If it
     does not exist, create a new file.'

which is translated to libc open
open (fname, O_CREAT|O_WRONLY|O_TRUNC) (or create())


> EAGAIN isn't listed among the possible errno values,
> but EWOULDBLOCK
> 
>    EWOULDBLOCK
>           The O_NONBLOCK flag was specified, and an incompatible
>           lease was held on the file (see fcntl(2)).
>

But in my case it's normal - not NONBLOCK file

> Now, on POSIX systems EWOULDBLOCK and EAGAIN could be one and the
> same. Lo and behold, a small test program on my box reveals that
> both at least translate to 'Resource temporarily unavailable':
> 
>     #include <stdio.h>
>     #include <errno.h>
>     #include <string.h>
> 
>     int main(int argc, char *argv[])
>     {
>      printf("EAGAIN is '%s'\n"
>             "EWOULDBLOCK is '%s'\n",
>             strerror(EAGAIN),
>             strerror(EWOULDBLOCK));
>     }
> 
>     ==>
> 
>     tomas <at> rasputin:~/prog/C$ ./errno
>     EAGAIN is 'Resource temporarily unavailable'
>     EWOULDBLOCK is 'Resource temporarily unavailable'
> 
> This will all depend on things like kernel version, libc and whatnot,
> but the most likely candidate at the moment seems to be the app playing
> games with fcntl leases.
> 

how it could be when I tried to save a file from Emacs and got 'Resource
temporarily unavailable'

well, I included all open(2) errors in your test:

int nerr[]={EACCES,EEXIST,EFAULT,EFBIG,EINTR,EINVAL,EISDIR,ELOOP,
	    EMFILE,ENAMETOOLONG,ENODEV,ENOENT,ENOMEM,ENOSPC,ENOTDIR,ENXIO,
	    EOPNOTSUPP,EOVERFLOW,EPERM,EROFS,ETXTBSY,EWOULDBLOCK};
char
*terr[]={"EACCES","EEXIST","EFAULT","EFBIG","EINTR","EINVAL","EISDIR","ELOOP",
	     
"EMFILE","ENAMETOOLONG","ENODEV","ENOENT","ENOMEM","ENOSPC","ENOTDIR","ENXIO",
	      "EOPNOTSUPP","EOVERFLOW","EPERM","EROFS","ETXTBSY","EWOULDBLOCK"};
	    
int main(int argc, char *argv[])
{ int i;
  for (i=0; i<sizeof(nerr)/sizeof(int); i++) {
    printf("%s - %s\n", terr[i], strerror(nerr[i]));
  }
}

serv:~$ ./errno |grep -i resource
EWOULDBLOCK - Resource temporarily unavailable

but it isn't the case, there aren't any muddling with fcntl leases -
 it's plain straight forward file create which could be BLOCKED for a while
but never denied

It may not appear for a week and
then one day I get the error three times but always unexpected :(

I can't trace every file access but
what would help me, I think, if there is a way to get the error in some log.


regards,
  Andrey




Reply to: