History

NFSv4/flexfiles: Abort I/O early if the layout segment was invalidated

If a layout segment gets invalidated while a pNFS I/O operation is queued for transmission, then we ideally want to abort immediately. This is particularly the case when there is a large number of I/O related RPCs queued in the RPC layer, and the layout segment gets invalidated due to an ENOSPC error, or an EACCES (because the client was fenced). We may end up forced to spam the MDS with a lot of otherwise unnecessary LAYOUTERRORs after that I/O fails.

Trond Myklebust committed 7 years ago

Commit a79f1941 parent 39a52013 files · +25 −0Browse files

Unified · Split

3 files
  1. fs/nfs/flexfilelayout/flexfilelayout.c +17 −0
  2. include/linux/sunrpc/sched.h +1 −0
  3. net/sunrpc/xprt.c +7 −0
fs/nfs/flexfilelayout/flexfilelayout.c+17−0
@@ -1071,6 +1071,8 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task, · 1070 unmodified lines
10711071 break;
10721072 case -NFS4ERR_RETRY_UNCACHED_REP:
10731073 break;
1074+ case -EAGAIN:
1075+ return -NFS4ERR_RESET_TO_PNFS;
10741076 /* Invalidate Layout errors */
10751077 case -NFS4ERR_PNFS_NO_LAYOUT:
10761078 case -ESTALE: /* mapped NFS4ERR_STALE */
@@ -1131,6 +1133,7 @@ static int ff_layout_async_handle_error_v3(struct rpc_task *task, · 54 unmodified lines
11311133 case -EBADHANDLE:
11321134 case -ELOOP:
11331135 case -ENOSPC:
1136+ case -EAGAIN:
11341137 break;
11351138 case -EJUKEBOX:
11361139 nfs_inc_stats(lseg->pls_layout->plh_inode, NFSIOS_DELAY);
@@ -1369,6 +1372,16 @@ static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data) · 232 unmodified lines
13691372 ff_layout_read_prepare_common(task, hdr);
13701373 }
13711374
1375+static void
1376+ff_layout_io_prepare_transmit(struct rpc_task *task,
1377+ void *data)
1378+{
1379+ struct nfs_pgio_header *hdr = data;
1380+
1381+ if (!pnfs_is_valid_lseg(hdr->lseg))
1382+ rpc_exit(task, -EAGAIN);
1383+}
1384+
13721385 static void ff_layout_read_call_done(struct rpc_task *task, void *data)
13731386 {
13741387 struct nfs_pgio_header *hdr = data;
@@ -1657,6 +1670,7 @@ static void ff_layout_commit_release(void *data) · 282 unmodified lines
16571670
16581671 static const struct rpc_call_ops ff_layout_read_call_ops_v3 = {
16591672 .rpc_call_prepare = ff_layout_read_prepare_v3,
1673+ .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
16601674 .rpc_call_done = ff_layout_read_call_done,
16611675 .rpc_count_stats = ff_layout_read_count_stats,
16621676 .rpc_release = ff_layout_read_release,
@@ -1664,6 +1678,7 @@ static const struct rpc_call_ops ff_layout_read_call_ops_v3 = { · 1 unmodified line
16641678
16651679 static const struct rpc_call_ops ff_layout_read_call_ops_v4 = {
16661680 .rpc_call_prepare = ff_layout_read_prepare_v4,
1681+ .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
16671682 .rpc_call_done = ff_layout_read_call_done,
16681683 .rpc_count_stats = ff_layout_read_count_stats,
16691684 .rpc_release = ff_layout_read_release,
@@ -1671,6 +1686,7 @@ static const struct rpc_call_ops ff_layout_read_call_ops_v4 = { · 1 unmodified line
16711686
16721687 static const struct rpc_call_ops ff_layout_write_call_ops_v3 = {
16731688 .rpc_call_prepare = ff_layout_write_prepare_v3,
1689+ .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
16741690 .rpc_call_done = ff_layout_write_call_done,
16751691 .rpc_count_stats = ff_layout_write_count_stats,
16761692 .rpc_release = ff_layout_write_release,
@@ -1678,6 +1694,7 @@ static const struct rpc_call_ops ff_layout_write_call_ops_v3 = { · 1 unmodified line
16781694
16791695 static const struct rpc_call_ops ff_layout_write_call_ops_v4 = {
16801696 .rpc_call_prepare = ff_layout_write_prepare_v4,
1697+ .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
16811698 .rpc_call_done = ff_layout_write_call_done,
16821699 .rpc_count_stats = ff_layout_write_count_stats,
16831700 .rpc_release = ff_layout_write_release,
include/linux/sunrpc/sched.h+1−0
@@ -97,6 +97,7 @@ typedef void (*rpc_action)(struct rpc_task *); · 96 unmodified lines
9797
9898 struct rpc_call_ops {
9999 void (*rpc_call_prepare)(struct rpc_task *, void *);
100+ void (*rpc_call_prepare_transmit)(struct rpc_task *, void *);
100101 void (*rpc_call_done)(struct rpc_task *, void *);
101102 void (*rpc_count_stats)(struct rpc_task *, void *);
102103 void (*rpc_release)(void *);
net/sunrpc/xprt.c+7−0
@@ -1330,6 +1330,13 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task) · 1329 unmodified lines
13301330 status = -EBADMSG;
13311331 goto out_dequeue;
13321332 }
1333+ if (task->tk_ops->rpc_call_prepare_transmit) {
1334+ task->tk_ops->rpc_call_prepare_transmit(task,
1335+ task->tk_calldata);
1336+ status = task->tk_status;
1337+ if (status < 0)
1338+ goto out_dequeue;
1339+ }
13331340 }
13341341
13351342 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t