Commit b5fdf841 authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4: Add support for CB_RECALL_ANY for flexfiles layouts



When we receive a CB_RECALL_ANY that asks us to return flexfiles
layouts, we iterate through all the layouts and look at whether or
not there are active open file descriptors that might need them
for I/O. If there are no such descriptors, we return the layouts.

Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 7f156ef0
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -127,7 +127,9 @@ extern __be32 nfs4_callback_sequence(void *argp, void *resp,
#define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX  9
#define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12
#define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15
#define RCA4_TYPE_MASK_ALL 0xf31f
#define PNFS_FF_RCA4_TYPE_MASK_READ 16
#define PNFS_FF_RCA4_TYPE_MASK_RW 17
#define RCA4_TYPE_MASK_ALL 0x3f31f

struct cb_recallanyargs {
	uint32_t	craa_objs_to_keep;
+13 −0
Original line number Diff line number Diff line
@@ -597,6 +597,7 @@ __be32 nfs4_callback_recallany(void *argp, void *resp,
	struct cb_recallanyargs *args = argp;
	__be32 status;
	fmode_t flags = 0;
	bool schedule_manager = false;

	status = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION);
	if (!cps->clp) /* set in cb_sequence */
@@ -619,6 +620,18 @@ __be32 nfs4_callback_recallany(void *argp, void *resp,

	if (args->craa_type_mask & BIT(RCA4_TYPE_MASK_FILE_LAYOUT))
		pnfs_recall_all_layouts(cps->clp);

	if (args->craa_type_mask & BIT(PNFS_FF_RCA4_TYPE_MASK_READ)) {
		set_bit(NFS4CLNT_RECALL_ANY_LAYOUT_READ, &cps->clp->cl_state);
		schedule_manager = true;
	}
	if (args->craa_type_mask & BIT(PNFS_FF_RCA4_TYPE_MASK_RW)) {
		set_bit(NFS4CLNT_RECALL_ANY_LAYOUT_RW, &cps->clp->cl_state);
		schedule_manager = true;
	}
	if (schedule_manager)
		nfs4_schedule_state_manager(cps->clp);

out:
	dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
	return status;
+3 −1
Original line number Diff line number Diff line
@@ -42,7 +42,9 @@ enum nfs4_client_state {
	NFS4CLNT_LEASE_MOVED,
	NFS4CLNT_DELEGATION_EXPIRED,
	NFS4CLNT_RUN_MANAGER,
	NFS4CLNT_DELEGRETURN_RUNNING,
	NFS4CLNT_RECALL_RUNNING,
	NFS4CLNT_RECALL_ANY_LAYOUT_READ,
	NFS4CLNT_RECALL_ANY_LAYOUT_RW,
};

#define NFS4_RENEW_TIMEOUT		0x01
+22 −2
Original line number Diff line number Diff line
@@ -2524,6 +2524,21 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp)
	}
	return 0;
}

static void nfs4_layoutreturn_any_run(struct nfs_client *clp)
{
	int iomode = 0;

	if (test_and_clear_bit(NFS4CLNT_RECALL_ANY_LAYOUT_READ, &clp->cl_state))
		iomode += IOMODE_READ;
	if (test_and_clear_bit(NFS4CLNT_RECALL_ANY_LAYOUT_RW, &clp->cl_state))
		iomode += IOMODE_RW;
	/* Note: IOMODE_READ + IOMODE_RW == IOMODE_ANY */
	if (iomode) {
		pnfs_layout_return_unused_byclid(clp, iomode);
		set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
	}
}
#else /* CONFIG_NFS_V4_1 */
static int nfs4_reset_session(struct nfs_client *clp) { return 0; }

@@ -2531,6 +2546,10 @@ static int nfs4_bind_conn_to_session(struct nfs_client *clp)
{
	return 0;
}

static void nfs4_layoutreturn_any_run(struct nfs_client *clp)
{
}
#endif /* CONFIG_NFS_V4_1 */

static void nfs4_state_manager(struct nfs_client *clp)
@@ -2635,12 +2654,13 @@ static void nfs4_state_manager(struct nfs_client *clp)
		nfs4_end_drain_session(clp);
		nfs4_clear_state_manager_bit(clp);

		if (!test_and_set_bit(NFS4CLNT_DELEGRETURN_RUNNING, &clp->cl_state)) {
		if (!test_and_set_bit(NFS4CLNT_RECALL_RUNNING, &clp->cl_state)) {
			if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
				nfs_client_return_marked_delegations(clp);
				set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
			}
			clear_bit(NFS4CLNT_DELEGRETURN_RUNNING, &clp->cl_state);
			nfs4_layoutreturn_any_run(clp);
			clear_bit(NFS4CLNT_RECALL_RUNNING, &clp->cl_state);
		}

		/* Did we race with an attempt to give us more work? */
+6 −2
Original line number Diff line number Diff line
@@ -584,7 +584,9 @@ TRACE_DEFINE_ENUM(NFS4CLNT_MOVED);
TRACE_DEFINE_ENUM(NFS4CLNT_LEASE_MOVED);
TRACE_DEFINE_ENUM(NFS4CLNT_DELEGATION_EXPIRED);
TRACE_DEFINE_ENUM(NFS4CLNT_RUN_MANAGER);
TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN_RUNNING);
TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_RUNNING);
TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_READ);
TRACE_DEFINE_ENUM(NFS4CLNT_RECALL_ANY_LAYOUT_RW);

#define show_nfs4_clp_state(state) \
	__print_flags(state, "|", \
@@ -605,7 +607,9 @@ TRACE_DEFINE_ENUM(NFS4CLNT_DELEGRETURN_RUNNING);
		{ NFS4CLNT_LEASE_MOVED,		"LEASE_MOVED" }, \
		{ NFS4CLNT_DELEGATION_EXPIRED,	"DELEGATION_EXPIRED" }, \
		{ NFS4CLNT_RUN_MANAGER,		"RUN_MANAGER" }, \
		{ NFS4CLNT_DELEGRETURN_RUNNING,	"DELEGRETURN_RUNNING" })
		{ NFS4CLNT_RECALL_RUNNING,	"RECALL_RUNNING" }, \
		{ NFS4CLNT_RECALL_ANY_LAYOUT_READ, "RECALL_ANY_LAYOUT_READ" }, \
		{ NFS4CLNT_RECALL_ANY_LAYOUT_RW, "RECALL_ANY_LAYOUT_RW" })

TRACE_EVENT(nfs4_state_mgr,
		TP_PROTO(
Loading