Merge tag 'nfs-for-4.9-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client updates from Anna Schumaker: "Highlights include: Stable bugfixes: - sunrpc: fix writ espace race causing stalls - NFS: Fix inode corruption in nfs_prime_dcache() - NFSv4: Don't report revoked delegations as valid in nfs_have_delegation() - NFSv4: nfs4_copy_delegation_stateid() must fail if the delegation is invalid - NFSv4: Open state recovery must account for file permission changes - NFSv4.2: Fix a reference leak in nfs42_proc_layoutstats_generic Features: - Add support for tracking multiple layout types with an ordered list - Add support for using multiple backchannel threads on the client - Add support for pNFS file layout session trunking - Delay xprtrdma use of DMA API (for device driver removal) - Add support for xprtrdma remote invalidation - Add support for larger xprtrdma inline thresholds - Use a scatter/gather list for sending xprtrdma RPC calls - Add support for the CB_NOTIFY_LOCK callback - Improve hashing sunrpc auth_creds by using both uid and gid Bugfixes: - Fix xprtrdma use of DMA API - Validate filenames before adding to the dcache - Fix corruption of xdr->nwords in xdr_copy_to_scratch - Fix setting buffer length in xdr_set_next_buffer() - Don't deadlock the state manager on the SEQUENCE status flags - Various delegation and stateid related fixes - Retry operations if an interrupted slot receives EREMOTEIO - Make nfs boot time y2038 safe" * tag 'nfs-for-4.9-1' of git://git.linux-nfs.org/projects/anna/linux-nfs: (100 commits) NFSv4.2: Fix a reference leak in nfs42_proc_layoutstats_generic fs: nfs: Make nfs boot time y2038 safe sunrpc: replace generic auth_cred hash with auth-specific function sunrpc: add RPCSEC_GSS hash_cred() function sunrpc: add auth_unix hash_cred() function sunrpc: add generic_auth hash_cred() function sunrpc: add hash_cred() function to rpc_authops struct Retry operation on EREMOTEIO on an interrupted slot pNFS: Fix atime updates on pNFS clients sunrpc: queue work on system_power_efficient_wq NFSv4.1: Even if the stateid is OK, we may need to recover the open modes NFSv4: If recovery failed for a specific open stateid, then don't retry NFSv4: Fix retry issues with nfs41_test/free_stateid NFSv4: Open state recovery must account for file permission changes NFSv4: Mark the lock and open stateids as invalid after freeing them NFSv4: Don't test open_stateid unless it is set NFSv4: nfs4_do_handle_exception() handle revoke/expiry of a single stateid NFS: Always call nfs_inode_find_state_and_recover() when revoking a delegation NFSv4: Fix a race when updating an open_stateid NFSv4: Fix a race in nfs_inode_reclaim_delegation() ...
This commit is contained in:
@@ -76,7 +76,7 @@ static void nfs_dns_cache_revisit(struct cache_deferred_req *d, int toomany)
|
||||
|
||||
dreq = container_of(d, struct nfs_cache_defer_req, deferred_req);
|
||||
|
||||
complete_all(&dreq->completion);
|
||||
complete(&dreq->completion);
|
||||
nfs_cache_defer_req_put(dreq);
|
||||
}
|
||||
|
||||
|
@@ -31,8 +31,6 @@
|
||||
struct nfs_callback_data {
|
||||
unsigned int users;
|
||||
struct svc_serv *serv;
|
||||
struct svc_rqst *rqst;
|
||||
struct task_struct *task;
|
||||
};
|
||||
|
||||
static struct nfs_callback_data nfs_callback_info[NFS4_MAX_MINOR_VERSION + 1];
|
||||
@@ -89,15 +87,6 @@ nfs4_callback_svc(void *vrqstp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare to bring up the NFSv4 callback service
|
||||
*/
|
||||
static struct svc_rqst *
|
||||
nfs4_callback_up(struct svc_serv *serv)
|
||||
{
|
||||
return svc_prepare_thread(serv, &serv->sv_pools[0], NUMA_NO_NODE);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_NFS_V4_1)
|
||||
/*
|
||||
* The callback service for NFSv4.1 callbacks
|
||||
@@ -139,29 +128,6 @@ nfs41_callback_svc(void *vrqstp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bring up the NFSv4.1 callback service
|
||||
*/
|
||||
static struct svc_rqst *
|
||||
nfs41_callback_up(struct svc_serv *serv)
|
||||
{
|
||||
struct svc_rqst *rqstp;
|
||||
|
||||
INIT_LIST_HEAD(&serv->sv_cb_list);
|
||||
spin_lock_init(&serv->sv_cb_lock);
|
||||
init_waitqueue_head(&serv->sv_cb_waitq);
|
||||
rqstp = svc_prepare_thread(serv, &serv->sv_pools[0], NUMA_NO_NODE);
|
||||
dprintk("--> %s return %d\n", __func__, PTR_ERR_OR_ZERO(rqstp));
|
||||
return rqstp;
|
||||
}
|
||||
|
||||
static void nfs_minorversion_callback_svc_setup(struct svc_serv *serv,
|
||||
struct svc_rqst **rqstpp, int (**callback_svc)(void *vrqstp))
|
||||
{
|
||||
*rqstpp = nfs41_callback_up(serv);
|
||||
*callback_svc = nfs41_callback_svc;
|
||||
}
|
||||
|
||||
static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
|
||||
struct svc_serv *serv)
|
||||
{
|
||||
@@ -173,13 +139,6 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
|
||||
xprt->bc_serv = serv;
|
||||
}
|
||||
#else
|
||||
static void nfs_minorversion_callback_svc_setup(struct svc_serv *serv,
|
||||
struct svc_rqst **rqstpp, int (**callback_svc)(void *vrqstp))
|
||||
{
|
||||
*rqstpp = ERR_PTR(-ENOTSUPP);
|
||||
*callback_svc = ERR_PTR(-ENOTSUPP);
|
||||
}
|
||||
|
||||
static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
|
||||
struct svc_serv *serv)
|
||||
{
|
||||
@@ -189,45 +148,22 @@ static inline void nfs_callback_bc_serv(u32 minorversion, struct rpc_xprt *xprt,
|
||||
static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
|
||||
struct svc_serv *serv)
|
||||
{
|
||||
struct svc_rqst *rqstp;
|
||||
int (*callback_svc)(void *vrqstp);
|
||||
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
|
||||
int nrservs = nfs_callback_nr_threads;
|
||||
int ret;
|
||||
|
||||
nfs_callback_bc_serv(minorversion, xprt, serv);
|
||||
|
||||
if (cb_info->task)
|
||||
if (nrservs < NFS4_MIN_NR_CALLBACK_THREADS)
|
||||
nrservs = NFS4_MIN_NR_CALLBACK_THREADS;
|
||||
|
||||
if (serv->sv_nrthreads-1 == nrservs)
|
||||
return 0;
|
||||
|
||||
switch (minorversion) {
|
||||
case 0:
|
||||
/* v4.0 callback setup */
|
||||
rqstp = nfs4_callback_up(serv);
|
||||
callback_svc = nfs4_callback_svc;
|
||||
break;
|
||||
default:
|
||||
nfs_minorversion_callback_svc_setup(serv,
|
||||
&rqstp, &callback_svc);
|
||||
}
|
||||
|
||||
if (IS_ERR(rqstp))
|
||||
return PTR_ERR(rqstp);
|
||||
|
||||
svc_sock_update_bufs(serv);
|
||||
|
||||
cb_info->serv = serv;
|
||||
cb_info->rqst = rqstp;
|
||||
cb_info->task = kthread_create(callback_svc, cb_info->rqst,
|
||||
"nfsv4.%u-svc", minorversion);
|
||||
if (IS_ERR(cb_info->task)) {
|
||||
ret = PTR_ERR(cb_info->task);
|
||||
svc_exit_thread(cb_info->rqst);
|
||||
cb_info->rqst = NULL;
|
||||
cb_info->task = NULL;
|
||||
ret = serv->sv_ops->svo_setup(serv, NULL, nrservs);
|
||||
if (ret) {
|
||||
serv->sv_ops->svo_setup(serv, NULL, 0);
|
||||
return ret;
|
||||
}
|
||||
rqstp->rq_task = cb_info->task;
|
||||
wake_up_process(cb_info->task);
|
||||
dprintk("nfs_callback_up: service started\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -281,19 +217,41 @@ err_bind:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct svc_serv_ops nfs_cb_sv_ops = {
|
||||
static struct svc_serv_ops nfs40_cb_sv_ops = {
|
||||
.svo_function = nfs4_callback_svc,
|
||||
.svo_enqueue_xprt = svc_xprt_do_enqueue,
|
||||
.svo_setup = svc_set_num_threads,
|
||||
.svo_module = THIS_MODULE,
|
||||
};
|
||||
#if defined(CONFIG_NFS_V4_1)
|
||||
static struct svc_serv_ops nfs41_cb_sv_ops = {
|
||||
.svo_function = nfs41_callback_svc,
|
||||
.svo_enqueue_xprt = svc_xprt_do_enqueue,
|
||||
.svo_setup = svc_set_num_threads,
|
||||
.svo_module = THIS_MODULE,
|
||||
};
|
||||
|
||||
struct svc_serv_ops *nfs4_cb_sv_ops[] = {
|
||||
[0] = &nfs40_cb_sv_ops,
|
||||
[1] = &nfs41_cb_sv_ops,
|
||||
};
|
||||
#else
|
||||
struct svc_serv_ops *nfs4_cb_sv_ops[] = {
|
||||
[0] = &nfs40_cb_sv_ops,
|
||||
[1] = NULL,
|
||||
};
|
||||
#endif
|
||||
|
||||
static struct svc_serv *nfs_callback_create_svc(int minorversion)
|
||||
{
|
||||
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
|
||||
struct svc_serv *serv;
|
||||
struct svc_serv_ops *sv_ops;
|
||||
|
||||
/*
|
||||
* Check whether we're already up and running.
|
||||
*/
|
||||
if (cb_info->task) {
|
||||
if (cb_info->serv) {
|
||||
/*
|
||||
* Note: increase service usage, because later in case of error
|
||||
* svc_destroy() will be called.
|
||||
@@ -302,6 +260,17 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
|
||||
return cb_info->serv;
|
||||
}
|
||||
|
||||
switch (minorversion) {
|
||||
case 0:
|
||||
sv_ops = nfs4_cb_sv_ops[0];
|
||||
break;
|
||||
default:
|
||||
sv_ops = nfs4_cb_sv_ops[1];
|
||||
}
|
||||
|
||||
if (sv_ops == NULL)
|
||||
return ERR_PTR(-ENOTSUPP);
|
||||
|
||||
/*
|
||||
* Sanity check: if there's no task,
|
||||
* we should be the first user ...
|
||||
@@ -310,11 +279,12 @@ static struct svc_serv *nfs_callback_create_svc(int minorversion)
|
||||
printk(KERN_WARNING "nfs_callback_create_svc: no kthread, %d users??\n",
|
||||
cb_info->users);
|
||||
|
||||
serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, &nfs_cb_sv_ops);
|
||||
serv = svc_create(&nfs4_callback_program, NFS4_CALLBACK_BUFSIZE, sv_ops);
|
||||
if (!serv) {
|
||||
printk(KERN_ERR "nfs_callback_create_svc: create service failed\n");
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
cb_info->serv = serv;
|
||||
/* As there is only one thread we need to over-ride the
|
||||
* default maximum of 80 connections
|
||||
*/
|
||||
@@ -357,6 +327,8 @@ int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt)
|
||||
* thread exits.
|
||||
*/
|
||||
err_net:
|
||||
if (!cb_info->users)
|
||||
cb_info->serv = NULL;
|
||||
svc_destroy(serv);
|
||||
err_create:
|
||||
mutex_unlock(&nfs_callback_mutex);
|
||||
@@ -374,18 +346,18 @@ err_start:
|
||||
void nfs_callback_down(int minorversion, struct net *net)
|
||||
{
|
||||
struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
|
||||
struct svc_serv *serv;
|
||||
|
||||
mutex_lock(&nfs_callback_mutex);
|
||||
nfs_callback_down_net(minorversion, cb_info->serv, net);
|
||||
serv = cb_info->serv;
|
||||
nfs_callback_down_net(minorversion, serv, net);
|
||||
cb_info->users--;
|
||||
if (cb_info->users == 0 && cb_info->task != NULL) {
|
||||
kthread_stop(cb_info->task);
|
||||
dprintk("nfs_callback_down: service stopped\n");
|
||||
svc_exit_thread(cb_info->rqst);
|
||||
if (cb_info->users == 0) {
|
||||
svc_get(serv);
|
||||
serv->sv_ops->svo_setup(serv, NULL, 0);
|
||||
svc_destroy(serv);
|
||||
dprintk("nfs_callback_down: service destroyed\n");
|
||||
cb_info->serv = NULL;
|
||||
cb_info->rqst = NULL;
|
||||
cb_info->task = NULL;
|
||||
}
|
||||
mutex_unlock(&nfs_callback_mutex);
|
||||
}
|
||||
|
@@ -179,6 +179,15 @@ extern __be32 nfs4_callback_devicenotify(
|
||||
struct cb_devicenotifyargs *args,
|
||||
void *dummy, struct cb_process_state *cps);
|
||||
|
||||
struct cb_notify_lock_args {
|
||||
struct nfs_fh cbnl_fh;
|
||||
struct nfs_lowner cbnl_owner;
|
||||
bool cbnl_valid;
|
||||
};
|
||||
|
||||
extern __be32 nfs4_callback_notify_lock(struct cb_notify_lock_args *args,
|
||||
void *dummy,
|
||||
struct cb_process_state *cps);
|
||||
#endif /* CONFIG_NFS_V4_1 */
|
||||
extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *);
|
||||
extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
|
||||
@@ -198,6 +207,9 @@ extern void nfs_callback_down(int minorversion, struct net *net);
|
||||
#define NFS41_BC_MIN_CALLBACKS 1
|
||||
#define NFS41_BC_MAX_CALLBACKS 1
|
||||
|
||||
#define NFS4_MIN_NR_CALLBACK_THREADS 1
|
||||
|
||||
extern unsigned int nfs_callback_set_tcpport;
|
||||
extern unsigned short nfs_callback_nr_threads;
|
||||
|
||||
#endif /* __LINUX_FS_NFS_CALLBACK_H */
|
||||
|
@@ -628,4 +628,20 @@ out:
|
||||
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
__be32 nfs4_callback_notify_lock(struct cb_notify_lock_args *args, void *dummy,
|
||||
struct cb_process_state *cps)
|
||||
{
|
||||
if (!cps->clp) /* set in cb_sequence */
|
||||
return htonl(NFS4ERR_OP_NOT_IN_SESSION);
|
||||
|
||||
dprintk_rcu("NFS: CB_NOTIFY_LOCK request from %s\n",
|
||||
rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
|
||||
|
||||
/* Don't wake anybody if the string looked bogus */
|
||||
if (args->cbnl_valid)
|
||||
__wake_up(&cps->clp->cl_lock_waitq, TASK_NORMAL, 0, args);
|
||||
|
||||
return htonl(NFS4_OK);
|
||||
}
|
||||
#endif /* CONFIG_NFS_V4_1 */
|
||||
|
@@ -35,6 +35,7 @@
|
||||
(1 + 3) * 4) // seqid, 3 slotids
|
||||
#define CB_OP_RECALLANY_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
|
||||
#define CB_OP_RECALLSLOT_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
|
||||
#define CB_OP_NOTIFY_LOCK_RES_MAXSZ (CB_OP_HDR_RES_MAXSZ)
|
||||
#endif /* CONFIG_NFS_V4_1 */
|
||||
|
||||
#define NFSDBG_FACILITY NFSDBG_CALLBACK
|
||||
@@ -72,7 +73,7 @@ static int nfs4_encode_void(struct svc_rqst *rqstp, __be32 *p, void *dummy)
|
||||
return xdr_ressize_check(rqstp, p);
|
||||
}
|
||||
|
||||
static __be32 *read_buf(struct xdr_stream *xdr, int nbytes)
|
||||
static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes)
|
||||
{
|
||||
__be32 *p;
|
||||
|
||||
@@ -534,6 +535,49 @@ static __be32 decode_recallslot_args(struct svc_rqst *rqstp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __be32 decode_lockowner(struct xdr_stream *xdr, struct cb_notify_lock_args *args)
|
||||
{
|
||||
__be32 *p;
|
||||
unsigned int len;
|
||||
|
||||
p = read_buf(xdr, 12);
|
||||
if (unlikely(p == NULL))
|
||||
return htonl(NFS4ERR_BADXDR);
|
||||
|
||||
p = xdr_decode_hyper(p, &args->cbnl_owner.clientid);
|
||||
len = be32_to_cpu(*p);
|
||||
|
||||
p = read_buf(xdr, len);
|
||||
if (unlikely(p == NULL))
|
||||
return htonl(NFS4ERR_BADXDR);
|
||||
|
||||
/* Only try to decode if the length is right */
|
||||
if (len == 20) {
|
||||
p += 2; /* skip "lock id:" */
|
||||
args->cbnl_owner.s_dev = be32_to_cpu(*p++);
|
||||
xdr_decode_hyper(p, &args->cbnl_owner.id);
|
||||
args->cbnl_valid = true;
|
||||
} else {
|
||||
args->cbnl_owner.s_dev = 0;
|
||||
args->cbnl_owner.id = 0;
|
||||
args->cbnl_valid = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static __be32 decode_notify_lock_args(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct cb_notify_lock_args *args)
|
||||
{
|
||||
__be32 status;
|
||||
|
||||
status = decode_fh(xdr, &args->cbnl_fh);
|
||||
if (unlikely(status != 0))
|
||||
goto out;
|
||||
status = decode_lockowner(xdr, args);
|
||||
out:
|
||||
dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NFS_V4_1 */
|
||||
|
||||
static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
|
||||
@@ -746,6 +790,7 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
|
||||
case OP_CB_RECALL_SLOT:
|
||||
case OP_CB_LAYOUTRECALL:
|
||||
case OP_CB_NOTIFY_DEVICEID:
|
||||
case OP_CB_NOTIFY_LOCK:
|
||||
*op = &callback_ops[op_nr];
|
||||
break;
|
||||
|
||||
@@ -753,7 +798,6 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
|
||||
case OP_CB_PUSH_DELEG:
|
||||
case OP_CB_RECALLABLE_OBJ_AVAIL:
|
||||
case OP_CB_WANTS_CANCELLED:
|
||||
case OP_CB_NOTIFY_LOCK:
|
||||
return htonl(NFS4ERR_NOTSUPP);
|
||||
|
||||
default:
|
||||
@@ -1006,6 +1050,11 @@ static struct callback_op callback_ops[] = {
|
||||
.decode_args = (callback_decode_arg_t)decode_recallslot_args,
|
||||
.res_maxsize = CB_OP_RECALLSLOT_RES_MAXSZ,
|
||||
},
|
||||
[OP_CB_NOTIFY_LOCK] = {
|
||||
.process_op = (callback_process_op_t)nfs4_callback_notify_lock,
|
||||
.decode_args = (callback_decode_arg_t)decode_notify_lock_args,
|
||||
.res_maxsize = CB_OP_NOTIFY_LOCK_RES_MAXSZ,
|
||||
},
|
||||
#endif /* CONFIG_NFS_V4_1 */
|
||||
};
|
||||
|
||||
|
@@ -313,7 +313,10 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
|
||||
continue;
|
||||
/* Match the full socket address */
|
||||
if (!rpc_cmp_addr_port(sap, clap))
|
||||
continue;
|
||||
/* Match all xprt_switch full socket addresses */
|
||||
if (!rpc_clnt_xprt_switch_has_addr(clp->cl_rpcclient,
|
||||
sap))
|
||||
continue;
|
||||
|
||||
atomic_inc(&clp->cl_count);
|
||||
return clp;
|
||||
@@ -785,7 +788,8 @@ int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs
|
||||
}
|
||||
|
||||
fsinfo.fattr = fattr;
|
||||
fsinfo.layouttype = 0;
|
||||
fsinfo.nlayouttypes = 0;
|
||||
memset(fsinfo.layouttype, 0, sizeof(fsinfo.layouttype));
|
||||
error = clp->rpc_ops->fsinfo(server, mntfh, &fsinfo);
|
||||
if (error < 0)
|
||||
goto out_error;
|
||||
@@ -1078,7 +1082,7 @@ void nfs_clients_init(struct net *net)
|
||||
idr_init(&nn->cb_ident_idr);
|
||||
#endif
|
||||
spin_lock_init(&nn->nfs_client_lock);
|
||||
nn->boot_time = CURRENT_TIME;
|
||||
nn->boot_time = ktime_get_real();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
|
@@ -41,6 +41,17 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation)
|
||||
set_bit(NFS_DELEGATION_REFERENCED, &delegation->flags);
|
||||
}
|
||||
|
||||
static bool
|
||||
nfs4_is_valid_delegation(const struct nfs_delegation *delegation,
|
||||
fmode_t flags)
|
||||
{
|
||||
if (delegation != NULL && (delegation->type & flags) == flags &&
|
||||
!test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) &&
|
||||
!test_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static int
|
||||
nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark)
|
||||
{
|
||||
@@ -50,8 +61,7 @@ nfs4_do_check_delegation(struct inode *inode, fmode_t flags, bool mark)
|
||||
flags &= FMODE_READ|FMODE_WRITE;
|
||||
rcu_read_lock();
|
||||
delegation = rcu_dereference(NFS_I(inode)->delegation);
|
||||
if (delegation != NULL && (delegation->type & flags) == flags &&
|
||||
!test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
|
||||
if (nfs4_is_valid_delegation(delegation, flags)) {
|
||||
if (mark)
|
||||
nfs_mark_delegation_referenced(delegation);
|
||||
ret = 1;
|
||||
@@ -185,15 +195,13 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred,
|
||||
rcu_read_unlock();
|
||||
put_rpccred(oldcred);
|
||||
trace_nfs4_reclaim_delegation(inode, res->delegation_type);
|
||||
} else {
|
||||
/* We appear to have raced with a delegation return. */
|
||||
spin_unlock(&delegation->lock);
|
||||
rcu_read_unlock();
|
||||
nfs_inode_set_delegation(inode, cred, res);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
rcu_read_unlock();
|
||||
/* We appear to have raced with a delegation return. */
|
||||
spin_unlock(&delegation->lock);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
nfs_inode_set_delegation(inode, cred, res);
|
||||
}
|
||||
|
||||
static int nfs_do_return_delegation(struct inode *inode, struct nfs_delegation *delegation, int issync)
|
||||
@@ -642,28 +650,49 @@ static void nfs_client_mark_return_unused_delegation_types(struct nfs_client *cl
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static void nfs_revoke_delegation(struct inode *inode)
|
||||
static void nfs_mark_delegation_revoked(struct nfs_server *server,
|
||||
struct nfs_delegation *delegation)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
rcu_read_lock();
|
||||
delegation = rcu_dereference(NFS_I(inode)->delegation);
|
||||
if (delegation != NULL) {
|
||||
set_bit(NFS_DELEGATION_REVOKED, &delegation->flags);
|
||||
nfs_mark_return_delegation(NFS_SERVER(inode), delegation);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
set_bit(NFS_DELEGATION_REVOKED, &delegation->flags);
|
||||
delegation->stateid.type = NFS4_INVALID_STATEID_TYPE;
|
||||
nfs_mark_return_delegation(server, delegation);
|
||||
}
|
||||
|
||||
void nfs_remove_bad_delegation(struct inode *inode)
|
||||
static bool nfs_revoke_delegation(struct inode *inode,
|
||||
const nfs4_stateid *stateid)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
nfs4_stateid tmp;
|
||||
bool ret = false;
|
||||
|
||||
rcu_read_lock();
|
||||
delegation = rcu_dereference(NFS_I(inode)->delegation);
|
||||
if (delegation == NULL)
|
||||
goto out;
|
||||
if (stateid == NULL) {
|
||||
nfs4_stateid_copy(&tmp, &delegation->stateid);
|
||||
stateid = &tmp;
|
||||
} else if (!nfs4_stateid_match(stateid, &delegation->stateid))
|
||||
goto out;
|
||||
nfs_mark_delegation_revoked(NFS_SERVER(inode), delegation);
|
||||
ret = true;
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
if (ret)
|
||||
nfs_inode_find_state_and_recover(inode, stateid);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void nfs_remove_bad_delegation(struct inode *inode,
|
||||
const nfs4_stateid *stateid)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
|
||||
nfs_revoke_delegation(inode);
|
||||
if (!nfs_revoke_delegation(inode, stateid))
|
||||
return;
|
||||
delegation = nfs_inode_detach_delegation(inode);
|
||||
if (delegation) {
|
||||
nfs_inode_find_state_and_recover(inode, &delegation->stateid);
|
||||
if (delegation)
|
||||
nfs_free_delegation(delegation);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nfs_remove_bad_delegation);
|
||||
|
||||
@@ -786,8 +815,15 @@ static void nfs_delegation_mark_reclaim_server(struct nfs_server *server)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
|
||||
list_for_each_entry_rcu(delegation, &server->delegations, super_list)
|
||||
list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
|
||||
/*
|
||||
* If the delegation may have been admin revoked, then we
|
||||
* cannot reclaim it.
|
||||
*/
|
||||
if (test_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags))
|
||||
continue;
|
||||
set_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -851,6 +887,141 @@ restart:
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
static inline bool nfs4_server_rebooted(const struct nfs_client *clp)
|
||||
{
|
||||
return (clp->cl_state & (BIT(NFS4CLNT_CHECK_LEASE) |
|
||||
BIT(NFS4CLNT_LEASE_EXPIRED) |
|
||||
BIT(NFS4CLNT_SESSION_RESET))) != 0;
|
||||
}
|
||||
|
||||
static void nfs_mark_test_expired_delegation(struct nfs_server *server,
|
||||
struct nfs_delegation *delegation)
|
||||
{
|
||||
if (delegation->stateid.type == NFS4_INVALID_STATEID_TYPE)
|
||||
return;
|
||||
clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
|
||||
set_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags);
|
||||
set_bit(NFS4CLNT_DELEGATION_EXPIRED, &server->nfs_client->cl_state);
|
||||
}
|
||||
|
||||
static void nfs_inode_mark_test_expired_delegation(struct nfs_server *server,
|
||||
struct inode *inode)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
|
||||
rcu_read_lock();
|
||||
delegation = rcu_dereference(NFS_I(inode)->delegation);
|
||||
if (delegation)
|
||||
nfs_mark_test_expired_delegation(server, delegation);
|
||||
rcu_read_unlock();
|
||||
|
||||
}
|
||||
|
||||
static void nfs_delegation_mark_test_expired_server(struct nfs_server *server)
|
||||
{
|
||||
struct nfs_delegation *delegation;
|
||||
|
||||
list_for_each_entry_rcu(delegation, &server->delegations, super_list)
|
||||
nfs_mark_test_expired_delegation(server, delegation);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_mark_test_expired_all_delegations - mark all delegations for testing
|
||||
* @clp: nfs_client to process
|
||||
*
|
||||
* Iterates through all the delegations associated with this server and
|
||||
* marks them as needing to be checked for validity.
|
||||
*/
|
||||
void nfs_mark_test_expired_all_delegations(struct nfs_client *clp)
|
||||
{
|
||||
struct nfs_server *server;
|
||||
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link)
|
||||
nfs_delegation_mark_test_expired_server(server);
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_reap_expired_delegations - reap expired delegations
|
||||
* @clp: nfs_client to process
|
||||
*
|
||||
* Iterates through all the delegations associated with this server and
|
||||
* checks if they have may have been revoked. This function is usually
|
||||
* expected to be called in cases where the server may have lost its
|
||||
* lease.
|
||||
*/
|
||||
void nfs_reap_expired_delegations(struct nfs_client *clp)
|
||||
{
|
||||
const struct nfs4_minor_version_ops *ops = clp->cl_mvops;
|
||||
struct nfs_delegation *delegation;
|
||||
struct nfs_server *server;
|
||||
struct inode *inode;
|
||||
struct rpc_cred *cred;
|
||||
nfs4_stateid stateid;
|
||||
|
||||
restart:
|
||||
rcu_read_lock();
|
||||
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
|
||||
list_for_each_entry_rcu(delegation, &server->delegations,
|
||||
super_list) {
|
||||
if (test_bit(NFS_DELEGATION_RETURNING,
|
||||
&delegation->flags))
|
||||
continue;
|
||||
if (test_bit(NFS_DELEGATION_TEST_EXPIRED,
|
||||
&delegation->flags) == 0)
|
||||
continue;
|
||||
if (!nfs_sb_active(server->super))
|
||||
continue;
|
||||
inode = nfs_delegation_grab_inode(delegation);
|
||||
if (inode == NULL) {
|
||||
rcu_read_unlock();
|
||||
nfs_sb_deactive(server->super);
|
||||
goto restart;
|
||||
}
|
||||
cred = get_rpccred_rcu(delegation->cred);
|
||||
nfs4_stateid_copy(&stateid, &delegation->stateid);
|
||||
clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags);
|
||||
rcu_read_unlock();
|
||||
if (cred != NULL &&
|
||||
ops->test_and_free_expired(server, &stateid, cred) < 0) {
|
||||
nfs_revoke_delegation(inode, &stateid);
|
||||
nfs_inode_find_state_and_recover(inode, &stateid);
|
||||
}
|
||||
put_rpccred(cred);
|
||||
if (nfs4_server_rebooted(clp)) {
|
||||
nfs_inode_mark_test_expired_delegation(server,inode);
|
||||
iput(inode);
|
||||
nfs_sb_deactive(server->super);
|
||||
return;
|
||||
}
|
||||
iput(inode);
|
||||
nfs_sb_deactive(server->super);
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
void nfs_inode_find_delegation_state_and_recover(struct inode *inode,
|
||||
const nfs4_stateid *stateid)
|
||||
{
|
||||
struct nfs_client *clp = NFS_SERVER(inode)->nfs_client;
|
||||
struct nfs_delegation *delegation;
|
||||
bool found = false;
|
||||
|
||||
rcu_read_lock();
|
||||
delegation = rcu_dereference(NFS_I(inode)->delegation);
|
||||
if (delegation &&
|
||||
nfs4_stateid_match_other(&delegation->stateid, stateid)) {
|
||||
nfs_mark_test_expired_delegation(NFS_SERVER(inode), delegation);
|
||||
found = true;
|
||||
}
|
||||
rcu_read_unlock();
|
||||
if (found)
|
||||
nfs4_schedule_state_manager(clp);
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs_delegations_present - check for existence of delegations
|
||||
* @clp: client state handle
|
||||
@@ -893,7 +1064,7 @@ bool nfs4_copy_delegation_stateid(struct inode *inode, fmode_t flags,
|
||||
flags &= FMODE_READ|FMODE_WRITE;
|
||||
rcu_read_lock();
|
||||
delegation = rcu_dereference(nfsi->delegation);
|
||||
ret = (delegation != NULL && (delegation->type & flags) == flags);
|
||||
ret = nfs4_is_valid_delegation(delegation, flags);
|
||||
if (ret) {
|
||||
nfs4_stateid_copy(dst, &delegation->stateid);
|
||||
nfs_mark_delegation_referenced(delegation);
|
||||
|
@@ -32,6 +32,7 @@ enum {
|
||||
NFS_DELEGATION_REFERENCED,
|
||||
NFS_DELEGATION_RETURNING,
|
||||
NFS_DELEGATION_REVOKED,
|
||||
NFS_DELEGATION_TEST_EXPIRED,
|
||||
};
|
||||
|
||||
int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
|
||||
@@ -47,11 +48,14 @@ void nfs_expire_unused_delegation_types(struct nfs_client *clp, fmode_t flags);
|
||||
void nfs_expire_unreferenced_delegations(struct nfs_client *clp);
|
||||
int nfs_client_return_marked_delegations(struct nfs_client *clp);
|
||||
int nfs_delegations_present(struct nfs_client *clp);
|
||||
void nfs_remove_bad_delegation(struct inode *inode);
|
||||
void nfs_remove_bad_delegation(struct inode *inode, const nfs4_stateid *stateid);
|
||||
|
||||
void nfs_delegation_mark_reclaim(struct nfs_client *clp);
|
||||
void nfs_delegation_reap_unclaimed(struct nfs_client *clp);
|
||||
|
||||
void nfs_mark_test_expired_all_delegations(struct nfs_client *clp);
|
||||
void nfs_reap_expired_delegations(struct nfs_client *clp);
|
||||
|
||||
/* NFSv4 delegation-related procedures */
|
||||
int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4_stateid *stateid, int issync);
|
||||
int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state *state, const nfs4_stateid *stateid, fmode_t type);
|
||||
@@ -62,6 +66,8 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
|
||||
int nfs4_have_delegation(struct inode *inode, fmode_t flags);
|
||||
int nfs4_check_delegation(struct inode *inode, fmode_t flags);
|
||||
bool nfs4_delegation_flush_on_close(const struct inode *inode);
|
||||
void nfs_inode_find_delegation_state_and_recover(struct inode *inode,
|
||||
const nfs4_stateid *stateid);
|
||||
|
||||
#endif
|
||||
|
||||
|
24
fs/nfs/dir.c
24
fs/nfs/dir.c
@@ -435,11 +435,11 @@ int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry)
|
||||
return 0;
|
||||
|
||||
nfsi = NFS_I(inode);
|
||||
if (entry->fattr->fileid == nfsi->fileid)
|
||||
return 1;
|
||||
if (nfs_compare_fh(entry->fh, &nfsi->fh) == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
if (entry->fattr->fileid != nfsi->fileid)
|
||||
return 0;
|
||||
if (entry->fh->size && nfs_compare_fh(entry->fh, &nfsi->fh) != 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static
|
||||
@@ -496,6 +496,14 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
|
||||
return;
|
||||
if (!(entry->fattr->valid & NFS_ATTR_FATTR_FSID))
|
||||
return;
|
||||
if (filename.len == 0)
|
||||
return;
|
||||
/* Validate that the name doesn't contain any illegal '\0' */
|
||||
if (strnlen(filename.name, filename.len) != filename.len)
|
||||
return;
|
||||
/* ...or '/' */
|
||||
if (strnchr(filename.name, filename.len, '/'))
|
||||
return;
|
||||
if (filename.name[0] == '.') {
|
||||
if (filename.len == 1)
|
||||
return;
|
||||
@@ -517,6 +525,8 @@ again:
|
||||
&entry->fattr->fsid))
|
||||
goto out;
|
||||
if (nfs_same_file(dentry, entry)) {
|
||||
if (!entry->fh->size)
|
||||
goto out;
|
||||
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
|
||||
status = nfs_refresh_inode(d_inode(dentry), entry->fattr);
|
||||
if (!status)
|
||||
@@ -529,6 +539,10 @@ again:
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
if (!entry->fh->size) {
|
||||
d_lookup_done(dentry);
|
||||
goto out;
|
||||
}
|
||||
|
||||
inode = nfs_fhget(dentry->d_sb, entry->fh, entry->fattr, entry->label);
|
||||
alias = d_splice_alias(inode, dentry);
|
||||
|
@@ -387,7 +387,7 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq)
|
||||
dreq->iocb->ki_complete(dreq->iocb, res, 0);
|
||||
}
|
||||
|
||||
complete_all(&dreq->completion);
|
||||
complete(&dreq->completion);
|
||||
|
||||
nfs_direct_req_release(dreq);
|
||||
}
|
||||
|
@@ -520,7 +520,9 @@ const struct address_space_operations nfs_file_aops = {
|
||||
.invalidatepage = nfs_invalidate_page,
|
||||
.releasepage = nfs_release_page,
|
||||
.direct_IO = nfs_direct_IO,
|
||||
#ifdef CONFIG_MIGRATION
|
||||
.migratepage = nfs_migrate_page,
|
||||
#endif
|
||||
.launder_page = nfs_launder_page,
|
||||
.is_dirty_writeback = nfs_check_dirty_writeback,
|
||||
.error_remove_page = generic_error_remove_page,
|
||||
@@ -685,11 +687,6 @@ out_noconflict:
|
||||
goto out;
|
||||
}
|
||||
|
||||
static int do_vfs_lock(struct file *file, struct file_lock *fl)
|
||||
{
|
||||
return locks_lock_file_wait(file, fl);
|
||||
}
|
||||
|
||||
static int
|
||||
do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
|
||||
{
|
||||
@@ -722,7 +719,7 @@ do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
|
||||
if (!is_local)
|
||||
status = NFS_PROTO(inode)->lock(filp, cmd, fl);
|
||||
else
|
||||
status = do_vfs_lock(filp, fl);
|
||||
status = locks_lock_file_wait(filp, fl);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -747,7 +744,7 @@ do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
|
||||
if (!is_local)
|
||||
status = NFS_PROTO(inode)->lock(filp, cmd, fl);
|
||||
else
|
||||
status = do_vfs_lock(filp, fl);
|
||||
status = locks_lock_file_wait(filp, fl);
|
||||
if (status < 0)
|
||||
goto out;
|
||||
|
||||
|
@@ -1080,7 +1080,7 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
|
||||
case -NFS4ERR_BAD_STATEID:
|
||||
if (state == NULL)
|
||||
break;
|
||||
nfs_remove_bad_delegation(state->inode);
|
||||
nfs_remove_bad_delegation(state->inode, NULL);
|
||||
case -NFS4ERR_OPENMODE:
|
||||
if (state == NULL)
|
||||
break;
|
||||
|
@@ -534,12 +534,9 @@ void nfs_clear_pnfs_ds_commit_verifiers(struct pnfs_ds_commit_info *cinfo)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_MIGRATION
|
||||
extern int nfs_migrate_page(struct address_space *,
|
||||
struct page *, struct page *, enum migrate_mode);
|
||||
#else
|
||||
#define nfs_migrate_page NULL
|
||||
#endif
|
||||
|
||||
static inline int
|
||||
@@ -562,7 +559,6 @@ void nfs_init_cinfo_from_dreq(struct nfs_commit_info *cinfo,
|
||||
extern ssize_t nfs_dreq_bytes_left(struct nfs_direct_req *dreq);
|
||||
|
||||
/* nfs4proc.c */
|
||||
extern void __nfs4_read_done_cb(struct nfs_pgio_header *);
|
||||
extern struct nfs_client *nfs4_init_client(struct nfs_client *clp,
|
||||
const struct nfs_client_initdata *);
|
||||
extern int nfs40_walk_client_list(struct nfs_client *clp,
|
||||
@@ -571,6 +567,9 @@ extern int nfs40_walk_client_list(struct nfs_client *clp,
|
||||
extern int nfs41_walk_client_list(struct nfs_client *clp,
|
||||
struct nfs_client **result,
|
||||
struct rpc_cred *cred);
|
||||
extern int nfs4_test_session_trunk(struct rpc_clnt *,
|
||||
struct rpc_xprt *,
|
||||
void *);
|
||||
|
||||
static inline struct inode *nfs_igrab_and_active(struct inode *inode)
|
||||
{
|
||||
|
@@ -29,7 +29,7 @@ struct nfs_net {
|
||||
int cb_users[NFS4_MAX_MINOR_VERSION + 1];
|
||||
#endif
|
||||
spinlock_t nfs_client_lock;
|
||||
struct timespec boot_time;
|
||||
ktime_t boot_time;
|
||||
#ifdef CONFIG_PROC_FS
|
||||
struct proc_dir_entry *proc_nfsfs;
|
||||
#endif
|
||||
|
@@ -443,6 +443,7 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server,
|
||||
task = rpc_run_task(&task_setup);
|
||||
if (IS_ERR(task))
|
||||
return PTR_ERR(task);
|
||||
rpc_put_task(task);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -39,6 +39,7 @@ enum nfs4_client_state {
|
||||
NFS4CLNT_BIND_CONN_TO_SESSION,
|
||||
NFS4CLNT_MOVED,
|
||||
NFS4CLNT_LEASE_MOVED,
|
||||
NFS4CLNT_DELEGATION_EXPIRED,
|
||||
};
|
||||
|
||||
#define NFS4_RENEW_TIMEOUT 0x01
|
||||
@@ -57,8 +58,11 @@ struct nfs4_minor_version_ops {
|
||||
struct nfs_fsinfo *);
|
||||
void (*free_lock_state)(struct nfs_server *,
|
||||
struct nfs4_lock_state *);
|
||||
int (*test_and_free_expired)(struct nfs_server *,
|
||||
nfs4_stateid *, struct rpc_cred *);
|
||||
struct nfs_seqid *
|
||||
(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t);
|
||||
int (*session_trunk)(struct rpc_clnt *, struct rpc_xprt *, void *);
|
||||
const struct rpc_call_ops *call_sync_ops;
|
||||
const struct nfs4_state_recovery_ops *reboot_recovery_ops;
|
||||
const struct nfs4_state_recovery_ops *nograce_recovery_ops;
|
||||
@@ -156,6 +160,7 @@ enum {
|
||||
NFS_STATE_RECLAIM_NOGRACE, /* OPEN stateid needs to recover state */
|
||||
NFS_STATE_POSIX_LOCKS, /* Posix locks are supported */
|
||||
NFS_STATE_RECOVERY_FAILED, /* OPEN stateid state recovery failed */
|
||||
NFS_STATE_MAY_NOTIFY_LOCK, /* server may CB_NOTIFY_LOCK */
|
||||
};
|
||||
|
||||
struct nfs4_state {
|
||||
@@ -203,6 +208,11 @@ struct nfs4_state_recovery_ops {
|
||||
struct rpc_cred *);
|
||||
};
|
||||
|
||||
struct nfs4_add_xprt_data {
|
||||
struct nfs_client *clp;
|
||||
struct rpc_cred *cred;
|
||||
};
|
||||
|
||||
struct nfs4_state_maintenance_ops {
|
||||
int (*sched_state_renewal)(struct nfs_client *, struct rpc_cred *, unsigned);
|
||||
struct rpc_cred * (*get_state_renewal_cred_locked)(struct nfs_client *);
|
||||
@@ -278,6 +288,8 @@ extern int nfs4_proc_get_lease_time(struct nfs_client *clp,
|
||||
struct nfs_fsinfo *fsinfo);
|
||||
extern int nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data,
|
||||
bool sync);
|
||||
extern int nfs4_detect_session_trunking(struct nfs_client *clp,
|
||||
struct nfs41_exchange_id_res *res, struct rpc_xprt *xprt);
|
||||
|
||||
static inline bool
|
||||
is_ds_only_client(struct nfs_client *clp)
|
||||
@@ -439,7 +451,7 @@ extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp);
|
||||
extern int nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *);
|
||||
extern int nfs4_schedule_migration_recovery(const struct nfs_server *);
|
||||
extern void nfs4_schedule_lease_moved_recovery(struct nfs_client *);
|
||||
extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags);
|
||||
extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags, bool);
|
||||
extern void nfs41_handle_server_scope(struct nfs_client *,
|
||||
struct nfs41_server_scope **);
|
||||
extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp);
|
||||
@@ -471,6 +483,7 @@ extern struct nfs_subversion nfs_v4;
|
||||
struct dentry *nfs4_try_mount(int, const char *, struct nfs_mount_info *, struct nfs_subversion *);
|
||||
extern bool nfs4_disable_idmapping;
|
||||
extern unsigned short max_session_slots;
|
||||
extern unsigned short max_session_cb_slots;
|
||||
extern unsigned short send_implementation_id;
|
||||
extern bool recover_lost_locks;
|
||||
|
||||
|
@@ -199,6 +199,9 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
|
||||
clp->cl_minorversion = cl_init->minorversion;
|
||||
clp->cl_mvops = nfs_v4_minor_ops[cl_init->minorversion];
|
||||
clp->cl_mig_gen = 1;
|
||||
#if IS_ENABLED(CONFIG_NFS_V4_1)
|
||||
init_waitqueue_head(&clp->cl_lock_waitq);
|
||||
#endif
|
||||
return clp;
|
||||
|
||||
error:
|
||||
@@ -562,15 +565,15 @@ out:
|
||||
/*
|
||||
* Returns true if the client IDs match
|
||||
*/
|
||||
static bool nfs4_match_clientids(struct nfs_client *a, struct nfs_client *b)
|
||||
static bool nfs4_match_clientids(u64 a, u64 b)
|
||||
{
|
||||
if (a->cl_clientid != b->cl_clientid) {
|
||||
if (a != b) {
|
||||
dprintk("NFS: --> %s client ID %llx does not match %llx\n",
|
||||
__func__, a->cl_clientid, b->cl_clientid);
|
||||
__func__, a, b);
|
||||
return false;
|
||||
}
|
||||
dprintk("NFS: --> %s client ID %llx matches %llx\n",
|
||||
__func__, a->cl_clientid, b->cl_clientid);
|
||||
__func__, a, b);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -578,17 +581,15 @@ static bool nfs4_match_clientids(struct nfs_client *a, struct nfs_client *b)
|
||||
* Returns true if the server major ids match
|
||||
*/
|
||||
static bool
|
||||
nfs4_check_clientid_trunking(struct nfs_client *a, struct nfs_client *b)
|
||||
nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1,
|
||||
struct nfs41_server_owner *o2)
|
||||
{
|
||||
struct nfs41_server_owner *o1 = a->cl_serverowner;
|
||||
struct nfs41_server_owner *o2 = b->cl_serverowner;
|
||||
|
||||
if (o1->major_id_sz != o2->major_id_sz)
|
||||
goto out_major_mismatch;
|
||||
if (memcmp(o1->major_id, o2->major_id, o1->major_id_sz) != 0)
|
||||
goto out_major_mismatch;
|
||||
|
||||
dprintk("NFS: --> %s server owners match\n", __func__);
|
||||
dprintk("NFS: --> %s server owner major IDs match\n", __func__);
|
||||
return true;
|
||||
|
||||
out_major_mismatch:
|
||||
@@ -597,6 +598,100 @@ out_major_mismatch:
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if server minor ids match
|
||||
*/
|
||||
static bool
|
||||
nfs4_check_serverowner_minor_id(struct nfs41_server_owner *o1,
|
||||
struct nfs41_server_owner *o2)
|
||||
{
|
||||
/* Check eir_server_owner so_minor_id */
|
||||
if (o1->minor_id != o2->minor_id)
|
||||
goto out_minor_mismatch;
|
||||
|
||||
dprintk("NFS: --> %s server owner minor IDs match\n", __func__);
|
||||
return true;
|
||||
|
||||
out_minor_mismatch:
|
||||
dprintk("NFS: --> %s server owner minor IDs do not match\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if the server scopes match
|
||||
*/
|
||||
static bool
|
||||
nfs4_check_server_scope(struct nfs41_server_scope *s1,
|
||||
struct nfs41_server_scope *s2)
|
||||
{
|
||||
if (s1->server_scope_sz != s2->server_scope_sz)
|
||||
goto out_scope_mismatch;
|
||||
if (memcmp(s1->server_scope, s2->server_scope,
|
||||
s1->server_scope_sz) != 0)
|
||||
goto out_scope_mismatch;
|
||||
|
||||
dprintk("NFS: --> %s server scopes match\n", __func__);
|
||||
return true;
|
||||
|
||||
out_scope_mismatch:
|
||||
dprintk("NFS: --> %s server scopes do not match\n",
|
||||
__func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs4_detect_session_trunking - Checks for session trunking.
|
||||
*
|
||||
* Called after a successful EXCHANGE_ID on a multi-addr connection.
|
||||
* Upon success, add the transport.
|
||||
*
|
||||
* @clp: original mount nfs_client
|
||||
* @res: result structure from an exchange_id using the original mount
|
||||
* nfs_client with a new multi_addr transport
|
||||
*
|
||||
* Returns zero on success, otherwise -EINVAL
|
||||
*
|
||||
* Note: since the exchange_id for the new multi_addr transport uses the
|
||||
* same nfs_client from the original mount, the cl_owner_id is reused,
|
||||
* so eir_clientowner is the same.
|
||||
*/
|
||||
int nfs4_detect_session_trunking(struct nfs_client *clp,
|
||||
struct nfs41_exchange_id_res *res,
|
||||
struct rpc_xprt *xprt)
|
||||
{
|
||||
/* Check eir_clientid */
|
||||
if (!nfs4_match_clientids(clp->cl_clientid, res->clientid))
|
||||
goto out_err;
|
||||
|
||||
/* Check eir_server_owner so_major_id */
|
||||
if (!nfs4_check_serverowner_major_id(clp->cl_serverowner,
|
||||
res->server_owner))
|
||||
goto out_err;
|
||||
|
||||
/* Check eir_server_owner so_minor_id */
|
||||
if (!nfs4_check_serverowner_minor_id(clp->cl_serverowner,
|
||||
res->server_owner))
|
||||
goto out_err;
|
||||
|
||||
/* Check eir_server_scope */
|
||||
if (!nfs4_check_server_scope(clp->cl_serverscope, res->server_scope))
|
||||
goto out_err;
|
||||
|
||||
/* Session trunking passed, add the xprt */
|
||||
rpc_clnt_xprt_switch_add_xprt(clp->cl_rpcclient, xprt);
|
||||
|
||||
pr_info("NFS: %s: Session trunking succeeded for %s\n",
|
||||
clp->cl_hostname,
|
||||
xprt->address_strings[RPC_DISPLAY_ADDR]);
|
||||
|
||||
return 0;
|
||||
out_err:
|
||||
pr_info("NFS: %s: Session trunking failed for %s\n", clp->cl_hostname,
|
||||
xprt->address_strings[RPC_DISPLAY_ADDR]);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* nfs41_walk_client_list - Find nfs_client that matches a client/server owner
|
||||
*
|
||||
@@ -650,7 +745,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
|
||||
if (pos->cl_cons_state != NFS_CS_READY)
|
||||
continue;
|
||||
|
||||
if (!nfs4_match_clientids(pos, new))
|
||||
if (!nfs4_match_clientids(pos->cl_clientid, new->cl_clientid))
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -658,7 +753,8 @@ int nfs41_walk_client_list(struct nfs_client *new,
|
||||
* client id trunking. In either case, we want to fall back
|
||||
* to using the existing nfs_client.
|
||||
*/
|
||||
if (!nfs4_check_clientid_trunking(pos, new))
|
||||
if (!nfs4_check_serverowner_major_id(pos->cl_serverowner,
|
||||
new->cl_serverowner))
|
||||
continue;
|
||||
|
||||
/* Unlike NFSv4.0, we know that NFSv4.1 always uses the
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@
|
||||
|
||||
/* maximum number of slots to use */
|
||||
#define NFS4_DEF_SLOT_TABLE_SIZE (64U)
|
||||
#define NFS4_DEF_CB_SLOT_TABLE_SIZE (1U)
|
||||
#define NFS4_MAX_SLOT_TABLE (1024U)
|
||||
#define NFS4_NO_SLOT ((u32)-1)
|
||||
|
||||
@@ -22,6 +23,7 @@ struct nfs4_slot {
|
||||
u32 slot_nr;
|
||||
u32 seq_nr;
|
||||
unsigned int interrupted : 1,
|
||||
privileged : 1,
|
||||
seq_done : 1;
|
||||
};
|
||||
|
||||
|
@@ -991,6 +991,8 @@ int nfs4_select_rw_stateid(struct nfs4_state *state,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!nfs4_valid_open_stateid(state))
|
||||
return -EIO;
|
||||
if (cred != NULL)
|
||||
*cred = NULL;
|
||||
ret = nfs4_copy_lock_stateid(dst, state, lockowner);
|
||||
@@ -1303,6 +1305,8 @@ void nfs4_schedule_path_down_recovery(struct nfs_client *clp)
|
||||
static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state)
|
||||
{
|
||||
|
||||
if (!nfs4_valid_open_stateid(state))
|
||||
return 0;
|
||||
set_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags);
|
||||
/* Don't recover state that expired before the reboot */
|
||||
if (test_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags)) {
|
||||
@@ -1316,6 +1320,8 @@ static int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_st
|
||||
|
||||
int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state)
|
||||
{
|
||||
if (!nfs4_valid_open_stateid(state))
|
||||
return 0;
|
||||
set_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags);
|
||||
clear_bit(NFS_STATE_RECLAIM_REBOOT, &state->flags);
|
||||
set_bit(NFS_OWNER_RECLAIM_NOGRACE, &state->owner->so_flags);
|
||||
@@ -1327,9 +1333,8 @@ int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_
|
||||
{
|
||||
struct nfs_client *clp = server->nfs_client;
|
||||
|
||||
if (!nfs4_valid_open_stateid(state))
|
||||
if (!nfs4_state_mark_reclaim_nograce(clp, state))
|
||||
return -EBADF;
|
||||
nfs4_state_mark_reclaim_nograce(clp, state);
|
||||
dprintk("%s: scheduling stateid recovery for server %s\n", __func__,
|
||||
clp->cl_hostname);
|
||||
nfs4_schedule_state_manager(clp);
|
||||
@@ -1337,6 +1342,35 @@ int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery);
|
||||
|
||||
static struct nfs4_lock_state *
|
||||
nfs_state_find_lock_state_by_stateid(struct nfs4_state *state,
|
||||
const nfs4_stateid *stateid)
|
||||
{
|
||||
struct nfs4_lock_state *pos;
|
||||
|
||||
list_for_each_entry(pos, &state->lock_states, ls_locks) {
|
||||
if (!test_bit(NFS_LOCK_INITIALIZED, &pos->ls_flags))
|
||||
continue;
|
||||
if (nfs4_stateid_match_other(&pos->ls_stateid, stateid))
|
||||
return pos;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static bool nfs_state_lock_state_matches_stateid(struct nfs4_state *state,
|
||||
const nfs4_stateid *stateid)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
if (test_bit(LK_STATE_IN_USE, &state->flags)) {
|
||||
spin_lock(&state->state_lock);
|
||||
if (nfs_state_find_lock_state_by_stateid(state, stateid))
|
||||
found = true;
|
||||
spin_unlock(&state->state_lock);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void nfs_inode_find_state_and_recover(struct inode *inode,
|
||||
const nfs4_stateid *stateid)
|
||||
{
|
||||
@@ -1351,14 +1385,18 @@ void nfs_inode_find_state_and_recover(struct inode *inode,
|
||||
state = ctx->state;
|
||||
if (state == NULL)
|
||||
continue;
|
||||
if (!test_bit(NFS_DELEGATED_STATE, &state->flags))
|
||||
if (nfs4_stateid_match_other(&state->stateid, stateid) &&
|
||||
nfs4_state_mark_reclaim_nograce(clp, state)) {
|
||||
found = true;
|
||||
continue;
|
||||
if (!nfs4_stateid_match(&state->stateid, stateid))
|
||||
continue;
|
||||
nfs4_state_mark_reclaim_nograce(clp, state);
|
||||
found = true;
|
||||
}
|
||||
if (nfs_state_lock_state_matches_stateid(state, stateid) &&
|
||||
nfs4_state_mark_reclaim_nograce(clp, state))
|
||||
found = true;
|
||||
}
|
||||
spin_unlock(&inode->i_lock);
|
||||
|
||||
nfs_inode_find_delegation_state_and_recover(inode, stateid);
|
||||
if (found)
|
||||
nfs4_schedule_state_manager(clp);
|
||||
}
|
||||
@@ -1498,6 +1536,9 @@ restart:
|
||||
__func__, status);
|
||||
case -ENOENT:
|
||||
case -ENOMEM:
|
||||
case -EACCES:
|
||||
case -EROFS:
|
||||
case -EIO:
|
||||
case -ESTALE:
|
||||
/* Open state on this file cannot be recovered */
|
||||
nfs4_state_mark_recovery_failed(state, status);
|
||||
@@ -1656,15 +1697,9 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)
|
||||
put_rpccred(cred);
|
||||
}
|
||||
|
||||
static void nfs_delegation_clear_all(struct nfs_client *clp)
|
||||
{
|
||||
nfs_delegation_mark_reclaim(clp);
|
||||
nfs_delegation_reap_unclaimed(clp);
|
||||
}
|
||||
|
||||
static void nfs4_state_start_reclaim_nograce(struct nfs_client *clp)
|
||||
{
|
||||
nfs_delegation_clear_all(clp);
|
||||
nfs_mark_test_expired_all_delegations(clp);
|
||||
nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce);
|
||||
}
|
||||
|
||||
@@ -2195,7 +2230,7 @@ static void nfs41_handle_all_state_revoked(struct nfs_client *clp)
|
||||
|
||||
static void nfs41_handle_some_state_revoked(struct nfs_client *clp)
|
||||
{
|
||||
nfs4_state_mark_reclaim_helper(clp, nfs4_state_mark_reclaim_nograce);
|
||||
nfs4_state_start_reclaim_nograce(clp);
|
||||
nfs4_schedule_state_manager(clp);
|
||||
|
||||
dprintk("%s: state revoked on server %s\n", __func__, clp->cl_hostname);
|
||||
@@ -2227,13 +2262,22 @@ static void nfs41_handle_cb_path_down(struct nfs_client *clp)
|
||||
nfs4_schedule_state_manager(clp);
|
||||
}
|
||||
|
||||
void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
|
||||
void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags,
|
||||
bool recovery)
|
||||
{
|
||||
if (!flags)
|
||||
return;
|
||||
|
||||
dprintk("%s: \"%s\" (client ID %llx) flags=0x%08x\n",
|
||||
__func__, clp->cl_hostname, clp->cl_clientid, flags);
|
||||
/*
|
||||
* If we're called from the state manager thread, then assume we're
|
||||
* already handling the RECLAIM_NEEDED and/or STATE_REVOKED.
|
||||
* Those flags are expected to remain set until we're done
|
||||
* recovering (see RFC5661, section 18.46.3).
|
||||
*/
|
||||
if (recovery)
|
||||
goto out_recovery;
|
||||
|
||||
if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED)
|
||||
nfs41_handle_server_reboot(clp);
|
||||
@@ -2246,6 +2290,7 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
|
||||
nfs4_schedule_lease_moved_recovery(clp);
|
||||
if (flags & SEQ4_STATUS_RECALLABLE_STATE_REVOKED)
|
||||
nfs41_handle_recallable_state_revoked(clp);
|
||||
out_recovery:
|
||||
if (flags & SEQ4_STATUS_BACKCHANNEL_FAULT)
|
||||
nfs41_handle_backchannel_fault(clp);
|
||||
else if (flags & (SEQ4_STATUS_CB_PATH_DOWN |
|
||||
@@ -2410,6 +2455,13 @@ static void nfs4_state_manager(struct nfs_client *clp)
|
||||
nfs4_state_end_reclaim_reboot(clp);
|
||||
}
|
||||
|
||||
/* Detect expired delegations... */
|
||||
if (test_and_clear_bit(NFS4CLNT_DELEGATION_EXPIRED, &clp->cl_state)) {
|
||||
section = "detect expired delegations";
|
||||
nfs_reap_expired_delegations(clp);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Now recover expired state... */
|
||||
if (test_and_clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &clp->cl_state)) {
|
||||
section = "reclaim nograce";
|
||||
|
@@ -1850,7 +1850,7 @@ static void encode_create_session(struct xdr_stream *xdr,
|
||||
*p++ = cpu_to_be32(RPC_AUTH_UNIX); /* auth_sys */
|
||||
|
||||
/* authsys_parms rfc1831 */
|
||||
*p++ = cpu_to_be32(nn->boot_time.tv_nsec); /* stamp */
|
||||
*p++ = cpu_to_be32(ktime_to_ns(nn->boot_time)); /* stamp */
|
||||
p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
|
||||
*p++ = cpu_to_be32(0); /* UID */
|
||||
*p++ = cpu_to_be32(0); /* GID */
|
||||
@@ -4725,34 +4725,37 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode potentially multiple layout types. Currently we only support
|
||||
* one layout driver per file system.
|
||||
* Decode potentially multiple layout types.
|
||||
*/
|
||||
static int decode_first_pnfs_layout_type(struct xdr_stream *xdr,
|
||||
uint32_t *layouttype)
|
||||
static int decode_pnfs_layout_types(struct xdr_stream *xdr,
|
||||
struct nfs_fsinfo *fsinfo)
|
||||
{
|
||||
__be32 *p;
|
||||
int num;
|
||||
uint32_t i;
|
||||
|
||||
p = xdr_inline_decode(xdr, 4);
|
||||
if (unlikely(!p))
|
||||
goto out_overflow;
|
||||
num = be32_to_cpup(p);
|
||||
fsinfo->nlayouttypes = be32_to_cpup(p);
|
||||
|
||||
/* pNFS is not supported by the underlying file system */
|
||||
if (num == 0) {
|
||||
*layouttype = 0;
|
||||
if (fsinfo->nlayouttypes == 0)
|
||||
return 0;
|
||||
}
|
||||
if (num > 1)
|
||||
printk(KERN_INFO "NFS: %s: Warning: Multiple pNFS layout "
|
||||
"drivers per filesystem not supported\n", __func__);
|
||||
|
||||
/* Decode and set first layout type, move xdr->p past unused types */
|
||||
p = xdr_inline_decode(xdr, num * 4);
|
||||
p = xdr_inline_decode(xdr, fsinfo->nlayouttypes * 4);
|
||||
if (unlikely(!p))
|
||||
goto out_overflow;
|
||||
*layouttype = be32_to_cpup(p);
|
||||
|
||||
/* If we get too many, then just cap it at the max */
|
||||
if (fsinfo->nlayouttypes > NFS_MAX_LAYOUT_TYPES) {
|
||||
printk(KERN_INFO "NFS: %s: Warning: Too many (%u) pNFS layout types\n",
|
||||
__func__, fsinfo->nlayouttypes);
|
||||
fsinfo->nlayouttypes = NFS_MAX_LAYOUT_TYPES;
|
||||
}
|
||||
|
||||
for(i = 0; i < fsinfo->nlayouttypes; ++i)
|
||||
fsinfo->layouttype[i] = be32_to_cpup(p++);
|
||||
return 0;
|
||||
out_overflow:
|
||||
print_overflow_msg(__func__, xdr);
|
||||
@@ -4764,7 +4767,7 @@ out_overflow:
|
||||
* Note we must ensure that layouttype is set in any non-error case.
|
||||
*/
|
||||
static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap,
|
||||
uint32_t *layouttype)
|
||||
struct nfs_fsinfo *fsinfo)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
@@ -4772,10 +4775,9 @@ static int decode_attr_pnfstype(struct xdr_stream *xdr, uint32_t *bitmap,
|
||||
if (unlikely(bitmap[1] & (FATTR4_WORD1_FS_LAYOUT_TYPES - 1U)))
|
||||
return -EIO;
|
||||
if (bitmap[1] & FATTR4_WORD1_FS_LAYOUT_TYPES) {
|
||||
status = decode_first_pnfs_layout_type(xdr, layouttype);
|
||||
status = decode_pnfs_layout_types(xdr, fsinfo);
|
||||
bitmap[1] &= ~FATTR4_WORD1_FS_LAYOUT_TYPES;
|
||||
} else
|
||||
*layouttype = 0;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -4856,7 +4858,7 @@ static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
|
||||
status = decode_attr_time_delta(xdr, bitmap, &fsinfo->time_delta);
|
||||
if (status != 0)
|
||||
goto xdr_error;
|
||||
status = decode_attr_pnfstype(xdr, bitmap, &fsinfo->layouttype);
|
||||
status = decode_attr_pnfstype(xdr, bitmap, fsinfo);
|
||||
if (status != 0)
|
||||
goto xdr_error;
|
||||
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include <linux/nfs_fs.h>
|
||||
#include <linux/nfs_page.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/sort.h>
|
||||
#include "internal.h"
|
||||
#include "pnfs.h"
|
||||
#include "iostat.h"
|
||||
@@ -98,36 +99,80 @@ unset_pnfs_layoutdriver(struct nfs_server *nfss)
|
||||
nfss->pnfs_curr_ld = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* When the server sends a list of layout types, we choose one in the order
|
||||
* given in the list below.
|
||||
*
|
||||
* FIXME: should this list be configurable in some fashion? module param?
|
||||
* mount option? something else?
|
||||
*/
|
||||
static const u32 ld_prefs[] = {
|
||||
LAYOUT_SCSI,
|
||||
LAYOUT_BLOCK_VOLUME,
|
||||
LAYOUT_OSD2_OBJECTS,
|
||||
LAYOUT_FLEX_FILES,
|
||||
LAYOUT_NFSV4_1_FILES,
|
||||
0
|
||||
};
|
||||
|
||||
static int
|
||||
ld_cmp(const void *e1, const void *e2)
|
||||
{
|
||||
u32 ld1 = *((u32 *)e1);
|
||||
u32 ld2 = *((u32 *)e2);
|
||||
int i;
|
||||
|
||||
for (i = 0; ld_prefs[i] != 0; i++) {
|
||||
if (ld1 == ld_prefs[i])
|
||||
return -1;
|
||||
|
||||
if (ld2 == ld_prefs[i])
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to set the server's pnfs module to the pnfs layout type specified by id.
|
||||
* Currently only one pNFS layout driver per filesystem is supported.
|
||||
*
|
||||
* @id layout type. Zero (illegal layout type) indicates pNFS not in use.
|
||||
* @ids array of layout types supported by MDS.
|
||||
*/
|
||||
void
|
||||
set_pnfs_layoutdriver(struct nfs_server *server, const struct nfs_fh *mntfh,
|
||||
u32 id)
|
||||
struct nfs_fsinfo *fsinfo)
|
||||
{
|
||||
struct pnfs_layoutdriver_type *ld_type = NULL;
|
||||
u32 id;
|
||||
int i;
|
||||
|
||||
if (id == 0)
|
||||
goto out_no_driver;
|
||||
if (!(server->nfs_client->cl_exchange_flags &
|
||||
(EXCHGID4_FLAG_USE_NON_PNFS | EXCHGID4_FLAG_USE_PNFS_MDS))) {
|
||||
printk(KERN_ERR "NFS: %s: id %u cl_exchange_flags 0x%x\n",
|
||||
__func__, id, server->nfs_client->cl_exchange_flags);
|
||||
printk(KERN_ERR "NFS: %s: cl_exchange_flags 0x%x\n",
|
||||
__func__, server->nfs_client->cl_exchange_flags);
|
||||
goto out_no_driver;
|
||||
}
|
||||
ld_type = find_pnfs_driver(id);
|
||||
if (!ld_type) {
|
||||
request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX, id);
|
||||
|
||||
sort(fsinfo->layouttype, fsinfo->nlayouttypes,
|
||||
sizeof(*fsinfo->layouttype), ld_cmp, NULL);
|
||||
|
||||
for (i = 0; i < fsinfo->nlayouttypes; i++) {
|
||||
id = fsinfo->layouttype[i];
|
||||
ld_type = find_pnfs_driver(id);
|
||||
if (!ld_type) {
|
||||
dprintk("%s: No pNFS module found for %u.\n",
|
||||
__func__, id);
|
||||
goto out_no_driver;
|
||||
request_module("%s-%u", LAYOUT_NFSV4_1_MODULE_PREFIX,
|
||||
id);
|
||||
ld_type = find_pnfs_driver(id);
|
||||
}
|
||||
if (ld_type)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ld_type) {
|
||||
dprintk("%s: No pNFS module found!\n", __func__);
|
||||
goto out_no_driver;
|
||||
}
|
||||
|
||||
server->pnfs_curr_ld = ld_type;
|
||||
if (ld_type->set_layoutdriver
|
||||
&& ld_type->set_layoutdriver(server, mntfh)) {
|
||||
@@ -2185,10 +2230,8 @@ static void pnfs_ld_handle_read_error(struct nfs_pgio_header *hdr)
|
||||
*/
|
||||
void pnfs_ld_read_done(struct nfs_pgio_header *hdr)
|
||||
{
|
||||
if (likely(!hdr->pnfs_error)) {
|
||||
__nfs4_read_done_cb(hdr);
|
||||
if (likely(!hdr->pnfs_error))
|
||||
hdr->mds_ops->rpc_call_done(&hdr->task, hdr);
|
||||
}
|
||||
trace_nfs4_pnfs_read(hdr, hdr->pnfs_error);
|
||||
if (unlikely(hdr->pnfs_error))
|
||||
pnfs_ld_handle_read_error(hdr);
|
||||
|
@@ -236,7 +236,7 @@ void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo);
|
||||
void pnfs_put_lseg(struct pnfs_layout_segment *lseg);
|
||||
void pnfs_put_lseg_locked(struct pnfs_layout_segment *lseg);
|
||||
|
||||
void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32);
|
||||
void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, struct nfs_fsinfo *);
|
||||
void unset_pnfs_layoutdriver(struct nfs_server *);
|
||||
void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *);
|
||||
int pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc);
|
||||
@@ -657,7 +657,8 @@ pnfs_wait_on_layoutreturn(struct inode *ino, struct rpc_task *task)
|
||||
}
|
||||
|
||||
static inline void set_pnfs_layoutdriver(struct nfs_server *s,
|
||||
const struct nfs_fh *mntfh, u32 id)
|
||||
const struct nfs_fh *mntfh,
|
||||
struct nfs_fsinfo *fsinfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -690,13 +690,50 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
|
||||
dprintk("%s: DS %s: trying address %s\n",
|
||||
__func__, ds->ds_remotestr, da->da_remotestr);
|
||||
|
||||
clp = nfs4_set_ds_client(mds_srv,
|
||||
(struct sockaddr *)&da->da_addr,
|
||||
da->da_addrlen, IPPROTO_TCP,
|
||||
timeo, retrans, minor_version,
|
||||
au_flavor);
|
||||
if (!IS_ERR(clp))
|
||||
break;
|
||||
if (!IS_ERR(clp) && clp->cl_mvops->session_trunk) {
|
||||
struct xprt_create xprt_args = {
|
||||
.ident = XPRT_TRANSPORT_TCP,
|
||||
.net = clp->cl_net,
|
||||
.dstaddr = (struct sockaddr *)&da->da_addr,
|
||||
.addrlen = da->da_addrlen,
|
||||
.servername = clp->cl_hostname,
|
||||
};
|
||||
struct nfs4_add_xprt_data xprtdata = {
|
||||
.clp = clp,
|
||||
.cred = nfs4_get_clid_cred(clp),
|
||||
};
|
||||
struct rpc_add_xprt_test rpcdata = {
|
||||
.add_xprt_test = clp->cl_mvops->session_trunk,
|
||||
.data = &xprtdata,
|
||||
};
|
||||
|
||||
/**
|
||||
* Test this address for session trunking and
|
||||
* add as an alias
|
||||
*/
|
||||
rpc_clnt_add_xprt(clp->cl_rpcclient, &xprt_args,
|
||||
rpc_clnt_setup_test_and_add_xprt,
|
||||
&rpcdata);
|
||||
if (xprtdata.cred)
|
||||
put_rpccred(xprtdata.cred);
|
||||
} else {
|
||||
clp = nfs4_set_ds_client(mds_srv,
|
||||
(struct sockaddr *)&da->da_addr,
|
||||
da->da_addrlen, IPPROTO_TCP,
|
||||
timeo, retrans, minor_version,
|
||||
au_flavor);
|
||||
if (IS_ERR(clp))
|
||||
continue;
|
||||
|
||||
status = nfs4_init_ds_session(clp,
|
||||
mds_srv->nfs_client->cl_lease_time);
|
||||
if (status) {
|
||||
nfs_put_client(clp);
|
||||
clp = ERR_PTR(-EIO);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ERR(clp)) {
|
||||
@@ -704,18 +741,11 @@ static int _nfs4_pnfs_v4_ds_connect(struct nfs_server *mds_srv,
|
||||
goto out;
|
||||
}
|
||||
|
||||
status = nfs4_init_ds_session(clp, mds_srv->nfs_client->cl_lease_time);
|
||||
if (status)
|
||||
goto out_put;
|
||||
|
||||
smp_wmb();
|
||||
ds->ds_clp = clp;
|
||||
dprintk("%s [new] addr: %s\n", __func__, ds->ds_remotestr);
|
||||
out:
|
||||
return status;
|
||||
out_put:
|
||||
nfs_put_client(clp);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -2848,19 +2848,23 @@ out_invalid_transport_udp:
|
||||
* NFS client for backwards compatibility
|
||||
*/
|
||||
unsigned int nfs_callback_set_tcpport;
|
||||
unsigned short nfs_callback_nr_threads;
|
||||
/* Default cache timeout is 10 minutes */
|
||||
unsigned int nfs_idmap_cache_timeout = 600;
|
||||
/* Turn off NFSv4 uid/gid mapping when using AUTH_SYS */
|
||||
bool nfs4_disable_idmapping = true;
|
||||
unsigned short max_session_slots = NFS4_DEF_SLOT_TABLE_SIZE;
|
||||
unsigned short max_session_cb_slots = NFS4_DEF_CB_SLOT_TABLE_SIZE;
|
||||
unsigned short send_implementation_id = 1;
|
||||
char nfs4_client_id_uniquifier[NFS4_CLIENT_ID_UNIQ_LEN] = "";
|
||||
bool recover_lost_locks = false;
|
||||
|
||||
EXPORT_SYMBOL_GPL(nfs_callback_nr_threads);
|
||||
EXPORT_SYMBOL_GPL(nfs_callback_set_tcpport);
|
||||
EXPORT_SYMBOL_GPL(nfs_idmap_cache_timeout);
|
||||
EXPORT_SYMBOL_GPL(nfs4_disable_idmapping);
|
||||
EXPORT_SYMBOL_GPL(max_session_slots);
|
||||
EXPORT_SYMBOL_GPL(max_session_cb_slots);
|
||||
EXPORT_SYMBOL_GPL(send_implementation_id);
|
||||
EXPORT_SYMBOL_GPL(nfs4_client_id_uniquifier);
|
||||
EXPORT_SYMBOL_GPL(recover_lost_locks);
|
||||
@@ -2887,6 +2891,9 @@ static const struct kernel_param_ops param_ops_portnr = {
|
||||
#define param_check_portnr(name, p) __param_check(name, p, unsigned int);
|
||||
|
||||
module_param_named(callback_tcpport, nfs_callback_set_tcpport, portnr, 0644);
|
||||
module_param_named(callback_nr_threads, nfs_callback_nr_threads, ushort, 0644);
|
||||
MODULE_PARM_DESC(callback_nr_threads, "Number of threads that will be "
|
||||
"assigned to the NFSv4 callback channels.");
|
||||
module_param(nfs_idmap_cache_timeout, int, 0644);
|
||||
module_param(nfs4_disable_idmapping, bool, 0644);
|
||||
module_param_string(nfs4_unique_id, nfs4_client_id_uniquifier,
|
||||
@@ -2896,6 +2903,9 @@ MODULE_PARM_DESC(nfs4_disable_idmapping,
|
||||
module_param(max_session_slots, ushort, 0644);
|
||||
MODULE_PARM_DESC(max_session_slots, "Maximum number of outstanding NFSv4.1 "
|
||||
"requests the client will negotiate");
|
||||
module_param(max_session_cb_slots, ushort, 0644);
|
||||
MODULE_PARM_DESC(max_session_slots, "Maximum number of parallel NFSv4.1 "
|
||||
"callbacks the client will process for a given server");
|
||||
module_param(send_implementation_id, ushort, 0644);
|
||||
MODULE_PARM_DESC(send_implementation_id,
|
||||
"Send implementation ID with NFSv4.1 exchange_id");
|
||||
|
Reference in New Issue
Block a user