Skip to contentSkip to conversation

Btrfs: remove unused delalloc_end parameter

PATCH In review [email protected] 2 participants 4 messages Mar 6, 2017 – Mar 9, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Btrfs: remove unused delalloc_end parameter

From: Filipe Manana <[email protected]>

The delalloc_end parameter for extent_clear_unlock_delalloc() is never used, and only making the code for all callers longer and more complex. Just remove it.

---
 fs/btrfs/extent_io.c |  2 +-
 fs/btrfs/extent_io.h |  2 +-
 fs/btrfs/inode.c     | 32 +++++++++++++-------------------
 3 files changed, 15 insertions(+), 21 deletions(-)
fs/btrfs/extent_io.c +1 -1
index 28e8192..2cce08b 100644
@@ -1760,7 +1760,7 @@ static int __process_pages_contig(struct address_space *mapping,
 }
 
 void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
-				 u64 delalloc_end, struct page *locked_page,
+				 struct page *locked_page,
 				 unsigned clear_bits,
 				 unsigned long page_ops)
 {
fs/btrfs/extent_io.h +1 -1
index 3e4fad4..b12f4db 100644
@@ -452,7 +452,7 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset,
 void extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end);
 void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end);
 void extent_clear_unlock_delalloc(struct inode *inode, u64 start, u64 end,
-				 u64 delalloc_end, struct page *locked_page,
+				 struct page *locked_page,
 				 unsigned bits_to_clear,
 				 unsigned long page_ops);
 struct bio *
fs/btrfs/inode.c +13 -19
index b2bc07a..07bee7d 100644
@@ -106,7 +106,7 @@ static int btrfs_truncate(struct inode *inode);
 static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);
 static noinline int cow_file_range(struct inode *inode,
 				   struct page *locked_page,
-				   u64 start, u64 end, u64 delalloc_end,
+				   u64 start, u64 end,
 				   int *page_started, unsigned long *nr_written,
 				   int unlock, struct btrfs_dedupe_hash *hash);
 static struct extent_map *create_io_em(struct inode *inode, u64 start, u64 len,
@@ -558,7 +558,7 @@ static noinline void compress_file_range(struct inode *inode,
 			 * we don't need to create any more async work items.
 			 * Unlock and free up our temp pages.
 			 */
-			extent_clear_unlock_delalloc(inode, start, end, end,
+			extent_clear_unlock_delalloc(inode, start, end,
 						     NULL, clear_flags,
 						     PAGE_UNLOCK |
 						     PAGE_CLEAR_DIRTY |
@@ -713,8 +713,6 @@ static noinline void submit_compressed_extents(struct inode *inode,
 					     async_extent->start,
 					     async_extent->start +
 					     async_extent->ram_size - 1,
-					     async_extent->start +
-					     async_extent->ram_size - 1,
 					     &page_started, &nr_written, 0,
 					     NULL);
 
@@ -810,8 +808,6 @@ static noinline void submit_compressed_extents(struct inode *inode,
 		extent_clear_unlock_delalloc(inode, async_extent->start,
 				async_extent->start +
 				async_extent->ram_size - 1,
-				async_extent->start +
-				async_extent->ram_size - 1,
 				NULL, EXTENT_LOCKED | EXTENT_DELALLOC,
 				PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
 				PAGE_SET_WRITEBACK);
@@ -831,7 +827,7 @@ static noinline void submit_compressed_extents(struct inode *inode,
 			tree->ops->writepage_end_io_hook(p, start, end,
 							 NULL, 0);
 			p->mapping = NULL;
-			extent_clear_unlock_delalloc(inode, start, end, end,
+			extent_clear_unlock_delalloc(inode, start, end,
 						     NULL, 0,
 						     PAGE_END_WRITEBACK |
 						     PAGE_SET_ERROR);
@@ -849,8 +845,6 @@ static noinline void submit_compressed_extents(struct inode *inode,
 	extent_clear_unlock_delalloc(inode, async_extent->start,
 				     async_extent->start +
 				     async_extent->ram_size - 1,
-				     async_extent->start +
-				     async_extent->ram_size - 1,
 				     NULL, EXTENT_LOCKED | EXTENT_DELALLOC |
 				     EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING,
 				     PAGE_UNLOCK | PAGE_CLEAR_DIRTY |
@@ -908,7 +902,7 @@ static u64 get_extent_allocation_hint(struct inode *inode, u64 start,
  */
 static noinline int cow_file_range(struct inode *inode,
 				   struct page *locked_page,
-				   u64 start, u64 end, u64 delalloc_end,
+				   u64 start, u64 end,
 				   int *page_started, unsigned long *nr_written,
 				   int unlock, struct btrfs_dedupe_hash *hash)
 {
@@ -942,7 +936,7 @@ static noinline int cow_file_range(struct inode *inode,
 					BTRFS_COMPRESS_NONE, NULL);
 		if (ret == 0) {
 			extent_clear_unlock_delalloc(inode, start, end,
-				     delalloc_end, NULL,
+				     NULL,
 				     EXTENT_LOCKED | EXTENT_DELALLOC |
 				     EXTENT_DEFRAG, PAGE_UNLOCK |
 				     PAGE_CLEAR_DIRTY | PAGE_SET_WRITEBACK |
@@ -1019,7 +1013,7 @@ static noinline int cow_file_range(struct inode *inode,
 
 		extent_clear_unlock_delalloc(inode, start,
 					     start + ram_size - 1,
-					     delalloc_end, locked_page,
+					     locked_page,
 					     EXTENT_LOCKED | EXTENT_DELALLOC,
 					     op);
 		disk_num_bytes -= cur_alloc_size;
@@ -1036,7 +1030,7 @@ static noinline int cow_file_range(struct inode *inode,
 	btrfs_dec_block_group_reservations(fs_info, ins.objectid);
 	btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 1);
 out_unlock:
-	extent_clear_unlock_delalloc(inode, start, end, delalloc_end,
+	extent_clear_unlock_delalloc(inode, start, end,
 				     locked_page,
 				     EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
 				     EXTENT_DELALLOC | EXTENT_DEFRAG,
@@ -1212,7 +1206,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 
 	path = btrfs_alloc_path();
 	if (!path) {
-		extent_clear_unlock_delalloc(inode, start, end, end,
+		extent_clear_unlock_delalloc(inode, start, end,
 					     locked_page,
 					     EXTENT_LOCKED | EXTENT_DELALLOC |
 					     EXTENT_DO_ACCOUNTING |
@@ -1366,7 +1360,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 		if (cow_start != (u64)-1) {
 			ret = cow_file_range(inode, locked_page,
 					     cow_start, found_key.offset - 1,
-					     end, page_started, nr_written, 1,
+					     page_started, nr_written, 1,
 					     NULL);
 			if (ret) {
 				if (!nolock && nocow)
@@ -1425,7 +1419,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 		}
 
 		extent_clear_unlock_delalloc(inode, cur_offset,
-					     cur_offset + num_bytes - 1, end,
+					     cur_offset + num_bytes - 1,
 					     locked_page, EXTENT_LOCKED |
 					     EXTENT_DELALLOC |
 					     EXTENT_CLEAR_DATA_RESV,
@@ -1445,7 +1439,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 	}
 
 	if (cow_start != (u64)-1) {
-		ret = cow_file_range(inode, locked_page, cow_start, end, end,
+		ret = cow_file_range(inode, locked_page, cow_start, end,
 				     page_started, nr_written, 1, NULL);
 		if (ret)
 			goto error;
@@ -1453,7 +1447,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
 
 error:
 	if (ret && cur_offset < end)
-		extent_clear_unlock_delalloc(inode, cur_offset, end, end,
+		extent_clear_unlock_delalloc(inode, cur_offset, end,
 					     locked_page, EXTENT_LOCKED |
 					     EXTENT_DELALLOC | EXTENT_DEFRAG |
 					     EXTENT_DO_ACCOUNTING, PAGE_UNLOCK |
@@ -1501,7 +1495,7 @@ static int run_delalloc_range(struct inode *inode, struct page *locked_page,
 		ret = run_delalloc_nocow(inode, locked_page, start, end,
 					 page_started, 0, nr_written);
 	} else if (!inode_need_compress(inode)) {
-		ret = cow_file_range(inode, locked_page, start, end, end,
+		ret = cow_file_range(inode, locked_page, start, end,
 				      page_started, nr_written, 1, NULL);
 	} else {
 		set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
Signature · 1 line
2.7.0.rc3
#1 lore raw
Quoted 5 lines · On Mon, Mar 06, 2017 at 11:32:47PM +0000, [email protected] wrote:

From: Filipe Manana <[email protected]>

The delalloc_end parameter for extent_clear_unlock_delalloc() is never used, and only making the code for all callers longer and more complex. Just remove it.

It's been added on purpose

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=dda3245eca18c73413a854a834c41fc770feb0dd

"btrfs: expand cow_file_range() to support in-band dedup and subpage-blocksize"

so we can merge both mentioned patchsets for testing.

#2 lore raw
Quoted 7 lines · David Sterba
Quoted 5 lines · On Mon, Mar 06, 2017 at 11:32:47PM +0000, [email protected] wrote:

From: Filipe Manana <[email protected]>

The delalloc_end parameter for extent_clear_unlock_delalloc() is never used, and only making the code for all callers longer and more complex. Just remove it.

Quoted 8 lines

It's been added on purpose

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=dda3245eca18c73413a854a834c41fc770feb0dd

"btrfs: expand cow_file_range() to support in-band dedup and subpage-blocksize"

so we can merge both mentioned patchsets for testing.

I definitely missed that. To be honest I was finding it strange that none of the usual cleanup fanatics noticed it before.

Anyway I'm sending a v2 of the 2nd patch so that it works correctly on top of Qu's patchset that I reviewed recently. I've added Qu's patches to my 4.11 integration branch just so that I could work on top of them, feel free to pick stuff from there if convenient or ignore otherwise.

Thanks.

#3 lore raw
Quoted 12 lines · Filipe Manana
Quoted 11 lines · David Sterba
Quoted 5 lines · On Mon, Mar 06, 2017 at 11:32:47PM +0000, [email protected] wrote:

From: Filipe Manana <[email protected]>

The delalloc_end parameter for extent_clear_unlock_delalloc() is never used, and only making the code for all callers longer and more complex. Just remove it.

It's been added on purpose

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=dda3245eca18c73413a854a834c41fc770feb0dd

Quoted 7 lines
Quoted 4 lines

"btrfs: expand cow_file_range() to support in-band dedup and subpage-blocksize"

so we can merge both mentioned patchsets for testing.

I definitely missed that. To be honest I was finding it strange that none of the usual cleanup fanatics noticed it before.

I was disappointed for a minute that I couldn't remove it, you bet.

Quoted 5 lines

Anyway I'm sending a v2 of the 2nd patch so that it works correctly on top of Qu's patchset that I reviewed recently. I've added Qu's patches to my 4.11 integration branch just so that I could work on top of them, feel free to pick stuff from there if convenient or ignore otherwise.

Let's keep it in your branch then.