Re: Question regarding CIFS cache=loose behavior.

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

 



On Fri, 21 Mar 2014 12:56:34 +0400
Pavel Shilovsky <piastryyy@xxxxxxxxx> wrote:

> 2014-03-21 3:10 GMT+04:00 Jeff Layton <jlayton@xxxxxxxxxx>:
> > On Fri, 21 Mar 2014 05:56:04 +0900
> > Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> >> Jeff Layton wrote:
> >> > That's expected behavior. The kernel believes that the file is frozen in
> >> > length so it returns short read() calls until the size is updated.
> >>
> >> The "size is updated" means "stat() detects the growth of file size",
> >> doesn't it? Then, the former is expected behavior.
> >>
> >> >
> >> > cache=loose is very much not recommended for use when you have multiple
> >> > hosts accessing files on the server (or access by processes on the
> >> > server itself). It only gives you "loose" cache coherency. The whole
> >> > point of it is to allow the client to cache data even when the protocol
> >> > says that it shouldn't.
> >>
> >> But why is the latter ( "read() returns non-0 when stat() detects the growth
> >> of file size but the data actually read is '\0'" ) is expected behavior?
> >> It sounds like a bug that the client caches '\0' (data nobody has ever wrote)
> >> instead of '.' (data somebody wrote when the file size grew).
> >>
> >
> > Yeah, that sounds wrong. What should happen is that the cache is
> > invalidated when the size changes. It's possible there is a race in
> > that code however. The locking around it is pretty sloppy...
> 
> When fstat() get a new file size it sets
> CIFS_I(inode)->invalid_mapping to true but do not revalidate the
> cache. Then generic_file_aio_read() reads the wrong data. I think we
> need to check if CIFS_I(inode)->invalid_mapping is true and revalidate
> the cache before calling generic_file_aio_read() in
> file->f_ops->aio_read(). Now cache revalidation happens in lookup/open
> and mmap codepaths only for cache=loose.
> 
> Of course, cache=loose is not recommended for this sort of work flow
> and cache=strict should be used to provide a data coherency between
> several machines.
> 

Ahh right, you're quite correct that we need to revalidate the cache
before doing an aio_read. We should have cifs do something like
nfs_file_read() does...

I also suspect that we have a problem with the invalid_mapping flag
similar to the one NFS had until recently. That was fixed by commit
d529ef83c355. We probably ought to do something similar for cifs.

-- 
Jeff Layton <jlayton@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux