Write failures and proper error code return to clients

Jeremy Allison jra at samba.org
Mon Jul 24 23:42:22 GMT 2006


On Sat, Jul 22, 2006 at 06:53:30AM +0300, Shlomi Yaakobovich wrote:
> Hi,
>  
> We've recently ran into situations when the pwrite system call fails. I've noticed that on -1 return code, a "disk full" error is returned to the user. For example, in reply_write_and_X:
>  
>  if (nwritten < (ssize_t)numtowrite) {
> SCVAL(outbuf,smb_rcls,ERRHRD);
> SSVAL(outbuf,smb_err,ERRdiskfull);      
> }
> 
> I saw no attempt to look at the exact errno, and attempt to return a more valid error code.

Ok, I've now had time to look at this.
You missed this code in reply_write_and_X() :

        if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
                END_PROFILE(SMBwriteX);
                return(UNIXERROR(ERRHRD,ERRdiskfull));
        }

UNIXERROR looks at errno. What is errno set to in your
particular case ? The default of ERRdiskfull is only
returned if errno == 0.

The code you complain about is a fallback case just in case
there are some systems where write returns less than was
requested on ENOSPC. It should never be true on a working POSIX
system.

> Furthermore, perhaps it is worth while thinking of retrying the call (e.g. if errno is EINTR) instead of returning an error to the client ?  We've noted that some applications don't behave well to "disk full" error, and abort their operations.

As noted before, this can't happen on disk writes except
for soft mounts.

Jeremy.


More information about the samba-technical mailing list