Skip to content

Commit

Permalink
Merge part 2 of branch 'sysfs-devel'
Browse files Browse the repository at this point in the history
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
Trond Myklebust committed Jul 8, 2021
2 parents dd5c153 + 6f08169 commit 878b3df
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 18 deletions.
38 changes: 33 additions & 5 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,11 @@ static int nfs4_call_sync_sequence(struct rpc_clnt *clnt,
struct nfs4_sequence_args *args,
struct nfs4_sequence_res *res)
{
return nfs4_do_call_sync(clnt, server, msg, args, res, 0);
unsigned short task_flags = 0;

if (server->nfs_client->cl_minorversion)
task_flags = RPC_TASK_MOVEABLE;
return nfs4_do_call_sync(clnt, server, msg, args, res, task_flags);
}


Expand Down Expand Up @@ -2566,6 +2570,9 @@ static int nfs4_run_open_task(struct nfs4_opendata *data,
};
int status;

if (server->nfs_client->cl_minorversion)
task_setup_data.flags |= RPC_TASK_MOVEABLE;

kref_get(&data->kref);
data->rpc_done = false;
data->rpc_status = 0;
Expand Down Expand Up @@ -3746,6 +3753,9 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait)
};
int status = -ENOMEM;

if (server->nfs_client->cl_minorversion)
task_setup_data.flags |= RPC_TASK_MOVEABLE;

nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_CLEANUP,
&task_setup_data.rpc_client, &msg);

Expand Down Expand Up @@ -4185,6 +4195,9 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
};
unsigned short task_flags = 0;

if (nfs4_has_session(server->nfs_client))
task_flags = RPC_TASK_MOVEABLE;

/* Is this is an attribute revalidation, subject to softreval? */
if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
task_flags |= RPC_TASK_TIMEOUT;
Expand Down Expand Up @@ -4304,6 +4317,9 @@ static int _nfs4_proc_lookup(struct rpc_clnt *clnt, struct inode *dir,
};
unsigned short task_flags = 0;

if (server->nfs_client->cl_minorversion)
task_flags = RPC_TASK_MOVEABLE;

/* Is this is an attribute revalidation, subject to softreval? */
if (nfs_lookup_is_soft_revalidate(dentry))
task_flags |= RPC_TASK_TIMEOUT;
Expand Down Expand Up @@ -6535,7 +6551,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred,
.rpc_client = server->client,
.rpc_message = &msg,
.callback_ops = &nfs4_delegreturn_ops,
.flags = RPC_TASK_ASYNC | RPC_TASK_TIMEOUT,
.flags = RPC_TASK_ASYNC | RPC_TASK_TIMEOUT | RPC_TASK_MOVEABLE,
};
int status = 0;

Expand Down Expand Up @@ -6853,6 +6869,11 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
.workqueue = nfsiod_workqueue,
.flags = RPC_TASK_ASYNC,
};
struct nfs_client *client =
NFS_SERVER(lsp->ls_state->inode)->nfs_client;

if (client->cl_minorversion)
task_setup_data.flags |= RPC_TASK_MOVEABLE;

nfs4_state_protect(NFS_SERVER(lsp->ls_state->inode)->nfs_client,
NFS_SP4_MACH_CRED_CLEANUP, &task_setup_data.rpc_client, &msg);
Expand Down Expand Up @@ -7127,6 +7148,10 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
.flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF,
};
int ret;
struct nfs_client *client = NFS_SERVER(state->inode)->nfs_client;

if (client->cl_minorversion)
task_setup_data.flags |= RPC_TASK_MOVEABLE;

dprintk("%s: begin!\n", __func__);
data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file),
Expand Down Expand Up @@ -9220,7 +9245,7 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
.rpc_client = clp->cl_rpcclient,
.rpc_message = &msg,
.callback_ops = &nfs41_sequence_ops,
.flags = RPC_TASK_ASYNC | RPC_TASK_TIMEOUT,
.flags = RPC_TASK_ASYNC | RPC_TASK_TIMEOUT | RPC_TASK_MOVEABLE,
};
struct rpc_task *ret;

Expand Down Expand Up @@ -9542,7 +9567,8 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout)
.rpc_message = &msg,
.callback_ops = &nfs4_layoutget_call_ops,
.callback_data = lgp,
.flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF,
.flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF |
RPC_TASK_MOVEABLE,
};
struct pnfs_layout_segment *lseg = NULL;
struct nfs4_exception exception = {
Expand Down Expand Up @@ -9680,6 +9706,7 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
.rpc_message = &msg,
.callback_ops = &nfs4_layoutreturn_call_ops,
.callback_data = lrp,
.flags = RPC_TASK_MOVEABLE,
};
int status = 0;

Expand Down Expand Up @@ -9834,6 +9861,7 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync)
.rpc_message = &msg,
.callback_ops = &nfs4_layoutcommit_ops,
.callback_data = data,
.flags = RPC_TASK_MOVEABLE,
};
struct rpc_task *task;
int status = 0;
Expand Down Expand Up @@ -10161,7 +10189,7 @@ static int nfs41_free_stateid(struct nfs_server *server,
.rpc_client = server->client,
.rpc_message = &msg,
.callback_ops = &nfs41_free_stateid_ops,
.flags = RPC_TASK_ASYNC,
.flags = RPC_TASK_ASYNC | RPC_TASK_MOVEABLE,
};
struct nfs_free_stateid_data *data;
struct rpc_task *task;
Expand Down
8 changes: 6 additions & 2 deletions fs/nfs/pagelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc)
{
struct nfs_pgio_header *hdr;
int ret;
unsigned short task_flags = 0;

hdr = nfs_pgio_header_alloc(desc->pg_rw_ops);
if (!hdr) {
Expand All @@ -962,14 +963,17 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc)
}
nfs_pgheader_init(desc, hdr, nfs_pgio_header_free);
ret = nfs_generic_pgio(desc, hdr);
if (ret == 0)
if (ret == 0) {
if (NFS_SERVER(hdr->inode)->nfs_client->cl_minorversion)
task_flags = RPC_TASK_MOVEABLE;
ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode),
hdr,
hdr->cred,
NFS_PROTO(hdr->inode),
desc->pg_rpc_callops,
desc->pg_ioflags,
RPC_TASK_CRED_NOREF);
RPC_TASK_CRED_NOREF | task_flags);
}
return ret;
}

Expand Down
6 changes: 5 additions & 1 deletion fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,7 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
struct nfs_commit_info *cinfo)
{
struct nfs_commit_data *data;
unsigned short task_flags = 0;

/* another commit raced with us */
if (list_empty(head))
Expand All @@ -1820,8 +1821,11 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
/* Set up the argument struct */
nfs_init_commit(data, head, NULL, cinfo);
atomic_inc(&cinfo->mds->rpcs_out);
if (NFS_SERVER(inode)->nfs_client->cl_minorversion)
task_flags = RPC_TASK_MOVEABLE;
return nfs_initiate_commit(NFS_CLIENT(inode), data, NFS_PROTO(inode),
data->mds_ops, how, RPC_TASK_CRED_NOREF);
data->mds_ops, how,
RPC_TASK_CRED_NOREF | task_flags);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions include/linux/sunrpc/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct rpc_task_setup {
*/
#define RPC_TASK_ASYNC 0x0001 /* is an async task */
#define RPC_TASK_SWAPPER 0x0002 /* is swapping in/out */
#define RPC_TASK_MOVEABLE 0x0004 /* nfs4.1+ rpc tasks */
#define RPC_TASK_NULLCREDS 0x0010 /* Use AUTH_NULL credential */
#define RPC_CALL_MAJORSEEN 0x0020 /* major timeout seen */
#define RPC_TASK_ROOTCREDS 0x0040 /* force root creds */
Expand All @@ -139,6 +140,7 @@ struct rpc_task_setup {
#define RPC_IS_SOFT(t) ((t)->tk_flags & (RPC_TASK_SOFT|RPC_TASK_TIMEOUT))
#define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN)
#define RPC_WAS_SENT(t) ((t)->tk_flags & RPC_TASK_SENT)
#define RPC_IS_MOVEABLE(t) ((t)->tk_flags & RPC_TASK_MOVEABLE)

#define RPC_TASK_RUNNING 0
#define RPC_TASK_QUEUED 1
Expand Down
3 changes: 3 additions & 0 deletions include/linux/sunrpc/xprt.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ struct rpc_xprt {
struct rcu_head rcu;
const struct xprt_class *xprt_class;
struct rpc_sysfs_xprt *xprt_sysfs;
bool main; /*mark if this is the 1st transport */
};

#if defined(CONFIG_SUNRPC_BACKCHANNEL)
Expand Down Expand Up @@ -426,6 +427,8 @@ void xprt_release_write(struct rpc_xprt *, struct rpc_task *);
#define XPRT_BOUND (4)
#define XPRT_BINDING (5)
#define XPRT_CLOSING (6)
#define XPRT_OFFLINE (7)
#define XPRT_REMOVE (8)
#define XPRT_CONGESTED (9)
#define XPRT_CWND_WAIT (10)
#define XPRT_WRITE_SPACE (11)
Expand Down
1 change: 1 addition & 0 deletions include/linux/sunrpc/xprtsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

int init_socket_xprt(void);
void cleanup_socket_xprt(void);
unsigned short get_srcport(struct rpc_xprt *);

#define RPC_MIN_RESVPORT (1U)
#define RPC_MAX_RESVPORT (65535U)
Expand Down
25 changes: 25 additions & 0 deletions net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args,
}

rpc_clnt_set_transport(clnt, xprt, timeout);
xprt->main = true;
xprt_iter_init(&clnt->cl_xpi, xps);
xprt_switch_put(xps);

Expand Down Expand Up @@ -2105,6 +2106,30 @@ call_connect_status(struct rpc_task *task)
case -ENOTCONN:
case -EAGAIN:
case -ETIMEDOUT:
if (!(task->tk_flags & RPC_TASK_NO_ROUND_ROBIN) &&
(task->tk_flags & RPC_TASK_MOVEABLE) &&
test_bit(XPRT_REMOVE, &xprt->state)) {
struct rpc_xprt *saved = task->tk_xprt;
struct rpc_xprt_switch *xps;

rcu_read_lock();
xps = xprt_switch_get(rcu_dereference(clnt->cl_xpi.xpi_xpswitch));
rcu_read_unlock();
if (xps->xps_nxprts > 1) {
long value;

xprt_release(task);
value = atomic_long_dec_return(&xprt->queuelen);
if (value == 0)
rpc_xprt_switch_remove_xprt(xps, saved);
xprt_put(saved);
task->tk_xprt = NULL;
task->tk_action = call_start;
}
xprt_switch_put(xps);
if (!task->tk_xprt)
return;
}
goto out_retry;
case -ENOBUFS:
rpc_delay(task, HZ >> 2);
Expand Down
Loading

0 comments on commit 878b3df

Please sign in to comment.