diff options
Diffstat (limited to 'net')
| -rw-r--r-- | net/sunrpc/cache.c | 18 | ||||
| -rw-r--r-- | net/sunrpc/clnt.c | 20 | ||||
| -rw-r--r-- | net/sunrpc/rpc_pipe.c | 40 |
3 files changed, 26 insertions, 52 deletions
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 49eb37010aa3..a72de074172d 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
| @@ -1823,19 +1823,11 @@ int sunrpc_cache_register_pipefs(struct dentry *parent, | |||
| 1823 | const char *name, umode_t umode, | 1823 | const char *name, umode_t umode, |
| 1824 | struct cache_detail *cd) | 1824 | struct cache_detail *cd) |
| 1825 | { | 1825 | { |
| 1826 | struct qstr q; | 1826 | struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); |
| 1827 | struct dentry *dir; | 1827 | if (IS_ERR(dir)) |
| 1828 | int ret = 0; | 1828 | return PTR_ERR(dir); |
| 1829 | 1829 | cd->u.pipefs.dir = dir; | |
| 1830 | q.name = name; | 1830 | return 0; |
| 1831 | q.len = strlen(name); | ||
| 1832 | q.hash = full_name_hash(q.name, q.len); | ||
| 1833 | dir = rpc_create_cache_dir(parent, &q, umode, cd); | ||
| 1834 | if (!IS_ERR(dir)) | ||
| 1835 | cd->u.pipefs.dir = dir; | ||
| 1836 | else | ||
| 1837 | ret = PTR_ERR(dir); | ||
| 1838 | return ret; | ||
| 1839 | } | 1831 | } |
| 1840 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); | 1832 | EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); |
| 1841 | 1833 | ||
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index aa401560777b..9963584605c0 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
| @@ -128,9 +128,7 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb, | |||
| 128 | { | 128 | { |
| 129 | static uint32_t clntid; | 129 | static uint32_t clntid; |
| 130 | char name[15]; | 130 | char name[15]; |
| 131 | struct qstr q = { .name = name }; | ||
| 132 | struct dentry *dir, *dentry; | 131 | struct dentry *dir, *dentry; |
| 133 | int error; | ||
| 134 | 132 | ||
| 135 | dir = rpc_d_lookup_sb(sb, dir_name); | 133 | dir = rpc_d_lookup_sb(sb, dir_name); |
| 136 | if (dir == NULL) { | 134 | if (dir == NULL) { |
| @@ -138,19 +136,17 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb, | |||
| 138 | return dir; | 136 | return dir; |
| 139 | } | 137 | } |
| 140 | for (;;) { | 138 | for (;;) { |
| 141 | q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); | 139 | snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); |
| 142 | name[sizeof(name) - 1] = '\0'; | 140 | name[sizeof(name) - 1] = '\0'; |
| 143 | q.hash = full_name_hash(q.name, q.len); | 141 | dentry = rpc_create_client_dir(dir, name, clnt); |
| 144 | dentry = rpc_create_client_dir(dir, &q, clnt); | ||
| 145 | if (!IS_ERR(dentry)) | 142 | if (!IS_ERR(dentry)) |
| 146 | break; | 143 | break; |
| 147 | error = PTR_ERR(dentry); | 144 | if (dentry == ERR_PTR(-EEXIST)) |
| 148 | if (error != -EEXIST) { | 145 | continue; |
| 149 | printk(KERN_INFO "RPC: Couldn't create pipefs entry" | 146 | printk(KERN_INFO "RPC: Couldn't create pipefs entry" |
| 150 | " %s/%s, error %d\n", | 147 | " %s/%s, error %ld\n", |
| 151 | dir_name, name, error); | 148 | dir_name, name, PTR_ERR(dentry)); |
| 152 | break; | 149 | break; |
| 153 | } | ||
| 154 | } | 150 | } |
| 155 | dput(dir); | 151 | dput(dir); |
| 156 | return dentry; | 152 | return dentry; |
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 61239a2cb786..406859cc68aa 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c | |||
| @@ -673,13 +673,12 @@ static int __rpc_rmpipe(struct inode *dir, struct dentry *dentry) | |||
| 673 | } | 673 | } |
| 674 | 674 | ||
| 675 | static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, | 675 | static struct dentry *__rpc_lookup_create_exclusive(struct dentry *parent, |
| 676 | struct qstr *name) | 676 | const char *name) |
| 677 | { | 677 | { |
| 678 | struct dentry *dentry; | 678 | struct qstr q = QSTR_INIT(name, strlen(name)); |
| 679 | 679 | struct dentry *dentry = d_hash_and_lookup(parent, &q); | |
| 680 | dentry = d_lookup(parent, name); | ||
| 681 | if (!dentry) { | 680 | if (!dentry) { |
| 682 | dentry = d_alloc(parent, name); | 681 | dentry = d_alloc(parent, &q); |
| 683 | if (!dentry) | 682 | if (!dentry) |
| 684 | return ERR_PTR(-ENOMEM); | 683 | return ERR_PTR(-ENOMEM); |
| 685 | } | 684 | } |
| @@ -704,8 +703,7 @@ static void __rpc_depopulate(struct dentry *parent, | |||
| 704 | for (i = start; i < eof; i++) { | 703 | for (i = start; i < eof; i++) { |
| 705 | name.name = files[i].name; | 704 | name.name = files[i].name; |
| 706 | name.len = strlen(files[i].name); | 705 | name.len = strlen(files[i].name); |
| 707 | name.hash = full_name_hash(name.name, name.len); | 706 | dentry = d_hash_and_lookup(parent, &name); |
| 708 | dentry = d_lookup(parent, &name); | ||
| 709 | 707 | ||
| 710 | if (dentry == NULL) | 708 | if (dentry == NULL) |
| 711 | continue; | 709 | continue; |
| @@ -747,12 +745,7 @@ static int rpc_populate(struct dentry *parent, | |||
| 747 | 745 | ||
| 748 | mutex_lock(&dir->i_mutex); | 746 | mutex_lock(&dir->i_mutex); |
| 749 | for (i = start; i < eof; i++) { | 747 | for (i = start; i < eof; i++) { |
| 750 | struct qstr q; | 748 | dentry = __rpc_lookup_create_exclusive(parent, files[i].name); |
| 751 | |||
| 752 | q.name = files[i].name; | ||
| 753 | q.len = strlen(files[i].name); | ||
| 754 | q.hash = full_name_hash(q.name, q.len); | ||
| 755 | dentry = __rpc_lookup_create_exclusive(parent, &q); | ||
| 756 | err = PTR_ERR(dentry); | 749 | err = PTR_ERR(dentry); |
| 757 | if (IS_ERR(dentry)) | 750 | if (IS_ERR(dentry)) |
| 758 | goto out_bad; | 751 | goto out_bad; |
| @@ -785,7 +778,7 @@ out_bad: | |||
| 785 | } | 778 | } |
| 786 | 779 | ||
| 787 | static struct dentry *rpc_mkdir_populate(struct dentry *parent, | 780 | static struct dentry *rpc_mkdir_populate(struct dentry *parent, |
| 788 | struct qstr *name, umode_t mode, void *private, | 781 | const char *name, umode_t mode, void *private, |
| 789 | int (*populate)(struct dentry *, void *), void *args_populate) | 782 | int (*populate)(struct dentry *, void *), void *args_populate) |
| 790 | { | 783 | { |
| 791 | struct dentry *dentry; | 784 | struct dentry *dentry; |
| @@ -856,7 +849,6 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name, | |||
| 856 | struct dentry *dentry; | 849 | struct dentry *dentry; |
| 857 | struct inode *dir = parent->d_inode; | 850 | struct inode *dir = parent->d_inode; |
| 858 | umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; | 851 | umode_t umode = S_IFIFO | S_IRUSR | S_IWUSR; |
| 859 | struct qstr q; | ||
| 860 | int err; | 852 | int err; |
| 861 | 853 | ||
| 862 | if (pipe->ops->upcall == NULL) | 854 | if (pipe->ops->upcall == NULL) |
| @@ -864,12 +856,8 @@ struct dentry *rpc_mkpipe_dentry(struct dentry *parent, const char *name, | |||
| 864 | if (pipe->ops->downcall == NULL) | 856 | if (pipe->ops->downcall == NULL) |
| 865 | umode &= ~S_IWUGO; | 857 | umode &= ~S_IWUGO; |
| 866 | 858 | ||
| 867 | q.name = name; | ||
| 868 | q.len = strlen(name); | ||
| 869 | q.hash = full_name_hash(q.name, q.len), | ||
| 870 | |||
| 871 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); | 859 | mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT); |
| 872 | dentry = __rpc_lookup_create_exclusive(parent, &q); | 860 | dentry = __rpc_lookup_create_exclusive(parent, name); |
| 873 | if (IS_ERR(dentry)) | 861 | if (IS_ERR(dentry)) |
| 874 | goto out; | 862 | goto out; |
| 875 | err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops, | 863 | err = __rpc_mkpipe_dentry(dir, dentry, umode, &rpc_pipe_fops, |
| @@ -940,8 +928,8 @@ static void rpc_clntdir_depopulate(struct dentry *dentry) | |||
| 940 | 928 | ||
| 941 | /** | 929 | /** |
| 942 | * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs | 930 | * rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs |
| 943 | * @dentry: dentry from the rpc_pipefs root to the new directory | 931 | * @dentry: the parent of new directory |
| 944 | * @name: &struct qstr for the name | 932 | * @name: the name of new directory |
| 945 | * @rpc_client: rpc client to associate with this directory | 933 | * @rpc_client: rpc client to associate with this directory |
| 946 | * | 934 | * |
| 947 | * This creates a directory at the given @path associated with | 935 | * This creates a directory at the given @path associated with |
| @@ -950,7 +938,7 @@ static void rpc_clntdir_depopulate(struct dentry *dentry) | |||
| 950 | * later be created using rpc_mkpipe(). | 938 | * later be created using rpc_mkpipe(). |
| 951 | */ | 939 | */ |
| 952 | struct dentry *rpc_create_client_dir(struct dentry *dentry, | 940 | struct dentry *rpc_create_client_dir(struct dentry *dentry, |
| 953 | struct qstr *name, | 941 | const char *name, |
| 954 | struct rpc_clnt *rpc_client) | 942 | struct rpc_clnt *rpc_client) |
| 955 | { | 943 | { |
| 956 | return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL, | 944 | return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL, |
| @@ -996,7 +984,7 @@ static void rpc_cachedir_depopulate(struct dentry *dentry) | |||
| 996 | rpc_depopulate(dentry, cache_pipefs_files, 0, 3); | 984 | rpc_depopulate(dentry, cache_pipefs_files, 0, 3); |
| 997 | } | 985 | } |
| 998 | 986 | ||
| 999 | struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name, | 987 | struct dentry *rpc_create_cache_dir(struct dentry *parent, const char *name, |
| 1000 | umode_t umode, struct cache_detail *cd) | 988 | umode_t umode, struct cache_detail *cd) |
| 1001 | { | 989 | { |
| 1002 | return rpc_mkdir_populate(parent, name, umode, NULL, | 990 | return rpc_mkdir_populate(parent, name, umode, NULL, |
| @@ -1076,9 +1064,7 @@ struct dentry *rpc_d_lookup_sb(const struct super_block *sb, | |||
| 1076 | const unsigned char *dir_name) | 1064 | const unsigned char *dir_name) |
| 1077 | { | 1065 | { |
| 1078 | struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name)); | 1066 | struct qstr dir = QSTR_INIT(dir_name, strlen(dir_name)); |
| 1079 | 1067 | return d_hash_and_lookup(sb->s_root, &dir); | |
| 1080 | dir.hash = full_name_hash(dir.name, dir.len); | ||
| 1081 | return d_lookup(sb->s_root, &dir); | ||
| 1082 | } | 1068 | } |
| 1083 | EXPORT_SYMBOL_GPL(rpc_d_lookup_sb); | 1069 | EXPORT_SYMBOL_GPL(rpc_d_lookup_sb); |
| 1084 | 1070 | ||
