Commit 98219727 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-3.8' of git://linux-nfs.org/~bfields/linux

Pull nfsd update from Bruce Fields:
 "Included this time:

   - more nfsd containerization work from Stanislav Kinsbursky: we're
     not quite there yet, but should be by 3.9.

   - NFSv4.1 progress: implementation of basic backchannel security
     negotiation and the mandatory BACKCHANNEL_CTL operation.  See

       http://wiki.linux-nfs.org/wiki/index.php/Server_4.0_and_4.1_issues

     for remaining TODO's

   - Fixes for some bugs that could be triggered by unusual compounds.
     Our xdr code wasn't designed with v4 compounds in mind, and it
     shows.  A more thorough rewrite is still a todo.

   - If you've ever seen "RPC: multiple fragments per record not
     supported" logged while using some sort of odd userland NFS client,
     that should now be fixed.

   - Further work from Jeff Layton on our mechanism for storing
     information about NFSv4 clients across reboots.

   - Further work from Bryan Schumaker on his fault-injection mechanism
     (which allows us to discard selective NFSv4 state, to excercise
     rarely-taken recovery code paths in the client.)

   - The usual mix of miscellaneous bugs and cleanup.

  Thanks to everyone who tested or contributed this cycle."

* 'for-3.8' of git://linux-nfs.org/~bfields/linux: (111 commits)
  nfsd4: don't leave freed stateid hashed
  nfsd4: free_stateid can use the current stateid
  nfsd4: cleanup: replace rq_resused count by rq_next_page pointer
  nfsd: warn on odd reply state in nfsd_vfs_read
  nfsd4: fix oops on unusual readlike compound
  nfsd4: disable zero-copy on non-final read ops
  svcrpc: fix some printks
  NFSD: Correct the size calculation in fault_inject_write
  NFSD: Pass correct buffer size to rpc_ntop
  nfsd: pass proper net to nfsd_destroy() from NFSd kthreads
  nfsd: simplify service shutdown
  nfsd: replace boolean nfsd_up flag by users counter
  nfsd: simplify NFSv4 state init and shutdown
  nfsd: introduce helpers for generic resources init and shutdown
  nfsd: make NFSd service structure allocated per net
  nfsd: make NFSd service boot time per-net
  nfsd: per-net NFSd up flag introduced
  nfsd: move per-net startup code to separated function
  nfsd: pass net to __write_ports() and down
  nfsd: pass net to nfsd_set_nrthreads()
  ...
parents 40889e8d 24ffb938
...@@ -39,21 +39,10 @@ interoperability problems with future clients. Known issues: ...@@ -39,21 +39,10 @@ interoperability problems with future clients. Known issues:
from a linux client are possible, but we aren't really from a linux client are possible, but we aren't really
conformant with the spec (for example, we don't use kerberos conformant with the spec (for example, we don't use kerberos
on the backchannel correctly). on the backchannel correctly).
- Incomplete backchannel support: incomplete backchannel gss
support and no support for BACKCHANNEL_CTL mean that
callbacks (hence delegations and layouts) may not be
available and clients confused by the incomplete
implementation may fail.
- We do not support SSV, which provides security for shared - We do not support SSV, which provides security for shared
client-server state (thus preventing unauthorized tampering client-server state (thus preventing unauthorized tampering
with locks and opens, for example). It is mandatory for with locks and opens, for example). It is mandatory for
servers to support this, though no clients use it yet. servers to support this, though no clients use it yet.
- Mandatory operations which we do not support, such as
DESTROY_CLIENTID, are not currently used by clients, but will be
(and the spec recommends their uses in common cases), and
clients should not be expected to know how to recover from the
case where they are not supported. This will eventually cause
interoperability failures.
In addition, some limitations are inherited from the current NFSv4 In addition, some limitations are inherited from the current NFSv4
implementation: implementation:
...@@ -89,7 +78,7 @@ Operations ...@@ -89,7 +78,7 @@ Operations
| | MNI | or OPT) | | | | MNI | or OPT) | |
+----------------------+------------+--------------+----------------+ +----------------------+------------+--------------+----------------+
| ACCESS | REQ | | Section 18.1 | | ACCESS | REQ | | Section 18.1 |
NS | BACKCHANNEL_CTL | REQ | | Section 18.33 | I | BACKCHANNEL_CTL | REQ | | Section 18.33 |
I | BIND_CONN_TO_SESSION | REQ | | Section 18.34 | I | BIND_CONN_TO_SESSION | REQ | | Section 18.34 |
| CLOSE | REQ | | Section 18.2 | | CLOSE | REQ | | Section 18.2 |
| COMMIT | REQ | | Section 18.3 | | COMMIT | REQ | | Section 18.3 |
...@@ -99,7 +88,7 @@ NS*| DELEGPURGE | OPT | FDELG (REQ) | Section 18.5 | ...@@ -99,7 +88,7 @@ NS*| DELEGPURGE | OPT | FDELG (REQ) | Section 18.5 |
| DELEGRETURN | OPT | FDELG, | Section 18.6 | | DELEGRETURN | OPT | FDELG, | Section 18.6 |
| | | DDELG, pNFS | | | | | DDELG, pNFS | |
| | | (REQ) | | | | | (REQ) | |
NS | DESTROY_CLIENTID | REQ | | Section 18.50 | I | DESTROY_CLIENTID | REQ | | Section 18.50 |
I | DESTROY_SESSION | REQ | | Section 18.37 | I | DESTROY_SESSION | REQ | | Section 18.37 |
I | EXCHANGE_ID | REQ | | Section 18.35 | I | EXCHANGE_ID | REQ | | Section 18.35 |
I | FREE_STATEID | REQ | | Section 18.38 | I | FREE_STATEID | REQ | | Section 18.38 |
...@@ -192,7 +181,6 @@ EXCHANGE_ID: ...@@ -192,7 +181,6 @@ EXCHANGE_ID:
CREATE_SESSION: CREATE_SESSION:
* backchannel attributes are ignored * backchannel attributes are ignored
* backchannel security parameters are ignored
SEQUENCE: SEQUENCE:
* no support for dynamic slot table renegotiation (optional) * no support for dynamic slot table renegotiation (optional)
...@@ -202,7 +190,7 @@ Nonstandard compound limitations: ...@@ -202,7 +190,7 @@ Nonstandard compound limitations:
ca_maxrequestsize request and a ca_maxresponsesize reply, so we may ca_maxrequestsize request and a ca_maxresponsesize reply, so we may
fail to live up to the promise we made in CREATE_SESSION fore channel fail to live up to the promise we made in CREATE_SESSION fore channel
negotiation. negotiation.
* No more than one IO operation (read, write, readdir) allowed per * No more than one read-like operation allowed per compound; encoding
compound. replies that cross page boundaries (except for read data) not handled.
See also http://wiki.linux-nfs.org/wiki/index.php/Server_4.0_and_4.1_issues. See also http://wiki.linux-nfs.org/wiki/index.php/Server_4.0_and_4.1_issues.
...@@ -322,10 +322,10 @@ static int export_encode_fh(struct inode *inode, struct fid *fid, ...@@ -322,10 +322,10 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
if (parent && (len < 4)) { if (parent && (len < 4)) {
*max_len = 4; *max_len = 4;
return 255; return FILEID_INVALID;
} else if (len < 2) { } else if (len < 2) {
*max_len = 2; *max_len = 2;
return 255; return FILEID_INVALID;
} }
len = 2; len = 2;
......
...@@ -52,7 +52,7 @@ static long do_sys_name_to_handle(struct path *path, ...@@ -52,7 +52,7 @@ static long do_sys_name_to_handle(struct path *path,
handle_bytes = handle_dwords * sizeof(u32); handle_bytes = handle_dwords * sizeof(u32);
handle->handle_bytes = handle_bytes; handle->handle_bytes = handle_bytes;
if ((handle->handle_bytes > f_handle.handle_bytes) || if ((handle->handle_bytes > f_handle.handle_bytes) ||
(retval == 255) || (retval == -ENOSPC)) { (retval == FILEID_INVALID) || (retval == -ENOSPC)) {
/* As per old exportfs_encode_fh documentation /* As per old exportfs_encode_fh documentation
* we could return ENOSPC to indicate overflow * we could return ENOSPC to indicate overflow
* But file system returned 255 always. So handle * But file system returned 255 always. So handle
......
...@@ -8,61 +8,144 @@ ...@@ -8,61 +8,144 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/nsproxy.h>
#include <linux/sunrpc/clnt.h>
#include <asm/uaccess.h>
#include "state.h" #include "state.h"
#include "fault_inject.h" #include "netns.h"
struct nfsd_fault_inject_op { struct nfsd_fault_inject_op {
char *file; char *file;
void (*func)(u64); u64 (*forget)(struct nfs4_client *, u64);
u64 (*print)(struct nfs4_client *, u64);
}; };
static struct nfsd_fault_inject_op inject_ops[] = { static struct nfsd_fault_inject_op inject_ops[] = {
{ {
.file = "forget_clients", .file = "forget_clients",
.func = nfsd_forget_clients, .forget = nfsd_forget_client,
.print = nfsd_print_client,
}, },
{ {
.file = "forget_locks", .file = "forget_locks",
.func = nfsd_forget_locks, .forget = nfsd_forget_client_locks,
.print = nfsd_print_client_locks,
}, },
{ {
.file = "forget_openowners", .file = "forget_openowners",
.func = nfsd_forget_openowners, .forget = nfsd_forget_client_openowners,
.print = nfsd_print_client_openowners,
}, },
{ {
.file = "forget_delegations", .file = "forget_delegations",
.func = nfsd_forget_delegations, .forget = nfsd_forget_client_delegations,
.print = nfsd_print_client_delegations,
}, },
{ {
.file = "recall_delegations", .file = "recall_delegations",
.func = nfsd_recall_delegations, .forget = nfsd_recall_client_delegations,
.print = nfsd_print_client_delegations,
}, },
}; };
static long int NUM_INJECT_OPS = sizeof(inject_ops) / sizeof(struct nfsd_fault_inject_op); static long int NUM_INJECT_OPS = sizeof(inject_ops) / sizeof(struct nfsd_fault_inject_op);
static struct dentry *debug_dir; static struct dentry *debug_dir;
static int nfsd_inject_set(void *op_ptr, u64 val) static void nfsd_inject_set(struct nfsd_fault_inject_op *op, u64 val)
{ {
struct nfsd_fault_inject_op *op = op_ptr; u64 count = 0;
if (val == 0) if (val == 0)
printk(KERN_INFO "NFSD Fault Injection: %s (all)", op->file); printk(KERN_INFO "NFSD Fault Injection: %s (all)", op->file);
else else
printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val); printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val);
op->func(val); nfs4_lock_state();
return 0; count = nfsd_for_n_state(val, op->forget);
nfs4_unlock_state();
printk(KERN_INFO "NFSD: %s: found %llu", op->file, count);
}
static void nfsd_inject_set_client(struct nfsd_fault_inject_op *op,
struct sockaddr_storage *addr,
size_t addr_size)
{
char buf[INET6_ADDRSTRLEN];
struct nfs4_client *clp;
u64 count;
nfs4_lock_state();
clp = nfsd_find_client(addr, addr_size);
if (clp) {
count = op->forget(clp, 0);
rpc_ntop((struct sockaddr *)&clp->cl_addr, buf, sizeof(buf));
printk(KERN_INFO "NFSD [%s]: Client %s had %llu state object(s)\n", op->file, buf, count);
}
nfs4_unlock_state();
}
static void nfsd_inject_get(struct nfsd_fault_inject_op *op, u64 *val)
{
nfs4_lock_state();
*val = nfsd_for_n_state(0, op->print);
nfs4_unlock_state();
} }
static int nfsd_inject_get(void *data, u64 *val) static ssize_t fault_inject_read(struct file *file, char __user *buf,
size_t len, loff_t *ppos)
{ {
*val = 0; static u64 val;
char read_buf[25];
size_t size, ret;
loff_t pos = *ppos;
if (!pos)
nfsd_inject_get(file->f_dentry->d_inode->i_private, &val);
size = scnprintf(read_buf, sizeof(read_buf), "%llu\n", val);
if (pos < 0)
return -EINVAL;
if (pos >= size || !len)
return 0; return 0;
if (len > size - pos)
len = size - pos;
ret = copy_to_user(buf, read_buf + pos, len);
if (ret == len)
return -EFAULT;
len -= ret;
*ppos = pos + len;
return len;
} }
DEFINE_SIMPLE_ATTRIBUTE(fops_nfsd, nfsd_inject_get, nfsd_inject_set, "%llu\n"); static ssize_t fault_inject_write(struct file *file, const char __user *buf,
size_t len, loff_t *ppos)
{
char write_buf[INET6_ADDRSTRLEN];
size_t size = min(sizeof(write_buf) - 1, len);
struct net *net = current->nsproxy->net_ns;
struct sockaddr_storage sa;
u64 val;
if (copy_from_user(write_buf, buf, size))
return -EFAULT;
write_buf[size] = '\0';
size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa));
if (size > 0)
nfsd_inject_set_client(file->f_dentry->d_inode->i_private, &sa, size);
else {
val = simple_strtoll(write_buf, NULL, 0);
nfsd_inject_set(file->f_dentry->d_inode->i_private, val);
}
return len; /* on success, claim we got the whole input */
}
static const struct file_operations fops_nfsd = {
.owner = THIS_MODULE,
.read = fault_inject_read,
.write = fault_inject_write,
};
void nfsd_fault_inject_cleanup(void) void nfsd_fault_inject_cleanup(void)
{ {
......
/*
* Copyright (c) 2011 Bryan Schumaker <bjschuma@netapp.com>
*
* Function definitions for fault injection
*/
#ifndef LINUX_NFSD_FAULT_INJECT_H
#define LINUX_NFSD_FAULT_INJECT_H
#ifdef CONFIG_NFSD_FAULT_INJECTION
int nfsd_fault_inject_init(void);
void nfsd_fault_inject_cleanup(void);
void nfsd_forget_clients(u64);
void nfsd_forget_locks(u64);
void nfsd_forget_openowners(u64);
void nfsd_forget_delegations(u64);
void nfsd_recall_delegations(u64);
#else /* CONFIG_NFSD_FAULT_INJECTION */
static inline int nfsd_fault_inject_init(void) { return 0; }
static inline void nfsd_fault_inject_cleanup(void) {}
static inline void nfsd_forget_clients(u64 num) {}
static inline void nfsd_forget_locks(u64 num) {}
static inline void nfsd_forget_openowners(u64 num) {}
static inline void nfsd_forget_delegations(u64 num) {}
static inline void nfsd_recall_delegations(u64 num) {}
#endif /* CONFIG_NFSD_FAULT_INJECTION */
#endif /* LINUX_NFSD_FAULT_INJECT_H */
...@@ -24,7 +24,18 @@ ...@@ -24,7 +24,18 @@
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/netns/generic.h> #include <net/netns/generic.h>
/* Hash tables for nfs4_clientid state */
#define CLIENT_HASH_BITS 4
#define CLIENT_HASH_SIZE (1 << CLIENT_HASH_BITS)
#define CLIENT_HASH_MASK (CLIENT_HASH_SIZE - 1)
#define LOCKOWNER_INO_HASH_BITS 8
#define LOCKOWNER_INO_HASH_SIZE (1 << LOCKOWNER_INO_HASH_BITS)
#define SESSION_HASH_SIZE 512
struct cld_net; struct cld_net;
struct nfsd4_client_tracking_ops;
struct nfsd_net { struct nfsd_net {
struct cld_net *cld_net; struct cld_net *cld_net;
...@@ -38,7 +49,62 @@ struct nfsd_net { ...@@ -38,7 +49,62 @@ struct nfsd_net {
struct lock_manager nfsd4_manager; struct lock_manager nfsd4_manager;
bool grace_ended; bool grace_ended;
time_t boot_time; time_t boot_time;
/*
* reclaim_str_hashtbl[] holds known client info from previous reset/reboot
* used in reboot/reset lease grace period processing
*
* conf_id_hashtbl[], and conf_name_tree hold confirmed
* setclientid_confirmed info.
*
* unconf_str_hastbl[] and unconf_name_tree hold unconfirmed
* setclientid info.
*/
struct list_head *reclaim_str_hashtbl;
int reclaim_str_hashtbl_size;
struct list_head *conf_id_hashtbl;
struct rb_root conf_name_tree;
struct list_head *unconf_id_hashtbl;
struct rb_root unconf_name_tree;
struct list_head *ownerstr_hashtbl;
struct list_head *lockowner_ino_hashtbl;
struct list_head *sessionid_hashtbl;
/*
* client_lru holds client queue ordered by nfs4_client.cl_time
* for lease renewal.
*
* close_lru holds (open) stateowner queue ordered by nfs4_stateowner.so_time
* for last close replay.
*
* All of the above fields are protected by the client_mutex.
*/
struct list_head client_lru;
struct list_head close_lru;
struct delayed_work laundromat_work;
/* client_lock protects the client lru list and session hash table */
spinlock_t client_lock;
struct file *rec_file;
bool in_grace;
struct nfsd4_client_tracking_ops *client_tracking_ops;
time_t nfsd4_lease;
time_t nfsd4_grace;
bool nfsd_net_up;
/*
* Time of server startup
*/
struct timeval nfssvc_boot;
struct svc_serv *nfsd_serv;
}; };
/* Simple check to find out if a given net was properly initialized */
#define nfsd_netns_ready(nn) ((nn)->sessionid_hashtbl)
extern int nfsd_net_id; extern int nfsd_net_id;
#endif /* __NFSD_NETNS_H__ */ #endif /* __NFSD_NETNS_H__ */
...@@ -253,7 +253,7 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p, ...@@ -253,7 +253,7 @@ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
(resp->mask & NFS_ACL) ? resp->acl_access : NULL, (resp->mask & NFS_ACL) ? resp->acl_access : NULL,
(resp->mask & NFS_DFACL) ? resp->acl_default : NULL); (resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
while (w > 0) { while (w > 0) {
if (!rqstp->rq_respages[rqstp->rq_resused++]) if (!*(rqstp->rq_next_page++))
return 0; return 0;
w -= PAGE_SIZE; w -= PAGE_SIZE;
} }
......
...@@ -184,7 +184,7 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p, ...@@ -184,7 +184,7 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p,
(resp->mask & NFS_ACL) ? resp->acl_access : NULL, (resp->mask & NFS_ACL) ? resp->acl_access : NULL,
(resp->mask & NFS_DFACL) ? resp->acl_default : NULL); (resp->mask & NFS_DFACL) ? resp->acl_default : NULL);
while (w > 0) { while (w > 0) {
if (!rqstp->rq_respages[rqstp->rq_resused++]) if (!*(rqstp->rq_next_page++))
return 0; return 0;
w -= PAGE_SIZE; w -= PAGE_SIZE;
} }
......
...@@ -460,7 +460,7 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp, ...@@ -460,7 +460,7 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
__be32 nfserr; __be32 nfserr;
int count = 0; int count = 0;
loff_t offset; loff_t offset;
int i; struct page **p;
caddr_t page_addr = NULL; caddr_t page_addr = NULL;
dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n", dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
...@@ -484,8 +484,8 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp, ...@@ -484,8 +484,8 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp, struct nfsd3_readdirargs *argp,
&resp->common, &resp->common,
nfs3svc_encode_entry_plus); nfs3svc_encode_entry_plus);
memcpy(resp->verf, argp->verf, 8); memcpy(resp->verf, argp->verf, 8);
for (i=1; i<rqstp->rq_resused ; i++) { for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
page_addr = page_address(rqstp->rq_respages[i]); page_addr = page_address(*p);
if (((caddr_t)resp->buffer >= page_addr) && if (((caddr_t)resp->buffer >= page_addr) &&
((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) { ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
*/ */
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/sunrpc/svc_xprt.h>
#include "xdr3.h" #include "xdr3.h"
#include "auth.h" #include "auth.h"
#include "netns.h"
#define NFSDDBG_FACILITY NFSDDBG_XDR #define NFSDDBG_FACILITY NFSDDBG_XDR
...@@ -323,7 +325,7 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -323,7 +325,7 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_readargs *args) struct nfsd3_readargs *args)
{ {
unsigned int len; unsigned int len;
int v,pn; int v;
u32 max_blocksize = svc_max_payload(rqstp); u32 max_blocksize = svc_max_payload(rqstp);
if (!(p = decode_fh(p, &args->fh))) if (!(p = decode_fh(p, &args->fh)))
...@@ -338,8 +340,9 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -338,8 +340,9 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p,
/* set up the kvec */ /* set up the kvec */
v=0; v=0;
while (len > 0) { while (len > 0) {
pn = rqstp->rq_resused++; struct page *p = *(rqstp->rq_next_page++);
rqstp->rq_vec[v].iov_base = page_address(rqstp->rq_respages[pn]);
rqstp->rq_vec[v].iov_base = page_address(p);
rqstp->rq_vec[v].iov_len = len < PAGE_SIZE? len : PAGE_SIZE; rqstp->rq_vec[v].iov_len = len < PAGE_SIZE? len : PAGE_SIZE;
len -= rqstp->rq_vec[v].iov_len; len -= rqstp->rq_vec[v].iov_len;
v++; v++;
...@@ -461,8 +464,7 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -461,8 +464,7 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p,
len = ntohl(*p++); len = ntohl(*p++);
if (len == 0 || len > NFS3_MAXPATHLEN || len >= PAGE_SIZE) if (len == 0 || len > NFS3_MAXPATHLEN || len >= PAGE_SIZE)
return 0; return 0;
args->tname = new = args->tname = new = page_address(*(rqstp->rq_next_page++));
page_address(rqstp->rq_respages[rqstp->rq_resused++]);
args->tlen = len; args->tlen = len;
/* first copy and check from the first page */ /* first copy and check from the first page */
old = (char*)p; old = (char*)p;
...@@ -533,8 +535,7 @@ nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -533,8 +535,7 @@ nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p,
{ {
if (!(p = decode_fh(p, &args->fh))) if (!(p = decode_fh(p, &args->fh)))
return 0; return 0;
args->buffer = args->buffer = page_address(*(rqstp->rq_next_page++));
page_address(rqstp->rq_respages[rqstp->rq_resused++]);
return xdr_argsize_check(rqstp, p); return xdr_argsize_check(rqstp, p);
} }
...@@ -565,8 +566,7 @@ nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -565,8 +566,7 @@ nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p,
if (args->count > PAGE_SIZE) if (args->count > PAGE_SIZE)
args->count = PAGE_SIZE; args->count = PAGE_SIZE;
args->buffer = args->buffer = page_address(*(rqstp->rq_next_page++));
page_address(rqstp->rq_respages[rqstp->rq_resused++]);
return xdr_argsize_check(rqstp, p); return xdr_argsize_check(rqstp, p);
} }
...@@ -575,7 +575,7 @@ int ...@@ -575,7 +575,7 @@ int
nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p, nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_readdirargs *args) struct nfsd3_readdirargs *args)
{ {
int len, pn; int len;
u32 max_blocksize = svc_max_payload(rqstp); u32 max_blocksize = svc_max_payload(rqstp);
if (!(p = decode_fh(p, &args->fh))) if (!(p = decode_fh(p, &args->fh)))
...@@ -590,9 +590,9 @@ nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -590,9 +590,9 @@ nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p,
args->count = len; args->count = len;
while (len > 0) { while (len > 0) {
pn = rqstp->rq_resused++; struct page *p = *(rqstp->rq_next_page++);
if (!args->buffer) if (!args->buffer)
args->buffer = page_address(rqstp->rq_respages[pn]); args->buffer = page_address(p);
len -= PAGE_SIZE; len -= PAGE_SIZE;
} }
...@@ -720,12 +720,14 @@ int ...@@ -720,12 +720,14 @@ int
nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p, nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_writeres *resp) struct nfsd3_writeres *resp)
{ {
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
p = encode_wcc_data(rqstp, p, &resp->fh); p = encode_wcc_data(rqstp, p, &resp->fh);
if (resp->status == 0) { if (resp->status == 0) {
*p++ = htonl(resp->count); *p++ = htonl(resp->count);
*p++ = htonl(resp->committed); *p++ = htonl(resp->committed);
*p++ = htonl(nfssvc_boot.tv_sec); *p++ = htonl(nn->nfssvc_boot.tv_sec);
*p++ = htonl(nfssvc_boot.tv_usec); *p++ = htonl(nn->nfssvc_boot.tv_usec);
} }
return xdr_ressize_check(rqstp, p); return xdr_ressize_check(rqstp, p);
} }
...@@ -876,7 +878,7 @@ encode_entry(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -876,7 +878,7 @@ encode_entry(struct readdir_cd *ccd, const char *name, int namlen,
common); common);
__be32 *p = cd->buffer; __be32 *p = cd->buffer;
caddr_t curr_page_addr = NULL; caddr_t curr_page_addr = NULL;
int pn; /* current page number */ struct page ** page;
int slen; /* string (name) length */ int slen; /* string (name) length */
int elen; /* estimated entry length in words */ int elen; /* estimated entry length in words */
int num_entry_words = 0; /* actual number of words */ int num_entry_words = 0; /* actual number of words */
...@@ -913,8 +915,9 @@ encode_entry(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -913,8 +915,9 @@ encode_entry(struct readdir_cd *ccd, const char *name, int namlen,
} }
/* determine which page in rq_respages[] we are currently filling */ /* determine which page in rq_respages[] we are currently filling */
for (pn=1; pn < cd->rqstp->rq_resused; pn++) { for (page = cd->rqstp->rq_respages + 1;
curr_page_addr = page_address(cd->rqstp->rq_respages[pn]); page < cd->rqstp->rq_next_page; page++) {
curr_page_addr = page_address(*page);
if (((caddr_t)cd->buffer >= curr_page_addr) && if (((caddr_t)cd->buffer >= curr_page_addr) &&
((caddr_t)cd->buffer < curr_page_addr + PAGE_SIZE)) ((caddr_t)cd->buffer < curr_page_addr + PAGE_SIZE))
...@@ -929,14 +932,14 @@ encode_entry(struct readdir_cd *ccd, const char *name, int namlen, ...@@ -929,14 +932,14 @@ encode_entry(struct readdir_cd *ccd, const char *name, int namlen,
if (plus) if (plus)
p = encode_entryplus_baggage(cd, p, name, namlen); p = encode_entryplus_baggage(cd, p, name, namlen);
num_entry_words = p - cd->buffer; num_entry_words = p - cd->buffer;
} else if (cd->rqstp->rq_respages[pn+1] != NULL) { } else if (*(page+1) != NULL) {
/* temporarily encode entry into next page, then move back to /* temporarily encode entry into next page, then move back to
* current and next page in rq_respages[] */ * current and next page in rq_respages[] */
__be32 *p1, *tmp; __be32 *p1, *tmp;
int len1, len2; int len1, len2;
/* grab next page for temporary storage of entry */ /* grab next page for temporary storage of entry */
p1 = tmp = page_address(cd->rqstp->rq_respages[pn+1]); p1 = tmp = page_address(*(page+1));
p1 = encode_entry_baggage(cd, p1, name, namlen, ino); p1 = encode_entry_baggage(cd, p1, name, namlen, ino);
...@@ -1082,11 +1085,13 @@ int ...@@ -1082,11 +1085,13 @@ int
nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p, nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p,
struct nfsd3_commitres *resp) struct nfsd3_commitres *resp)
{ {
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
p = encode_wcc_data(rqstp, p, &resp->fh); p = encode_wcc_data(rqstp, p, &resp->fh);
/* Write verifier */ /* Write verifier */
if (resp->status == 0) { if (resp->status == 0) {
*p++ = htonl(nfssvc_boot.tv_sec); *p++ = htonl(nn->nfssvc_boot.tv_sec);
*p++ = htonl(nfssvc_boot.tv_usec); *p++ = htonl(nn->nfssvc_boot.tv_usec);
} }
return xdr_ressize_check(rqstp, p); return xdr_ressize_check(rqstp, p);
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include "nfsd.h" #include "nfsd.h"
#include "state.h" #include "state.h"
#include "netns.h"
#define NFSDDBG_FACILITY NFSDDBG_PROC #define NFSDDBG_FACILITY NFSDDBG_PROC
...@@ -625,20 +626,46 @@ static const struct rpc_program cb_program = { ...@@ -625,20 +626,46 @@ static const struct rpc_program cb_program = {
.pipe_dir_name = "nfsd4_cb", .pipe_dir_name = "nfsd4_cb",
}; };
static int max_cb_time(void) static int max_cb_time(struct net *net)
{ {
return max(nfsd4_lease/10, (time_t)1) * HZ; struct nfsd_net *nn = net_generic(net, nfsd_net_id);
return max(nn->nfsd4_lease/10, (time_t)1) * HZ;
} }
static struct rpc_cred *callback_cred;
int set_callback_cred(void)
{
if (callback_cred)
return 0;
callback_cred = rpc_lookup_machine_cred("nfs");
if (!callback_cred)
return -ENOMEM;
return 0;
}
static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
{
if (clp->cl_minorversion == 0) {
return get_rpccred(callback_cred);
} else {
struct rpc_auth *auth = client->cl_auth;
struct auth_cred acred = {};
acred.uid = ses->se_cb_sec.uid;
acred.gid = ses->se_cb_sec.gid;
return auth->au_ops->lookup_cred(client->cl_auth, &acred, 0);
}
}
static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses) static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *conn, struct nfsd4_session *ses)
{ {
struct rpc_timeout timeparms = { struct rpc_timeout timeparms = {
.to_initval = max_cb_time(), .to_initval = max_cb_time(clp->net),
.to_retries = 0, .to_retries = 0,
}; };
struct rpc_create_args args = { struct rpc_create_args args = {
.net = &init_net, .net = clp->net,
.address = (struct sockaddr *) &conn->cb_addr, .address = (struct sockaddr *) &conn->cb_addr,
.addrsize = conn->cb_addrlen, .addrsize = conn->cb_addrlen,
.saddress = (struct sockaddr *) &conn->cb_saddr, .saddress = (struct sockaddr *) &conn->cb_saddr,
...@@ -648,6 +675,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c ...@@ -648,6 +675,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
.flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET),
}; };
struct rpc_clnt *client; struct rpc_clnt *client;
struct rpc_cred *cred;
if (clp->cl_minorversion == 0) { if (clp->cl_minorversion == 0) {
if (!clp->cl_cred.cr_principal && if (!clp->cl_cred.cr_principal &&
...@@ -666,7 +694,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c ...@@ -666,7 +694,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
args.bc_xprt = conn->cb_xprt; args.bc_xprt = conn->cb_xprt;
args.prognumber = clp->cl_cb_session->se_cb_prog; args.prognumber = clp->cl_cb_session->se_cb_prog;
args.protocol = XPRT_TRANSPORT_BC_TCP; args.protocol = XPRT_TRANSPORT_BC_TCP;
args.authflavor = RPC_AUTH_UNIX; args.authflavor = ses->se_cb_sec.flavor;
} }
/* Create RPC client */ /* Create RPC client */
client = rpc_create(&args); client = rpc_create(&args);
...@@ -675,9 +703,14 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c ...@@ -675,9 +703,14 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c
PTR_ERR(client)); PTR_ERR(client));
return PTR_ERR(client); return PTR_ERR(client);
} }
cred = get_backchannel_cred(clp, client, ses);
if (IS_ERR(cred)) {
rpc_shutdown_client(client);
return PTR_ERR(cred);
}
clp->cl_cb_client = client; clp->cl_cb_client = client;
clp->cl_cb_cred = cred;
return 0; return 0;
} }
static void warn_no_callback_path(struct nfs4_client *clp, int reason) static void warn_no_callback_path(struct nfs4_client *clp, int reason)
...@@ -714,18 +747,6 @@ static const struct rpc_call_ops nfsd4_cb_probe_ops = { ...@@ -714,18 +747,6 @@ static const struct rpc_call_ops nfsd4_cb_probe_ops = {
.rpc_call_done = nfsd4_cb_probe_done, .rpc_call_done = nfsd4_cb_probe_done,
}; };
static struct rpc_cred *callback_cred;
int set_callback_cred(void)
{
if (callback_cred)
return 0;
callback_cred = rpc_lookup_machine_cred("nfs");
if (!callback_cred)
return -ENOMEM;
return 0;
}
static struct workqueue_struct *callback_wq; static struct workqueue_struct *callback_wq;
static void run_nfsd4_cb(struct nfsd4_callback *cb) static void run_nfsd4_cb(struct nfsd4_callback *cb)
...@@ -743,7 +764,6 @@ static void do_probe_callback(struct nfs4_client *clp) ...@@ -743,7 +764,6 @@ static void do_probe_callback(struct nfs4_client *clp)
cb->cb_msg.rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL]; cb->cb_msg.rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_NULL];
cb->cb_msg.rpc_argp = NULL; cb->cb_msg.rpc_argp = NULL;
cb->cb_msg.rpc_resp = NULL; cb->cb_msg.rpc_resp = NULL;
cb->cb_msg.rpc_cred = callback_cred;
cb->cb_ops = &nfsd4_cb_probe_ops; cb->cb_ops = &nfsd4_cb_probe_ops;
...@@ -962,6 +982,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) ...@@ -962,6 +982,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb)
if (clp->cl_cb_client) { if (clp->cl_cb_client) {
rpc_shutdown_client(clp->cl_cb_client); rpc_shutdown_client(clp->cl_cb_client);
clp->cl_cb_client = NULL; clp->cl_cb_client = NULL;
put_rpccred(clp->cl_cb_cred);
clp->cl_cb_cred = NULL;
} }
if (clp->cl_cb_conn.cb_xprt) { if (clp->cl_cb_conn.cb_xprt) {
svc_xprt_put(clp->cl_cb_conn.cb_xprt); svc_xprt_put(clp->cl_cb_conn.cb_xprt);
...@@ -995,7 +1017,7 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) ...@@ -995,7 +1017,7 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb)
run_nfsd4_cb(cb); run_nfsd4_cb(cb);
} }
void nfsd4_do_callback_rpc(struct work_struct *w) static void nfsd4_do_callback_rpc(struct work_struct *w)
{ {
struct nfsd4_callback *cb = container_of(w, struct nfsd4_callback, cb_work); struct nfsd4_callback *cb = container_of(w, struct nfsd4_callback, cb_work);
struct nfs4_client *clp = cb->cb_clp; struct nfs4_client *clp = cb->cb_clp;
...@@ -1010,10 +1032,16 @@ void nfsd4_do_callback_rpc(struct work_struct *w) ...@@ -1010,10 +1032,16 @@ void nfsd4_do_callback_rpc(struct work_struct *w)
nfsd4_release_cb(cb); nfsd4_release_cb(cb);
return; return;
} }
cb->cb_msg.rpc_cred = clp->cl_cb_cred;
rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN, rpc_call_async(clnt, &cb->cb_msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN,
cb->cb_ops, cb); cb->cb_ops, cb);
} }
void nfsd4_init_callback(struct nfsd4_callback *cb)
{
INIT_WORK(&cb->cb_work, nfsd4_do_callback_rpc);
}
void nfsd4_cb_recall(struct nfs4_delegation *dp) void nfsd4_cb_recall(struct nfs4_delegation *dp)
{ {
struct nfsd4_callback *cb = &dp->dl_recall; struct nfsd4_callback *cb = &dp->dl_recall;
...@@ -1025,7 +1053,6 @@ void nfsd4_cb_recall(struct nfs4_delegation *dp) ...@@ -1025,7 +1053,6 @@ void nfsd4_cb_recall(struct nfs4_delegation *dp)
cb->cb_msg.rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL]; cb->cb_msg.rpc_proc = &nfs4_cb_procedures[NFSPROC4_CLNT_CB_RECALL];
cb->cb_msg.rpc_argp = cb; cb->cb_msg.rpc_argp = cb;
cb->cb_msg.rpc_resp = cb; cb->cb_msg.rpc_resp = cb;
cb->cb_msg.rpc_cred = callback_cred;
cb->cb_ops = &nfsd4_cb_recall_ops; cb->cb_ops = &nfsd4_cb_recall_ops;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "xdr4.h" #include "xdr4.h"
#include "vfs.h" #include "vfs.h"
#include "current_stateid.h" #include "current_stateid.h"
#include "netns.h"
#define NFSDDBG_FACILITY NFSDDBG_PROC #define NFSDDBG_FACILITY NFSDDBG_PROC
...@@ -194,6 +195,7 @@ static __be32 ...@@ -194,6 +195,7 @@ static __be32
do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open) do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_open *open)
{ {
struct svc_fh *resfh; struct svc_fh *resfh;
int accmode;
__be32 status; __be32 status;
resfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL); resfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
...@@ -253,9 +255,10 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o ...@@ -253,9 +255,10 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
/* set reply cache */ /* set reply cache */
fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh, fh_copy_shallow(&open->op_openowner->oo_owner.so_replay.rp_openfh,
&resfh->fh_handle); &resfh->fh_handle);
if (!open->op_created) accmode = NFSD_MAY_NOP;
status = do_open_permission(rqstp, resfh, open, if (open->op_created)
NFSD_MAY_NOP); accmode |= NFSD_MAY_OWNER_OVERRIDE;
status = do_open_permission(rqstp, resfh, open, accmode);
set_change_info(&open->op_cinfo, current_fh); set_change_info(&open->op_cinfo, current_fh);
fh_dup2(current_fh, resfh); fh_dup2(current_fh, resfh);
out: out:
...@@ -304,6 +307,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -304,6 +307,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
{ {
__be32 status; __be32 status;
struct nfsd4_compoundres *resp; struct nfsd4_compoundres *resp;
struct net *net = SVC_NET(rqstp);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n", dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n",
(int)open->op_fname.len, open->op_fname.data, (int)open->op_fname.len, open->op_fname.data,
...@@ -331,7 +336,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -331,7 +336,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
/* check seqid for replay. set nfs4_owner */ /* check seqid for replay. set nfs4_owner */
resp = rqstp->rq_resp; resp = rqstp->rq_resp;
status = nfsd4_process_open1(&resp->cstate, open); status = nfsd4_process_open1(&resp->cstate, open, nn);
if (status == nfserr_replay_me) { if (status == nfserr_replay_me) {
struct nfs4_replay *rp = &open->op_openowner->oo_owner.so_replay; struct nfs4_replay *rp = &open->op_openowner->oo_owner.so_replay;
fh_put(&cstate->current_fh); fh_put(&cstate->current_fh);
...@@ -354,10 +359,10 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -354,10 +359,10 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
/* Openowner is now set, so sequence id will get bumped. Now we need /* Openowner is now set, so sequence id will get bumped. Now we need
* these checks before we do any creates: */ * these checks before we do any creates: */
status = nfserr_grace; status = nfserr_grace;
if (locks_in_grace(SVC_NET(rqstp)) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) if (locks_in_grace(net) && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS)
goto out; goto out;
status = nfserr_no_grace; status = nfserr_no_grace;
if (!locks_in_grace(SVC_NET(rqstp)) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS) if (!locks_in_grace(net) && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS)
goto out; goto out;
switch (open->op_claim_type) { switch (open->op_claim_type) {
...@@ -370,7 +375,9 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -370,7 +375,9 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
break; break;
case NFS4_OPEN_CLAIM_PREVIOUS: case NFS4_OPEN_CLAIM_PREVIOUS:
open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED; open->op_openowner->oo_flags |= NFS4_OO_CONFIRMED;
status = nfs4_check_open_reclaim(&open->op_clientid, cstate->minorversion); status = nfs4_check_open_reclaim(&open->op_clientid,
cstate->minorversion,
nn);
if (status) if (status)
goto out; goto out;
case NFS4_OPEN_CLAIM_FH: case NFS4_OPEN_CLAIM_FH:
...@@ -490,12 +497,13 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -490,12 +497,13 @@ nfsd4_access(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
&access->ac_supported); &access->ac_supported);
} }
static void gen_boot_verifier(nfs4_verifier *verifier) static void gen_boot_verifier(nfs4_verifier *verifier, struct net *net)
{ {
__be32 verf[2]; __be32 verf[2];
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
verf[0] = (__be32)nfssvc_boot.tv_sec; verf[0] = (__be32)nn->nfssvc_boot.tv_sec;
verf[1] = (__be32)nfssvc_boot.tv_usec; verf[1] = (__be32)nn->nfssvc_boot.tv_usec;
memcpy(verifier->data, verf, sizeof(verifier->data)); memcpy(verifier->data, verf, sizeof(verifier->data));
} }
...@@ -503,7 +511,7 @@ static __be32 ...@@ -503,7 +511,7 @@ static __be32
nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfsd4_commit(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct nfsd4_commit *commit) struct nfsd4_commit *commit)
{ {
gen_boot_verifier(&commit->co_verf); gen_boot_verifier(&commit->co_verf, SVC_NET(rqstp));
return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset, return nfsd_commit(rqstp, &cstate->current_fh, commit->co_offset,
commit->co_count); commit->co_count);
} }
...@@ -684,6 +692,17 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -684,6 +692,17 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
if (read->rd_offset >= OFFSET_MAX) if (read->rd_offset >= OFFSET_MAX)
return nfserr_inval; return nfserr_inval;
/*
* If we do a zero copy read, then a client will see read data
* that reflects the state of the file *after* performing the
* following compound.
*
* To ensure proper ordering, we therefore turn off zero copy if
* the client wants us to do more in this compound:
*/
if (!nfsd4_last_compound_op(rqstp))
rqstp->rq_splice_ok = false;
nfs4_lock_state(); nfs4_lock_state();
/* check stateid */ /* check stateid */
if ((status = nfs4_preprocess_stateid_op(SVC_NET(rqstp), if ((status = nfs4_preprocess_stateid_op(SVC_NET(rqstp),
...@@ -876,6 +895,24 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -876,6 +895,24 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
return status; return status;
} }
static int fill_in_write_vector(struct kvec *vec, struct nfsd4_write *write)
{
int i = 1;
int buflen = write->wr_buflen;
vec[0].iov_base = write->wr_head.iov_base;
vec[0].iov_len = min_t(int, buflen, write->wr_head.iov_len);
buflen -= vec[0].iov_len;
while (buflen) {
vec[i].iov_base = page_address(write->wr_pagelist[i - 1]);
vec[i].iov_len = min_t(int, PAGE_SIZE, buflen);
buflen -= vec[i].iov_len;
i++;
}
return i;
}
static __be32 static __be32
nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct nfsd4_write *write) struct nfsd4_write *write)
...@@ -884,6 +921,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -884,6 +921,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct file *filp = NULL; struct file *filp = NULL;
__be32 status = nfs_ok; __be32 status = nfs_ok;
unsigned long cnt; unsigned long cnt;
int nvecs;
/* no need to check permission - this will be done in nfsd_write() */ /* no need to check permission - this will be done in nfsd_write() */
...@@ -904,10 +942,13 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -904,10 +942,13 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
cnt = write->wr_buflen; cnt = write->wr_buflen;
write->wr_how_written = write->wr_stable_how; write->wr_how_written = write->wr_stable_how;
gen_boot_verifier(&write->wr_verifier); gen_boot_verifier(&write->wr_verifier, SVC_NET(rqstp));
nvecs = fill_in_write_vector(rqstp->rq_vec, write);
WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec));
status = nfsd_write(rqstp, &cstate->current_fh, filp, status = nfsd_write(rqstp, &cstate->current_fh, filp,
write->wr_offset, rqstp->rq_vec, write->wr_vlen, write->wr_offset, rqstp->rq_vec, nvecs,
&cnt, &write->wr_how_written); &cnt, &write->wr_how_written);
if (filp) if (filp)
fput(filp); fput(filp);
...@@ -1666,6 +1707,12 @@ static struct nfsd4_operation nfsd4_ops[] = { ...@@ -1666,6 +1707,12 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_name = "OP_EXCHANGE_ID", .op_name = "OP_EXCHANGE_ID",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_exchange_id_rsize, .op_rsize_bop = (nfsd4op_rsize)nfsd4_exchange_id_rsize,
}, },
[OP_BACKCHANNEL_CTL] = {
.op_func = (nfsd4op_func)nfsd4_backchannel_ctl,
.op_flags = ALLOWED_WITHOUT_FH | OP_MODIFIES_SOMETHING,
.op_name = "OP_BACKCHANNEL_CTL",
.op_rsize_bop = (nfsd4op_rsize)nfsd4_only_status_rsize,
},
[OP_BIND_CONN_TO_SESSION] = { [OP_BIND_CONN_TO_SESSION] = {
.op_func = (nfsd4op_func)nfsd4_bind_conn_to_session, .op_func = (nfsd4op_func)nfsd4_bind_conn_to_session,
.op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP
...@@ -1719,6 +1766,7 @@ static struct nfsd4_operation nfsd4_ops[] = { ...@@ -1719,6 +1766,7 @@ static struct nfsd4_operation nfsd4_ops[] = {
.op_func = (nfsd4op_func)nfsd4_free_stateid, .op_func = (nfsd4op_func)nfsd4_free_stateid,
.op_flags = ALLOWED_WITHOUT_FH | OP_MODIFIES_SOMETHING, .op_flags = ALLOWED_WITHOUT_FH | OP_MODIFIES_SOMETHING,
.op_name = "OP_FREE_STATEID", .op_name = "OP_FREE_STATEID",
.op_get_currentstateid = (stateid_getter)nfsd4_get_freestateid,
.op_rsize_bop = (nfsd4op_rsize)nfsd4_only_status_rsize, .op_rsize_bop = (nfsd4op_rsize)nfsd4_only_status_rsize,
}, },
}; };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "idmap.h" #include "idmap.h"
#include "nfsd.h" #include "nfsd.h"
#include "cache.h" #include "cache.h"
#include "fault_inject.h" #include "state.h"
#include "netns.h" #include "netns.h"
/* /*
...@@ -186,9 +186,6 @@ static struct file_operations supported_enctypes_ops = { ...@@ -186,9 +186,6 @@ static struct file_operations supported_enctypes_ops = {
}; };
#endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */
extern int nfsd_pool_stats_open(struct inode *inode, struct file *file);
extern int nfsd_pool_stats_release(struct inode *inode, struct file *file);
static const struct file_operations pool_stats_operations = { static const struct file_operations pool_stats_operations = {
.open = nfsd_pool_stats_open, .open = nfsd_pool_stats_open,
.read = seq_read, .read = seq_read,
...@@ -399,6 +396,8 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) ...@@ -399,6 +396,8 @@ 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 = &init_net;
if (size > 0) { if (size > 0) {
int newthreads; int newthreads;
rv = get_int(&mesg, &newthreads); rv = get_int(&mesg, &newthreads);
...@@ -406,11 +405,11 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) ...@@ -406,11 +405,11 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)
return rv; return rv;
if (newthreads < 0) if (newthreads < 0)
return -EINVAL; return -EINVAL;
rv = nfsd_svc(newthreads); rv = nfsd_svc(newthreads, net);
if (rv < 0) if (rv < 0)
return rv; return rv;
} else } else
rv = nfsd_nrthreads(); rv = nfsd_nrthreads(net);
return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", rv); return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%d\n", rv);
} }
...@@ -448,9 +447,10 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) ...@@ -448,9 +447,10 @@ 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 = &init_net;
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
npools = nfsd_nrpools(); npools = nfsd_nrpools(net);
if (npools == 0) { if (npools == 0) {
/* /*
* NFS is shut down. The admin can start it by * NFS is shut down. The admin can start it by
...@@ -478,12 +478,12 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) ...@@ -478,12 +478,12 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
if (nthreads[i] < 0) if (nthreads[i] < 0)
goto out_free; goto out_free;
} }
rv = nfsd_set_nrthreads(i, nthreads); rv = nfsd_set_nrthreads(i, nthreads, net);
if (rv) if (rv)
goto out_free; goto out_free;
} }
rv = nfsd_get_nrthreads(npools, nthreads); rv = nfsd_get_nrthreads(npools, nthreads, net);
if (rv) if (rv)
goto out_free; goto out_free;
...@@ -510,11 +510,13 @@ static ssize_t __write_versions(struct file *file, char *buf, size_t size) ...@@ -510,11 +510,13 @@ 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 = &init_net;
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (size>0) { if (size>0) {
if (nfsd_serv) if (nn->nfsd_serv)
/* Cannot change versions without updating /* Cannot change versions without updating
* nfsd_serv->sv_xdrsize, and reallocing * nn->nfsd_serv->sv_xdrsize, and reallocing
* rq_argp and rq_resp * rq_argp and rq_resp
*/ */
return -EBUSY; return -EBUSY;
...@@ -645,11 +647,13 @@ static ssize_t write_versions(struct file *file, char *buf, size_t size) ...@@ -645,11 +647,13 @@ static ssize_t write_versions(struct file *file, char *buf, size_t size)
* Zero-length write. Return a list of NFSD's current listener * Zero-length write. Return a list of NFSD's current listener
* transports. * transports.
*/ */
static ssize_t __write_ports_names(char *buf) static ssize_t __write_ports_names(char *buf, struct net *net)
{ {
if (nfsd_serv == NULL) struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (nn->nfsd_serv == NULL)
return 0; return 0;
return svc_xprt_names(nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT); return svc_xprt_names(nn->nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT);
} }
/* /*
...@@ -657,28 +661,28 @@ static ssize_t __write_ports_names(char *buf) ...@@ -657,28 +661,28 @@ static ssize_t __write_ports_names(char *buf)
* a socket of a supported family/protocol, and we use it as an * a socket of a supported family/protocol, and we use it as an
* nfsd listener. * nfsd listener.
*/ */
static ssize_t __write_ports_addfd(char *buf) static ssize_t __write_ports_addfd(char *buf, struct net *net)
{ {
char *mesg = buf; char *mesg = buf;
int fd, err; int fd, err;
struct net *net = &init_net; struct nfsd_net *nn = net_generic(net, nfsd_net_id);
err = get_int(&mesg, &fd); err = get_int(&mesg, &fd);
if (err != 0 || fd < 0) if (err != 0 || fd < 0)
return -EINVAL; return -EINVAL;
err = nfsd_create_serv(); err = nfsd_create_serv(net);
if (err != 0) if (err != 0)
return err; return err;
err = svc_addsock(nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT); err = svc_addsock(nn->nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT);
if (err < 0) { if (err < 0) {
nfsd_destroy(net); nfsd_destroy(net);
return err; return err;
} }
/* Decrease the count, but don't shut down the service */ /* Decrease the count, but don't shut down the service */
nfsd_serv->sv_nrthreads--; nn->nfsd_serv->sv_nrthreads--;
return err; return err;
} }
...@@ -686,12 +690,12 @@ static ssize_t __write_ports_addfd(char *buf) ...@@ -686,12 +690,12 @@ static ssize_t __write_ports_addfd(char *buf)
* A transport listener is added by writing it's transport name and * A transport listener is added by writing it's transport name and
* a port number. * a port number.
*/ */
static ssize_t __write_ports_addxprt(char *buf) static ssize_t __write_ports_addxprt(char *buf, struct net *net)
{ {
char transport[16]; char transport[16];
struct svc_xprt *xprt; struct svc_xprt *xprt;
int port, err; int port, err;
struct net *net = &init_net; struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (sscanf(buf, "%15s %5u", transport, &port) != 2) if (sscanf(buf, "%15s %5u", transport, &port) != 2)
return -EINVAL; return -EINVAL;
...@@ -699,25 +703,25 @@ static ssize_t __write_ports_addxprt(char *buf) ...@@ -699,25 +703,25 @@ static ssize_t __write_ports_addxprt(char *buf)
if (port < 1 || port > USHRT_MAX) if (port < 1 || port > USHRT_MAX)
return -EINVAL; return -EINVAL;
err = nfsd_create_serv(); err = nfsd_create_serv(net);
if (err != 0) if (err != 0)
return err; return err;
err = svc_create_xprt(nfsd_serv, transport, net, err = svc_create_xprt(nn->nfsd_serv, transport, net,
PF_INET, port, SVC_SOCK_ANONYMOUS); PF_INET, port, SVC_SOCK_ANONYMOUS);
if (err < 0) if (err < 0)
goto out_err; goto out_err;
err = svc_create_xprt(nfsd_serv, transport, net, err = svc_create_xprt(nn->nfsd_serv, transport, net,
PF_INET6, port, SVC_SOCK_ANONYMOUS); PF_INET6, port, SVC_SOCK_ANONYMOUS);
if (err < 0 && err != -EAFNOSUPPORT) if (err < 0 && err != -EAFNOSUPPORT)
goto out_close; goto out_close;
/* Decrease the count, but don't shut down the service */ /* Decrease the count, but don't shut down the service */
nfsd_serv->sv_nrthreads--; nn->nfsd_serv->sv_nrthreads--;
return 0; return 0;
out_close: out_close:
xprt = svc_find_xprt(nfsd_serv, transport, net, PF_INET, port); xprt = svc_find_xprt(nn->nfsd_serv, transport, net, PF_INET, port);
if (xprt != NULL) { if (xprt != NULL) {
svc_close_xprt(xprt); svc_close_xprt(xprt);
svc_xprt_put(xprt); svc_xprt_put(xprt);
...@@ -727,16 +731,17 @@ static ssize_t __write_ports_addxprt(char *buf) ...@@ -727,16 +731,17 @@ static ssize_t __write_ports_addxprt(char *buf)
return err; return err;
} }
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,
struct net *net)
{ {
if (size == 0) if (size == 0)
return __write_ports_names(buf); return __write_ports_names(buf, net);
if (isdigit(buf[0])) if (isdigit(buf[0]))
return __write_ports_addfd(buf); return __write_ports_addfd(buf, net);
if (isalpha(buf[0])) if (isalpha(buf[0]))
return __write_ports_addxprt(buf); return __write_ports_addxprt(buf, net);
return -EINVAL; return -EINVAL;
} }
...@@ -787,9 +792,10 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size) ...@@ -787,9 +792,10 @@ 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 = &init_net;
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
rv = __write_ports(file, buf, size); rv = __write_ports(file, buf, size, net);
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return rv; return rv;
} }
...@@ -821,6 +827,9 @@ int nfsd_max_blksize; ...@@ -821,6 +827,9 @@ 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 = &init_net;
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (size > 0) { if (size > 0) {
int bsize; int bsize;
int rv = get_int(&mesg, &bsize); int rv = get_int(&mesg, &bsize);
...@@ -835,7 +844,7 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) ...@@ -835,7 +844,7 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
bsize = NFSSVC_MAXBLKSIZE; bsize = NFSSVC_MAXBLKSIZE;
bsize &= ~(1024-1); bsize &= ~(1024-1);
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
if (nfsd_serv) { if (nn->nfsd_serv) {
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return -EBUSY; return -EBUSY;
} }
...@@ -848,13 +857,14 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) ...@@ -848,13 +857,14 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size)
} }
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size,
time_t *time, struct nfsd_net *nn)
{ {
char *mesg = buf; char *mesg = buf;
int rv, i; int rv, i;
if (size > 0) { if (size > 0) {
if (nfsd_serv) if (nn->nfsd_serv)
return -EBUSY; return -EBUSY;
rv = get_int(&mesg, &i); rv = get_int(&mesg, &i);
if (rv) if (rv)
...@@ -879,12 +889,13 @@ static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, tim ...@@ -879,12 +889,13 @@ static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, tim
return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time); return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time);
} }
static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size,
time_t *time, struct nfsd_net *nn)
{ {
ssize_t rv; ssize_t rv;
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
rv = __nfsd4_write_time(file, buf, size, time); rv = __nfsd4_write_time(file, buf, size, time, nn);
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return rv; return rv;
} }
...@@ -912,7 +923,8 @@ static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_ ...@@ -912,7 +923,8 @@ static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_
*/ */
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)
{ {
return nfsd4_write_time(file, buf, size, &nfsd4_lease); struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
return nfsd4_write_time(file, buf, size, &nn->nfsd4_lease, nn);
} }
/** /**
...@@ -927,17 +939,19 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size) ...@@ -927,17 +939,19 @@ 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)
{ {
return nfsd4_write_time(file, buf, size, &nfsd4_grace); struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
return nfsd4_write_time(file, buf, size, &nn->nfsd4_grace, nn);
} }
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,
struct nfsd_net *nn)
{ {
char *mesg = buf; char *mesg = buf;
char *recdir; char *recdir;
int len, status; int len, status;
if (size > 0) { if (size > 0) {
if (nfsd_serv) if (nn->nfsd_serv)
return -EBUSY; return -EBUSY;
if (size > PATH_MAX || buf[size-1] != '\n') if (size > PATH_MAX || buf[size-1] != '\n')
return -EINVAL; return -EINVAL;
...@@ -981,9 +995,10 @@ static ssize_t __write_recoverydir(struct file *file, char *buf, size_t size) ...@@ -981,9 +995,10 @@ 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 nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
rv = __write_recoverydir(file, buf, size); rv = __write_recoverydir(file, buf, size, nn);
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return rv; return rv;
} }
...@@ -1063,6 +1078,7 @@ int nfsd_net_id; ...@@ -1063,6 +1078,7 @@ int nfsd_net_id;
static __net_init int nfsd_init_net(struct net *net) static __net_init int nfsd_init_net(struct net *net)
{ {
int retval; int retval;
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
retval = nfsd_export_init(net); retval = nfsd_export_init(net);
if (retval) if (retval)
...@@ -1070,6 +1086,8 @@ static __net_init int nfsd_init_net(struct net *net) ...@@ -1070,6 +1086,8 @@ static __net_init int nfsd_init_net(struct net *net)
retval = nfsd_idmap_init(net); retval = nfsd_idmap_init(net);
if (retval) if (retval)
goto out_idmap_error; goto out_idmap_error;
nn->nfsd4_lease = 90; /* default lease time */
nn->nfsd4_grace = 90;
return 0; return 0;
out_idmap_error: out_idmap_error:
......
...@@ -55,7 +55,6 @@ extern struct svc_version nfsd_version2, nfsd_version3, ...@@ -55,7 +55,6 @@ extern struct svc_version nfsd_version2, nfsd_version3,
nfsd_version4; nfsd_version4;
extern u32 nfsd_supported_minorversion; extern u32 nfsd_supported_minorversion;
extern struct mutex nfsd_mutex; extern struct mutex nfsd_mutex;
extern struct svc_serv *nfsd_serv;
extern spinlock_t nfsd_drc_lock; extern spinlock_t nfsd_drc_lock;
extern unsigned int nfsd_drc_max_mem; extern unsigned int nfsd_drc_max_mem;
extern unsigned int nfsd_drc_mem_used; extern unsigned int nfsd_drc_mem_used;
...@@ -65,26 +64,17 @@ extern const struct seq_operations nfs_exports_op; ...@@ -65,26 +64,17 @@ extern const struct seq_operations nfs_exports_op;
/* /*
* Function prototypes. * Function prototypes.
*/ */
int nfsd_svc(int nrservs); int nfsd_svc(int nrservs, struct net *net);
int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp); int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp);
int nfsd_nrthreads(void); int nfsd_nrthreads(struct net *);
int nfsd_nrpools(void); int nfsd_nrpools(struct net *);
int nfsd_get_nrthreads(int n, int *); int nfsd_get_nrthreads(int n, int *, struct net *);
int nfsd_set_nrthreads(int n, int *); int nfsd_set_nrthreads(int n, int *, struct net *);
int nfsd_pool_stats_open(struct inode *, struct file *); int nfsd_pool_stats_open(struct inode *, struct file *);
int nfsd_pool_stats_release(struct inode *, struct file *); int nfsd_pool_stats_release(struct inode *, struct file *);
static inline void nfsd_destroy(struct net *net) void nfsd_destroy(struct net *net);
{
int destroy = (nfsd_serv->sv_nrthreads == 1);
if (destroy)
svc_shutdown_net(nfsd_serv, net);
svc_destroy(nfsd_serv);
if (destroy)
nfsd_serv = NULL;
}
#if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL) #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
#ifdef CONFIG_NFSD_V2_ACL #ifdef CONFIG_NFSD_V2_ACL
...@@ -103,7 +93,7 @@ enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL }; ...@@ -103,7 +93,7 @@ enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL };
int nfsd_vers(int vers, enum vers_op change); int nfsd_vers(int vers, enum vers_op change);
int nfsd_minorversion(u32 minorversion, enum vers_op change); int nfsd_minorversion(u32 minorversion, enum vers_op change);
void nfsd_reset_versions(void); void nfsd_reset_versions(void);
int nfsd_create_serv(void); int nfsd_create_serv(struct net *net);
extern int nfsd_max_blksize; extern int nfsd_max_blksize;
...@@ -121,7 +111,9 @@ void nfs4_state_init(void); ...@@ -121,7 +111,9 @@ void nfs4_state_init(void);
int nfsd4_init_slabs(void); int nfsd4_init_slabs(void);
void nfsd4_free_slabs(void); void nfsd4_free_slabs(void);
int nfs4_state_start(void); int nfs4_state_start(void);
int nfs4_state_start_net(struct net *net);
void nfs4_state_shutdown(void); void nfs4_state_shutdown(void);
void nfs4_state_shutdown_net(struct net *net);
void nfs4_reset_lease(time_t leasetime); void nfs4_reset_lease(time_t leasetime);
int nfs4_reset_recoverydir(char *recdir); int nfs4_reset_recoverydir(char *recdir);
char * nfs4_recoverydir(void); char * nfs4_recoverydir(void);
...@@ -130,7 +122,9 @@ static inline void nfs4_state_init(void) { } ...@@ -130,7 +122,9 @@ static inline void nfs4_state_init(void) { }
static inline int nfsd4_init_slabs(void) { return 0; } static inline int nfsd4_init_slabs(void) { return 0; }
static inline void nfsd4_free_slabs(void) { } static inline void nfsd4_free_slabs(void) { }
static inline int nfs4_state_start(void) { return 0; } static inline int nfs4_state_start(void) { return 0; }
static inline int nfs4_state_start_net(struct net *net) { return 0; }
static inline void nfs4_state_shutdown(void) { } static inline void nfs4_state_shutdown(void) { }
static inline void nfs4_state_shutdown_net(struct net *net) { }
static inline void nfs4_reset_lease(time_t leasetime) { } static inline void nfs4_reset_lease(time_t leasetime) { }
static inline int nfs4_reset_recoverydir(char *recdir) { return 0; } static inline int nfs4_reset_recoverydir(char *recdir) { return 0; }
static inline char * nfs4_recoverydir(void) {return NULL; } static inline char * nfs4_recoverydir(void) {return NULL; }
...@@ -265,16 +259,8 @@ void nfsd_lockd_shutdown(void); ...@@ -265,16 +259,8 @@ void nfsd_lockd_shutdown(void);
/* Check for dir entries '.' and '..' */ /* Check for dir entries '.' and '..' */
#define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.')) #define isdotent(n, l) (l < 3 && n[0] == '.' && (l == 1 || n[1] == '.'))
/*
* Time of server startup
*/
extern struct timeval nfssvc_boot;
#ifdef CONFIG_NFSD_V4 #ifdef CONFIG_NFSD_V4
extern time_t nfsd4_lease;
extern time_t nfsd4_grace;
/* before processing a COMPOUND operation, we have to check that there /* before processing a COMPOUND operation, we have to check that there
* is enough space in the buffer for XDR encode to succeed. otherwise, * is enough space in the buffer for XDR encode to succeed. otherwise,
* we might process an operation with side effects, and be unable to * we might process an operation with side effects, and be unable to
......
...@@ -572,7 +572,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry, ...@@ -572,7 +572,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
if (inode) if (inode)
_fh_update(fhp, exp, dentry); _fh_update(fhp, exp, dentry);
if (fhp->fh_handle.fh_fileid_type == 255) { if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) {
fh_put(fhp); fh_put(fhp);
return nfserr_opnotsupp; return nfserr_opnotsupp;
} }
...@@ -603,7 +603,7 @@ fh_update(struct svc_fh *fhp) ...@@ -603,7 +603,7 @@ fh_update(struct svc_fh *fhp)
goto out; goto out;
_fh_update(fhp, fhp->fh_export, dentry); _fh_update(fhp, fhp->fh_export, dentry);
if (fhp->fh_handle.fh_fileid_type == 255) if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID)
return nfserr_opnotsupp; return nfserr_opnotsupp;
} }
out: out:
......
This diff is collapsed.
...@@ -246,7 +246,7 @@ nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -246,7 +246,7 @@ nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p,
struct nfsd_readargs *args) struct nfsd_readargs *args)
{ {
unsigned int len; unsigned int len;
int v,pn; int v;
if (!(p = decode_fh(p, &args->fh))) if (!(p = decode_fh(p, &args->fh)))
return 0; return 0;
...@@ -262,8 +262,9 @@ nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -262,8 +262,9 @@ nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p,
*/ */
v=0; v=0;
while (len > 0) { while (len > 0) {
pn = rqstp->rq_resused++; struct page *p = *(rqstp->rq_next_page++);
rqstp->rq_vec[v].iov_base = page_address(rqstp->rq_respages[pn]);
rqstp->rq_vec[v].iov_base = page_address(p);
rqstp->rq_vec[v].iov_len = len < PAGE_SIZE?len:PAGE_SIZE; rqstp->rq_vec[v].iov_len = len < PAGE_SIZE?len:PAGE_SIZE;
len -= rqstp->rq_vec[v].iov_len; len -= rqstp->rq_vec[v].iov_len;
v++; v++;
...@@ -355,7 +356,7 @@ nfssvc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd_readli ...@@ -355,7 +356,7 @@ nfssvc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd_readli
{ {
if (!(p = decode_fh(p, &args->fh))) if (!(p = decode_fh(p, &args->fh)))
return 0; return 0;
args->buffer = page_address(rqstp->rq_respages[rqstp->rq_resused++]); args->buffer = page_address(*(rqstp->rq_next_page++));
return xdr_argsize_check(rqstp, p); return xdr_argsize_check(rqstp, p);
} }
...@@ -396,7 +397,7 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p, ...@@ -396,7 +397,7 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p,
if (args->count > PAGE_SIZE) if (args->count > PAGE_SIZE)
args->count = PAGE_SIZE; args->count = PAGE_SIZE;
args->buffer = page_address(rqstp->rq_respages[rqstp->rq_resused++]); args->buffer = page_address(*(rqstp->rq_next_page++));
return xdr_argsize_check(rqstp, p); return xdr_argsize_check(rqstp, p);
} }
......
...@@ -150,6 +150,12 @@ struct nfsd4_channel_attrs { ...@@ -150,6 +150,12 @@ struct nfsd4_channel_attrs {
u32 rdma_attrs; u32 rdma_attrs;
}; };
struct nfsd4_cb_sec {
u32 flavor; /* (u32)(-1) used to mean "no valid flavor" */
u32 uid;
u32 gid;
};
struct nfsd4_create_session { struct nfsd4_create_session {
clientid_t clientid; clientid_t clientid;
struct nfs4_sessionid sessionid; struct nfs4_sessionid sessionid;
...@@ -158,8 +164,12 @@ struct nfsd4_create_session { ...@@ -158,8 +164,12 @@ struct nfsd4_create_session {
struct nfsd4_channel_attrs fore_channel; struct nfsd4_channel_attrs fore_channel;
struct nfsd4_channel_attrs back_channel; struct nfsd4_channel_attrs back_channel;
u32 callback_prog; u32 callback_prog;
u32 uid; struct nfsd4_cb_sec cb_sec;
u32 gid; };
struct nfsd4_backchannel_ctl {
u32 bc_cb_program;
struct nfsd4_cb_sec bc_cb_sec;
}; };
struct nfsd4_bind_conn_to_session { struct nfsd4_bind_conn_to_session {
...@@ -192,6 +202,7 @@ struct nfsd4_session { ...@@ -192,6 +202,7 @@ struct nfsd4_session {
struct nfs4_sessionid se_sessionid; struct nfs4_sessionid se_sessionid;
struct nfsd4_channel_attrs se_fchannel; struct nfsd4_channel_attrs se_fchannel;
struct nfsd4_channel_attrs se_bchannel; struct nfsd4_channel_attrs se_bchannel;
struct nfsd4_cb_sec se_cb_sec;
struct list_head se_conns; struct list_head se_conns;
u32 se_cb_prog; u32 se_cb_prog;
u32 se_cb_seq_nr; u32 se_cb_seq_nr;
...@@ -221,13 +232,12 @@ struct nfsd4_sessionid { ...@@ -221,13 +232,12 @@ struct nfsd4_sessionid {
*/ */
struct nfs4_client { struct nfs4_client {
struct list_head cl_idhash; /* hash by cl_clientid.id */ struct list_head cl_idhash; /* hash by cl_clientid.id */
struct list_head cl_strhash; /* hash by cl_name */ struct rb_node cl_namenode; /* link into by-name trees */
struct list_head cl_openowners; struct list_head cl_openowners;
struct idr cl_stateids; /* stateid lookup */ struct idr cl_stateids; /* stateid lookup */
struct list_head cl_delegations; struct list_head cl_delegations;
struct list_head cl_lru; /* tail queue */ struct list_head cl_lru; /* tail queue */
struct xdr_netobj cl_name; /* id generated by client */ struct xdr_netobj cl_name; /* id generated by client */
char cl_recdir[HEXDIR_LEN]; /* recovery dir */
nfs4_verifier cl_verifier; /* generated by client */ nfs4_verifier cl_verifier; /* generated by client */
time_t cl_time; /* time of last lease renewal */ time_t cl_time; /* time of last lease renewal */
struct sockaddr_storage cl_addr; /* client ipaddress */ struct sockaddr_storage cl_addr; /* client ipaddress */
...@@ -242,9 +252,11 @@ struct nfs4_client { ...@@ -242,9 +252,11 @@ struct nfs4_client {
#define NFSD4_CLIENT_CB_KILL (1) #define NFSD4_CLIENT_CB_KILL (1)
#define NFSD4_CLIENT_STABLE (2) /* client on stable storage */ #define NFSD4_CLIENT_STABLE (2) /* client on stable storage */
#define NFSD4_CLIENT_RECLAIM_COMPLETE (3) /* reclaim_complete done */ #define NFSD4_CLIENT_RECLAIM_COMPLETE (3) /* reclaim_complete done */
#define NFSD4_CLIENT_CONFIRMED (4) /* client is confirmed */
#define NFSD4_CLIENT_CB_FLAG_MASK (1 << NFSD4_CLIENT_CB_UPDATE | \ #define NFSD4_CLIENT_CB_FLAG_MASK (1 << NFSD4_CLIENT_CB_UPDATE | \
1 << NFSD4_CLIENT_CB_KILL) 1 << NFSD4_CLIENT_CB_KILL)
unsigned long cl_flags; unsigned long cl_flags;
struct rpc_cred *cl_cb_cred;
struct rpc_clnt *cl_cb_client; struct rpc_clnt *cl_cb_client;
u32 cl_cb_ident; u32 cl_cb_ident;
#define NFSD4_CB_UP 0 #define NFSD4_CB_UP 0
...@@ -271,6 +283,7 @@ struct nfs4_client { ...@@ -271,6 +283,7 @@ struct nfs4_client {
unsigned long cl_cb_slot_busy; unsigned long cl_cb_slot_busy;
struct rpc_wait_queue cl_cb_waitq; /* backchannel callers may */ struct rpc_wait_queue cl_cb_waitq; /* backchannel callers may */
/* wait here for slots */ /* wait here for slots */
struct net *net;
}; };
static inline void static inline void
...@@ -292,6 +305,7 @@ is_client_expired(struct nfs4_client *clp) ...@@ -292,6 +305,7 @@ is_client_expired(struct nfs4_client *clp)
*/ */
struct nfs4_client_reclaim { struct nfs4_client_reclaim {
struct list_head cr_strhash; /* hash by cr_name */ struct list_head cr_strhash; /* hash by cr_name */
struct nfs4_client *cr_clp; /* pointer to associated clp */
char cr_recdir[HEXDIR_LEN]; /* recover dir */ char cr_recdir[HEXDIR_LEN]; /* recover dir */
}; };
...@@ -452,25 +466,26 @@ extern __be32 nfs4_preprocess_stateid_op(struct net *net, ...@@ -452,25 +466,26 @@ extern __be32 nfs4_preprocess_stateid_op(struct net *net,
stateid_t *stateid, int flags, struct file **filp); stateid_t *stateid, int flags, struct file **filp);
extern void nfs4_lock_state(void); extern void nfs4_lock_state(void);
extern void nfs4_unlock_state(void); extern void nfs4_unlock_state(void);
extern int nfs4_in_grace(void); void nfs4_remove_reclaim_record(struct nfs4_client_reclaim *, struct nfsd_net *);
extern void nfs4_release_reclaim(void); extern void nfs4_release_reclaim(struct nfsd_net *);
extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(struct nfs4_client *crp); extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(const char *recdir,
extern __be32 nfs4_check_open_reclaim(clientid_t *clid, bool sessions); struct nfsd_net *nn);
extern __be32 nfs4_check_open_reclaim(clientid_t *clid, bool sessions, struct nfsd_net *nn);
extern void nfs4_free_openowner(struct nfs4_openowner *); extern void nfs4_free_openowner(struct nfs4_openowner *);
extern void nfs4_free_lockowner(struct nfs4_lockowner *); extern void nfs4_free_lockowner(struct nfs4_lockowner *);
extern int set_callback_cred(void); extern int set_callback_cred(void);
extern void nfsd4_init_callback(struct nfsd4_callback *);
extern void nfsd4_probe_callback(struct nfs4_client *clp); extern void nfsd4_probe_callback(struct nfs4_client *clp);
extern void nfsd4_probe_callback_sync(struct nfs4_client *clp); extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *); extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);
extern void nfsd4_do_callback_rpc(struct work_struct *);
extern void nfsd4_cb_recall(struct nfs4_delegation *dp); extern void nfsd4_cb_recall(struct nfs4_delegation *dp);
extern int nfsd4_create_callback_queue(void); extern int nfsd4_create_callback_queue(void);
extern void nfsd4_destroy_callback_queue(void); extern void nfsd4_destroy_callback_queue(void);
extern void nfsd4_shutdown_callback(struct nfs4_client *); extern void nfsd4_shutdown_callback(struct nfs4_client *);
extern void nfs4_put_delegation(struct nfs4_delegation *dp); extern void nfs4_put_delegation(struct nfs4_delegation *dp);
extern __be32 nfs4_make_rec_clidname(char *clidname, struct xdr_netobj *clname); extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(const char *name,
extern int nfs4_client_to_reclaim(const char *name); struct nfsd_net *nn);
extern int nfs4_has_reclaimed_state(const char *name, bool use_exchange_id); extern bool nfs4_has_reclaimed_state(const char *name, struct nfsd_net *nn);
extern void release_session_client(struct nfsd4_session *); extern void release_session_client(struct nfsd4_session *);
extern void nfsd4_purge_closed_stateid(struct nfs4_stateowner *); extern void nfsd4_purge_closed_stateid(struct nfs4_stateowner *);
...@@ -480,5 +495,28 @@ extern void nfsd4_client_tracking_exit(struct net *net); ...@@ -480,5 +495,28 @@ extern void nfsd4_client_tracking_exit(struct net *net);
extern void nfsd4_client_record_create(struct nfs4_client *clp); extern void nfsd4_client_record_create(struct nfs4_client *clp);
extern void nfsd4_client_record_remove(struct nfs4_client *clp); extern void nfsd4_client_record_remove(struct nfs4_client *clp);
extern int nfsd4_client_record_check(struct nfs4_client *clp); extern int nfsd4_client_record_check(struct nfs4_client *clp);
extern void nfsd4_record_grace_done(struct net *net, time_t boot_time); extern void nfsd4_record_grace_done(struct nfsd_net *nn, time_t boot_time);
/* nfs fault injection functions */
#ifdef CONFIG_NFSD_FAULT_INJECTION
int nfsd_fault_inject_init(void);
void nfsd_fault_inject_cleanup(void);
u64 nfsd_for_n_state(u64, u64 (*)(struct nfs4_client *, u64));
struct nfs4_client *nfsd_find_client(struct sockaddr_storage *, size_t);
u64 nfsd_forget_client(struct nfs4_client *, u64);
u64 nfsd_forget_client_locks(struct nfs4_client*, u64);
u64 nfsd_forget_client_openowners(struct nfs4_client *, u64);
u64 nfsd_forget_client_delegations(struct nfs4_client *, u64);
u64 nfsd_recall_client_delegations(struct nfs4_client *, u64);
u64 nfsd_print_client(struct nfs4_client *, u64);
u64 nfsd_print_client_locks(struct nfs4_client *, u64);
u64 nfsd_print_client_openowners(struct nfs4_client *, u64);
u64 nfsd_print_client_delegations(struct nfs4_client *, u64);
#else /* CONFIG_NFSD_FAULT_INJECTION */
static inline int nfsd_fault_inject_init(void) { return 0; }
static inline void nfsd_fault_inject_cleanup(void) {}
#endif /* CONFIG_NFSD_FAULT_INJECTION */
#endif /* NFSD4_STATE_H */ #endif /* NFSD4_STATE_H */
...@@ -886,7 +886,7 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf, ...@@ -886,7 +886,7 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
struct splice_desc *sd) struct splice_desc *sd)
{ {
struct svc_rqst *rqstp = sd->u.data; struct svc_rqst *rqstp = sd->u.data;
struct page **pp = rqstp->rq_respages + rqstp->rq_resused; struct page **pp = rqstp->rq_next_page;
struct page *page = buf->page; struct page *page = buf->page;
size_t size; size_t size;
...@@ -894,17 +894,15 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf, ...@@ -894,17 +894,15 @@ nfsd_splice_actor(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
if (rqstp->rq_res.page_len == 0) { if (rqstp->rq_res.page_len == 0) {
get_page(page); get_page(page);
put_page(*pp); put_page(*rqstp->rq_next_page);
*pp = page; *(rqstp->rq_next_page++) = page;
rqstp->rq_resused++;
rqstp->rq_res.page_base = buf->offset; rqstp->rq_res.page_base = buf->offset;
rqstp->rq_res.page_len = size; rqstp->rq_res.page_len = size;
} else if (page != pp[-1]) { } else if (page != pp[-1]) {
get_page(page); get_page(page);
if (*pp) if (*rqstp->rq_next_page)
put_page(*pp); put_page(*rqstp->rq_next_page);
*pp = page; *(rqstp->rq_next_page++) = page;
rqstp->rq_resused++;
rqstp->rq_res.page_len += size; rqstp->rq_res.page_len += size;
} else } else
rqstp->rq_res.page_len += size; rqstp->rq_res.page_len += size;
...@@ -936,7 +934,8 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, ...@@ -936,7 +934,8 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
.u.data = rqstp, .u.data = rqstp,
}; };
rqstp->rq_resused = 1; WARN_ON_ONCE(rqstp->rq_next_page != rqstp->rq_respages + 1);
rqstp->rq_next_page = rqstp->rq_respages + 1;
host_err = splice_direct_to_actor(file, &sd, nfsd_direct_splice_actor); host_err = splice_direct_to_actor(file, &sd, nfsd_direct_splice_actor);
} else { } else {
oldfs = get_fs(); oldfs = get_fs();
...@@ -1020,28 +1019,10 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, ...@@ -1020,28 +1019,10 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
inode = dentry->d_inode; inode = dentry->d_inode;
exp = fhp->fh_export; exp = fhp->fh_export;
/*
* Request sync writes if
* - the sync export option has been set, or
* - the client requested O_SYNC behavior (NFSv3 feature).
* - The file system doesn't support fsync().
* When NFSv2 gathered writes have been configured for this volume,
* flushing the data to disk is handled separately below.
*/
use_wgather = (rqstp->rq_vers == 2) && EX_WGATHER(exp); use_wgather = (rqstp->rq_vers == 2) && EX_WGATHER(exp);
if (!file->f_op->fsync) {/* COMMIT3 cannot work */
stable = 2;
*stablep = 2; /* FILE_SYNC */
}
if (!EX_ISSYNC(exp)) if (!EX_ISSYNC(exp))
stable = 0; stable = 0;
if (stable && !use_wgather) {
spin_lock(&file->f_lock);
file->f_flags |= O_SYNC;
spin_unlock(&file->f_lock);
}
/* Write the data. */ /* Write the data. */
oldfs = get_fs(); set_fs(KERNEL_DS); oldfs = get_fs(); set_fs(KERNEL_DS);
...@@ -1057,8 +1038,12 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, ...@@ -1057,8 +1038,12 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
if (inode->i_mode & (S_ISUID | S_ISGID)) if (inode->i_mode & (S_ISUID | S_ISGID))
kill_suid(dentry); kill_suid(dentry);
if (stable && use_wgather) if (stable) {
if (use_wgather)
host_err = wait_for_concurrent_writes(file); host_err = wait_for_concurrent_writes(file);
else
host_err = vfs_fsync_range(file, offset, offset+*cnt, 0);
}
out_nfserr: out_nfserr:
dprintk("nfsd: write complete host_err=%d\n", host_err); dprintk("nfsd: write complete host_err=%d\n", host_err);
...@@ -1485,13 +1470,19 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, ...@@ -1485,13 +1470,19 @@ do_nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
case NFS3_CREATE_EXCLUSIVE: case NFS3_CREATE_EXCLUSIVE:
if ( dchild->d_inode->i_mtime.tv_sec == v_mtime if ( dchild->d_inode->i_mtime.tv_sec == v_mtime
&& dchild->d_inode->i_atime.tv_sec == v_atime && dchild->d_inode->i_atime.tv_sec == v_atime
&& dchild->d_inode->i_size == 0 ) && dchild->d_inode->i_size == 0 ) {
if (created)
*created = 1;
break; break;
}
case NFS4_CREATE_EXCLUSIVE4_1: case NFS4_CREATE_EXCLUSIVE4_1:
if ( dchild->d_inode->i_mtime.tv_sec == v_mtime if ( dchild->d_inode->i_mtime.tv_sec == v_mtime
&& dchild->d_inode->i_atime.tv_sec == v_atime && dchild->d_inode->i_atime.tv_sec == v_atime
&& dchild->d_inode->i_size == 0 ) && dchild->d_inode->i_size == 0 ) {
if (created)
*created = 1;
goto set_attr; goto set_attr;
}
/* fallthru */ /* fallthru */
case NFS3_CREATE_GUARDED: case NFS3_CREATE_GUARDED:
err = nfserr_exist; err = nfserr_exist;
......
...@@ -385,7 +385,8 @@ struct nfsd4_write { ...@@ -385,7 +385,8 @@ struct nfsd4_write {
u64 wr_offset; /* request */ u64 wr_offset; /* request */
u32 wr_stable_how; /* request */ u32 wr_stable_how; /* request */
u32 wr_buflen; /* request */ u32 wr_buflen; /* request */
int wr_vlen; struct kvec wr_head;
struct page ** wr_pagelist; /* request */
u32 wr_bytes_written; /* response */ u32 wr_bytes_written; /* response */
u32 wr_how_written; /* response */ u32 wr_how_written; /* response */
...@@ -462,6 +463,7 @@ struct nfsd4_op { ...@@ -462,6 +463,7 @@ struct nfsd4_op {
/* NFSv4.1 */ /* NFSv4.1 */
struct nfsd4_exchange_id exchange_id; struct nfsd4_exchange_id exchange_id;
struct nfsd4_backchannel_ctl backchannel_ctl;
struct nfsd4_bind_conn_to_session bind_conn_to_session; struct nfsd4_bind_conn_to_session bind_conn_to_session;
struct nfsd4_create_session create_session; struct nfsd4_create_session create_session;
struct nfsd4_destroy_session destroy_session; struct nfsd4_destroy_session destroy_session;
...@@ -526,6 +528,14 @@ static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp) ...@@ -526,6 +528,14 @@ static inline bool nfsd4_not_cached(struct nfsd4_compoundres *resp)
|| nfsd4_is_solo_sequence(resp); || nfsd4_is_solo_sequence(resp);
} }
static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp)
{
struct nfsd4_compoundres *resp = rqstp->rq_resp;
struct nfsd4_compoundargs *argp = rqstp->rq_argp;
return argp->opcnt == resp->opcnt;
}
#define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
static inline void static inline void
...@@ -566,6 +576,7 @@ extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp, ...@@ -566,6 +576,7 @@ extern __be32 nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp,
struct nfsd4_sequence *seq); struct nfsd4_sequence *seq);
extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp, extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
struct nfsd4_compound_state *, struct nfsd4_exchange_id *); struct nfsd4_compound_state *, struct nfsd4_exchange_id *);
extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_backchannel_ctl *);
extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_bind_conn_to_session *); extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_bind_conn_to_session *);
extern __be32 nfsd4_create_session(struct svc_rqst *, extern __be32 nfsd4_create_session(struct svc_rqst *,
struct nfsd4_compound_state *, struct nfsd4_compound_state *,
...@@ -579,7 +590,7 @@ extern __be32 nfsd4_destroy_session(struct svc_rqst *, ...@@ -579,7 +590,7 @@ extern __be32 nfsd4_destroy_session(struct svc_rqst *,
extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_destroy_clientid *); extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_destroy_clientid *);
__be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_reclaim_complete *); __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *, struct nfsd4_reclaim_complete *);
extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *, extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
struct nfsd4_open *open); struct nfsd4_open *open, struct nfsd_net *nn);
extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp, extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
struct svc_fh *current_fh, struct nfsd4_open *open); struct svc_fh *current_fh, struct nfsd4_open *open);
extern void nfsd4_cleanup_open_state(struct nfsd4_open *open, __be32 status); extern void nfsd4_cleanup_open_state(struct nfsd4_open *open, __be32 status);
......
...@@ -83,6 +83,11 @@ enum fid_type { ...@@ -83,6 +83,11 @@ enum fid_type {
* 64 bit parent inode number. * 64 bit parent inode number.
*/ */
FILEID_NILFS_WITH_PARENT = 0x62, FILEID_NILFS_WITH_PARENT = 0x62,
/*
* Filesystems must not use 0xff file ID.
*/
FILEID_INVALID = 0xff,
}; };
struct fid { struct fid {
......
...@@ -217,6 +217,8 @@ extern int qword_get(char **bpp, char *dest, int bufsize); ...@@ -217,6 +217,8 @@ extern int qword_get(char **bpp, char *dest, int bufsize);
static inline int get_int(char **bpp, int *anint) static inline int get_int(char **bpp, int *anint)
{ {
char buf[50]; char buf[50];
char *ep;
int rv;
int len = qword_get(bpp, buf, sizeof(buf)); int len = qword_get(bpp, buf, sizeof(buf));
if (len < 0) if (len < 0)
...@@ -224,9 +226,11 @@ static inline int get_int(char **bpp, int *anint) ...@@ -224,9 +226,11 @@ static inline int get_int(char **bpp, int *anint)
if (len == 0) if (len == 0)
return -ENOENT; return -ENOENT;
if (kstrtoint(buf, 0, anint)) rv = simple_strtol(buf, &ep, 0);
if (*ep)
return -EINVAL; return -EINVAL;
*anint = rv;
return 0; return 0;
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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