Skip to content

Commit e36438f

Browse files
committed
Merge: pNFS/flexfiles: don't attempt pnfs on fatal DS errors
MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-10/-/merge_requests/287 JIRA: https://issues.redhat.com/browse/RHEL-110294 commit f06bedf Author: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de> Date: Fri Jun 27 09:17:51 2025 +0200 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> Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Approved-by: Paulo Alcantara <paalcant@redhat.com> Approved-by: Scott Mayhew <smayhew@redhat.com> Approved-by: Olga Kornievskaia <okorniev@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Julio Faracco <jfaracco@redhat.com>
2 parents 2a18702 + 977fc93 commit e36438f

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -762,25 +762,28 @@ 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 &&
776-
nfs4_test_deviceid_unavailable(&mirror->mirror_ds->id_node))
776+
nfs4_test_deviceid_unavailable(&mirror->mirror_ds->id_node)) {
777+
// reinitialize the error state in case if this is the last iteration
778+
ds = ERR_PTR(-EINVAL);
777779
continue;
780+
}
778781

779782
*best_idx = idx;
780-
return ds;
783+
break;
781784
}
782785

783-
return NULL;
786+
return ds;
784787
}
785788

786789
static struct nfs4_pnfs_ds *
@@ -804,7 +807,7 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
804807
struct nfs4_pnfs_ds *ds;
805808

806809
ds = ff_layout_choose_valid_ds_for_read(lseg, start_idx, best_idx);
807-
if (ds)
810+
if (!IS_ERR(ds))
808811
return ds;
809812
return ff_layout_choose_any_ds_for_read(lseg, start_idx, best_idx);
810813
}
@@ -818,7 +821,7 @@ ff_layout_get_ds_for_read(struct nfs_pageio_descriptor *pgio,
818821

819822
ds = ff_layout_choose_best_ds_for_read(lseg, pgio->pg_mirror_idx,
820823
best_idx);
821-
if (ds || !pgio->pg_mirror_idx)
824+
if (!IS_ERR(ds) || !pgio->pg_mirror_idx)
822825
return ds;
823826
return ff_layout_choose_best_ds_for_read(lseg, 0, best_idx);
824827
}
@@ -868,7 +871,7 @@ ff_layout_pg_init_read(struct nfs_pageio_descriptor *pgio,
868871
req->wb_nio = 0;
869872

870873
ds = ff_layout_get_ds_for_read(pgio, &ds_idx);
871-
if (!ds) {
874+
if (IS_ERR(ds)) {
872875
if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
873876
goto out_mds;
874877
pnfs_generic_pg_cleanup(pgio);
@@ -942,7 +945,7 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
942945
for (i = 0; i < pgio->pg_mirror_count; i++) {
943946
mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
944947
ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, mirror, true);
945-
if (!ds) {
948+
if (IS_ERR(ds)) {
946949
if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
947950
goto out_mds;
948951
pnfs_generic_pg_cleanup(pgio);
@@ -1072,11 +1075,13 @@ static void ff_layout_resend_pnfs_read(struct nfs_pgio_header *hdr)
10721075
{
10731076
u32 idx = hdr->pgio_mirror_idx + 1;
10741077
u32 new_idx = 0;
1078+
struct nfs4_pnfs_ds *ds;
10751079

1076-
if (ff_layout_choose_any_ds_for_read(hdr->lseg, idx, &new_idx))
1077-
ff_layout_send_layouterror(hdr->lseg);
1078-
else
1080+
ds = ff_layout_choose_any_ds_for_read(hdr->lseg, idx, &new_idx);
1081+
if (IS_ERR(ds))
10791082
pnfs_error_mark_layout_for_return(hdr->inode, hdr->lseg);
1083+
else
1084+
ff_layout_send_layouterror(hdr->lseg);
10801085
pnfs_read_resend_pnfs(hdr, new_idx);
10811086
}
10821087

@@ -1867,15 +1872,18 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
18671872
u32 idx = hdr->pgio_mirror_idx;
18681873
int vers;
18691874
struct nfs_fh *fh;
1875+
bool ds_fatal_error = false;
18701876

18711877
dprintk("--> %s ino %lu pgbase %u req %zu@%llu\n",
18721878
__func__, hdr->inode->i_ino,
18731879
hdr->args.pgbase, (size_t)hdr->args.count, offset);
18741880

18751881
mirror = FF_LAYOUT_COMP(lseg, idx);
18761882
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, false);
1877-
if (!ds)
1883+
if (IS_ERR(ds)) {
1884+
ds_fatal_error = nfs_error_is_fatal(PTR_ERR(ds));
18781885
goto out_failed;
1886+
}
18791887

18801888
ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp,
18811889
hdr->inode);
@@ -1923,7 +1931,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
19231931
return PNFS_ATTEMPTED;
19241932

19251933
out_failed:
1926-
if (ff_layout_avoid_mds_available_ds(lseg))
1934+
if (ff_layout_avoid_mds_available_ds(lseg) && !ds_fatal_error)
19271935
return PNFS_TRY_AGAIN;
19281936
trace_pnfs_mds_fallback_read_pagelist(hdr->inode,
19291937
hdr->args.offset, hdr->args.count,
@@ -1945,11 +1953,14 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
19451953
int vers;
19461954
struct nfs_fh *fh;
19471955
u32 idx = hdr->pgio_mirror_idx;
1956+
bool ds_fatal_error = false;
19481957

19491958
mirror = FF_LAYOUT_COMP(lseg, idx);
19501959
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true);
1951-
if (!ds)
1960+
if (IS_ERR(ds)) {
1961+
ds_fatal_error = nfs_error_is_fatal(PTR_ERR(ds));
19521962
goto out_failed;
1963+
}
19531964

19541965
ds_clnt = nfs4_ff_find_or_create_ds_client(mirror, ds->ds_clp,
19551966
hdr->inode);
@@ -2000,7 +2011,7 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
20002011
return PNFS_ATTEMPTED;
20012012

20022013
out_failed:
2003-
if (ff_layout_avoid_mds_available_ds(lseg))
2014+
if (ff_layout_avoid_mds_available_ds(lseg) && !ds_fatal_error)
20042015
return PNFS_TRY_AGAIN;
20052016
trace_pnfs_mds_fallback_write_pagelist(hdr->inode,
20062017
hdr->args.offset, hdr->args.count,
@@ -2043,7 +2054,7 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how)
20432054
idx = calc_ds_index_from_commit(lseg, data->ds_commit_index);
20442055
mirror = FF_LAYOUT_COMP(lseg, idx);
20452056
ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true);
2046-
if (!ds)
2057+
if (IS_ERR(ds))
20472058
goto out_err;
20482059

20492060
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)