Skip to content

Commit a95e691

Browse files
author
Al Viro
committed
rpc_create_*_dir: don't bother with qstr
just pass the name Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e9a17bd commit a95e691

File tree

4 files changed

+23
-33
lines changed

4 files changed

+23
-33
lines changed

include/linux/sunrpc/rpc_pipe_fs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *,
7373
extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *);
7474

7575
struct rpc_clnt;
76-
extern struct dentry *rpc_create_client_dir(struct dentry *, struct qstr *, struct rpc_clnt *);
76+
extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *);
7777
extern int rpc_remove_client_dir(struct dentry *);
7878

7979
struct cache_detail;
8080
extern struct dentry *rpc_create_cache_dir(struct dentry *,
81-
struct qstr *,
81+
const char *,
8282
umode_t umode,
8383
struct cache_detail *);
8484
extern void rpc_remove_cache_dir(struct dentry *);

net/sunrpc/cache.c

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,19 +1812,11 @@ int sunrpc_cache_register_pipefs(struct dentry *parent,
18121812
const char *name, umode_t umode,
18131813
struct cache_detail *cd)
18141814
{
1815-
struct qstr q;
1816-
struct dentry *dir;
1817-
int ret = 0;
1818-
1819-
q.name = name;
1820-
q.len = strlen(name);
1821-
q.hash = full_name_hash(q.name, q.len);
1822-
dir = rpc_create_cache_dir(parent, &q, umode, cd);
1823-
if (!IS_ERR(dir))
1824-
cd->u.pipefs.dir = dir;
1825-
else
1826-
ret = PTR_ERR(dir);
1827-
return ret;
1815+
struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd);
1816+
if (IS_ERR(dir))
1817+
return PTR_ERR(dir);
1818+
cd->u.pipefs.dir = dir;
1819+
return 0;
18281820
}
18291821
EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
18301822

net/sunrpc/clnt.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,29 +128,25 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb,
128128
{
129129
static uint32_t clntid;
130130
char name[15];
131-
struct qstr q = { .name = name };
132131
struct dentry *dir, *dentry;
133-
int error;
134132

135133
dir = rpc_d_lookup_sb(sb, dir_name);
136134
if (dir == NULL) {
137135
pr_info("RPC: pipefs directory doesn't exist: %s\n", dir_name);
138136
return dir;
139137
}
140138
for (;;) {
141-
q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
139+
snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
142140
name[sizeof(name) - 1] = '\0';
143-
q.hash = full_name_hash(q.name, q.len);
144-
dentry = rpc_create_client_dir(dir, &q, clnt);
141+
dentry = rpc_create_client_dir(dir, name, clnt);
145142
if (!IS_ERR(dentry))
146143
break;
147-
error = PTR_ERR(dentry);
148-
if (error != -EEXIST) {
149-
printk(KERN_INFO "RPC: Couldn't create pipefs entry"
150-
" %s/%s, error %d\n",
151-
dir_name, name, error);
152-
break;
153-
}
144+
if (dentry == ERR_PTR(-EEXIST))
145+
continue;
146+
printk(KERN_INFO "RPC: Couldn't create pipefs entry"
147+
" %s/%s, error %ld\n",
148+
dir_name, name, PTR_ERR(dentry));
149+
break;
154150
}
155151
dput(dir);
156152
return dentry;

net/sunrpc/rpc_pipe.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,15 +770,17 @@ static int rpc_populate(struct dentry *parent,
770770
}
771771

772772
static struct dentry *rpc_mkdir_populate(struct dentry *parent,
773-
struct qstr *name, umode_t mode, void *private,
773+
const char *name, umode_t mode, void *private,
774774
int (*populate)(struct dentry *, void *), void *args_populate)
775775
{
776776
struct dentry *dentry;
777+
struct qstr q = QSTR_INIT(name, strlen(name));
777778
struct inode *dir = parent->d_inode;
778779
int error;
779780

781+
q.hash = full_name_hash(q.name, q.len);
780782
mutex_lock_nested(&dir->i_mutex, I_MUTEX_PARENT);
781-
dentry = __rpc_lookup_create_exclusive(parent, name);
783+
dentry = __rpc_lookup_create_exclusive(parent, &q);
782784
if (IS_ERR(dentry))
783785
goto out;
784786
error = __rpc_mkdir(dir, dentry, mode, NULL, private);
@@ -925,8 +927,8 @@ static void rpc_clntdir_depopulate(struct dentry *dentry)
925927

926928
/**
927929
* rpc_create_client_dir - Create a new rpc_client directory in rpc_pipefs
928-
* @dentry: dentry from the rpc_pipefs root to the new directory
929-
* @name: &struct qstr for the name
930+
* @dentry: the parent of new directory
931+
* @name: the name of new directory
930932
* @rpc_client: rpc client to associate with this directory
931933
*
932934
* This creates a directory at the given @path associated with
@@ -935,7 +937,7 @@ static void rpc_clntdir_depopulate(struct dentry *dentry)
935937
* later be created using rpc_mkpipe().
936938
*/
937939
struct dentry *rpc_create_client_dir(struct dentry *dentry,
938-
struct qstr *name,
940+
const char *name,
939941
struct rpc_clnt *rpc_client)
940942
{
941943
return rpc_mkdir_populate(dentry, name, S_IRUGO | S_IXUGO, NULL,
@@ -981,7 +983,7 @@ static void rpc_cachedir_depopulate(struct dentry *dentry)
981983
rpc_depopulate(dentry, cache_pipefs_files, 0, 3);
982984
}
983985

984-
struct dentry *rpc_create_cache_dir(struct dentry *parent, struct qstr *name,
986+
struct dentry *rpc_create_cache_dir(struct dentry *parent, const char *name,
985987
umode_t umode, struct cache_detail *cd)
986988
{
987989
return rpc_mkdir_populate(parent, name, umode, NULL,

0 commit comments

Comments
 (0)