Skip to contentSkip to conversation

NFS: LOOKUP_DIRECTORY is also ok with symlinks

PATCH In review [email protected] 4 participants 5 messages Feb 8, 2022 – Feb 15, 2022

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 NFS: LOOKUP_DIRECTORY is also ok with symlinks

From: Trond Myklebust <[email protected]>

Commit ac795161c936 (NFSv4: Handle case where the lookup of a directory fails) [1], part of Linux since 5.17-rc2, introduced a regression, where a symbolic link on an NFS mount to a directory on another NFS does not resolve(?) the first time it is accessed:

Fixes ac795161c936 ("NFSv4: Handle case where the lookup of a directory fails")
---
 fs/nfs/dir.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +2 -2
index e128503728f2..6dee4e12d381 100644
@@ -2051,14 +2051,14 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
 	if (!res) {
 		inode = d_inode(dentry);
 		if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
-		    !S_ISDIR(inode->i_mode))
+		    !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)))
 			res = ERR_PTR(-ENOTDIR);
 		else if (inode && S_ISREG(inode->i_mode))
 			res = ERR_PTR(-EOPENSTALE);
 	} else if (!IS_ERR(res)) {
 		inode = d_inode(res);
 		if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
-		    !S_ISDIR(inode->i_mode)) {
+		    !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) {
 			dput(res);
 			res = ERR_PTR(-ENOTDIR);
 		} else if (inode && S_ISREG(inode->i_mode)) {
Signature · 1 line
2.34.1
Tested-by Donald Buczek on v1 1/1
#1 lore raw

Dear Trond,

Am 08.02.22 um 19:38 schrieb [email protected]:

Quoted 10 lines

From: Trond Myklebust <[email protected]>

Commit ac795161c936 (NFSv4: Handle case where the lookup of a directory fails) [1], part of Linux since 5.17-rc2, introduced a regression, where a symbolic link on an NFS mount to a directory on another NFS does not resolve(?) the first time it is accessed:

Fixes ac795161c936 ("NFSv4: Handle case where the lookup of a directory fails")

Thank you for fixing it so quickly. My colleague verified, that it fixes our issue.

Kind regards,

Paul

Quoted 25 lines
---
  fs/nfs/dir.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +2 -2
index e128503728f2..6dee4e12d381 100644
@@ -2051,14 +2051,14 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
  	if (!res) {
  		inode = d_inode(dentry);
  		if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
-		    !S_ISDIR(inode->i_mode))
+		    !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)))
  			res = ERR_PTR(-ENOTDIR);
  		else if (inode && S_ISREG(inode->i_mode))
  			res = ERR_PTR(-EOPENSTALE);
  	} else if (!IS_ERR(res)) {
  		inode = d_inode(res);
  		if ((lookup_flags & LOOKUP_DIRECTORY) && inode &&
-		    !S_ISDIR(inode->i_mode)) {
+		    !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) {
  			dput(res);
  			res = ERR_PTR(-ENOTDIR);
  		} else if (inode && S_ISREG(inode->i_mode)) {
#2 lore raw

#regzbot monitor: https://lore.kernel.org/linux-nfs/[email protected]/

Dear Trond,

Am 09.02.22 um 23:02 schrieb Paul Menzel:

Quoted 8 lines

Am 08.02.22 um 19:38 schrieb [email protected]:

Quoted 7 lines

From: Trond Myklebust <[email protected]>

Commit ac795161c936 (NFSv4: Handle case where the lookup of a directory fails) [1], part of Linux since 5.17-rc2, introduced a regression, where a symbolic link on an NFS mount to a directory on another NFS does not resolve(?) the first time it is accessed:

Quoted 7 lines
Quoted 3 lines
Fixes ac795161c936 ("NFSv4: Handle case where the lookup of a directory fails")

Thank you for fixing it so quickly. My colleague verified, that it fixes our issue.

Also for regzbot:

Kind regards,

Paul

Quoted 26 lines
Quoted 26 lines

---
  fs/nfs/dir.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +0 -0
index e128503728f2..6dee4e12d381 100644
@@ -2051,14 +2051,14 @@ int nfs_atomic_open(struct inode *dir, struct 
 dentry *dentry,
       if (!res) {
           inode = d_inode(dentry);

          if ((lookup_flags & LOOKUP_DIRECTORY) && inode && -            !S_ISDIR(inode->i_mode))
+            !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) res = ERR_PTR(-ENOTDIR);
          else if (inode && S_ISREG(inode->i_mode))
              res = ERR_PTR(-EOPENSTALE);
      } else if (!IS_ERR(res)) {
          inode = d_inode(res);
          if ((lookup_flags & LOOKUP_DIRECTORY) && inode && -            !S_ISDIR(inode->i_mode)) {
+            !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) { dput(res);
              res = ERR_PTR(-ENOTDIR);
          } else if (inode && S_ISREG(inode->i_mode)) {

#3 lore raw
Quoted 2 lines · Paul Menzel

#regzbot monitor:
https://lore.kernel.org/linux-nfs/[email protected]/

Thx for trying, but that failed (as is unneeded, see below): regzbot can't determine which of the tracked regression might be meant here, so it can't associate it with your report.

Quoted 18 lines

Am 09.02.22 um 23:02 schrieb Paul Menzel:

Quoted 16 lines

Am 08.02.22 um 19:38 schrieb [email protected]:

Quoted 11 lines

From: Trond Myklebust <[email protected]>

Commit ac795161c936 (NFSv4: Handle case where the lookup of a directory fails) [1], part of Linux since 5.17-rc2, introduced a regression, where a symbolic link on an NFS mount to a directory on another NFS does not resolve(?) the first time it is accessed:

Fixes ac795161c936 ("NFSv4: Handle case where the lookup of a

directory fails")

Thank you for fixing it so quickly. My colleague verified, that it fixes our issue.

Quoted 6 lines
Quoted 1 line

Also for regzbot:

Link:
https://lore.kernel.org/linux-nfs/[email protected]/

Hmmm, regzbot from this could in theory be modified to determine which regression was meant, but right now regzbot processes commands sequentially, so in this order it wouldn't work anyway.

But there is a bigger problem: that link points to a reply to your report, not the report. I guess I can modify regzbot to handle such cases, but I have more pressing issue right now, sorry. But I'll keep it in mind.

The right link tag one would have been:

Link:
https://lore.kernel.org/r/[email protected]/

(s!/r/!/linux-nfs/! would have worked for regzbot as well)

Trond, can you please add this tag to your patch in case you respin it, as explained, as explained in 'Documentation/process/submitting-patches.rst' and 'Documentation/process/5.Posting.rst'.

BTW, paul: Regzbot will monitor every subthread with a proper link tag (like I gave above), so there is no need for a "#regzbot monitor" in anyway if developers would just place the tags as the documentation states.

Ciao, Thorsten

Quoted 28 lines
Quoted 26 lines
Quoted 26 lines

---
  fs/nfs/dir.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +0 -0
index e128503728f2..6dee4e12d381 100644
@@ -2051,14 +2051,14 @@ int nfs_atomic_open(struct inode *dir, struct
 dentry *dentry,
       if (!res) {
           inode = d_inode(dentry);

          if ((lookup_flags & LOOKUP_DIRECTORY) && inode && -            !S_ISDIR(inode->i_mode))
+            !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) res = ERR_PTR(-ENOTDIR);
          else if (inode && S_ISREG(inode->i_mode))
              res = ERR_PTR(-EOPENSTALE);
      } else if (!IS_ERR(res)) {
          inode = d_inode(res);
          if ((lookup_flags & LOOKUP_DIRECTORY) && inode && -            !S_ISDIR(inode->i_mode)) {
+            !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) { dput(res);
              res = ERR_PTR(-ENOTDIR);
          } else if (inode && S_ISREG(inode->i_mode)) {

#4 lore raw

Re: [PATCH] NFS: LOOKUP_DIRECTORY is also ok with symlinks #forregzbot

for the record:

#regzbot fixed-by: e0caaf75d443e02e55e146fd75fe2efc8aed5540

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?h=master&id=e0caaf75d443e02e55e146fd75fe2efc8aed5540

TWIMC: this mail is primarily send for documentation purposes and for regzbot, my Linux kernel regression tracking bot. These mails usually contain '' in the subject, to make them easy to spot and filter.

Quoted 91 lines · Thorsten Leemhuis
Quoted 2 lines · Paul Menzel

#regzbot monitor:
https://lore.kernel.org/linux-nfs/[email protected]/

Thx for trying, but that failed (as is unneeded, see below): regzbot can't determine which of the tracked regression might be meant here, so it can't associate it with your report.

Quoted 18 lines

Am 09.02.22 um 23:02 schrieb Paul Menzel:

Quoted 16 lines

Am 08.02.22 um 19:38 schrieb [email protected]:

Quoted 11 lines

From: Trond Myklebust <[email protected]>

Commit ac795161c936 (NFSv4: Handle case where the lookup of a directory fails) [1], part of Linux since 5.17-rc2, introduced a regression, where a symbolic link on an NFS mount to a directory on another NFS does not resolve(?) the first time it is accessed:

Fixes ac795161c936 ("NFSv4: Handle case where the lookup of a

directory fails")

Thank you for fixing it so quickly. My colleague verified, that it fixes our issue.

Quoted 6 lines
Quoted 1 line

Also for regzbot:

Link:
https://lore.kernel.org/linux-nfs/[email protected]/

Hmmm, regzbot from this could in theory be modified to determine which regression was meant, but right now regzbot processes commands sequentially, so in this order it wouldn't work anyway.

But there is a bigger problem: that link points to a reply to your report, not the report. I guess I can modify regzbot to handle such cases, but I have more pressing issue right now, sorry. But I'll keep it in mind.

The right link tag one would have been:

Link:
https://lore.kernel.org/r/[email protected]/

(s!/r/!/linux-nfs/! would have worked for regzbot as well)

Trond, can you please add this tag to your patch in case you respin it, as explained, as explained in 'Documentation/process/submitting-patches.rst' and 'Documentation/process/5.Posting.rst'.

BTW, paul: Regzbot will monitor every subthread with a proper link tag (like I gave above), so there is no need for a "#regzbot monitor" in anyway if developers would just place the tags as the documentation states.

Ciao, Thorsten

Quoted 28 lines
Quoted 26 lines
Quoted 26 lines

---
  fs/nfs/dir.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/dir.c +0 -0
index e128503728f2..6dee4e12d381 100644
@@ -2051,14 +2051,14 @@ int nfs_atomic_open(struct inode *dir, struct
 dentry *dentry,
       if (!res) {
           inode = d_inode(dentry);

          if ((lookup_flags & LOOKUP_DIRECTORY) && inode && -            !S_ISDIR(inode->i_mode))
+            !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) res = ERR_PTR(-ENOTDIR);
          else if (inode && S_ISREG(inode->i_mode))
              res = ERR_PTR(-EOPENSTALE);
      } else if (!IS_ERR(res)) {
          inode = d_inode(res);
          if ((lookup_flags & LOOKUP_DIRECTORY) && inode && -            !S_ISDIR(inode->i_mode)) {
+            !(S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) { dput(res);
              res = ERR_PTR(-ENOTDIR);
          } else if (inode && S_ISREG(inode->i_mode)) {