diff mbox series

[v3,03/49] btrfs: extent_io: fix the comment on lock_extent_buffer_for_io().

Message ID 20200930015539.48867-4-wqu@suse.com
State New, archived
Headers show
Series btrfs: add partial rw support for subpage sector size | expand

Commit Message

Qu Wenruo Sept. 30, 2020, 1:54 a.m. UTC
The return value of that function is completely wrong.

That function only return 0 if the the extent buffer doesn't need to be
The "ret = 1" and "ret = 0" are determined by the return value of
"test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags)".

And if we get ret == 1, it's because the extent buffer is dirty, and we
set its status to EXTENT_BUFFER_WRITE_BACK, and continue to page

While if we get ret == 0, it means the extent is not dirty from the
beginning, so we don't need to write it back.

The caller also follows this, in btree_write_cache_pages(), if
lock_extent_buffer_for_io() return 0, we just skip the extent buffer

So the comment is completely wrong.

Since we're here, also change the description a little.
The write bio flushing won't be visible to the caller, thus it's not an
major feature.
In the main decription, only describe the locking part to make the point
more clear.

Fixes: 2e3c25136adf ("btrfs: extent_io: add proper error handling to lock_extent_buffer_for_io()")
Signed-off-by: Qu Wenruo <wqu@suse.com>
 fs/btrfs/extent_io.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series


diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 64f7f61ce718..a64d88163f3b 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3688,11 +3688,14 @@  static void end_extent_buffer_writeback(struct extent_buffer *eb)
- * Lock eb pages and flush the bio if we can't the locks
+ * Lock extent buffer status and pages for write back.
- * Return  0 if nothing went wrong
- * Return >0 is same as 0, except bio is not submitted
- * Return <0 if something went wrong, no page is locked
+ * May try to flush write bio if we can't get the lock.
+ *
+ * Return  0 if the extent buffer doesn't need to be submitted.
+ * (E.g. the extent buffer is not dirty)
+ * Return >0 is the extent buffer is submitted to bio.
+ * Return <0 if something went wrong, no page is locked.
 static noinline_for_stack int lock_extent_buffer_for_io(struct extent_buffer *eb,
 			  struct extent_page_data *epd)