Skip to content

Commit a204f25

Browse files
author
J. Bruce Fields
committed
nfsd: create get_nfsdfs_clp helper
Factor our some common code. No change in behavior. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 0c4b62b commit a204f25

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

fs/nfsd/nfs4state.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,6 +2216,15 @@ find_stateid_by_type(struct nfs4_client *cl, stateid_t *t, char typemask)
22162216
return s;
22172217
}
22182218

2219+
static struct nfs4_client *get_nfsdfs_clp(struct inode *inode)
2220+
{
2221+
struct nfsdfs_client *nc;
2222+
nc = get_nfsdfs_client(inode);
2223+
if (!nc)
2224+
return NULL;
2225+
return container_of(nc, struct nfs4_client, cl_nfsdfs);
2226+
}
2227+
22192228
static void seq_quote_mem(struct seq_file *m, char *data, int len)
22202229
{
22212230
seq_printf(m, "\"");
@@ -2226,14 +2235,12 @@ static void seq_quote_mem(struct seq_file *m, char *data, int len)
22262235
static int client_info_show(struct seq_file *m, void *v)
22272236
{
22282237
struct inode *inode = m->private;
2229-
struct nfsdfs_client *nc;
22302238
struct nfs4_client *clp;
22312239
u64 clid;
22322240

2233-
nc = get_nfsdfs_client(inode);
2234-
if (!nc)
2241+
clp = get_nfsdfs_clp(inode);
2242+
if (!clp)
22352243
return -ENXIO;
2236-
clp = container_of(nc, struct nfs4_client, cl_nfsdfs);
22372244
memcpy(&clid, &clp->cl_clientid, sizeof(clid));
22382245
seq_printf(m, "clientid: 0x%llx\n", clid);
22392246
seq_printf(m, "address: \"%pISpc\"\n", (struct sockaddr *)&clp->cl_addr);
@@ -2444,15 +2451,13 @@ static struct seq_operations states_seq_ops = {
24442451

24452452
static int client_states_open(struct inode *inode, struct file *file)
24462453
{
2447-
struct nfsdfs_client *nc;
24482454
struct seq_file *s;
24492455
struct nfs4_client *clp;
24502456
int ret;
24512457

2452-
nc = get_nfsdfs_client(inode);
2453-
if (!nc)
2458+
clp = get_nfsdfs_clp(inode);
2459+
if (!clp)
24542460
return -ENXIO;
2455-
clp = container_of(nc, struct nfs4_client, cl_nfsdfs);
24562461

24572462
ret = seq_open(file, &states_seq_ops);
24582463
if (ret)

0 commit comments

Comments
 (0)