Skip to content

Commit f4a4756

Browse files
andypriceAndreas Gruenbacher
authored andcommitted
gfs2: Return more useful errors from gfs2_rgrp_send_discards()
The bug that 27ca827 ("gfs2: Make sure FITRIM minlen is rounded up to fs block size") fixes was a little confusing as the user saw "Input/output error" which masked the -EINVAL that sb_issue_discard() returned. sb_issue_discard() can fail for various reasons, so we should return its return value from gfs2_rgrp_send_discards() to avoid all errors being reported as IO errors. This improves error reporting for FITRIM and makes no difference to the -o discard code path because the return value from gfs2_rgrp_send_discards() gets thrown away in that case (and the option switches off). Presumably that's why it was ok to just return -EIO in the past, before FITRIM was implemented. Tested with xfstests. Signed-off-by: Andrew Price <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 11d8b79 commit f4a4756

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/gfs2/rgrp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
13151315
u64 blk;
13161316
sector_t start = 0;
13171317
sector_t nr_blks = 0;
1318-
int rv;
1318+
int rv = -EIO;
13191319
unsigned int x;
13201320
u32 trimmed = 0;
13211321
u8 diff;
@@ -1371,7 +1371,7 @@ int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset,
13711371
if (sdp->sd_args.ar_discard)
13721372
fs_warn(sdp, "error %d on discard request, turning discards off for this filesystem\n", rv);
13731373
sdp->sd_args.ar_discard = 0;
1374-
return -EIO;
1374+
return rv;
13751375
}
13761376

13771377
/**

0 commit comments

Comments
 (0)