mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
flexfiles/pNFS: fix NULL checks on result of ff_layout_choose_ds_for_read
[ Upstream commit 5a46d2339a5ae268ede53a221f20433d8ea4f2f9 ]
Recent commit f06bedfa62d5 ("pNFS/flexfiles: don't attempt pnfs on fatal DS
errors") has changed the error return type of ff_layout_choose_ds_for_read() from
NULL to an error pointer. However, not all code paths have been updated
to match the change. Thus, some non-NULL checks will accept error pointers
as a valid return value.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Suggested-by: Dan Carpenter <dan.carpenter@linaro.org>
Fixes: f06bedfa62d5 ("pNFS/flexfiles: don't attempt pnfs on fatal DS errors")
Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0214b96a6a
commit
fd00ae04c5
@@ -756,8 +756,11 @@ ff_layout_choose_ds_for_read(struct pnfs_layout_segment *lseg,
|
||||
continue;
|
||||
|
||||
if (check_device &&
|
||||
nfs4_test_deviceid_unavailable(&mirror->mirror_ds->id_node))
|
||||
nfs4_test_deviceid_unavailable(&mirror->mirror_ds->id_node)) {
|
||||
// reinitialize the error state in case if this is the last iteration
|
||||
ds = ERR_PTR(-EINVAL);
|
||||
continue;
|
||||
}
|
||||
|
||||
*best_idx = idx;
|
||||
break;
|
||||
@@ -787,7 +790,7 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
|
||||
struct nfs4_pnfs_ds *ds;
|
||||
|
||||
ds = ff_layout_choose_valid_ds_for_read(lseg, start_idx, best_idx);
|
||||
if (ds)
|
||||
if (!IS_ERR(ds))
|
||||
return ds;
|
||||
return ff_layout_choose_any_ds_for_read(lseg, start_idx, best_idx);
|
||||
}
|
||||
@@ -801,7 +804,7 @@ ff_layout_get_ds_for_read(struct nfs_pageio_descriptor *pgio,
|
||||
|
||||
ds = ff_layout_choose_best_ds_for_read(lseg, pgio->pg_mirror_idx,
|
||||
best_idx);
|
||||
if (ds || !pgio->pg_mirror_idx)
|
||||
if (!IS_ERR(ds) || !pgio->pg_mirror_idx)
|
||||
return ds;
|
||||
return ff_layout_choose_best_ds_for_read(lseg, 0, best_idx);
|
||||
}
|
||||
@@ -859,7 +862,7 @@ retry:
|
||||
req->wb_nio = 0;
|
||||
|
||||
ds = ff_layout_get_ds_for_read(pgio, &ds_idx);
|
||||
if (!ds) {
|
||||
if (IS_ERR(ds)) {
|
||||
if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
|
||||
goto out_mds;
|
||||
pnfs_generic_pg_cleanup(pgio);
|
||||
@@ -1063,11 +1066,13 @@ static void ff_layout_resend_pnfs_read(struct nfs_pgio_header *hdr)
|
||||
{
|
||||
u32 idx = hdr->pgio_mirror_idx + 1;
|
||||
u32 new_idx = 0;
|
||||
struct nfs4_pnfs_ds *ds;
|
||||
|
||||
if (ff_layout_choose_any_ds_for_read(hdr->lseg, idx, &new_idx))
|
||||
ff_layout_send_layouterror(hdr->lseg);
|
||||
else
|
||||
ds = ff_layout_choose_any_ds_for_read(hdr->lseg, idx, &new_idx);
|
||||
if (IS_ERR(ds))
|
||||
pnfs_error_mark_layout_for_return(hdr->inode, hdr->lseg);
|
||||
else
|
||||
ff_layout_send_layouterror(hdr->lseg);
|
||||
pnfs_read_resend_pnfs(hdr, new_idx);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user