NFS: only invalidate dentrys that are clearly invalid.
Subsystems (2)
PATCH 1/1 NFS: only invalidate dentrys that are clearly invalid.
Prior to commit 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()") and error from nfs_lookup_verify_inode() other than -ESTALE would result in nfs_lookup_revalidate() returning that error code (-ESTALE is mapped to zero).
Since that commit, all errors result in zero being returned.
When nfs_lookup_revalidate() returns zero, the dentry is invalidated and, significantly, if the dentry is a directory that is mounted on, that mountpoint is lost.
If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.
This can be fixed by returning the actual error code from nfs_lookup_verify_inode() rather then zero (except for -ESTALE).
--- fs/nfs/dir.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/nfs/dir.c +5 -3
@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, unsigned int flags) {struct inode *inode; -int error; +int error =0 ;nfs_inc_stats (dir,NFSIOS_DENTRYREVALIDATE ); inode =d_inode (dentry);
@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) { error =nfs_lookup_verify_inode (inode, flags);if (error) { -if (error == -ESTALE ) +if (error == -ESTALE ) {nfs_zap_caches (dir); + error =0 ; + } goto out_bad; }nfs_advise_use_readdirplus (dir);
@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, out_bad:if (flags &LOOKUP_RCU )return -ECHILD ; -return nfs_lookup_revalidate_done (dir, dentry, inode,0 ); +return nfs_lookup_revalidate_done (dir, dentry, inode, error); } static int
Signature · 1 line
2.29.2
Quoted 60 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than-ESTALEwould result
innfs_lookup_revalidate()returning that error code (-ESTALEis mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated and, significantly, if the dentry is a directory that is mounted on, that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for-ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +1
-1@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, unsigned int flags) { struct inode *inode; - int error; + int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +3
-1@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) { error = nfs_lookup_verify_inode(inode, flags); if (error) { - if (error == -ESTALE) + if (error == -ESTALE) { nfs_zap_caches(dir); + error = 0; + } goto out_bad; }nfs_advise_use_readdirplus(dir);
fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
Quoted 5 lines
out_bad:
if (flags &LOOKUP_RCU)
return-ECHILD;
- returnnfs_lookup_revalidate_done(dir, dentry, inode, 0); + returnnfs_lookup_revalidate_done(dir, dentry, inode, error);
Which errors do we actually need to return here? As far as I can tell, the only errors that nfs_lookup_verify_inode() is supposed to return is ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.
Why would it be better to return those errors rather than just a 0 when we need to invalidate the inode, particularly since we already have a special case in nfs_lookup_revalidate_done() when the dentry is root?
Quoted 3 lines
}
static int
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 71 lines · Trond Myklebust
Quoted 60 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than-ESTALEwould result
innfs_lookup_revalidate()returning that error code (-ESTALEis mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated and, significantly, if the dentry is a directory that is mounted on, that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for-ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +1
-1@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, unsigned int flags) { struct inode *inode; - int error; + int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +3
-1@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) { error = nfs_lookup_verify_inode(inode, flags); if (error) { - if (error == -ESTALE) + if (error == -ESTALE) { nfs_zap_caches(dir); + error = 0; + } goto out_bad; }nfs_advise_use_readdirplus(dir);
fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,Quoted 5 lines
out_bad:
if (flags &LOOKUP_RCU)
return-ECHILD;
- returnnfs_lookup_revalidate_done(dir, dentry, inode, 0); + returnnfs_lookup_revalidate_done(dir, dentry, inode, error);Which errors do we actually need to return here? As far as I can tell, the only errors that
nfs_lookup_verify_inode()is supposed to return is ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.
Quoted 3 lines
Why would it be better to return those errors rather than just a 0 when we need to invalidate the inode, particularly since we already have a special case in
nfs_lookup_revalidate_done()when the dentry is root?
ERESTARTSYS is the error that easily causes problems.
Returning 0 causes d_invalidate() to be called which is quite heavy handed in mountpoints.
So it is only reasonable to return 0 when we have unambiguous confirmation from the server that the object no longer exists. ESTALE is unambiguous. EIO might be unambiguous. ERESTARTSYS, ENOMEM, ETIMEDOUT are transient and don't justify d_invalidate() being called.
(BTW, Commit cc89684c9a26 ("NFS: only invalidate dentrys that are clearly invalid.")
fixed much the same bug 3 years ago).
Thanks,
NeilBrown
Quoted 9 lines
Quoted 4 lines
}
static intSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 87 lines · NeilBrown
Quoted 78 lines · Trond Myklebust
Quoted 64 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than-ESTALEwould result
innfs_lookup_revalidate()returning that error code (-ESTALEis mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated
and, significantly, if the dentry is a directory that is mounted on,
that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for-ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +1
-1@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, unsigned int flags) { struct inode *inode; - int error; + int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +3
-1@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) { error = nfs_lookup_verify_inode(inode, flags); if (error) { - if (error == -ESTALE) + if (error == -ESTALE) { nfs_zap_caches(dir); + error = 0; + }goto
out_bad;
}
nfs_advise_use_readdirplus(dir);fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,Quoted 6 lines
out_bad:
if (flags &LOOKUP_RCU)
return-ECHILD;
- returnnfs_lookup_revalidate_done(dir, dentry, inode, 0); + returnnfs_lookup_revalidate_done(dir, dentry, inode, error);Which errors do we actually need to return here? As far as I can tell,
the only errors thatnfs_lookup_verify_inode()is supposed to return is
ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.Quoted 6 lines
Why would it be better to return those errors rather than just a 0 when
we need to invalidate the inode, particularly since we already have a
special case innfs_lookup_revalidate_done()when the dentry is root?
Quoted 4 lines
ERESTARTSYS is the error that easily causes problems.
Returning 0 causes
d_invalidate()to be called which is quite heavy handed in mountpoints.
My point is that it shouldn't get returned for mountpoints. See nfs_lookup_revalidate_done().
Quoted 24 lines
So it is only reasonable to return 0 when we have unambiguous confirmation from the server that the object no longer exists. ESTALE
is unambiguous. EIO might be unambiguous. ERESTARTSYS, ENOMEM, ETIMEDOUT are transient and don't justifyd_invalidate()being called.(BTW, Commit
cc89684c9a26("NFS: only invalidate dentrys that are clearly invalid.")
fixed much the same bug 3 years ago).
Thanks,
NeilBrownQuoted 9 lines
Quoted 4 lines
}
static intSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.space
Quoted 88 lines · Trond Myklebust
Quoted 87 lines · NeilBrown
Quoted 84 lines · Trond Myklebust
Quoted 64 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than-ESTALEwould result
innfs_lookup_revalidate()returning that error code (-ESTALEis mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated
and, significantly, if the dentry is a directory that is mounted on,
that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for-ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +1
-1@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, unsigned int flags) { struct inode *inode; - int error; + int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +3
-1@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(struct inode *dir,struct dentry *dentry, nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) { error = nfs_lookup_verify_inode(inode, flags); if (error) { - if (error == -ESTALE) + if (error == -ESTALE) { nfs_zap_caches(dir); + error = 0; + }goto
out_bad;
}
nfs_advise_use_readdirplus(dir);fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,Quoted 6 lines
out_bad:
if (flags &LOOKUP_RCU)
return-ECHILD;
- returnnfs_lookup_revalidate_done(dir, dentry, inode, 0); + returnnfs_lookup_revalidate_done(dir, dentry, inode, error);Which errors do we actually need to return here? As far as I can tell,
the only errors thatnfs_lookup_verify_inode()is supposed to return is
ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.Why would it be better to return those errors rather than just a 0 when
we need to invalidate the inode, particularly since we already have a
special case innfs_lookup_revalidate_done()when the dentry is root?
Quoted 7 lines
Quoted 4 lines
ERESTARTSYS is the error that easily causes problems.
Returning 0 causes
d_invalidate()to be called which is quite heavy handed in mountpoints.My point is that it shouldn't get returned for mountpoints. See
nfs_lookup_revalidate_done().
nfs_lookup_revalidate_done() only checks IS_ROOT(), and while many mountpoints are IS_ROOT(), not all are (--bind easily makes others).
But that isn't even really relevant here. The dentry being revalidated is the underlying directory - that something else is mounted on. step_into() which follows mount points is called in walk_component() *after* lookup_fast or lookup_slow which will have revalidated the dentry.
NeilBrown
Quoted 33 lines
Quoted 25 lines
So it is only reasonable to return 0 when we have unambiguous confirmation from the server that the object no longer exists. ESTALE
is unambiguous. EIO might be unambiguous. ERESTARTSYS, ENOMEM, ETIMEDOUT are transient and don't justifyd_invalidate()being called.(BTW, Commit
cc89684c9a26("NFS: only invalidate dentrys that are clearly invalid.")
fixed much the same bug 3 years ago).
Thanks,
NeilBrownQuoted 9 lines
Quoted 4 lines
}
static intSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.space
Quoted 114 lines · NeilBrown
Quoted 100 lines · Trond Myklebust
Quoted 99 lines · NeilBrown
Quoted 96 lines · Trond Myklebust
Quoted 72 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than-ESTALEwould
result
innfs_lookup_revalidate()returning that error code (-ESTALEis
mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated
and, significantly, if the dentry is a directory that is mounted
on,
that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for - ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +1
-1@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, unsigned int flags) { struct inode *inode; - int error; + int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +0
-0@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU))
{
error =nfs_lookup_verify_inode(inode, flags);
if (error) {
- if (error ==-ESTALE) + if (error ==-ESTALE) {nfs_zap_caches(dir); + error = 0;
+ }
gotoout_bad;
}nfs_advise_use_readdirplus(dir);fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,Quoted 7 lines
out_bad:
if (flags &LOOKUP_RCU)
return-ECHILD;
- returnnfs_lookup_revalidate_done(dir, dentry, inode, 0);
+ returnnfs_lookup_revalidate_done(dir, dentry, inode, error);Which errors do we actually need to return here? As far as I can
tell,
the only errors thatnfs_lookup_verify_inode()is supposed to return is
ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.Why would it be better to return those errors rather than just a 0
when
we need to invalidate the inode, particularly since we already have
a
special case innfs_lookup_revalidate_done()when the dentry is root?Quoted 8 lines
Quoted 5 lines
ERESTARTSYS is the error that easily causes problems.
Returning 0 causes
d_invalidate()to be called which is quite heavy
handed in mountpoints.My point is that it shouldn't get returned for mountpoints. See
nfs_lookup_revalidate_done().
nfs_lookup_revalidate_done()only checksIS_ROOT(), and while many mountpoints areIS_ROOT(), not all are (--bind easily makes others).
Quoted 6 lines
But that isn't even really relevant here. The dentry being revalidated
is the underlying directory - that something else is mounted on.step_into()which follows mount points is called inwalk_component()*after*lookup_fastorlookup_slowwhich will have revalidated the dentry.
So then why is it not sufficient to just add a check for d_mountpoint()? This is a revalidation, not a new lookup.
Quoted 37 lines
NeilBrown
Quoted 33 lines
Quoted 25 lines
So it is only reasonable to return 0 when we have unambiguous confirmation from the server that the object no longer exists. ESTALE
is unambiguous. EIO might be unambiguous. ERESTARTSYS, ENOMEM, ETIMEDOUT are transient and don't justifyd_invalidate()being called.(BTW, Commit
cc89684c9a26("NFS: only invalidate dentrys that are clearly invalid.")
fixed much the same bug 3 years ago).
Thanks,
NeilBrownQuoted 9 lines
Quoted 4 lines
}
static intSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.space
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 122 lines · Trond Myklebust
Quoted 114 lines · NeilBrown
Quoted 100 lines · Trond Myklebust
Quoted 99 lines · NeilBrown
Quoted 96 lines · Trond Myklebust
Quoted 72 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than-ESTALEwould
result
innfs_lookup_revalidate()returning that error code (-ESTALEis
mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated
and, significantly, if the dentry is a directory that is mounted
on,
that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for - ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +1
-1@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, unsigned int flags) { struct inode *inode; - int error; + int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +0
-0@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU))
{
error =nfs_lookup_verify_inode(inode, flags);
if (error) {
- if (error ==-ESTALE) + if (error ==-ESTALE) {nfs_zap_caches(dir); + error = 0;
+ }
gotoout_bad;
}nfs_advise_use_readdirplus(dir);fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,Quoted 7 lines
out_bad:
if (flags &LOOKUP_RCU)
return-ECHILD;
- returnnfs_lookup_revalidate_done(dir, dentry, inode, 0);
+ returnnfs_lookup_revalidate_done(dir, dentry, inode, error);Which errors do we actually need to return here? As far as I can
tell,
the only errors thatnfs_lookup_verify_inode()is supposed to return is
ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.Why would it be better to return those errors rather than just a 0
when
we need to invalidate the inode, particularly since we already have
a
special case innfs_lookup_revalidate_done()when the dentry is root?Quoted 8 lines
Quoted 5 lines
ERESTARTSYS is the error that easily causes problems.
Returning 0 causes
d_invalidate()to be called which is quite heavy
handed in mountpoints.My point is that it shouldn't get returned for mountpoints. See
nfs_lookup_revalidate_done().
nfs_lookup_revalidate_done()only checksIS_ROOT(), and while many mountpoints areIS_ROOT(), not all are (--bind easily makes others).Quoted 6 lines
But that isn't even really relevant here. The dentry being revalidated
is the underlying directory - that something else is mounted on.step_into()which follows mount points is called inwalk_component()*after*lookup_fastorlookup_slowwhich will have revalidated the dentry.
Quoted 3 lines
So then why is it not sufficient to just add a check for
d_mountpoint()? This is a revalidation, not a new lookup.
I guess you could do that.
But why would you want to call d_invalidate() just because a signal was received, or a memory allocation failed?
NeilBrown
Quoted 42 lines
Quoted 37 lines
NeilBrown
Quoted 33 lines
Quoted 25 lines
So it is only reasonable to return 0 when we have unambiguous confirmation from the server that the object no longer exists. ESTALE
is unambiguous. EIO might be unambiguous. ERESTARTSYS, ENOMEM, ETIMEDOUT are transient and don't justifyd_invalidate()being called.(BTW, Commit
cc89684c9a26("NFS: only invalidate dentrys that are clearly invalid.")
fixed much the same bug 3 years ago).
Thanks,
NeilBrownQuoted 9 lines
Quoted 4 lines
}
static intSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.spaceSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 143 lines · NeilBrown
Quoted 141 lines · Trond Myklebust
Quoted 139 lines · NeilBrown
Quoted 115 lines · Trond Myklebust
Quoted 114 lines · NeilBrown
Quoted 111 lines · Trond Myklebust
Quoted 81 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than - ESTALE
would
result
innfs_lookup_revalidate()returning that error code (- ESTALE
is
mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated
and, significantly, if the dentry is a directory that is mounted
on,
that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for - ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor
nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +0
-0@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(structinode
*dir,
struct dentry *dentry,
unsigned int flags) {
struct inode *inode;
- int error;
+ int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +0
-0@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(structinode
*dir,
struct dentry *dentry,nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU))
{
error =nfs_lookup_verify_inode(inode, flags);
if (error) {
- if (error ==-ESTALE) + if (error ==-ESTALE) {nfs_zap_caches(dir); + error = 0;
+ }
gotoout_bad;
}nfs_advise_use_readdirplus(dir);fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(structinode
*dir,
struct dentry *dentry,
out_bad:Quoted 8 lines
if (flags &
LOOKUP_RCU)
return-ECHILD;
- return nfs_lookup_revalidate_done(dir, dentry, inode,
0);
+ return nfs_lookup_revalidate_done(dir, dentry, inode,
error);Which errors do we actually need to return here? As far as I
can
tell,
the only errors thatnfs_lookup_verify_inode()is supposed to
return is
ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.Why would it be better to return those errors rather than just
a 0
when
we need to invalidate the inode, particularly since we already
have
a
special case innfs_lookup_revalidate_done()when the dentry is
root?Quoted 8 lines
Quoted 5 lines
ERESTARTSYS is the error that easily causes problems.
Returning 0 causes
d_invalidate()to be called which is quite heavy
handed in mountpoints.My point is that it shouldn't get returned for mountpoints. See
nfs_lookup_revalidate_done().
nfs_lookup_revalidate_done()only checksIS_ROOT(), and while many
mountpoints areIS_ROOT(), not all are (--bind easily makes others).But that isn't even really relevant here. The dentry being revalidated
is the underlying directory - that something else is mounted on.step_into()which follows mount points is called inwalk_component()
*after*lookup_fastorlookup_slowwhich will have revalidated the
dentry.
Quoted 8 lines
Quoted 3 lines
So then why is it not sufficient to just add a check for
d_mountpoint()? This is a revalidation, not a new lookup.I guess you could do that.
But why would you want to calld_invalidate()just because a signal was
received, or a memory allocation failed?
Why would I care about the error return from nfs_lookup_verify_inode()? This is a revalidation, and so sometimes the error returned is not transient, but is persistent (e.g. EIO/ETIMEDOUT if the server is down). In those cases, I still want to be able to do things like unmount the filesystem.
Quoted 50 lines
NeilBrown
Quoted 46 lines
Quoted 41 lines
NeilBrown
Quoted 37 lines
Quoted 29 lines
So it is only reasonable to return 0 when we have unambiguous confirmation from the server that the object no longer exists.
ESTALE
is unambiguous. EIO might be unambiguous. ERESTARTSYS, ENOMEM,
ETIMEDOUT are transient and don't justifyd_invalidate()being
called.(BTW, Commit
cc89684c9a26("NFS: only invalidate dentrys that are
clearly invalid.")
fixed much the same bug 3 years ago).
Thanks,
NeilBrownQuoted 9 lines
Quoted 4 lines
}
static intSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.spaceSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.space
Quoted 148 lines · Trond Myklebust
Quoted 147 lines · NeilBrown
Quoted 144 lines · Trond Myklebust
Quoted 131 lines · NeilBrown
Quoted 115 lines · Trond Myklebust
Quoted 114 lines · NeilBrown
Quoted 111 lines · Trond Myklebust
Quoted 81 lines · NeilBrown
Prior to commit
5ceb9d7fdaaf("NFS: Refactornfs_lookup_revalidate()")
and error fromnfs_lookup_verify_inode()other than - ESTALE
would
result
innfs_lookup_revalidate()returning that error code (- ESTALE
is
mapped
to zero).
Since that commit, all errors result in zero being returned.When
nfs_lookup_revalidate()returns zero, the dentry is invalidated
and, significantly, if the dentry is a directory that is mounted
on,
that mountpoint is lost.If you:
- mount an NFS filesystem which contains a directory
- mount something (e.g. tmpfs) on that directory
- use iptables (or scissors) to block traffic to the server
- ls -l the-mounted-on-directory
- interrupt the 'ls -l'
you will find that the directory has been unmounted.This can be fixed by returning the actual error code from
nfs_lookup_verify_inode()rather then zero (except for - ESTALE).Fixes 5ceb9d7fdaaf ("NFS: Refactor
nfs_lookup_revalidate()")Signed-off-by NeilBrown <[email protected]>---
fs/nfs/dir.c | 8 +++++---1 file changed, 5 insertions(+), 3 deletions(-)fs/nfs/dir.c +0
-0@@ -1350,7 +1350,7 @@ nfs_do_lookup_revalidate(structinode
*dir,
struct dentry *dentry,
unsigned int flags) {
struct inode *inode;
- int error;
+ int error = 0;
nfs_inc_stats(dir,NFSIOS_DENTRYREVALIDATE); inode =d_inode(dentry);fs/nfs/dir.c +0
-0@@ -1372,8 +1372,10 @@ nfs_do_lookup_revalidate(structinode
*dir,
struct dentry *dentry,nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU))
{
error =nfs_lookup_verify_inode(inode, flags);
if (error) {
- if (error ==-ESTALE) + if (error ==-ESTALE) {nfs_zap_caches(dir); + error = 0;
+ }
gotoout_bad;
}nfs_advise_use_readdirplus(dir);fs/nfs/dir.c +0
-0@@ -1395,7 +1397,7 @@ nfs_do_lookup_revalidate(structinode
*dir,
struct dentry *dentry,
out_bad:Quoted 8 lines
if (flags &
LOOKUP_RCU)
return-ECHILD;
- return nfs_lookup_revalidate_done(dir, dentry, inode,
0);
+ return nfs_lookup_revalidate_done(dir, dentry, inode,
error);Which errors do we actually need to return here? As far as I
can
tell,
the only errors thatnfs_lookup_verify_inode()is supposed to
return is
ENOMEM, ESTALE, ECHILD, and possibly EIO or ETiMEDOUT.Why would it be better to return those errors rather than just
a 0
when
we need to invalidate the inode, particularly since we already
have
a
special case innfs_lookup_revalidate_done()when the dentry is
root?Quoted 8 lines
Quoted 5 lines
ERESTARTSYS is the error that easily causes problems.
Returning 0 causes
d_invalidate()to be called which is quite heavy
handed in mountpoints.My point is that it shouldn't get returned for mountpoints. See
nfs_lookup_revalidate_done().
nfs_lookup_revalidate_done()only checksIS_ROOT(), and while many
mountpoints areIS_ROOT(), not all are (--bind easily makes others).Quoted 8 lines
But that isn't even really relevant here. The dentry being revalidated
is the underlying directory - that something else is mounted on.step_into()which follows mount points is called inwalk_component()
*after*lookup_fastorlookup_slowwhich will have revalidated the
dentry.So then why is it not sufficient to just add a check for
d_mountpoint()? This is a revalidation, not a new lookup.
Quoted 6 lines
Quoted 4 lines
I guess you could do that.
But why would you want to calld_invalidate()just because a signal was
received, or a memory allocation failed?Why would I care about the error return from
nfs_lookup_verify_inode()?
?? Why wouldn't you? What am I missing?
Quoted 4 lines
This is a revalidation, and so sometimes the error returned is not transient, but is persistent (e.g. EIO/ETIMEDOUT if the server is down). In those cases, I still want to be able to do things like unmount the filesystem.
Why do you think that a server being down is a persistent error? Servers come back up.
I don't have a particular opinion on how EIO and ETIMEDOUT should be handled as I don't have a clear idea of what underlying issue produces them.
I do know that ESTALE means the directory doesn't exist any more, so the dentry should be invalidated, whether it is mounted on or not. I do know that ERESTARTSYS means that a fatal signal was received by the current process, so it is inappropriate to invalidate the dentry.
So I'm certain that we need to be able to handle different error codes differently. Maybe EIO should be treated the same as ESTALE. Probably ENOMEM should be handled like ERESTARTSYS....
NeilBrown
Quoted 59 lines
Quoted 51 lines
NeilBrown
Quoted 46 lines
Quoted 41 lines
NeilBrown
Quoted 37 lines
Quoted 29 lines
So it is only reasonable to return 0 when we have unambiguous confirmation from the server that the object no longer exists.
ESTALE
is unambiguous. EIO might be unambiguous. ERESTARTSYS, ENOMEM,
ETIMEDOUT are transient and don't justifyd_invalidate()being
called.(BTW, Commit
cc89684c9a26("NFS: only invalidate dentrys that are
clearly invalid.")
fixed much the same bug 3 years ago).
Thanks,
NeilBrownQuoted 9 lines
Quoted 4 lines
}
static intSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.spaceSignature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]Signature · 6 lines
Trond Myklebust CTO, Hammerspace Inc 4984 El Camino Real, Suite 208 Los Altos, CA 94022 www.hammer.space