Skip to content

Commit 42375c2

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
NFSv4/pnfs: Give nfs4_proc_layoutreturn() a flags argument
Replace the boolean in nfs4_proc_layoutreturn() with a set of flags that will allow us to craft a version that is appropriate for reboot recovery. Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent bbbff6d commit 42375c2

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

fs/nfs/nfs4proc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10048,7 +10048,7 @@ static const struct rpc_call_ops nfs4_layoutreturn_call_ops = {
1004810048
.rpc_release = nfs4_layoutreturn_release,
1004910049
};
1005010050

10051-
int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
10051+
int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, unsigned int flags)
1005210052
{
1005310053
struct rpc_task *task;
1005410054
struct rpc_message msg = {
@@ -10071,14 +10071,16 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
1007110071
&task_setup_data.rpc_client, &msg);
1007210072

1007310073
lrp->inode = nfs_igrab_and_active(lrp->args.inode);
10074-
if (!sync) {
10074+
if (flags & PNFS_FL_LAYOUTRETURN_ASYNC) {
1007510075
if (!lrp->inode) {
1007610076
nfs4_layoutreturn_release(lrp);
1007710077
return -EAGAIN;
1007810078
}
1007910079
task_setup_data.flags |= RPC_TASK_ASYNC;
1008010080
}
1008110081
if (!lrp->inode)
10082+
flags |= PNFS_FL_LAYOUTRETURN_PRIVILEGED;
10083+
if (flags & PNFS_FL_LAYOUTRETURN_PRIVILEGED)
1008210084
nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1,
1008310085
1);
1008410086
else
@@ -10087,7 +10089,7 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
1008710089
task = rpc_run_task(&task_setup_data);
1008810090
if (IS_ERR(task))
1008910091
return PTR_ERR(task);
10090-
if (sync)
10092+
if (!(flags & PNFS_FL_LAYOUTRETURN_ASYNC))
1009110093
status = task->tk_status;
1009210094
trace_nfs4_layoutreturn(lrp->args.inode, &lrp->args.stateid, status);
1009310095
dprintk("<-- %s status=%d\n", __func__, status);

fs/nfs/pnfs.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo,
12791279
const nfs4_stateid *stateid,
12801280
const struct cred **pcred,
12811281
enum pnfs_iomode iomode,
1282-
bool sync)
1282+
unsigned int flags)
12831283
{
12841284
struct inode *ino = lo->plh_inode;
12851285
struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld;
@@ -1306,7 +1306,7 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo,
13061306
if (ld->prepare_layoutreturn)
13071307
ld->prepare_layoutreturn(&lrp->args);
13081308

1309-
status = nfs4_proc_layoutreturn(lrp, sync);
1309+
status = nfs4_proc_layoutreturn(lrp, flags);
13101310
out:
13111311
dprintk("<-- %s status: %d\n", __func__, status);
13121312
return status;
@@ -1340,7 +1340,8 @@ static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)
13401340
spin_unlock(&inode->i_lock);
13411341
if (send) {
13421342
/* Send an async layoutreturn so we dont deadlock */
1343-
pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, false);
1343+
pnfs_send_layoutreturn(lo, &stateid, &cred, iomode,
1344+
PNFS_FL_LAYOUTRETURN_ASYNC);
13441345
}
13451346
} else
13461347
spin_unlock(&inode->i_lock);
@@ -1407,7 +1408,8 @@ _pnfs_return_layout(struct inode *ino)
14071408
send = pnfs_prepare_layoutreturn(lo, &stateid, &cred, NULL);
14081409
spin_unlock(&ino->i_lock);
14091410
if (send)
1410-
status = pnfs_send_layoutreturn(lo, &stateid, &cred, IOMODE_ANY, true);
1411+
status = pnfs_send_layoutreturn(lo, &stateid, &cred, IOMODE_ANY,
1412+
0);
14111413
out_wait_layoutreturn:
14121414
wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, TASK_UNINTERRUPTIBLE);
14131415
out_put_layout_hdr:
@@ -1548,7 +1550,7 @@ bool pnfs_roc(struct inode *ino,
15481550
return true;
15491551
}
15501552
if (layoutreturn)
1551-
pnfs_send_layoutreturn(lo, &stateid, &lc_cred, iomode, true);
1553+
pnfs_send_layoutreturn(lo, &stateid, &lc_cred, iomode, 0);
15521554
pnfs_put_layout_hdr(lo);
15531555
return false;
15541556
}
@@ -2595,7 +2597,8 @@ pnfs_mark_layout_for_return(struct inode *inode,
25952597
return_now = pnfs_prepare_layoutreturn(lo, &stateid, &cred, &iomode);
25962598
spin_unlock(&inode->i_lock);
25972599
if (return_now)
2598-
pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, false);
2600+
pnfs_send_layoutreturn(lo, &stateid, &cred, iomode,
2601+
PNFS_FL_LAYOUTRETURN_ASYNC);
25992602
} else {
26002603
spin_unlock(&inode->i_lock);
26012604
nfs_commit_inode(inode, 0);
@@ -2711,7 +2714,8 @@ static int pnfs_layout_return_unused_byserver(struct nfs_server *server,
27112714
}
27122715
spin_unlock(&inode->i_lock);
27132716
rcu_read_unlock();
2714-
pnfs_send_layoutreturn(lo, &stateid, &cred, iomode, false);
2717+
pnfs_send_layoutreturn(lo, &stateid, &cred, iomode,
2718+
PNFS_FL_LAYOUTRETURN_ASYNC);
27152719
pnfs_put_layout_hdr(lo);
27162720
cond_resched();
27172721
goto restart;

fs/nfs/pnfs.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,18 @@ extern const struct pnfs_layoutdriver_type *pnfs_find_layoutdriver(u32 id);
248248
extern void pnfs_put_layoutdriver(const struct pnfs_layoutdriver_type *ld);
249249

250250
/* nfs4proc.c */
251+
#define PNFS_FL_LAYOUTRETURN_ASYNC (1U << 0)
252+
#define PNFS_FL_LAYOUTRETURN_PRIVILEGED (1U << 1)
253+
251254
extern size_t max_response_pages(struct nfs_server *server);
252255
extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,
253256
struct pnfs_device *dev,
254257
const struct cred *cred);
255258
extern struct pnfs_layout_segment *
256259
nfs4_proc_layoutget(struct nfs4_layoutget *lgp,
257260
struct nfs4_exception *exception);
258-
extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync);
261+
extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp,
262+
unsigned int flags);
259263

260264
/* pnfs.c */
261265
void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo);

0 commit comments

Comments
 (0)