diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-10-21 20:19:11 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-19 13:01:21 -0500 |
commit | 244c7d444b8bf5b1b76efd53f65c13bde809dbaa (patch) | |
tree | ea01a101b1607cbb395f785f648ff5b8ba9fc16d /fs | |
parent | a455589f181e60439c736c6c6a068bb7e6dc23f0 (diff) |
nfsd/nfsctl.c: new helper
... to get from opened file on nfsctl to relevant struct net *
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfsctl.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index ca73ca79a0ee..9506ea565610 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -231,6 +231,10 @@ static struct file_operations reply_cache_stats_operations = { | |||
231 | * payload - write methods | 231 | * payload - write methods |
232 | */ | 232 | */ |
233 | 233 | ||
234 | static inline struct net *netns(struct file *file) | ||
235 | { | ||
236 | return file_inode(file)->i_sb->s_fs_info; | ||
237 | } | ||
234 | 238 | ||
235 | /** | 239 | /** |
236 | * write_unlock_ip - Release all locks used by a client | 240 | * write_unlock_ip - Release all locks used by a client |
@@ -252,7 +256,7 @@ static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size) | |||
252 | struct sockaddr *sap = (struct sockaddr *)&address; | 256 | struct sockaddr *sap = (struct sockaddr *)&address; |
253 | size_t salen = sizeof(address); | 257 | size_t salen = sizeof(address); |
254 | char *fo_path; | 258 | char *fo_path; |
255 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 259 | struct net *net = netns(file); |
256 | 260 | ||
257 | /* sanity check */ | 261 | /* sanity check */ |
258 | if (size == 0) | 262 | if (size == 0) |
@@ -350,7 +354,6 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size) | |||
350 | int len; | 354 | int len; |
351 | struct auth_domain *dom; | 355 | struct auth_domain *dom; |
352 | struct knfsd_fh fh; | 356 | struct knfsd_fh fh; |
353 | struct net *net = file->f_dentry->d_sb->s_fs_info; | ||
354 | 357 | ||
355 | if (size == 0) | 358 | if (size == 0) |
356 | return -EINVAL; | 359 | return -EINVAL; |
@@ -385,7 +388,7 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size) | |||
385 | if (!dom) | 388 | if (!dom) |
386 | return -ENOMEM; | 389 | return -ENOMEM; |
387 | 390 | ||
388 | len = exp_rootfh(net, dom, path, &fh, maxsize); | 391 | len = exp_rootfh(netns(file), dom, path, &fh, maxsize); |
389 | auth_domain_put(dom); | 392 | auth_domain_put(dom); |
390 | if (len) | 393 | if (len) |
391 | return len; | 394 | return len; |
@@ -429,7 +432,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) | |||
429 | { | 432 | { |
430 | char *mesg = buf; | 433 | char *mesg = buf; |
431 | int rv; | 434 | int rv; |
432 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 435 | struct net *net = netns(file); |
433 | 436 | ||
434 | if (size > 0) { | 437 | if (size > 0) { |
435 | int newthreads; | 438 | int newthreads; |
@@ -480,7 +483,7 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) | |||
480 | int len; | 483 | int len; |
481 | int npools; | 484 | int npools; |
482 | int *nthreads; | 485 | int *nthreads; |
483 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 486 | struct net *net = netns(file); |
484 | 487 | ||
485 | mutex_lock(&nfsd_mutex); | 488 | mutex_lock(&nfsd_mutex); |
486 | npools = nfsd_nrpools(net); | 489 | npools = nfsd_nrpools(net); |
@@ -543,8 +546,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) | |||
543 | unsigned minor; | 546 | unsigned minor; |
544 | ssize_t tlen = 0; | 547 | ssize_t tlen = 0; |
545 | char *sep; | 548 | char *sep; |
546 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 549 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
547 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
548 | 550 | ||
549 | if (size>0) { | 551 | if (size>0) { |
550 | if (nn->nfsd_serv) | 552 | if (nn->nfsd_serv) |
@@ -830,10 +832,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size, | |||
830 | static ssize_t write_ports(struct file *file, char *buf, size_t size) | 832 | static ssize_t write_ports(struct file *file, char *buf, size_t size) |
831 | { | 833 | { |
832 | ssize_t rv; | 834 | ssize_t rv; |
833 | struct net *net = file->f_dentry->d_sb->s_fs_info; | ||
834 | 835 | ||
835 | mutex_lock(&nfsd_mutex); | 836 | mutex_lock(&nfsd_mutex); |
836 | rv = __write_ports(file, buf, size, net); | 837 | rv = __write_ports(file, buf, size, netns(file)); |
837 | mutex_unlock(&nfsd_mutex); | 838 | mutex_unlock(&nfsd_mutex); |
838 | return rv; | 839 | return rv; |
839 | } | 840 | } |
@@ -865,8 +866,7 @@ int nfsd_max_blksize; | |||
865 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) | 866 | static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) |
866 | { | 867 | { |
867 | char *mesg = buf; | 868 | char *mesg = buf; |
868 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 869 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
869 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
870 | 870 | ||
871 | if (size > 0) { | 871 | if (size > 0) { |
872 | int bsize; | 872 | int bsize; |
@@ -915,8 +915,7 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) | |||
915 | static ssize_t write_maxconn(struct file *file, char *buf, size_t size) | 915 | static ssize_t write_maxconn(struct file *file, char *buf, size_t size) |
916 | { | 916 | { |
917 | char *mesg = buf; | 917 | char *mesg = buf; |
918 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 918 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
919 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
920 | unsigned int maxconn = nn->max_connections; | 919 | unsigned int maxconn = nn->max_connections; |
921 | 920 | ||
922 | if (size > 0) { | 921 | if (size > 0) { |
@@ -997,8 +996,7 @@ static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, | |||
997 | */ | 996 | */ |
998 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) | 997 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) |
999 | { | 998 | { |
1000 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 999 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
1001 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
1002 | return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn); | 1000 | return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn); |
1003 | } | 1001 | } |
1004 | 1002 | ||
@@ -1014,8 +1012,7 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size) | |||
1014 | */ | 1012 | */ |
1015 | static ssize_t write_gracetime(struct file *file, char *buf, size_t size) | 1013 | static ssize_t write_gracetime(struct file *file, char *buf, size_t size) |
1016 | { | 1014 | { |
1017 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 1015 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
1018 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
1019 | return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn); | 1016 | return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn); |
1020 | } | 1017 | } |
1021 | 1018 | ||
@@ -1071,8 +1068,7 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size, | |||
1071 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | 1068 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) |
1072 | { | 1069 | { |
1073 | ssize_t rv; | 1070 | ssize_t rv; |
1074 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 1071 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
1075 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
1076 | 1072 | ||
1077 | mutex_lock(&nfsd_mutex); | 1073 | mutex_lock(&nfsd_mutex); |
1078 | rv = __write_recoverydir(file, buf, size, nn); | 1074 | rv = __write_recoverydir(file, buf, size, nn); |
@@ -1102,8 +1098,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | |||
1102 | */ | 1098 | */ |
1103 | static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size) | 1099 | static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size) |
1104 | { | 1100 | { |
1105 | struct net *net = file->f_dentry->d_sb->s_fs_info; | 1101 | struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id); |
1106 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | ||
1107 | 1102 | ||
1108 | if (size > 0) { | 1103 | if (size > 0) { |
1109 | switch(buf[0]) { | 1104 | switch(buf[0]) { |