Skip to contentSkip to conversation

vfs: don't revalidate dentries that serve as mountpoints

RFC PATCH In review Jeff Layton 4 participants 6 messages Nov 5, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 vfs: don't revalidate dentries that serve as mountpoints

We had a couple of reports of people that are mounting NFS filesystems, and then bind mounting certain local files onto dentries in that nfs mount (sort of like a poor-man's unionmount).

This all works well until the dentry serving as the mountpoint fails d_revalidate. The dentry will end up being invalidated which makes the bind mount unreachable via pathwalk.

It doesn't make much sense to me to allow dentries to serve as mountpoints to end up invalidated, so there's no real point in attempting to d_revalidate them at all.

---
 fs/namei.c | 3 +++
 1 file changed, 3 insertions(+)
fs/namei.c +3 -0
index caa2805..5b10ad0 100644
@@ -585,6 +585,9 @@ drop_root_mnt:
 
 static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
 {
+	/* dentries that serve as mountpoints are always considered valid */
+	if (d_mountpoint(dentry))
+		return 1;
 	return dentry->d_op->d_revalidate(dentry, flags);
 }
 
Signature · 6 lines
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 24 lines · On Mon, 4 Nov 2013 20:16:26 -0500 Jeff Layton…

We had a couple of reports of people that are mounting NFS filesystems, and then bind mounting certain local files onto dentries in that nfs mount (sort of like a poor-man's unionmount).

This all works well until the dentry serving as the mountpoint fails d_revalidate. The dentry will end up being invalidated which makes the bind mount unreachable via pathwalk.

It doesn't make much sense to me to allow dentries to serve as mountpoints to end up invalidated, so there's no real point in attempting to d_revalidate them at all.

---
 fs/namei.c | 3 +++
 1 file changed, 3 insertions(+)
fs/namei.c +0 -0
index caa2805..5b10ad0 100644

fs/namei.c drop_root_mnt: · line 593

Quoted 9 lines
fs/namei.c +3 -0
@@ -585,6 +585,9 @@ drop_root_mnt:
 
 static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
 {
+	/* dentries that serve as mountpoints are always considered valid */
+	if (d_mountpoint(dentry))
+		return 1;
 	return dentry->d_op->d_revalidate(dentry, flags);
 }
 

Makes sense to me. But what about the parent or grandparent of the mountpoint?

Presumably we don't want to invalidate them either, and I don't think d_mountpoint() returns true for those, does it?

NeilBrown

#2 lore raw
Quoted 38 lines · On Tue, 5 Nov 2013 13:39:59 +1100 NeilBrown <[email protected]> wrote:
Quoted 24 lines · On Mon, 4 Nov 2013 20:16:26 -0500 Jeff Layton <[email protected]> wrote:

We had a couple of reports of people that are mounting NFS filesystems, and then bind mounting certain local files onto dentries in that nfs mount (sort of like a poor-man's unionmount).

This all works well until the dentry serving as the mountpoint fails d_revalidate. The dentry will end up being invalidated which makes the bind mount unreachable via pathwalk.

It doesn't make much sense to me to allow dentries to serve as mountpoints to end up invalidated, so there's no real point in attempting to d_revalidate them at all.

---
 fs/namei.c | 3 +++
 1 file changed, 3 insertions(+)
fs/namei.c +0 -0
index caa2805..5b10ad0 100644

fs/namei.c drop_root_mnt: · line 593

Quoted 9 lines
fs/namei.c +3 -0
@@ -585,6 +585,9 @@ drop_root_mnt:
 
 static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
 {
+	/* dentries that serve as mountpoints are always considered valid */
+	if (d_mountpoint(dentry))
+		return 1;
 	return dentry->d_op->d_revalidate(dentry, flags);
 }
 

Makes sense to me. But what about the parent or grandparent of the mountpoint?

Quoted 4 lines

Presumably we don't want to invalidate them either, and I don't think d_mountpoint() returns true for those, does it?

NeilBrown

Good point...

I think we're probably saved there (at least on NFS) by the check_submounts_and_drop() call in nfs_lookup_revalidate.

Hmmm, that said...I did do most of this testing on a slightly older kernel that doesn't have that call, and I can't reproduce this problem on a 3.12-ish kernel. I think this is probably already fixed by Miklos' patches that added that.

Sorry for the noise!

Signature · 1 line
Jeff Layton <[email protected]>
#3 lore raw
In reply to Jeff Layton

For a similar issue in cifs vfs (samba bugzilla 8950), I was going to try unset the bit DCACHE_OP_REVALIDATE of d_flags of the
dentry. Would something like work for the mountpoint dentry?

Quoted 36 lines · Jeff Layton

We had a couple of reports of people that are mounting NFS filesystems, and then bind mounting certain local files onto dentries in that nfs mount (sort of like a poor-man's unionmount).

This all works well until the dentry serving as the mountpoint fails d_revalidate. The dentry will end up being invalidated which makes the bind mount unreachable via pathwalk.

It doesn't make much sense to me to allow dentries to serve as mountpoints to end up invalidated, so there's no real point in attempting to d_revalidate them at all.

---
 fs/namei.c | 3 +++
 1 file changed, 3 insertions(+)
fs/namei.c +3 -1
index caa2805..5b10ad0 100644
@@ -585,6 +585,9 @@ drop_root_mnt:
 
 static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
 {
+       /* dentries that serve as mountpoints are always considered valid */
+       if (d_mountpoint(dentry))
+               return 1;
        return dentry->d_op->d_revalidate(dentry, flags);
 }
 
--

1.8.3.1

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 3 lines · Shirish Pargaonkar

For a similar issue in cifs vfs (samba bugzilla 8950), I was going to try unset the bit DCACHE_OP_REVALIDATE of d_flags of the
dentry. Would something like work for the mountpoint dentry?

The DCACHE_OP_REVALIDATE are just caches of the available dentry operations, please don't manipulate those flags on their own.

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to Shirish Pargaonkar
Quoted 5 lines · On Mon, 4 Nov 2013 21:00:23 -0600 Shirish Pargaonkar…

For a similar issue in cifs vfs (samba bugzilla 8950), I was going to try unset the bit DCACHE_OP_REVALIDATE of d_flags of the
dentry. Would something like work for the mountpoint dentry?

I don't think that's the same issue at all. The problem there is that you need to instantiate a dentry for the root of the mount on the client, when you don't have any information about the parents.

In this case, we have dentries that are acting as mountpoints that were getting invalidated.

Quoted 42 lines · Jeff Layton
Quoted 40 lines

We had a couple of reports of people that are mounting NFS filesystems, and then bind mounting certain local files onto dentries in that nfs mount (sort of like a poor-man's unionmount).

This all works well until the dentry serving as the mountpoint fails d_revalidate. The dentry will end up being invalidated which makes the bind mount unreachable via pathwalk.

It doesn't make much sense to me to allow dentries to serve as mountpoints to end up invalidated, so there's no real point in attempting to d_revalidate them at all.

---
 fs/namei.c | 3 +++
 1 file changed, 3 insertions(+)
fs/namei.c +3 -1
index caa2805..5b10ad0 100644
@@ -585,6 +585,9 @@ drop_root_mnt:
 
 static inline int d_revalidate(struct dentry *dentry, unsigned int flags)
 {
+       /* dentries that serve as mountpoints are always considered valid */
+       if (d_mountpoint(dentry))
+               return 1;
        return dentry->d_op->d_revalidate(dentry, flags);
 }
 
--

1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Jeff Layton <[email protected]>