diff options
author | Brian Foster <bfoster@redhat.com> | 2012-07-16 15:23:50 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@suse.cz> | 2012-07-18 10:09:40 -0400 |
commit | a8894274a3581125fb311eabfc97cd0123740c5e (patch) | |
tree | 5d229b3f11b1e9800b95f47bdd1570c2b40e7675 /fs | |
parent | eed2179efe1aac145bf6d54b925b750976380fa6 (diff) |
fuse: update attributes on aio_read
A fuse-based network filesystem might allow for the inode
and/or file data to change unexpectedly. A local client
that opens and repeatedly reads a file might never pick
up on such changes and indefinitely return stale data.
Always invoke fuse_update_attributes() in the read path
to cause an attr revalidation when the attributes expire.
This leads to a page cache invalidation if necessary and
ensures fuse issues new read requests to the fuse client.
The original logic (reval only on reads beyond EOF) is
preserved unless the client specifies FUSE_AUTO_INVAL_DATA
on init.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fuse/file.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index b321a688cde7..5800101e5ce1 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -703,13 +703,16 @@ static ssize_t fuse_file_aio_read(struct kiocb *iocb, const struct iovec *iov, | |||
703 | unsigned long nr_segs, loff_t pos) | 703 | unsigned long nr_segs, loff_t pos) |
704 | { | 704 | { |
705 | struct inode *inode = iocb->ki_filp->f_mapping->host; | 705 | struct inode *inode = iocb->ki_filp->f_mapping->host; |
706 | struct fuse_conn *fc = get_fuse_conn(inode); | ||
706 | 707 | ||
707 | if (pos + iov_length(iov, nr_segs) > i_size_read(inode)) { | 708 | /* |
709 | * In auto invalidate mode, always update attributes on read. | ||
710 | * Otherwise, only update if we attempt to read past EOF (to ensure | ||
711 | * i_size is up to date). | ||
712 | */ | ||
713 | if (fc->auto_inval_data || | ||
714 | (pos + iov_length(iov, nr_segs) > i_size_read(inode))) { | ||
708 | int err; | 715 | int err; |
709 | /* | ||
710 | * If trying to read past EOF, make sure the i_size | ||
711 | * attribute is up-to-date. | ||
712 | */ | ||
713 | err = fuse_update_attributes(inode, NULL, iocb->ki_filp, NULL); | 716 | err = fuse_update_attributes(inode, NULL, iocb->ki_filp, NULL); |
714 | if (err) | 717 | if (err) |
715 | return err; | 718 | return err; |