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
1071 break;1071 break;
1072 case -NFS4ERR_RETRY_UNCACHED_REP:1072 case -NFS4ERR_RETRY_UNCACHED_REP:
1073 break;1073 break;
1074 case -EAGAIN:
1075 return -NFS4ERR_RESET_TO_PNFS;
1074 /* Invalidate Layout errors */1076 /* Invalidate Layout errors */
1075 case -NFS4ERR_PNFS_NO_LAYOUT:1077 case -NFS4ERR_PNFS_NO_LAYOUT:
1076 case -ESTALE: /* mapped NFS4ERR_STALE */1078 case -ESTALE: /* mapped NFS4ERR_STALE */
@@ -1131,6 +1133,7 @@ static int ff_layout_async_handle_error_v3(struct rpc_task *task, · 54 unmodified lines
1131 case -EBADHANDLE:1133 case -EBADHANDLE:
1132 case -ELOOP:1134 case -ELOOP:
1133 case -ENOSPC:1135 case -ENOSPC:
1136 case -EAGAIN:
1134 break;1137 break;
1135 case -EJUKEBOX:1138 case -EJUKEBOX:
1136 nfs_inc_stats(lseg->pls_layout->plh_inode, NFSIOS_DELAY);1139 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
1369 ff_layout_read_prepare_common(task, hdr);1372 ff_layout_read_prepare_common(task, hdr);
1370}1373}
1371 1374
1375static void
1376ff_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
1372static void ff_layout_read_call_done(struct rpc_task *task, void *data)1385static void ff_layout_read_call_done(struct rpc_task *task, void *data)
1373{1386{
1374 struct nfs_pgio_header *hdr = data;1387 struct nfs_pgio_header *hdr = data;
@@ -1657,6 +1670,7 @@ static void ff_layout_commit_release(void *data) · 282 unmodified lines
1657 1670
1658static const struct rpc_call_ops ff_layout_read_call_ops_v3 = {1671static const struct rpc_call_ops ff_layout_read_call_ops_v3 = {
1659 .rpc_call_prepare = ff_layout_read_prepare_v3,1672 .rpc_call_prepare = ff_layout_read_prepare_v3,
1673 .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
1660 .rpc_call_done = ff_layout_read_call_done,1674 .rpc_call_done = ff_layout_read_call_done,
1661 .rpc_count_stats = ff_layout_read_count_stats,1675 .rpc_count_stats = ff_layout_read_count_stats,
1662 .rpc_release = ff_layout_read_release,1676 .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
1664 1678
1665static const struct rpc_call_ops ff_layout_read_call_ops_v4 = {1679static const struct rpc_call_ops ff_layout_read_call_ops_v4 = {
1666 .rpc_call_prepare = ff_layout_read_prepare_v4,1680 .rpc_call_prepare = ff_layout_read_prepare_v4,
1681 .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
1667 .rpc_call_done = ff_layout_read_call_done,1682 .rpc_call_done = ff_layout_read_call_done,
1668 .rpc_count_stats = ff_layout_read_count_stats,1683 .rpc_count_stats = ff_layout_read_count_stats,
1669 .rpc_release = ff_layout_read_release,1684 .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
1671 1686
1672static const struct rpc_call_ops ff_layout_write_call_ops_v3 = {1687static const struct rpc_call_ops ff_layout_write_call_ops_v3 = {
1673 .rpc_call_prepare = ff_layout_write_prepare_v3,1688 .rpc_call_prepare = ff_layout_write_prepare_v3,
1689 .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
1674 .rpc_call_done = ff_layout_write_call_done,1690 .rpc_call_done = ff_layout_write_call_done,
1675 .rpc_count_stats = ff_layout_write_count_stats,1691 .rpc_count_stats = ff_layout_write_count_stats,
1676 .rpc_release = ff_layout_write_release,1692 .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
1678 1694
1679static const struct rpc_call_ops ff_layout_write_call_ops_v4 = {1695static const struct rpc_call_ops ff_layout_write_call_ops_v4 = {
1680 .rpc_call_prepare = ff_layout_write_prepare_v4,1696 .rpc_call_prepare = ff_layout_write_prepare_v4,
1697 .rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
1681 .rpc_call_done = ff_layout_write_call_done,1698 .rpc_call_done = ff_layout_write_call_done,
1682 .rpc_count_stats = ff_layout_write_count_stats,1699 .rpc_count_stats = ff_layout_write_count_stats,
1683 .rpc_release = ff_layout_write_release,1700 .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
97 97
98struct rpc_call_ops {98struct rpc_call_ops {
99 void (*rpc_call_prepare)(struct rpc_task *, void *);99 void (*rpc_call_prepare)(struct rpc_task *, void *);
100 void (*rpc_call_prepare_transmit)(struct rpc_task *, void *);
100 void (*rpc_call_done)(struct rpc_task *, void *);101 void (*rpc_call_done)(struct rpc_task *, void *);
101 void (*rpc_count_stats)(struct rpc_task *, void *);102 void (*rpc_count_stats)(struct rpc_task *, void *);
102 void (*rpc_release)(void *);103 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
1330 status = -EBADMSG;1330 status = -EBADMSG;
1331 goto out_dequeue;1331 goto out_dequeue;
1332 }1332 }
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 }
1333 }1340 }
1334 1341
1335 /*1342 /*

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