Skip to contentSkip to conversation

Minor parameter cleanups

PATCH In review David Sterba 3 participants 6 messages Oct 29, 2019 – Oct 30, 2019 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

cover Minor parameter cleanups

We can remove write_flags parameter in case the function also has wbc (and the value is equal).

David Sterba (2):
btrfs: sink write_flags to __extent_writepage_io
btrfs: sink write flags to cow_file_range_async

 fs/btrfs/extent_io.c | 8 +++-----
 fs/btrfs/inode.c     | 8 +++-----
 2 files changed, 6 insertions(+), 10 deletions(-)
Signature · 1 line
2.23.0
author maintainer
#1 lore raw

PATCH 1/2 btrfs: sink write_flags to __extent_writepage_io

__extent_writepage reads write flags from wbc and passes both to __extent_writepage_io. This makes write_flags redundant and we can remove it.

---
 fs/btrfs/extent_io.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/btrfs/extent_io.c +3 -5
index ed8ad14338de..ba1ddb2a5520 100644
@@ -3413,7 +3413,7 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode,
 				 struct extent_page_data *epd,
 				 loff_t i_size,
 				 unsigned long nr_written,
-				 unsigned int write_flags, int *nr_ret)
+				 int *nr_ret)
 {
 	struct extent_io_tree *tree = epd->tree;
 	u64 start = page_offset(page);
@@ -3428,6 +3428,7 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode,
 	size_t blocksize;
 	int ret = 0;
 	int nr = 0;
+	const unsigned int write_flags = wbc_to_write_flags(wbc);
 	bool compressed;
 
 	ret = btrfs_writepage_cow_fixup(page, start, page_end);
@@ -3560,11 +3561,8 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
 	size_t pg_offset = 0;
 	loff_t i_size = i_size_read(inode);
 	unsigned long end_index = i_size >> PAGE_SHIFT;
-	unsigned int write_flags = 0;
 	unsigned long nr_written = 0;
 
-	write_flags = wbc_to_write_flags(wbc);
-
 	trace___extent_writepage(page, inode, wbc);
 
 	WARN_ON(!PageLocked(page));
@@ -3602,7 +3600,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
 	}
 
 	ret = __extent_writepage_io(inode, page, wbc, epd,
-				    i_size, nr_written, write_flags, &nr);
+				    i_size, nr_written, &nr);
 	if (ret == 1)
 		goto done_unlocked;
 
Signature · 1 line
2.23.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] btrfs: sink write_flags to __extent_writepage_io

Looks good,

Signature · 9 lines
Johannes Thumshirn                            SUSE Labs Filesystems
[email protected]                                +49 911 74053 689
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 Nürnberg
Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
author maintainer
#3 lore raw

PATCH 2/2 btrfs: sink write flags to cow_file_range_async

In reply to David Sterba

In commit "Btrfs: use REQ_CGROUP_PUNT for worker thread submitted bios", cow_file_range_async gained wbc as a parameter and this makes passing write flags redundant. Set it inside the function and remove the parameter.

---
 fs/btrfs/inode.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/btrfs/inode.c +3 -5
index 09118a0f82d1..e7ea139a8e63 100644
@@ -1201,8 +1201,7 @@ static int cow_file_range_async(struct inode *inode,
 				struct writeback_control *wbc,
 				struct page *locked_page,
 				u64 start, u64 end, int *page_started,
-				unsigned long *nr_written,
-				unsigned int write_flags)
+				unsigned long *nr_written)
 {
 	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	struct cgroup_subsys_state *blkcg_css = wbc_blkcg_css(wbc);
@@ -1214,6 +1213,7 @@ static int cow_file_range_async(struct inode *inode,
 	int i;
 	bool should_compress;
 	unsigned nofs_flag;
+	const unsigned int write_flags = wbc_to_write_flags(wbc);
 
 	unlock_extent(&BTRFS_I(inode)->io_tree, start, end);
 
@@ -1724,7 +1724,6 @@ int btrfs_run_delalloc_range(struct inode *inode, struct page *locked_page,
 {
 	int ret;
 	int force_cow = need_force_cow(inode, start, end);
-	unsigned int write_flags = wbc_to_write_flags(wbc);
 
 	if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW && !force_cow) {
 		ret = run_delalloc_nocow(inode, locked_page, start, end,
@@ -1740,8 +1739,7 @@ int btrfs_run_delalloc_range(struct inode *inode, struct page *locked_page,
 		set_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
 			&BTRFS_I(inode)->runtime_flags);
 		ret = cow_file_range_async(inode, wbc, locked_page, start, end,
-					   page_started, nr_written,
-					   write_flags);
+					   page_started, nr_written);
 	}
 	if (ret)
 		btrfs_cleanup_ordered_extents(inode, locked_page, start,
Signature · 1 line
2.23.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] btrfs: sink write flags to cow_file_range_async

Looks good,

Signature · 9 lines
Johannes Thumshirn                            SUSE Labs Filesystems
[email protected]                                +49 911 74053 689
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 Nürnberg
Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Reviewed-by on the v1 series
#5 lore raw
In reply to David Sterba
Quoted 11 lines · David Sterba

We can remove write_flags parameter in case the function also has wbc (and the value is equal).

David Sterba (2):
btrfs: sink write_flags to __extent_writepage_io
btrfs: sink write flags to cow_file_range_async

 fs/btrfs/extent_io.c | 8 +++-----
 fs/btrfs/inode.c     | 8 +++-----
 2 files changed, 6 insertions(+), 10 deletions(-)

For the whole series: