AUTOFS4: Fix the return from autofs4_d_automount() and simplify autofs4_d_manage()
PATCH 1/1 AUTOFS4: Fix the return from autofs4_d_automount() and simplify autofs4_d_manage()
autofs4_d_automount() returns 0 if it detects that the calling process is in Oz mode (ie. it's the autofs userspace daemon). This return, however, is meant to indicate to follow_automount() that the caller should retry the check on the the current path point. In the Oz mode case, this is a bad idea because nothing has changed on the path, and follow_managed() will just repeat until follow_automount() hits the total_link_count limit and returns -ELOOP.
What it should do is return -EISDIR to indicate to the callers that actually it wants the daemon to see this directory as an ordinary directory.
Now, given that change outlined above, it is then unnecessary for autofs4_d_manage() to return -EISDIR if the current path point is not a mountpoint. If it returns 0 instead, and the path point isn't a mountpoint, then follow_managed() will skip the attempt to transit to the mounted filesystem and proceed to call autofs4_d_automount(), which will return -EISDIR.
---
fs/autofs4/root.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)
fs/autofs4/root.c +2 -7
@@ -334,7 +334,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)/* The daemon never triggers a mount. */ if (autofs4_oz_mode (sbi)) -return NULL ; +return ERR_PTR (-EISDIR );/* * If an expire request is pending everyone must wait.
@@ -435,13 +435,8 @@ int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) dentry, dentry->d_name.len, dentry->d_name.name);/* The daemon never waits. */ -if (autofs4_oz_mode (sbi)) { -if (rcu_walk) -return 0 ; -if (!d_mountpoint (dentry)) -return -EISDIR ; +if (autofs4_oz_mode (sbi))return 0 ; - }/* We need to sleep, so we need pathwalk to be in ref-mode */ if (rcu_walk)
Ian Kent
maintainerQuoted 9 lines · David Howells
autofs4_d_automount()returns 0 if it detects that the calling process is in Oz mode (ie. it's the autofs userspace daemon). This return, however, is meant to indicate tofollow_automount()that the caller should retry the check on the the current path point. In the Oz mode case, this is a bad idea because nothing has changed on the path, andfollow_managed()will just repeat untilfollow_automount()hits thetotal_link_countlimit and returns-ELOOP.What it should do is return
-EISDIRto indicate to the callers that actually it wants the daemon to see this directory as an ordinary directory.
No, not unless the check below can be changed to somehow not trigger when LOOKUP_CONTINUE is set for autofs automount dentrys that don't actually end up with a mount on them, but are automount triggers never the less:
if (PTR_ERR(mnt) == -EISDIR && (flags & LOOKUP_CONTINUE))
return -EREMOTE;
return PTR_ERR(mnt);Fact is in our discussions on this we could never reach agreement so I worked around it by breaking out of the follow_managed() loop using ->d_managed() instead, thinking that the above check must remain to satisfy the needs of other kernel users.
Quoted 44 lines
Now, given that change outlined above, it is then unnecessary for
autofs4_d_manage()to return-EISDIRif the current path point is not a mountpoint. If it returns 0 instead, and the path point isn't a mountpoint, thenfollow_managed()will skip the attempt to transit to the mounted filesystem and proceed to callautofs4_d_automount(), which will return-EISDIR.Signed-off-by David Howells <[email protected]>---
fs/autofs4/root.c | 9 ++------- 1 files changed, 2 insertions(+), 7 deletions(-)fs/autofs4/root.c +2
-7@@ -334,7 +334,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)/* The daemon never triggers a mount. */ if (autofs4_oz_mode (sbi)) -return NULL ; +return ERR_PTR (-EISDIR );/* * If an expire request is pending everyone must wait. @@ -435,13 +435,8 @@ int autofs4_d_manage(struct dentry *dentry, bool rcu_walk) dentry, dentry->d_name.len, dentry->d_name.name);/* The daemon never waits. */ -if (autofs4_oz_mode (sbi)) { -if (rcu_walk) -return 0 ; -if (!d_mountpoint (dentry)) -return -EISDIR ; +if (autofs4_oz_mode (sbi))return 0 ; - }/* We need to sleep, so we need pathwalk to be in ref-mode */ if (rcu_walk)