[Gluster-devel] [PATCH] fuse: ignore entry-timeout on LOOKUP_REVAL

Niels de Vos ndevos at redhat.com
Fri Jun 27 07:59:24 UTC 2014


On Thu, Jun 26, 2014 at 08:21:57PM -0400, Anand Avati wrote:
> The following test case demonstrates the bug:
> 
>   sh# mount -t glusterfs localhost:meta-test /mnt/one
> 
>   sh# mount -t glusterfs localhost:meta-test /mnt/two
> 
>   sh# echo stuff > /mnt/one/file; rm -f /mnt/two/file; echo stuff > /mnt/one/file
>   bash: /mnt/one/file: Stale file handle
> 
>   sh# echo stuff > /mnt/one/file; rm -f /mnt/two/file; sleep 1; echo stuff > /mnt/one/file
> 
> On the second open() on /mnt/one, FUSE would have used the old
> nodeid (file handle) trying to re-open it. Gluster is returning
> -ESTALE. The ESTALE propagates back to namei.c:filename_lookup()
> where lookup is re-attempted with LOOKUP_REVAL. The right
> behavior now, would be for FUSE to ignore the entry-timeout and
> and do the up-call revalidation. Instead FUSE is ignoring
> LOOKUP_REVAL, succeeding the revalidation (because entry-timeout
> has not passed), and open() is again retried on the old file
> handle and finally the ESTALE is going back to the application.
> 
> Fix: if revalidation is happening with LOOKUP_REVAL, then ignore
> entry-timeout and always do the up-call.
> 
> Signed-off-by: Anand Avati <avati at redhat.com>

Looks good to me.

Reviewed-by: Niels de Vos <ndevos at redhat.com>


> ---
>  fs/fuse/dir.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 4219835..4eaa30d 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -198,7 +198,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
>  	inode = ACCESS_ONCE(entry->d_inode);
>  	if (inode && is_bad_inode(inode))
>  		goto invalid;
> -	else if (fuse_dentry_time(entry) < get_jiffies_64()) {
> +	else if (fuse_dentry_time(entry) < get_jiffies_64() || (flags & LOOKUP_REVAL)) {
>  		int err;
>  		struct fuse_entry_out outarg;
>  		struct fuse_req *req;
> -- 
> 1.7.1
> 
> _______________________________________________
> Gluster-devel mailing list
> Gluster-devel at gluster.org
> http://supercolony.gluster.org/mailman/listinfo/gluster-devel


More information about the Gluster-devel mailing list