Skip to contentSkip to conversation

btrfs: Use raw numbers when setting passing uptodate parameter to btrfs_writepage_endio_finish_ordered

PATCH In review Nikolay Borisov 3 participants 5 messages Mar 20, 2019 – Mar 22, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Use raw numbers when setting passing uptodate parameter to btrfs_writepage_endio_finish_ordered

The uptodate parameter of btrfs_writepage_endio_finish_ordered is used to signal whether an error has occured while writing the given page. 0 signal an error, which is propagated to callees and 1 signifies success. In end_compressed_bio_write the ->bi_status is checked and based on it either BLK_STS_OK (0) or BLK_STS_NOTSUPP (1) are used. While from functional point of view this is ok it's a for the poor reader of the code, since the block layer values are conflated with the semantics of the parameter.

Just use plain 0 or 1. No functional changes.

---
 fs/btrfs/compression.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/compression.c +1 -1
index eb8e20b740d6..f82441f18512 100644
@@ -250,7 +250,7 @@ static void end_compressed_bio_write(struct bio *bio)
 	cb->compressed_pages[0]->mapping = cb->inode->i_mapping;
 	btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0],
 			cb->start, cb->start + cb->len - 1,
-			bio->bi_status ? BLK_STS_OK : BLK_STS_NOTSUPP);
+			bio->bi_status ? 0 : 1);
 	cb->compressed_pages[0]->mapping = NULL;
 
 	end_compressed_writeback(inode, cb);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 21 lines · Nikolay Borisov

The uptodate parameter of btrfs_writepage_endio_finish_ordered is used to signal whether an error has occured while writing the given page. 0 signal an error, which is propagated to callees and 1 signifies success. In end_compressed_bio_write the ->bi_status is checked and based on it either BLK_STS_OK (0) or BLK_STS_NOTSUPP (1) are used. While from functional point of view this is ok it's a for the poor reader of the code, since the block layer values are conflated with the semantics of the parameter.

Just use plain 0 or 1. No functional changes.

---
 fs/btrfs/compression.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/compression.c +0 -0
index eb8e20b740d6..f82441f18512 100644

fs/btrfs/compression.c static void end_compressed_bio_write(struct bio *bio) · line 253

Quoted 5 lines
fs/btrfs/compression.c +1 -1
@@ -250,7 +250,7 @@ static void end_compressed_bio_write(struct bio *bio)
 	cb->compressed_pages[0]->mapping = cb->inode->i_mapping;
 	btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0],
 			cb->start, cb->start + cb->len - 1,
-			bio->bi_status ? BLK_STS_OK : BLK_STS_NOTSUPP);
+			bio->bi_status ? 0 : 1);

Essentially reverting 2dbe0c77186c691386b74391039899808a4d3f59, but using the BLK_STS constants is definetelly wrong. The values match the intended use of 'uptodate', but otherwise are confusing.

I actually think it can be simplified to bio->bi_staus == BLK_STS_OK.

#2 lore raw
Quoted 32 lines · David Sterba
Quoted 21 lines · Nikolay Borisov

The uptodate parameter of btrfs_writepage_endio_finish_ordered is used to signal whether an error has occured while writing the given page. 0 signal an error, which is propagated to callees and 1 signifies success. In end_compressed_bio_write the ->bi_status is checked and based on it either BLK_STS_OK (0) or BLK_STS_NOTSUPP (1) are used. While from functional point of view this is ok it's a for the poor reader of the code, since the block layer values are conflated with the semantics of the parameter.

Just use plain 0 or 1. No functional changes.

---
 fs/btrfs/compression.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/compression.c +0 -0
index eb8e20b740d6..f82441f18512 100644

fs/btrfs/compression.c static void end_compressed_bio_write(struct bio *bio) · line 253

Quoted 5 lines
fs/btrfs/compression.c +1 -1
@@ -250,7 +250,7 @@ static void end_compressed_bio_write(struct bio *bio)
 	cb->compressed_pages[0]->mapping = cb->inode->i_mapping;
 	btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0],
 			cb->start, cb->start + cb->len - 1,
-			bio->bi_status ? BLK_STS_OK : BLK_STS_NOTSUPP);
+			bio->bi_status ? 0 : 1);

Essentially reverting 2dbe0c77186c691386b74391039899808a4d3f59, but using the BLK_STS constants is definetelly wrong. The values match the intended use of 'uptodate', but otherwise are confusing.

Quoted 1 line

I actually think it can be simplified to bio->bi_staus == BLK_STS_OK.

Yes that would work, are you going to fix up the patch or shall I resend?

Quoted 1 line
#3 lore raw
Quoted 35 lines · Nikolay Borisov
Quoted 32 lines · David Sterba
Quoted 21 lines · Nikolay Borisov

The uptodate parameter of btrfs_writepage_endio_finish_ordered is used to signal whether an error has occured while writing the given page. 0 signal an error, which is propagated to callees and 1 signifies success. In end_compressed_bio_write the ->bi_status is checked and based on it either BLK_STS_OK (0) or BLK_STS_NOTSUPP (1) are used. While from functional point of view this is ok it's a for the poor reader of the code, since the block layer values are conflated with the semantics of the parameter.

Just use plain 0 or 1. No functional changes.

---
 fs/btrfs/compression.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/compression.c +0 -0
index eb8e20b740d6..f82441f18512 100644

fs/btrfs/compression.c static void end_compressed_bio_write(struct bio *bio) · line 253

Quoted 5 lines
fs/btrfs/compression.c +1 -1
@@ -250,7 +250,7 @@ static void end_compressed_bio_write(struct bio *bio)
 	cb->compressed_pages[0]->mapping = cb->inode->i_mapping;
 	btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0],
 			cb->start, cb->start + cb->len - 1,
-			bio->bi_status ? BLK_STS_OK : BLK_STS_NOTSUPP);
+			bio->bi_status ? 0 : 1);

Essentially reverting 2dbe0c77186c691386b74391039899808a4d3f59, but using the BLK_STS constants is definetelly wrong. The values match the intended use of 'uptodate', but otherwise are confusing.

Quoted 3 lines
Quoted 1 line

I actually think it can be simplified to bio->bi_staus == BLK_STS_OK.

Yes that would work, are you going to fix up the patch or shall I resend?

I'll fix it.

Reviewed-by
#4 lore raw
Quoted 36 lines · David Sterba
Quoted 35 lines · Nikolay Borisov
Quoted 32 lines · David Sterba
Quoted 21 lines · Nikolay Borisov

The uptodate parameter of btrfs_writepage_endio_finish_ordered is used to signal whether an error has occured while writing the given page. 0 signal an error, which is propagated to callees and 1 signifies success. In end_compressed_bio_write the ->bi_status is checked and based on it either BLK_STS_OK (0) or BLK_STS_NOTSUPP (1) are used. While from functional point of view this is ok it's a for the poor reader of the code, since the block layer values are conflated with the semantics of the parameter.

Just use plain 0 or 1. No functional changes.

---
  fs/btrfs/compression.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/compression.c +0 -0
index eb8e20b740d6..f82441f18512 100644

fs/btrfs/compression.c static void end_compressed_bio_write(struct bio *bio) · line 253

Quoted 5 lines
fs/btrfs/compression.c +1 -1
@@ -250,7 +250,7 @@ static void end_compressed_bio_write(struct bio *bio)
  	cb->compressed_pages[0]->mapping = cb->inode->i_mapping;
  	btrfs_writepage_endio_finish_ordered(cb->compressed_pages[0],
  			cb->start, cb->start + cb->len - 1,
-			bio->bi_status ? BLK_STS_OK : BLK_STS_NOTSUPP);
+			bio->bi_status ? 0 : 1);

Essentially reverting 2dbe0c77186c691386b74391039899808a4d3f59, but using the BLK_STS constants is definetelly wrong. The values match the intended use of 'uptodate', but otherwise are confusing.

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I actually think it can be simplified to bio->bi_staus == BLK_STS_OK.

Yes that would work, are you going to fix up the patch or shall I resend?

I'll fix it.

bio->bi_staus == BLK_STS_OK ? 1 : 0);

Is better. Its confusing. Thanks for the fix.