[linux-cifs-client] ENOSPC without O_SYNC

Jeff Layton jlayton at poochiereds.net
Fri Jul 18 21:12:53 GMT 2008


On Fri, 18 Jul 2008 16:10:12 -0400
Jeff Layton <jlayton at redhat.com> wrote:

> On Fri, 18 Jul 2008 17:21:05 +0200
> Oliver Martin <oliver.martin at student.tuwien.ac.at> wrote:
> 
> > Hello,
> > 
> > as of 2.6.26, the cifs kernel driver doesn't return ENOSPC on write()
> > if the file system on the server is full if the file is opened without
> > O_SYNC. 
> 
> To my knowledge, CIFS has never done this on async writes. Writes are
> buffered up and then flushed in the background. As long as the data is
> successfully written to memory, then the write is allowed to return.
> 
> > ENOSPC is only returned on close(), but the man page doesn't
> > even mention it as a possible errno value there.
> 
> Sounds like an omission in the close(2) manpage (or maybe the posix
> spec). If it's really a problem we could translate that into EIO, I
> suppose.
> 
> > It works correctly with
> > O_SYNC set.
> > Is that intended? It caused problems for me when I made a backup with
> > dar and forgot to tell it to pause after each slice so I could mount
> > another share. It's supposed to stop when it runs out of space, but it
> > kept copying data right into nowhere.
> 
> What's supposed to stop? To quote the write(2) manpage:
> 
> A  successful return from write() does not make any guarantee that data
> has been committed to disk.  In fact, on some buggy implementations, it
> does  not  even guarantee that space has successfully been reserved for
> the data.  The only way to be sure is to call fsync(2)  after  you  are
> done writing all your data.
> 
> ...if you're not calling fsync() then there are no consistency
> guarantees here.
> 
> > It dosen't matter if the server is Samba or Windows and it works with
> > fusesmb, so I suspect the problem is in the cifs module. Unfortunately,
> > I couldn't try smbfs because Debian has replaced mount.smbfs with a
> > wrapper around mount.cifs and I don't have any other distro here at the
> > moment.
> > 
> 
> fusesmb is probably doing synchronous writes.
> 
> > Simple way to reproduce: Make a small loopback device, share it with
> > Samba, and fill it with something. Then use this small program to try
> > to create new files with and without O_SYNC and see the difference.
> > 
> 
> What might be nice is at some point to implement the solution that nfs
> did a year or so ago and make it so that when writes to a file start
> failing cifs would flip to using synchronous writes. That's really just
> a "nice to have" though.
> 
> Cheers,

Forgot to mention, that there's another potential workaround...

You can mount with the "directio" mount option and that should also
give you the effect you're looking for, though it'll probably slow
things down vs. the buffered write situation.

-- 
Jeff Layton <jlayton at poochiereds.net>


More information about the linux-cifs-client mailing list