Jeff Layton <jlayton@xxxxxxxxxx> writes: > On Tue, 17 Apr 2012 16:27:16 +0200 > Miklos Szeredi <miklos@xxxxxxxxxx> wrote: > >> Steve Dickson <SteveD@xxxxxxxxxx> writes: >> >> > True, but even so... Giving file systems an opt-out option with the >> > default being out, maybe still have some merit... Making file systems >> > enable this new type of functionality would cut down on any of the >> > "surprise" that might occur with this redo ;-) >> >> I've been arguing for something slightly different for quite some time: >> I never liked errno values which have side effects in the kernel yet >> might be visible to userspace. >> >> So why not introduce ERETRYSTALE, a *kernel internal* errno value that >> userspace will never see and filesystems never accidentally set. The >> VFS can turn this into ESTALE if it doesn't retry for some reason >> (e.g. already retried). >> > > That's possible but it's certainly a lot more invasive. It's also far > more difficult for filesystems to opt-in to this sort of behavior. As a first step all that is needed to opt in is to convert -ESTALE to -ESTALERETRY on those operations that allow retrying. Which is lookup, at the moment. If we decide to make more ops retryable (I'm not convinced that's the best approach, but it might be) then those can be converted without too much pain. Thanks, Miklos diff --git a/fs/namei.c b/fs/namei.c index 0062dd1..66b7d06 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1776,9 +1776,14 @@ static int do_path_lookup(int dfd, const char *name, int retval = path_lookupat(dfd, name, flags | LOOKUP_RCU, nd); if (unlikely(retval == -ECHILD)) retval = path_lookupat(dfd, name, flags, nd); - if (unlikely(retval == -ESTALE)) + if (unlikely(retval == -ERETRYLOOKUP)) { retval = path_lookupat(dfd, name, flags | LOOKUP_REVAL, nd); + /* retry only once */ + if (retval == -ERETRYLOOKUP) + retval = -ESTALE; + } + if (likely(!retval)) { if (unlikely(!audit_dummy_context())) { if (nd->path.dentry && nd->inode) @@ -2433,8 +2438,12 @@ struct file *do_filp_open(int dfd, const char *pathname, filp = path_openat(dfd, pathname, &nd, op, flags | LOOKUP_RCU); if (unlikely(filp == ERR_PTR(-ECHILD))) filp = path_openat(dfd, pathname, &nd, op, flags); - if (unlikely(filp == ERR_PTR(-ESTALE))) + if (unlikely(filp == ERR_PTR(-ERETRYLOOKUP))) { filp = path_openat(dfd, pathname, &nd, op, flags | LOOKUP_REVAL); + if (filp == ERR_PTR(-ERETRYLOOKUP)) + filp = ERR_PTR(-ESTALE); + } + return filp; } @@ -2455,8 +2464,11 @@ struct file *do_file_open_root(struct dentry *dentry, struct vfsmount *mnt, file = path_openat(-1, name, &nd, op, flags | LOOKUP_RCU); if (unlikely(file == ERR_PTR(-ECHILD))) file = path_openat(-1, name, &nd, op, flags); - if (unlikely(file == ERR_PTR(-ESTALE))) + if (unlikely(file == ERR_PTR(-ESTALE))) { file = path_openat(-1, name, &nd, op, flags | LOOKUP_REVAL); + if (file == ERR_PTR(-ERETRYLOOKUP)) + file = ERR_PTR(-ESTALE); + } return file; } diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 4aaf031..cd35da3 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1303,6 +1303,8 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru if (error == -ENOENT) goto no_entry; if (error < 0) { + if (error == -ESTALE) + error = -ERETRYLOOKUP; res = ERR_PTR(error); goto out_unblock_sillyrename; } diff --git a/include/linux/errno.h b/include/linux/errno.h index 2d09bfa..cfaedb8 100644 --- a/include/linux/errno.h +++ b/include/linux/errno.h @@ -17,6 +17,7 @@ #define ENOIOCTLCMD 515 /* No ioctl command */ #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ #define EPROBE_DEFER 517 /* Driver requests probe retry */ +#define ERETRYLOOKUP 519 /* Retry lookup */ /* Defined for the NFSv3 protocol */ #define EBADHANDLE 521 /* Illegal NFS file handle */ -- 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