rpc_pipe: clean up how dentry operations get set in rpc_pipefs
Subsystems (4)
cover rpc_pipe: clean up how dentry operations get set in rpc_pipefs
Recently, I proposed a patch on the linux-nfs list to silence a WARNING:
[PATCH] rpc_pipefs: only set rpc_dentry_ops if d_op isn't already set
When reviewing that, Bruce (properly) pointed out that that patch sucked since it just hacked around the warning and did nothing to improve the code. This patchset is an attempt to correct that by making rpc_pipefs use a consistent set of dentry_operations, and ensuring that they're set on every dentry at d_alloc time.
Since Trond has already merged the earlier patch I sent into his nfs-for-next branch, this is based on top of that.
Jeff Layton (2):
rpc_pipe: export simple_dentry_operations and have rpc_pipefs use it
rpc_pipe: set dentry operations at d_alloc time
fs/libfs.c | 9 +++++---- include/linux/fs.h | 1 + net/sunrpc/rpc_pipe.c | 24 +++++++++++++++--------- 3 files changed, 21 insertions(+), 13 deletions(-)
Signature · 6 lines
1.8.1.4 -- 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
A message that is not in the archive (sent off-list or not yet received): 1372122340-28982-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
PATCH 2/2 rpc_pipe: set dentry operations at d_alloc time
Currently the way these get set is a little convoluted. If the dentry is allocated via lookup from userland, then it gets set by simple_lookup. If it gets allocated when the kernel is populating the directory, then it gets set via __rpc_lookup_create_exclusive, which has to check whether they might already be set. Between both of these, this ensures that all dentries have their d_op pointer set.
Instead of doing that, just have them set at d_alloc time by pointing sb->s_d_op at them. With that change, we no longer want the lookup op to set them, so we must move to using our own lookup routine.
--- net/sunrpc/rpc_pipe.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
net/sunrpc/rpc_pipe.c +20 -5
@@ -471,6 +471,23 @@ struct rpc_filelist {umode_t mode; }; +/* +* Lookup the data. This is trivial - if the dentry didn't already +* exist, we know it is negative. +*/ +static struct dentry * +rpc_lookup (struct inode *dir,struct dentry *dentry,unsigned int flags) +{ +if (dentry->d_name.len >NAME_MAX ) +return ERR_PTR (-ENAMETOOLONG ); +d_add (dentry,NULL ); +return NULL ; +} + +const struct inode_operations rpc_dir_inode_operations = { + .lookup = rpc_lookup, +}; +static struct inode *rpc_get_inode (struct super_block *sb,umode_t mode) {
@@ -483,7 +500,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode)switch (mode &S_IFMT ) {case S_IFDIR : inode->i_fop = &simple_dir_operations; - inode->i_op = &simple_dir_inode_operations; + inode->i_op = &rpc_dir_inode_operations;inc_nlink (inode);default :break ;
@@ -657,11 +674,8 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,if (!dentry)return ERR_PTR (-ENOMEM ); } -if (dentry->d_inode ==NULL ) { -if (!dentry->d_op) -d_set_d_op (dentry, &simple_dentry_operations); +if (dentry->d_inode ==NULL )return dentry; - }dput (dentry);return ERR_PTR (-EEXIST ); }
@@ -1108,6 +1122,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) sb->s_blocksize_bits =PAGE_CACHE_SHIFT ; sb->s_magic =RPCAUTH_GSSMAGIC ; sb->s_op = &s_ops; + sb->s_d_op = &simple_dentry_operations; sb->s_time_gran =1 ; inode =rpc_get_inode (sb,S_IFDIR |S_IRUGO |S_IXUGO );
Signature · 6 lines
1.8.1.4 -- 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
A message that is not in the archive (sent off-list or not yet received): 1372122340-28982-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 2/2] rpc_pipe: set dentry operations at d_alloc time
Quoted 31 lines · On Mon, 24 Jun 2013 21:05:40 -0400 Jeff Layton <[email protected]> wrote:
Currently the way these get set is a little convoluted. If the dentry is allocated via lookup from userland, then it gets set by
simple_lookup. If it gets allocated when the kernel is populating the directory, then it gets set via__rpc_lookup_create_exclusive, which has to check whether they might already be set. Between both of these, this ensures that all dentries have theird_oppointer set.Instead of doing that, just have them set at
d_alloctime by pointingsb->s_d_opat them. With that change, we no longer want the lookup op to set them, so we must move to using our own lookup routine.Signed-off-by Jeff Layton <[email protected]>--- net/sunrpc/rpc_pipe.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)net/sunrpc/rpc_pipe.c +7
-0@@ -471,6 +471,23 @@ struct rpc_filelist {umode_t mode; }; +/* +* Lookup the data. This is trivial - if the dentry didn't already +* exist, we know it is negative. +*/ +static struct dentry * +rpc_lookup (struct inode *dir,struct dentry *dentry,unsigned int flags) +{
net/sunrpc/rpc_pipe.c struct rpc_filelist { · line 490
Quoted 10 lines
net/sunrpc/rpc_pipe.c +10
-0+if (dentry->d_name.len >NAME_MAX ) +return ERR_PTR (-ENAMETOOLONG ); +d_add (dentry,NULL ); +return NULL ; +} + +const struct inode_operations rpc_dir_inode_operations = { + .lookup = rpc_lookup, +}; +
Nit: the above should probably be static. Let me know if you want me to respin...
Quoted 33 lines
net/sunrpc/rpc_pipe.c +3
-5static struct inode *rpc_get_inode (struct super_block *sb,umode_t mode) {@@ -483,7 +500,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode)switch (mode &S_IFMT ) {case S_IFDIR : inode->i_fop = &simple_dir_operations; - inode->i_op = &simple_dir_inode_operations; + inode->i_op = &rpc_dir_inode_operations;inc_nlink (inode);default :break ;@@ -657,11 +674,8 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,if (!dentry)return ERR_PTR (-ENOMEM ); } -if (dentry->d_inode ==NULL ) { -if (!dentry->d_op) -d_set_d_op (dentry, &simple_dentry_operations); +if (dentry->d_inode ==NULL )return dentry; - }dput (dentry);return ERR_PTR (-EEXIST ); }@@ -1108,6 +1122,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) sb->s_blocksize_bits =PAGE_CACHE_SHIFT ; sb->s_magic =RPCAUTH_GSSMAGIC ; sb->s_op = &s_ops; + sb->s_d_op = &simple_dentry_operations; sb->s_time_gran =1 ; inode =rpc_get_inode (sb,S_IFDIR |S_IRUGO |S_IXUGO );
Signature · 1 line
Jeff Layton <[email protected]>
PATCH v2 1/1 rpc_pipe: set dentry operations at d_alloc time
In reply to a message not in the archiveCurrently the way these get set is a little convoluted. If the dentry is allocated via lookup from userland, then it gets set by simple_lookup. If it gets allocated when the kernel is populating the directory, then it gets set via __rpc_lookup_create_exclusive, which has to check whether they might already be set. Between both of these, this ensures that all dentries have their d_op pointer set.
Instead of doing that, just have them set at d_alloc time by pointing sb->s_d_op at them. With that change, we no longer want the lookup op to set them, so we must move to using our own lookup routine.
--- net/sunrpc/rpc_pipe.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
net/sunrpc/rpc_pipe.c +20 -5
@@ -480,6 +480,23 @@ static const struct dentry_operations rpc_dentry_operations = { .d_delete = rpc_delete_dentry, }; +/* +* Lookup the data. This is trivial - if the dentry didn't already +* exist, we know it is negative. +*/ +static struct dentry * +rpc_lookup (struct inode *dir,struct dentry *dentry,unsigned int flags) +{ +if (dentry->d_name.len >NAME_MAX ) +return ERR_PTR (-ENAMETOOLONG ); +d_add (dentry,NULL ); +return NULL ; +} + +const struct inode_operations rpc_dir_inode_operations = { + .lookup = rpc_lookup, +}; +static struct inode *rpc_get_inode (struct super_block *sb,umode_t mode) {
@@ -492,7 +509,7 @@ rpc_get_inode(struct super_block *sb, umode_t mode)switch (mode &S_IFMT ) {case S_IFDIR : inode->i_fop = &simple_dir_operations; - inode->i_op = &simple_dir_inode_operations; + inode->i_op = &rpc_dir_inode_operations;inc_nlink (inode);default :break ;
@@ -666,11 +683,8 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,if (!dentry)return ERR_PTR (-ENOMEM ); } -if (dentry->d_inode ==NULL ) { -if (!dentry->d_op) -d_set_d_op (dentry, &rpc_dentry_operations); +if (dentry->d_inode ==NULL )return dentry; - }dput (dentry);return ERR_PTR (-EEXIST ); }
@@ -1117,6 +1131,7 @@ rpc_fill_super(struct super_block *sb, void *data, int silent) sb->s_blocksize_bits =PAGE_CACHE_SHIFT ; sb->s_magic =RPCAUTH_GSSMAGIC ; sb->s_op = &s_ops; + sb->s_d_op = &rpc_dentry_operations; sb->s_time_gran =1 ; inode =rpc_get_inode (sb,S_IFDIR |S_IRUGO |S_IXUGO );
Signature · 6 lines
1.8.1.4 -- 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
A message that is not in the archive (sent off-list or not yet received): 1372784452-2403-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH v2] rpc_pipe: set dentry operations at d_alloc time
Quoted 10 lines · Jeff Layton
Currently the way these get set is a little convoluted. If the dentry is allocated via lookup from userland, then it gets set by
simple_lookup. If it gets allocated when the kernel is populating the directory, then it gets set via__rpc_lookup_create_exclusive, which has to check whether they might already be set. Between both of these, this ensures that all dentries have theird_oppointer set.Instead of doing that, just have them set at
d_alloctime by pointingsb->s_d_opat them. With that change, we no longer want the lookup op to set them, so we must move to using our own lookup routine.
There's a better solution - just make simple_lookup() skip d_set_d_op() if superblock already has ->s_d_op (and thus d_alloc() has already set the damn thing). Voila - we can just set ->s_d_op and leave inode_operations as is.
--
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
A message that is not in the archive (sent off-list or not yet received): 20130714140011.GI4165-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org
Re: [PATCH v2] rpc_pipe: set dentry operations at d_alloc time
Quoted 8 lines · On Sun, 14 Jul 2013 15:00:11 +0100 Al Viro <[email protected]> wrote:
Quoted 7 lines · Jeff Layton
Currently the way these get set is a little convoluted. If the dentry is allocated via lookup from userland, then it gets set by
simple_lookup. If it gets allocated when the kernel is populating the directory, then it gets set via__rpc_lookup_create_exclusive, which has to check whether they might already be set. Between both of these, this ensures that all dentries have theird_oppointer set.
Quoted 8 lines
Quoted 3 lines
Instead of doing that, just have them set at
d_alloctime by pointingsb->s_d_opat them. With that change, we no longer want the lookup op to set them, so we must move to using our own lookup routine.There's a better solution - just make
simple_lookup()skipd_set_d_op()if superblock already has ->s_d_op (and thusd_alloc()has already set the damn thing). Voila - we can just set ->s_d_op and leaveinode_operationsas is.
Yeah, that is a better solution and the code now in mainline looks reasonable. Trond already merged this patch however, so I'll spin up another patch on top of mainline to convert this back to simple_dir_inode_operations.
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
PATCH 1/2 rpc_pipe: export simple_dentry_operations and have rpc_pipefs use it
In reply to Jeff Layton...instead of replicating a copy of them.
--- fs/libfs.c | 9 +++++---- include/linux/fs.h | 1 + net/sunrpc/rpc_pipe.c | 11 +---------- 3 files changed, 7 insertions(+), 14 deletions(-)
fs/libfs.c +5 -4
@@ -49,16 +49,16 @@ static int simple_delete_dentry(const struct dentry *dentry)return 1 ; } +const struct dentry_operations simple_dentry_operations = { + .d_delete = simple_delete_dentry, +}; +/* * Lookup the data. This is trivial - if the dentry didn't already * exist, we know it is negative. Set d_op to delete negative dentries. */ struct dentry *simple_lookup (struct inode *dir,struct dentry *dentry,unsigned int flags) { -static const struct dentry_operations simple_dentry_operations = { - .d_delete = simple_delete_dentry, - }; -if (dentry->d_name.len >NAME_MAX )return ERR_PTR (-ENAMETOOLONG );d_set_d_op (dentry, &simple_dentry_operations);
@@ -987,6 +987,7 @@ EXPORT_SYMBOL(simple_write_begin);EXPORT_SYMBOL (simple_write_end);EXPORT_SYMBOL (simple_dir_inode_operations);EXPORT_SYMBOL (simple_dir_operations); +EXPORT_SYMBOL (simple_dentry_operations);EXPORT_SYMBOL (simple_empty);EXPORT_SYMBOL (simple_fill_super);EXPORT_SYMBOL (simple_getattr);
include/linux/fs.h +1 -0
@@ -2546,6 +2546,7 @@ extern int simple_write_end(struct file *file, struct address_space *mapping,extern struct dentry *simple_lookup (struct inode *,struct dentry *,unsigned int flags);extern ssize_t generic_read_dir (struct file *,char __user *,size_t ,loff_t *);extern const struct file_operations simple_dir_operations; +extern const struct dentry_operations simple_dentry_operations;extern const struct inode_operations simple_dir_inode_operations;struct tree_descr {char *name;const struct file_operations *ops;int mode; };struct dentry *d_alloc_name (struct dentry *,const char *);
net/sunrpc/rpc_pipe.c +1 -10
@@ -471,15 +471,6 @@ struct rpc_filelist {umode_t mode; }; -static int rpc_delete_dentry (const struct dentry *dentry) -{ -return 1 ; -} - -static const struct dentry_operations rpc_dentry_operations = { - .d_delete = rpc_delete_dentry, -}; -static struct inode *rpc_get_inode (struct super_block *sb,umode_t mode) {
@@ -668,7 +659,7 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, }if (dentry->d_inode ==NULL ) {if (!dentry->d_op) -d_set_d_op (dentry, &rpc_dentry_operations); +d_set_d_op (dentry, &simple_dentry_operations);return dentry; }dput (dentry);
Signature · 1 line
1.8.1.4
A message that is not in the archive (sent off-list or not yet received): 1372122340-28982-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Re: [PATCH 1/2] rpc_pipe: export simple_dentry_operations and have rpc_pipefs use it
Quoted 9 lines · Jeff Layton
...instead of replicating a copy of them.
Signed-off-by Jeff Layton <[email protected]>--- fs/libfs.c | 9 +++++---- include/linux/fs.h | 1 + net/sunrpc/rpc_pipe.c | 11 +---------- 3 files changed, 7 insertions(+), 14 deletions(-)
Can you please get an ACK from Al on this patch.
Cheers
Trond
Quoted 74 lines
fs/libfs.c +5
-4@@ -49,16 +49,16 @@ static int simple_delete_dentry(const struct dentry *dentry)return 1 ; } +const struct dentry_operations simple_dentry_operations = { + .d_delete = simple_delete_dentry, +}; +/* * Lookup the data. This is trivial - if the dentry didn't already * exist, we know it is negative. Set d_op to delete negative dentries. */ struct dentry *simple_lookup (struct inode *dir,struct dentry *dentry,unsigned int flags) { -static const struct dentry_operations simple_dentry_operations = { - .d_delete = simple_delete_dentry, - }; -if (dentry->d_name.len >NAME_MAX )return ERR_PTR (-ENAMETOOLONG );d_set_d_op (dentry, &simple_dentry_operations);@@ -987,6 +987,7 @@ EXPORT_SYMBOL(simple_write_begin);EXPORT_SYMBOL (simple_write_end);EXPORT_SYMBOL (simple_dir_inode_operations);EXPORT_SYMBOL (simple_dir_operations); +EXPORT_SYMBOL (simple_dentry_operations);EXPORT_SYMBOL (simple_empty);EXPORT_SYMBOL (simple_fill_super);EXPORT_SYMBOL (simple_getattr);include/linux/fs.h +1
-0@@ -2546,6 +2546,7 @@ extern int simple_write_end(struct file *file, struct address_space *mapping,extern struct dentry *simple_lookup (struct inode *,struct dentry *,unsigned int flags);extern ssize_t generic_read_dir (struct file *,char __user *,size_t ,loff_t *);extern const struct file_operations simple_dir_operations; +extern const struct dentry_operations simple_dentry_operations;extern const struct inode_operations simple_dir_inode_operations;struct tree_descr {char *name;const struct file_operations *ops;int mode; };struct dentry *d_alloc_name (struct dentry *,const char *);net/sunrpc/rpc_pipe.c +1
-10@@ -471,15 +471,6 @@ struct rpc_filelist {umode_t mode; }; -static int rpc_delete_dentry (const struct dentry *dentry) -{ -return 1 ; -} - -static const struct dentry_operations rpc_dentry_operations = { - .d_delete = rpc_delete_dentry, -}; -static struct inode *rpc_get_inode (struct super_block *sb,umode_t mode) {@@ -668,7 +659,7 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, }if (dentry->d_inode ==NULL ) {if (!dentry->d_op) -d_set_d_op (dentry, &rpc_dentry_operations); +d_set_d_op (dentry, &simple_dentry_operations);return dentry; }dput (dentry);
Signature · 10 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com -- 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
A message that is not in the archive (sent off-list or not yet received): 1372174611.5968.28.camel-5lNtUQgoD8Pfa3cDbr2K10B+6BGkLq7r@public.gmane.org
Re: [PATCH 1/2] rpc_pipe: export simple_dentry_operations and have rpc_pipefs use it
Quoted 11 lines · Trond
Quoted 9 lines · Jeff Layton
...instead of replicating a copy of them.
Signed-off-by Jeff Layton <[email protected]>--- fs/libfs.c | 9 +++++---- include/linux/fs.h | 1 + net/sunrpc/rpc_pipe.c | 11 +---------- 3 files changed, 7 insertions(+), 14 deletions(-)
Quoted 5 lines
Can you please get an ACK from Al on this patch.
Cheers
Trond
Al, could you weigh in on this? The only real change to generic VFS code is that I'm exporting simple_dentry_operations here.
Thanks,
Jeff
Quoted 76 lines
Quoted 74 lines
fs/libfs.c +5
-4@@ -49,16 +49,16 @@ static int simple_delete_dentry(const struct dentry *dentry)return 1 ; } +const struct dentry_operations simple_dentry_operations = { + .d_delete = simple_delete_dentry, +}; +/* * Lookup the data. This is trivial - if the dentry didn't already * exist, we know it is negative. Set d_op to delete negative dentries. */ struct dentry *simple_lookup (struct inode *dir,struct dentry *dentry,unsigned int flags) { -static const struct dentry_operations simple_dentry_operations = { - .d_delete = simple_delete_dentry, - }; -if (dentry->d_name.len >NAME_MAX )return ERR_PTR (-ENAMETOOLONG );d_set_d_op (dentry, &simple_dentry_operations);@@ -987,6 +987,7 @@ EXPORT_SYMBOL(simple_write_begin);EXPORT_SYMBOL (simple_write_end);EXPORT_SYMBOL (simple_dir_inode_operations);EXPORT_SYMBOL (simple_dir_operations); +EXPORT_SYMBOL (simple_dentry_operations);EXPORT_SYMBOL (simple_empty);EXPORT_SYMBOL (simple_fill_super);EXPORT_SYMBOL (simple_getattr);include/linux/fs.h +1
-0@@ -2546,6 +2546,7 @@ extern int simple_write_end(struct file *file, struct address_space *mapping,extern struct dentry *simple_lookup (struct inode *,struct dentry *,unsigned int flags);extern ssize_t generic_read_dir (struct file *,char __user *,size_t ,loff_t *);extern const struct file_operations simple_dir_operations; +extern const struct dentry_operations simple_dentry_operations;extern const struct inode_operations simple_dir_inode_operations;struct tree_descr {char *name;const struct file_operations *ops;int mode; };struct dentry *d_alloc_name (struct dentry *,const char *);net/sunrpc/rpc_pipe.c +1
-10@@ -471,15 +471,6 @@ struct rpc_filelist {umode_t mode; }; -static int rpc_delete_dentry (const struct dentry *dentry) -{ -return 1 ; -} - -static const struct dentry_operations rpc_dentry_operations = { - .d_delete = rpc_delete_dentry, -}; -static struct inode *rpc_get_inode (struct super_block *sb,umode_t mode) {@@ -668,7 +659,7 @@ static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, }if (dentry->d_inode ==NULL ) {if (!dentry->d_op) -d_set_d_op (dentry, &rpc_dentry_operations); +d_set_d_op (dentry, &simple_dentry_operations);return dentry; }dput (dentry);
Signature · 5 lines
Jeff Layton <[email protected]> -- 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
A message that is not in the archive (sent off-list or not yet received): 20130701122201.6a8fc966-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Re: [PATCH 1/2] rpc_pipe: export simple_dentry_operations and have rpc_pipefs use it
Quoted 14 lines · Jeff Layton
Quoted 11 lines · Trond
Quoted 9 lines · Jeff Layton
...instead of replicating a copy of them.
Signed-off-by Jeff Layton <[email protected]>--- fs/libfs.c | 9 +++++---- include/linux/fs.h | 1 + net/sunrpc/rpc_pipe.c | 11 +---------- 3 files changed, 7 insertions(+), 14 deletions(-)
Quoted 9 lines
Quoted 5 lines
Can you please get an ACK from Al on this patch.
Cheers
TrondAl, could you weigh in on this? The only real change to generic VFS code is that I'm exporting
simple_dentry_operationshere.
Trond, I've been unable to get in touch with Al to get him to ACK this. I'm guessing he's busy getting patches together for the merge window.
I propose we do this instead:
I'll respin the patch such that sb->s_d_op is set to rpc_dentry_operations, and we'll just keep those for now. Then, I can propose a patch later to export simple_dentry_operations and convert rpc_pipefs to use that afterward (probably for 3.12).
I'll post the respin after I've done a bit of testing...
Signature · 6 lines
Jeff Layton <[email protected]> -- 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