Commit 244c7d44 authored by Al Viro's avatar Al Viro

nfsd/nfsctl.c: new helper

... to get from opened file on nfsctl to relevant struct net *
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a455589f
...@@ -231,6 +231,10 @@ static struct file_operations reply_cache_stats_operations = { ...@@ -231,6 +231,10 @@ static struct file_operations reply_cache_stats_operations = {
* payload - write methods * payload - write methods
*/ */
static inline struct net *netns(struct file *file)
{
return file_inode(file)->i_sb->s_fs_info;
}
/** /**
* write_unlock_ip - Release all locks used by a client * 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,7 +256,7 @@ static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size)
struct sockaddr *sap = (struct sockaddr *)&address; struct sockaddr *sap = (struct sockaddr *)&address;
size_t salen = sizeof(address); size_t salen = sizeof(address);
char *fo_path; char *fo_path;
struct net *net = file->f_dentry->d_sb->s_fs_info; struct net *net = netns(file);
/* sanity check */ /* sanity check */
if (size == 0) if (size == 0)
...@@ -350,7 +354,6 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size) ...@@ -350,7 +354,6 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
int len; int len;
struct auth_domain *dom; struct auth_domain *dom;
struct knfsd_fh fh; struct knfsd_fh fh;
struct net *net = file->f_dentry->d_sb->s_fs_info;
if (size == 0) if (size == 0)
return -EINVAL; return -EINVAL;
...@@ -385,7 +388,7 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size) ...@@ -385,7 +388,7 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
if (!dom) if (!dom)
return -ENOMEM; return -ENOMEM;
len = exp_rootfh(net, dom, path, &fh, maxsize); len = exp_rootfh(netns(file), dom, path, &fh, maxsize);
auth_domain_put(dom); auth_domain_put(dom);
if (len) if (len)
return len; return len;
...@@ -429,7 +432,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) ...@@ -429,7 +432,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
{ {
char *mesg = buf; char *mesg = buf;
int rv; int rv;
struct net *net = file->f_dentry->d_sb->s_fs_info; struct net *net = netns(file);
if (size > 0) { if (size > 0) {
int newthreads; int newthreads;
...@@ -480,7 +483,7 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) ...@@ -480,7 +483,7 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
int len; int len;
int npools; int npools;
int *nthreads; int *nthreads;
struct net *net = file->f_dentry->d_sb->s_fs_info; struct net *net = netns(file);
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
npools = nfsd_nrpools(net); npools = nfsd_nrpools(net);
...@@ -543,8 +546,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) ...@@ -543,8 +546,7 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size)
unsigned minor; unsigned minor;
ssize_t tlen = 0; ssize_t tlen = 0;
char *sep; char *sep;
struct net *net = file->f_dentry->d_sb->s_fs_info; struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (size>0) { if (size>0) {
if (nn->nfsd_serv) if (nn->nfsd_serv)
...@@ -830,10 +832,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size, ...@@ -830,10 +832,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size,
static ssize_t write_ports(struct file *file, char *buf, size_t size) static ssize_t write_ports(struct file *file, char *buf, size_t size)
{ {
ssize_t rv; ssize_t rv;
struct net *net = file->f_dentry->d_sb->s_fs_info;
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
rv = __write_ports(file, buf, size, net); rv = __write_ports(file, buf, size, netns(file));
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return rv; return rv;
} }
...@@ -865,8 +866,7 @@ int nfsd_max_blksize; ...@@ -865,8 +866,7 @@ int nfsd_max_blksize;
static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
{ {
char *mesg = buf; char *mesg = buf;
struct net *net = file->f_dentry->d_sb->s_fs_info; struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (size > 0) { if (size > 0) {
int bsize; int bsize;
...@@ -915,8 +915,7 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) ...@@ -915,8 +915,7 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
static ssize_t write_maxconn(struct file *file, char *buf, size_t size) static ssize_t write_maxconn(struct file *file, char *buf, size_t size)
{ {
char *mesg = buf; char *mesg = buf;
struct net *net = file->f_dentry->d_sb->s_fs_info; struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
unsigned int maxconn = nn->max_connections; unsigned int maxconn = nn->max_connections;
if (size > 0) { if (size > 0) {
...@@ -997,8 +996,7 @@ static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, ...@@ -997,8 +996,7 @@ static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size,
*/ */
static ssize_t write_leasetime(struct file *file, char *buf, size_t size) static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
{ {
struct net *net = file->f_dentry->d_sb->s_fs_info; struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn); return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn);
} }
...@@ -1014,8 +1012,7 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size) ...@@ -1014,8 +1012,7 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size)
*/ */
static ssize_t write_gracetime(struct file *file, char *buf, size_t size) static ssize_t write_gracetime(struct file *file, char *buf, size_t size)
{ {
struct net *net = file->f_dentry->d_sb->s_fs_info; struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn); return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn);
} }
...@@ -1071,8 +1068,7 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size, ...@@ -1071,8 +1068,7 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size,
static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
{ {
ssize_t rv; ssize_t rv;
struct net *net = file->f_dentry->d_sb->s_fs_info; struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
rv = __write_recoverydir(file, buf, size, nn); 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,8 +1098,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size)
*/ */
static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size) static ssize_t write_v4_end_grace(struct file *file, char *buf, size_t size)
{ {
struct net *net = file->f_dentry->d_sb->s_fs_info; struct nfsd_net *nn = net_generic(netns(file), nfsd_net_id);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (size > 0) { if (size > 0) {
switch(buf[0]) { switch(buf[0]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment