Skip to content

Commit f06bedf

Browse files
kofemannTrond Myklebust
authored andcommitted
pNFS/flexfiles: don't attempt pnfs on fatal DS errors
When an applications get killed (SIGTERM/SIGINT) while pNFS client performs a connection to DS, client ends in an infinite loop of connect-disconnect. This source of the issue, it that flexfilelayoutdev#nfs4_ff_layout_prepare_ds gets an error on nfs4_pnfs_ds_connect with status ERESTARTSYS, which is set by rpc_signal_task, but the error is treated as transient, thus retried. The issue is reproducible with Ctrl+C the following script(there should be ~1000 files in a directory, client should must not have any connections to DSes): ``` echo 3 > /proc/sys/vm/drop_caches for i in * do head -1 $i done ``` The change aims to propagate the nfs4_ff_layout_prepare_ds error state to the caller that can decide whatever this is a retryable error or not. Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de> Link: https://lore.kernel.org/r/20250627071751.189663-1-tigran.mkrtchyan@desy.de Fixes: 260f32a ("pNFS/flexfiles: Check the result of nfs4_pnfs_ds_connect") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent c262b44 commit f06bedf

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -762,25 +762,25 @@ ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg,
762762
{
763763
struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg);
764764
struct nfs4_ff_layout_mirror *mirror;
765-
struct nfs4_pnfs_ds *ds;
765+
struct nfs4_pnfs_ds *ds = ERR_PTR(-EAGAIN);
766766
u32 idx;
767767

768768
/* mirrors are initially sorted by efficiency */
769769
for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) {
770770
mirror = FF_LAYOUT_COMP(lseg, idx);
771771
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, false);
772-
if (!ds)
772+
if (IS_ERR(ds))
773773
continue;
774774

775775
if (check_device &&
776776
nfs4_test_deviceid_unavailable(&mirror->mirror_ds->id_node))
777777
continue;
778778

779779
*best_idx = idx;
780-
return ds;
780+
break;
781781
}
782782

783-
return NULL;
783+
return ds;
784784
}
785785

786786
static struct nfs4_pnfs_ds *
@@ -942,7 +942,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
942942
for (i = 0; i < pgio->pg_mirror_count; i++) {
943943
mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
944944
ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, mirror, true);
945-
if (!ds) {
945+
if (IS_ERR(ds)) {
946946
if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
947947
goto out_mds;
948948
pnfs_generic_pg_cleanup(pgio);
@@ -1867,15 +1867,18 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
18671867
u32 idx = hdr->pgio_mirror_idx;
18681868
int vers;
18691869
struct nfs_fh *fh;
1870+
bool ds_fatal_error = false;
18701871

18711872
dprintk("--> %s ino %lu pgbase %u req %zu@%llu\n",
18721873
__func__, hdr->inode->i_ino,
18731874
hdr->args.pgbase, (size_t)hdr->args.count, offset);
18741875

18751876
mirror = FF_LAYOUT_COMP(lseg, idx);
18761877
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, false);
1877-
if (!ds)
1878+
if (IS_ERR(ds)) {
1879+
ds_fatal_error = nfs_error_is_fatal(PTR_ERR(ds));
18781880
goto out_failed;
1881+
}
18791882

18801883
ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp,
18811884
hdr->inode);
@@ -1923,7 +1926,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
19231926
return PNFS_ATTEMPTED;
19241927

19251928
out_failed:
1926-
if (ff_layout_avoid_mds_available_ds(lseg))
1929+
if (ff_layout_avoid_mds_available_ds(lseg) && !ds_fatal_error)
19271930
return PNFS_TRY_AGAIN;
19281931
trace_pnfs_mds_fallback_read_pagelist(hdr->inode,
19291932
hdr->args.offset, hdr->args.count,
@@ -1945,11 +1948,14 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
19451948
int vers;
19461949
struct nfs_fh *fh;
19471950
u32 idx = hdr->pgio_mirror_idx;
1951+
bool ds_fatal_error = false;
19481952

19491953
mirror = FF_LAYOUT_COMP(lseg, idx);
19501954
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true);
1951-
if (!ds)
1955+
if (IS_ERR(ds)) {
1956+
ds_fatal_error = nfs_error_is_fatal(PTR_ERR(ds));
19521957
goto out_failed;
1958+
}
19531959

19541960
ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp,
19551961
hdr->inode);
@@ -2000,7 +2006,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
20002006
return PNFS_ATTEMPTED;
20012007

20022008
out_failed:
2003-
if (ff_layout_avoid_mds_available_ds(lseg))
2009+
if (ff_layout_avoid_mds_available_ds(lseg) && !ds_fatal_error)
20042010
return PNFS_TRY_AGAIN;
20052011
trace_pnfs_mds_fallback_write_pagelist(hdr->inode,
20062012
hdr->args.offset, hdr->args.count,
@@ -2043,7 +2049,7 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how)
20432049
idx = calc_ds_index_from_commit(lseg, data->ds_commit_index);
20442050
mirror = FF_LAYOUT_COMP(lseg, idx);
20452051
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true);
2046-
if (!ds)
2052+
if (IS_ERR(ds))
20472053
goto out_err;
20482054

20492055
ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp,

fs/nfs/flexfilelayout/flexfilelayoutdev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,11 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
370370
struct nfs4_ff_layout_mirror *mirror,
371371
bool fail_return)
372372
{
373-
struct nfs4_pnfs_ds *ds = NULL;
373+
struct nfs4_pnfs_ds *ds;
374374
struct inode *ino = lseg->pls_layout->plh_inode;
375375
struct nfs_server *s = NFS_SERVER(ino);
376376
unsigned int max_payload;
377-
int status;
377+
int status = -EAGAIN;
378378

379379
if (!ff_layout_init_mirror_ds(lseg->pls_layout, mirror))
380380
goto noconnect;
@@ -418,7 +418,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
418418
ff_layout_send_layouterror(lseg);
419419
if (fail_return || !ff_layout_has_available_ds(lseg))
420420
pnfs_error_mark_layout_for_return(ino, lseg);
421-
ds = NULL;
421+
ds = ERR_PTR(status);
422422
out:
423423
return ds;
424424
}

0 commit comments

Comments
 (0)