Skip to contentSkip to conversation

xfs: don't clobber bi_status in xfs_zone_alloc_and_submit

PATCH Applied Andreas Gruenbacher 4 participants 7 messages Mar 4 – Mar 5 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: don't clobber bi_status in xfs_zone_alloc_and_submit

Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error() which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status.

---
 fs/xfs/xfs_zone_alloc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/xfs/xfs_zone_alloc.c +6 -3
index e3d19b6dc64a..c3328b9dda37 100644
@@ -862,7 +862,7 @@ xfs_zone_alloc_and_submit(
 	bool			is_seq;
 
 	if (xfs_is_shutdown(mp))
-		goto out_error;
+		goto out_io_error;
 
 	/*
 	 * If we don't have a locally cached zone in this write context, see if
@@ -875,7 +875,7 @@ xfs_zone_alloc_and_submit(
 select_zone:
 		*oz = xfs_select_zone(mp, write_hint, pack_tight);
 		if (!*oz)
-			goto out_error;
+			goto out_io_error;
 		xfs_set_cached_zone(ip, *oz);
 	}
 
@@ -902,7 +902,10 @@ xfs_zone_alloc_and_submit(
 
 out_split_error:
 	ioend->io_bio.bi_status = errno_to_blk_status(PTR_ERR(split));
-out_error:
+	bio_endio(&ioend->io_bio);
+	return;
+
+out_io_error:
 	bio_io_error(&ioend->io_bio);
 }
 
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Andreas Gruenbacher

Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error() which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status.

Yeah, that make sense to me that we shouldn't override the value set in out_split_error.

Cc <[email protected]> # v6.15
Fixes 4e4d5207557770 ("xfs: add the zoned space allocator")

--D

Quoted 42 lines
---
 fs/xfs/xfs_zone_alloc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/xfs/xfs_zone_alloc.c +6 -3
index e3d19b6dc64a..c3328b9dda37 100644
@@ -862,7 +862,7 @@ xfs_zone_alloc_and_submit(
 	bool			is_seq;
 
 	if (xfs_is_shutdown(mp))
-		goto out_error;
+		goto out_io_error;
 
 	/*
 	 * If we don't have a locally cached zone in this write context, see if
@@ -875,7 +875,7 @@ xfs_zone_alloc_and_submit(
 select_zone:
 		*oz = xfs_select_zone(mp, write_hint, pack_tight);
 		if (!*oz)
-			goto out_error;
+			goto out_io_error;
 		xfs_set_cached_zone(ip, *oz);
 	}
 
@@ -902,7 +902,10 @@ xfs_zone_alloc_and_submit(
 
 out_split_error:
 	ioend->io_bio.bi_status = errno_to_blk_status(PTR_ERR(split));
-out_error:
+	bio_endio(&ioend->io_bio);
+	return;
+
+out_io_error:
 	bio_io_error(&ioend->io_bio);
 }
 
Signature · 1 line
2.52.0
maintainer Reviewed-by
#2 lore raw
Quoted 5 lines · Darrick J. Wong
Quoted 4 lines · Andreas Gruenbacher

Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error() which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status.

Quoted 8 lines
Quoted 1 line

Yeah, that make sense to me that we shouldn't override the value set in out_split_error.

Cc <[email protected]> # v6.15
Fixes 4e4d5207557770 ("xfs: add the zoned space allocator")

I can add that at commit time, no need to send again Andreas.

For the patch itself:

Quoted 45 lines

--D

Quoted 42 lines
---
 fs/xfs/xfs_zone_alloc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/xfs/xfs_zone_alloc.c +6 -3
index e3d19b6dc64a..c3328b9dda37 100644
@@ -862,7 +862,7 @@ xfs_zone_alloc_and_submit(
 	bool			is_seq;
 
 	if (xfs_is_shutdown(mp))
-		goto out_error;
+		goto out_io_error;
 
 	/*
 	 * If we don't have a locally cached zone in this write context, see if
@@ -875,7 +875,7 @@ xfs_zone_alloc_and_submit(
 select_zone:
 		*oz = xfs_select_zone(mp, write_hint, pack_tight);
 		if (!*oz)
-			goto out_error;
+			goto out_io_error;
 		xfs_set_cached_zone(ip, *oz);
 	}
 
@@ -902,7 +902,10 @@ xfs_zone_alloc_and_submit(
 
 out_split_error:
 	ioend->io_bio.bi_status = errno_to_blk_status(PTR_ERR(split));
-out_error:
+	bio_endio(&ioend->io_bio);
+	return;
+
+out_io_error:
 	bio_io_error(&ioend->io_bio);
 }
 
Signature · 1 line
2.52.0
maintainer Applied
#3 lore raw
In reply to Andreas Gruenbacher
Quoted 5 lines · Andreas Gruenbacher

Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error() which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status.

Applied to for-next, thanks!

[1/1] xfs: don't clobber bi_status in xfs_zone_alloc_and_submit

      commit: 5be2161f245bab6aaf0723fdd0c9635dfcaf9de5

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>
#4 lore raw
In reply to Andreas Gruenbacher
Quoted 3 lines · Andreas Gruenbacher

Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error() which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status.

Looks good, but can you drop the pointless goto label renaming? I'd also be tempted to just open code the split error case instead of adding a label for it.

maintainer
#5 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Andreas Gruenbacher

Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error() which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status.

Looks good, but can you drop the pointless goto label renaming? I'd also be tempted to just open code the split error case instead of adding a label for it.

/me goes pull it off the next pull-request

#6 lore raw
In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Andreas Gruenbacher

Function xfs_zone_alloc_and_submit() sets bio->bi_status and then it calls bio_io_error() which overwrites that value again. Fix that by completing the bio separately after setting bio->bi_status.

Looks good, but can you drop the pointless goto label renaming? I'd also be tempted to just open code the split error case instead of adding a label for it.

Feel free to adjust things as you see fit.

Andreas