btrfs: Evaluate io_tree in find_lock_delalloc_range()
PATCH 1/1 btrfs: Evaluate io_tree in find_lock_delalloc_range()
Simplification.
No point passing the tree variable when it can be evaluated from inode.
--- fs/btrfs/extent_io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/extent_io.c +2 -4
@@ -1719,10 +1719,10 @@ static noinline int lock_delalloc_pages(struct inode *inode,*/ EXPORT_FOR_TESTS noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, -struct extent_io_tree *tree,struct page *locked_page,u64 *start,u64 *end) { +struct extent_io_tree *tree = &BTRFS_I (inode)->io_tree;u64 max_bytes =BTRFS_MAX_EXTENT_SIZE ;u64 delalloc_start;u64 delalloc_end;
@@ -3290,7 +3290,6 @@ static noinline_for_stack int writepage_delalloc(struct inode *inode, struct page *page, struct writeback_control *wbc, u64 delalloc_start, unsigned long *nr_written) { - struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; u64 page_end = delalloc_start + PAGE_SIZE - 1;bool found;u64 delalloc_to_write =0 ;
@@ -3300,8 +3299,7 @@ static noinline_for_stack int writepage_delalloc(struct inode *inode,while (delalloc_end < page_end) { - found =find_lock_delalloc_range (inode, tree, - page, + found =find_lock_delalloc_range (inode, page, &delalloc_start, &delalloc_end);if (!found) {
Signature · 1 line
2.16.4
Quoted 5 lines · Goldwyn Rodrigues
Simplification.
No point passing the tree variable when it can be evaluated from inode.Signed-off-by Goldwyn Rodrigues <[email protected]>
The patch is good, however, there are several calls to find_ lock_delalloc_range in btrfs tests so you'd need to fix those invocations, otherwise compilation of the in-kernel test suite will fails.
fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
Quoted 39 lines
--- fs/btrfs/extent_io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/btrfs/extent_io.c +2
-4@@ -1719,10 +1719,10 @@ static noinline int lock_delalloc_pages(struct inode *inode,*/ EXPORT_FOR_TESTS noinline_for_stack bool find_lock_delalloc_range(struct inode *inode, -struct extent_io_tree *tree,struct page *locked_page,u64 *start,u64 *end) { +struct extent_io_tree *tree = &BTRFS_I (inode)->io_tree;u64 max_bytes =BTRFS_MAX_EXTENT_SIZE ;u64 delalloc_start;u64 delalloc_end;@@ -3290,7 +3290,6 @@ static noinline_for_stack int writepage_delalloc(struct inode *inode, struct page *page, struct writeback_control *wbc, u64 delalloc_start, unsigned long *nr_written) { - struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree; u64 page_end = delalloc_start + PAGE_SIZE - 1;bool found;u64 delalloc_to_write =0 ;@@ -3300,8 +3299,7 @@ static noinline_for_stack int writepage_delalloc(struct inode *inode,while (delalloc_end < page_end) { - found =find_lock_delalloc_range (inode, tree, - page, + found =find_lock_delalloc_range (inode, page, &delalloc_start, &delalloc_end);if (!found) {
Quoted 13 lines · Nikolay Borisov
Quoted 5 lines · Goldwyn Rodrigues
Simplification.
No point passing the tree variable when it can be evaluated from inode.Signed-off-by Goldwyn Rodrigues <[email protected]>The patch is good, however, there are several calls to
find_lock_delalloc_rangein btrfs tests so you'd need to fix those invocations, otherwise compilation of the in-kernel test suite will fails.
Quoted 7 lines
fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
Oh, I missed the test, even if it was listed as EXPORT_FOR_TESTS. Looking at the tests, it seems it needs to work on a different io_tree than in the inode. So, I suppose this patch should NOT be included for the sake of tests. Perhaps we should use wrapper functions for simplifications.
Signature · 1 line
Goldwyn
Quoted 22 lines · Goldwyn Rodrigues
Quoted 13 lines · Nikolay Borisov
Quoted 5 lines · Goldwyn Rodrigues
Simplification.
No point passing the tree variable when it can be evaluated from inode.Signed-off-by Goldwyn Rodrigues <[email protected]>The patch is good, however, there are several calls to
find_lock_delalloc_rangein btrfs tests so you'd need to fix those invocations, otherwise compilation of the in-kernel test suite will fails.Quoted 7 lines
fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start, fs/btrfs/tests/extent-io-tests.c: found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
Quoted 3 lines
Oh, I missed the test, even if it was listed as
EXPORT_FOR_TESTS. Looking at the tests, it seems it needs to work on a differentio_treethan in the inode.
If it's possible/correct to set the test inode tree pointer, then I guess the change still applies. The testing code works on dummy or otherwise crafted structures, so this kind of tweak does not sound off.