Skip to content

Commit a3efb2f

Browse files
adam900710kdave
authored andcommitted
btrfs: fix the comment on lock_extent_buffer_for_io
The return value of that function is completely wrong. That function only returns 0 if the extent buffer doesn't need to be submitted. 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 locking. 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() returns 0, we just skip the extent buffer completely. 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 description, only describe the locking part to make the point more clear. For reference, added in commit 2e3c251 ("btrfs: extent_io: add proper error handling to lock_extent_buffer_for_io()") Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent cc7c771 commit a3efb2f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/btrfs/extent_io.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,11 +3652,14 @@ static void end_extent_buffer_writeback(struct extent_buffer *eb)
36523652
}
36533653

36543654
/*
3655-
* Lock eb pages and flush the bio if we can't the locks
3655+
* Lock extent buffer status and pages for writeback.
36563656
*
3657-
* Return 0 if nothing went wrong
3658-
* Return >0 is same as 0, except bio is not submitted
3659-
* Return <0 if something went wrong, no page is locked
3657+
* May try to flush write bio if we can't get the lock.
3658+
*
3659+
* Return 0 if the extent buffer doesn't need to be submitted.
3660+
* (E.g. the extent buffer is not dirty)
3661+
* Return >0 is the extent buffer is submitted to bio.
3662+
* Return <0 if something went wrong, no page is locked.
36603663
*/
36613664
static noinline_for_stack int lock_extent_buffer_for_io(struct extent_buffer *eb,
36623665
struct extent_page_data *epd)

0 commit comments

Comments
 (0)