aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2013-07-14 09:09:57 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2013-07-14 09:09:57 -0400
commitd3db90b0a448bfdf77ab3d887c9579fead656cc5 (patch)
tree82e363aec98fbbedcfa3f8f26405c711a6771359 /net
parenta95e691f9c4a6e24fdeab6d7feae6d5411fe8a69 (diff)
__rpc_lookup_create_exclusive: pass string instead of qstr
... and use d_hash_and_lookup() instead of open-coding it, for fsck sake... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/rpc_pipe.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 63364cb5d11a..27e54d265705 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -656,13 +656,12 @@ static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry)
656} 656}
657 657
658static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, 658static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent,
659 struct qstr *name) 659 const char *name)
660{ 660{
661 struct dentry *dentry; 661 struct qstr q = QSTR_INIT(name, strlen(name));
662 662 struct dentry *dentry = d_hash_and_lookup(parent, &q);
663 dentry = d_lookup(parent, name);
664 if (!dentry) { 663 if (!dentry) {
665 dentry = d_alloc(parent, name); 664 dentry = d_alloc(parent, &q);
666 if (!dentry) 665 if (!dentry)
667 return ERR_PTR(-ENOMEM); 666 return ERR_PTR(-ENOMEM);
668 } 667 }
@@ -689,8 +688,7 @@ static void __rpc_depopulate(struct dentry *parent,
689 for (i = start; i < eof; i++) { 688 for (i = start; i < eof; i++) {
690 name.name = files[i].name; 689 name.name = files[i].name;
691 name.len = strlen(files[i].name); 690 name.len = strlen(files[i].name);
692 name.hash = full_name_hash(name.name, name.len); 691 dentry = d_hash_and_lookup(parent, &name);
693 dentry = d_lookup(parent, &name);
694 692
695 if (dentry == NULL) 693 if (dentry == NULL)
696 continue; 694 continue;
@@ -732,12 +730,7 @@ static int rpc_populate(struct dentry *parent,
732 730
733 mutex_lock(&dir->i_mutex); 731 mutex_lock(&dir->i_mutex);
734 for (i = start; i < eof; i++) { 732 for (i = start; i < eof; i++) {
735 struct qstr q; 733 dentry = __rpc_lookup_create_exclusive(parent, files[i].name);
736
737 q.name = files[i].name;
738 q.len = strlen(files[i].name);
739 q.hash = full_name_hash(q.name, q.len);
740 dentry = __rpc_lookup_create_exclusive(parent, &q);
741 err = PTR_ERR(dentry); 734 err = PTR_ERR(dentry);
742 if (IS_ERR(dentry)) 735 if (IS_ERR(dentry))
743 goto out_bad; 736 goto out_bad;
@@ -774,13 +767,11 @@ static struct dentry *rpc_mkdir_populate(struct dentry *parent,
774 int (*populate)(struct dentry *, void *), void *args_populate) 767 int (*populate)(struct dentry *, void *), void *args_populate)
775{ 768{
776 struct dentry *dentry; 769 struct dentry *dentry;
777 struct qstr q = QSTR_INIT(name, strlen(name));
778 struct inode *dir = parent->d_inode; 770 struct inode *dir = parent->d_inode;
779 int error; 771 int error;
780 772
781 q.hash = full_name_hash(q.name, q.len);
782 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); 773 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
783 dentry = __rpc_lookup_create_exclusive(parent, &q); 774 dentry = __rpc_lookup_create_exclusive(parent, name);
784 if (IS_ERR(dentry)) 775 if (IS_ERR(dentry))
785 goto out; 776 goto out;
786 error = __rpc_mkdir(dir, dentry, mode, NULL, private); 777 error = __rpc_mkdir(dir, dentry, mode, NULL, private);
@@ -843,7 +834,6 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name,
843 struct dentry *dentry; 834 struct dentry *dentry;
844 struct inode *dir = parent->d_inode; 835 struct inode *dir = parent->d_inode;
845 umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; 836 umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR;
846 struct qstr q;
847 int err; 837 int err;
848 838
849 if (pipe->ops->upcall == NULL) 839 if (pipe->ops->upcall == NULL)
@@ -851,12 +841,8 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name,
851 if (pipe->ops->downcall == NULL) 841 if (pipe->ops->downcall == NULL)
852 umode &= ~S_IWUGO; 842 umode &= ~S_IWUGO;
853 843
854 q.name = name;
855 q.len = strlen(name);
856 q.hash = full_name_hash(q.name, q.len),
857
858 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); 844 mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
859 dentry = __rpc_lookup_create_exclusive(parent, &q); 845 dentry = __rpc_lookup_create_exclusive(parent, name);
860 if (IS_ERR(dentry)) 846 if (IS_ERR(dentry))
861 goto out; 847 goto out;
862 err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops, 848 err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops,
@@ -1063,9 +1049,7 @@ struct dentry *rpc_d_lookup_sb(const struct super_block *sb,
1063 const unsigned char *dir_name) 1049 const unsigned char *dir_name)
1064{ 1050{
1065 struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name)); 1051 struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name));
1066 1052 return d_hash_and_lookup(sb->s_root, &dir);
1067 dir.hash = full_name_hash(dir.name, dir.len);
1068 return d_lookup(sb->s_root, &dir);
1069} 1053}
1070EXPORT_SYMBOL_GPL(rpc_d_lookup_sb); 1054EXPORT_SYMBOL_GPL(rpc_d_lookup_sb);
1071 1055