Skip to contentSkip to conversation

NFS: Allow NULL nameidata in d_revalidate and create

PATCH NAK Tyler Hicks 2 participants 6 messages May 5, 2011

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

PATCH 1/1 NFS: Allow NULL nameidata in d_revalidate and create

To add support for eCryptfs mounts on top of NFS client mounts, the NFS client must properly handle NULL nameidata pointers in its d_revalidate functions.

NFS clients should also handle NULL nameidata in its create functions, although this is not currently required for eCryptfs support.

---
 fs/nfs/dir.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
fs/nfs/dir.c +4 -4
index 7237672..03c6ab2 100644
@@ -1095,7 +1095,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
 	struct nfs_fattr *fattr = NULL;
 	int error;
 
-	if (nd->flags & LOOKUP_RCU)
+	if (nd && nd->flags & LOOKUP_RCU)
 		return -ECHILD;
 
 	parent = dget_parent(dentry);
@@ -1493,7 +1493,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
 	struct nfs_open_context *ctx;
 	int openflags, ret = 0;
 
-	if (nd->flags & LOOKUP_RCU)
+	if (nd && nd->flags & LOOKUP_RCU)
 		return -ECHILD;
 
 	inode = dentry->d_inode;
@@ -1583,7 +1583,7 @@ static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
 	attr.ia_mode = mode;
 	attr.ia_valid = ATTR_MODE;
 
-	if ((nd->flags & LOOKUP_CREATE) != 0) {
+	if (nd && (nd->flags & LOOKUP_CREATE) != 0) {
 		open_flags = nd->intent.open.flags;
 
 		ctx = nameidata_to_nfs_open_context(dentry, nd);
@@ -1673,7 +1673,7 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
 	attr.ia_mode = mode;
 	attr.ia_valid = ATTR_MODE;
 
-	if ((nd->flags & LOOKUP_CREATE) != 0)
+	if (nd && (nd->flags & LOOKUP_CREATE) != 0)
 		open_flags = nd->intent.open.flags;
 
 	error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, NULL);
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 9 lines · Tyler Hicks

To add support for eCryptfs mounts on top of NFS client mounts, the NFS client must properly handle NULL nameidata pointers in its d_revalidate functions.

NFS clients should also handle NULL nameidata in its create functions, although this is not currently required for eCryptfs support.

---

We (eCryptfs) are in the process of switching mailing lists, so I copied both the old (launchpad.net) and the new (vger.kernel.org), but it doesn't look like the vger.kernel.org list is accepting mail yet. Sorry about that, I should have tested it first. Feel free to drop it from any replies.

I should also mention that if/when this patch is merged, eCryptfs will have basic support of mounting on top of NFSv3 client mounts. I say basic because I'm sure there are some bugs, I'm not yet confident that the required cache flushes are there in the eCryptfs layer to have NFSv3 cache consistency, and we have some trouble with silly rename.

All files unlinked through eCryptfs get silly renamed in the NFS client because of the extra reference eCryptfs holds on the NFS dentry.

This also seems to come into play when unlinking the last file in a directory and then immediately removing the directory. nfs_rmdir() will sometimes return -EBUSY.

BTW, I think these are all issues that should be handled in the eCryptfs layer, but I wanted to provide an update on the status of eCryptfs on top of NFS.

Tyler

Quoted 46 lines
 fs/nfs/dir.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
fs/nfs/dir.c +4 -4
index 7237672..03c6ab2 100644
@@ -1095,7 +1095,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
 	struct nfs_fattr *fattr = NULL;
 	int error;
 
-	if (nd->flags & LOOKUP_RCU)
+	if (nd && nd->flags & LOOKUP_RCU)
 		return -ECHILD;
 
 	parent = dget_parent(dentry);
@@ -1493,7 +1493,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
 	struct nfs_open_context *ctx;
 	int openflags, ret = 0;
 
-	if (nd->flags & LOOKUP_RCU)
+	if (nd && nd->flags & LOOKUP_RCU)
 		return -ECHILD;
 
 	inode = dentry->d_inode;
@@ -1583,7 +1583,7 @@ static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
 	attr.ia_mode = mode;
 	attr.ia_valid = ATTR_MODE;
 
-	if ((nd->flags & LOOKUP_CREATE) != 0) {
+	if (nd && (nd->flags & LOOKUP_CREATE) != 0) {
 		open_flags = nd->intent.open.flags;
 
 		ctx = nameidata_to_nfs_open_context(dentry, nd);
@@ -1673,7 +1673,7 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
 	attr.ia_mode = mode;
 	attr.ia_valid = ATTR_MODE;
 
-	if ((nd->flags & LOOKUP_CREATE) != 0)
+	if (nd && (nd->flags & LOOKUP_CREATE) != 0)
 		open_flags = nd->intent.open.flags;
 
 	error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, NULL);
Signature · 1 line
1.7.4.4
#2 lore raw
Quoted 26 lines · Tyler Hicks
Quoted 9 lines · Tyler Hicks

To add support for eCryptfs mounts on top of NFS client mounts, the NFS client must properly handle NULL nameidata pointers in its d_revalidate functions.

NFS clients should also handle NULL nameidata in its create functions, although this is not currently required for eCryptfs support.

---

We (eCryptfs) are in the process of switching mailing lists, so I copied both the old (launchpad.net) and the new (vger.kernel.org), but it doesn't look like the vger.kernel.org list is accepting mail yet. Sorry about that, I should have tested it first. Feel free to drop it from any replies.

I should also mention that if/when this patch is merged, eCryptfs will have basic support of mounting on top of NFSv3 client mounts. I say basic because I'm sure there are some bugs, I'm not yet confident that the required cache flushes are there in the eCryptfs layer to have NFSv3 cache consistency, and we have some trouble with silly rename.

All files unlinked through eCryptfs get silly renamed in the NFS client because of the extra reference eCryptfs holds on the NFS dentry.

Quoted 7 lines

This also seems to come into play when unlinking the last file in a directory and then immediately removing the directory. nfs_rmdir() will sometimes return -EBUSY.

BTW, I think these are all issues that should be handled in the eCryptfs layer, but I wanted to provide an update on the status of eCryptfs on top of NFS.

Why would we want to 'support' ecryptfs in this manner? Can't you set up a proper nameidata with appropriate open intents?

This patch might allow you to look up files on NFS, but without open intents, you certainly won't be able to open them, nor will you be able to create them (as you seem to believe).

NACKed...

Signature · 6 lines
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com
#3 lore raw
Quoted 31 lines · Trond Myklebust
Quoted 30 lines · Tyler Hicks
Quoted 9 lines · Tyler Hicks

To add support for eCryptfs mounts on top of NFS client mounts, the NFS client must properly handle NULL nameidata pointers in its d_revalidate functions.

NFS clients should also handle NULL nameidata in its create functions, although this is not currently required for eCryptfs support.

---

We (eCryptfs) are in the process of switching mailing lists, so I copied both the old (launchpad.net) and the new (vger.kernel.org), but it doesn't look like the vger.kernel.org list is accepting mail yet. Sorry about that, I should have tested it first. Feel free to drop it from any replies.

I should also mention that if/when this patch is merged, eCryptfs will have basic support of mounting on top of NFSv3 client mounts. I say basic because I'm sure there are some bugs, I'm not yet confident that the required cache flushes are there in the eCryptfs layer to have NFSv3 cache consistency, and we have some trouble with silly rename.

All files unlinked through eCryptfs get silly renamed in the NFS client because of the extra reference eCryptfs holds on the NFS dentry.

This also seems to come into play when unlinking the last file in a directory and then immediately removing the directory. nfs_rmdir() will sometimes return -EBUSY.

Quoted 6 lines
Quoted 3 lines

BTW, I think these are all issues that should be handled in the eCryptfs layer, but I wanted to provide an update on the status of eCryptfs on top of NFS.

Why would we want to 'support' ecryptfs in this manner? Can't you set up a proper nameidata with appropriate open intents?

Sorry, that was bad wording in my commit message. NFS would not be "supporting" eCryptfs. eCryptfs supports the filesystem that it is mounted on top of. We keep any quirks from the stacking scheme in fs/ecryptfs/ and don't expect filesystems to do anything special for eCryptfs.

In this case, I believe it is a bug for NFS to oops on NULL nameidata in d_revalidate. It was introduced by 34286d66 and 657e94b6 and has been fixed in most other filesystems (9177ada9, 8ce84eeb, 4714e637, 53fe9241, 529c5f95, 0eb980e3).

I saw two potential oopses in the NFS create functions and patched those, too. However, in the case of create, eCryptfs does pass a proper nameidata to vfs_create().

Quoted 4 lines

This patch might allow you to look up files on NFS, but without open intents, you certainly won't be able to open them, nor will you be able to create them (as you seem to believe).

I'm not sure why open and create would not work. My testing shows that with this patch applied, I can compile the kernel in an eCryptfs mount mounted on top of an NFSv3 client, run fsx-linux, etc.

Tyler

Quoted 11 lines

NACKed...

Signature · 6 lines
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com
#4 lore raw
Quoted 45 lines · Tyler Hicks
Quoted 31 lines · Trond Myklebust
Quoted 30 lines · Tyler Hicks
Quoted 9 lines · Tyler Hicks

To add support for eCryptfs mounts on top of NFS client mounts, the NFS client must properly handle NULL nameidata pointers in its d_revalidate functions.

NFS clients should also handle NULL nameidata in its create functions, although this is not currently required for eCryptfs support.

---

We (eCryptfs) are in the process of switching mailing lists, so I copied both the old (launchpad.net) and the new (vger.kernel.org), but it doesn't look like the vger.kernel.org list is accepting mail yet. Sorry about that, I should have tested it first. Feel free to drop it from any replies.

I should also mention that if/when this patch is merged, eCryptfs will have basic support of mounting on top of NFSv3 client mounts. I say basic because I'm sure there are some bugs, I'm not yet confident that the required cache flushes are there in the eCryptfs layer to have NFSv3 cache consistency, and we have some trouble with silly rename.

All files unlinked through eCryptfs get silly renamed in the NFS client because of the extra reference eCryptfs holds on the NFS dentry.

This also seems to come into play when unlinking the last file in a directory and then immediately removing the directory. nfs_rmdir() will sometimes return -EBUSY.

Quoted 6 lines
Quoted 3 lines

BTW, I think these are all issues that should be handled in the eCryptfs layer, but I wanted to provide an update on the status of eCryptfs on top of NFS.

Why would we want to 'support' ecryptfs in this manner? Can't you set up a proper nameidata with appropriate open intents?

Sorry, that was bad wording in my commit message. NFS would not be "supporting" eCryptfs. eCryptfs supports the filesystem that it is mounted on top of. We keep any quirks from the stacking scheme in fs/ecryptfs/ and don't expect filesystems to do anything special for eCryptfs.

Quoted 8 lines

In this case, I believe it is a bug for NFS to oops on NULL nameidata in d_revalidate. It was introduced by 34286d66 and 657e94b6 and has been fixed in most other filesystems (9177ada9, 8ce84eeb, 4714e637, 53fe9241, 529c5f95, 0eb980e3).

I saw two potential oopses in the NFS create functions and patched those, too. However, in the case of create, eCryptfs does pass a proper nameidata to vfs_create().

Does it do so to d_revalidate() when opening a file?

Quoted 8 lines
Quoted 4 lines

This patch might allow you to look up files on NFS, but without open intents, you certainly won't be able to open them, nor will you be able to create them (as you seem to believe).

I'm not sure why open and create would not work. My testing shows that with this patch applied, I can compile the kernel in an eCryptfs mount mounted on top of an NFSv3 client, run fsx-linux, etc.

Please try testing with NFSv4, which requires intents in both lookup() and d_revalidate() when opening a file.

Signature · 6 lines
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com
#5 lore raw
Quoted 51 lines · Trond Myklebust
Quoted 50 lines · Tyler Hicks
Quoted 31 lines · Trond Myklebust
Quoted 30 lines · Tyler Hicks
Quoted 9 lines · Tyler Hicks

To add support for eCryptfs mounts on top of NFS client mounts, the NFS client must properly handle NULL nameidata pointers in its d_revalidate functions.

NFS clients should also handle NULL nameidata in its create functions, although this is not currently required for eCryptfs support.

---

We (eCryptfs) are in the process of switching mailing lists, so I copied both the old (launchpad.net) and the new (vger.kernel.org), but it doesn't look like the vger.kernel.org list is accepting mail yet. Sorry about that, I should have tested it first. Feel free to drop it from any replies.

I should also mention that if/when this patch is merged, eCryptfs will have basic support of mounting on top of NFSv3 client mounts. I say basic because I'm sure there are some bugs, I'm not yet confident that the required cache flushes are there in the eCryptfs layer to have NFSv3 cache consistency, and we have some trouble with silly rename.

All files unlinked through eCryptfs get silly renamed in the NFS client because of the extra reference eCryptfs holds on the NFS dentry.

This also seems to come into play when unlinking the last file in a directory and then immediately removing the directory. nfs_rmdir() will sometimes return -EBUSY.

Quoted 6 lines
Quoted 3 lines

BTW, I think these are all issues that should be handled in the eCryptfs layer, but I wanted to provide an update on the status of eCryptfs on top of NFS.

Why would we want to 'support' ecryptfs in this manner? Can't you set up a proper nameidata with appropriate open intents?

Sorry, that was bad wording in my commit message. NFS would not be "supporting" eCryptfs. eCryptfs supports the filesystem that it is mounted on top of. We keep any quirks from the stacking scheme in fs/ecryptfs/ and don't expect filesystems to do anything special for eCryptfs.

In this case, I believe it is a bug for NFS to oops on NULL nameidata in d_revalidate. It was introduced by 34286d66 and 657e94b6 and has been fixed in most other filesystems (9177ada9, 8ce84eeb, 4714e637, 53fe9241, 529c5f95, 0eb980e3).

Quoted 5 lines
Quoted 3 lines

I saw two potential oopses in the NFS create functions and patched those, too. However, in the case of create, eCryptfs does pass a proper nameidata to vfs_create().

Does it do so to d_revalidate() when opening a file?

I don't believe so.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

This patch might allow you to look up files on NFS, but without open intents, you certainly won't be able to open them, nor will you be able to create them (as you seem to believe).

Quoted 6 lines
Quoted 3 lines

I'm not sure why open and create would not work. My testing shows that with this patch applied, I can compile the kernel in an eCryptfs mount mounted on top of an NFSv3 client, run fsx-linux, etc.

Please try testing with NFSv4, which requires intents in both lookup() and d_revalidate() when opening a file.

I acknowledge that eCryptfs won't work on top of NFSv4 in its current form. The lookup, create, and open paths in eCryptfs will need some rewriting, as you've mentioned.

This patch simply allows eCryptfs to be mounted on top of NFSv3, which is the first step in allowing client-side file encryption. This is an eCryptfs feature that is asked for quite often and I hope you'll reconsider merging the patch until I can make the changes needed to support NFSv4.

Tyler

Quoted 9 lines
Signature · 7 lines
-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
[email protected]
www.netapp.com