Skip to contentSkip to conversation

btrfs: remove the dead comment in writepage_delalloc()

PATCH In review Qu Wenruo 2 participants 2 messages Jul 28, 2021 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: remove the dead comment in writepage_delalloc()

When btrfs_run_delalloc_range() failed, we will error out.

But there is a strange comment mentioning that btrfs_run_delalloc_range() could have return value >0 to indicate the IO has already started.

Commit 40f765805f08 ("Btrfs: split up __extent_writepage to lower stack usage") introduced the comment, but unfortunately at that time, we are already using @page_started to indicate that case, and still return 0.

Furthermore, even if that comment is right (which is not), we would return -EIO if the IO is already started.

By all means the comment is incorrect, just remove the comment along with the dead check.

Just to be extra safe, add an ASSERT() in btrfs_run_delalloc_range() to make sure we either return 0 or error, no positive return value.

---
 fs/btrfs/extent_io.c | 8 +-------
 fs/btrfs/inode.c     | 1 +
 2 files changed, 2 insertions(+), 7 deletions(-)
fs/btrfs/extent_io.c +1 -7
index f6723a7aab37..da9aca720047 100644
@@ -3824,13 +3824,7 @@ static noinline_for_stack int writepage_delalloc(struct btrfs_inode *inode,
 		if (ret) {
 			btrfs_page_set_error(inode->root->fs_info, page,
 					     page_offset(page), PAGE_SIZE);
-			/*
-			 * btrfs_run_delalloc_range should return < 0 for error
-			 * but just in case, we use > 0 here meaning the IO is
-			 * started, so we don't want to return > 0 unless
-			 * things are going well.
-			 */
-			return ret < 0 ? ret : -EIO;
+			return ret;
 		}
 		/*
 		 * delalloc_end is already one less than the total length, so
fs/btrfs/inode.c +1 -0
index 4c758ec8b8fd..becdd5fb330c 100644
@@ -2019,6 +2019,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
 		ret = cow_file_range_async(inode, wbc, locked_page, start, end,
 					   page_started, nr_written);
 	}
+	ASSERT(ret <= 0);
 	if (ret)
 		btrfs_cleanup_ordered_extents(inode, locked_page, start,
 					      end - start + 1);
Signature · 1 line
2.32.0
#1 lore raw
Quoted 13 lines · Qu Wenruo

When btrfs_run_delalloc_range() failed, we will error out.

But there is a strange comment mentioning that btrfs_run_delalloc_range() could have return value >0 to indicate the IO has already started.

Commit 40f765805f08 ("Btrfs: split up __extent_writepage to lower stack usage") introduced the comment, but unfortunately at that time, we are already using @page_started to indicate that case, and still return 0.

Furthermore, even if that comment is right (which is not), we would return -EIO if the IO is already started.

Quoted 7 lines

By all means the comment is incorrect, just remove the comment along with the dead check.

Just to be extra safe, add an ASSERT() in btrfs_run_delalloc_range() to make sure we either return 0 or error, no positive return value.

Added to misc-next, thanks.