提交 c8bb0c8b 编写于 作者: A Ashish Samant 提交者: David Sterba

btrfs: Cleanup compress_file_range()

Remove unnecessary checks in compress_file_range().
Signed-off-by: NAshish Samant <ashish.samant@oracle.com>
[ minor coding style fixups ]
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 6f034ece
...@@ -585,9 +585,27 @@ static noinline void compress_file_range(struct inode *inode, ...@@ -585,9 +585,27 @@ static noinline void compress_file_range(struct inode *inode,
will_compress = 0; will_compress = 0;
} else { } else {
num_bytes = total_in; num_bytes = total_in;
*num_added += 1;
/*
* The async work queues will take care of doing actual
* allocation on disk for these compressed pages, and
* will submit them to the elevator.
*/
add_async_extent(async_cow, start, num_bytes,
total_compressed, pages, nr_pages_ret,
compress_type);
if (start + num_bytes < end) {
start += num_bytes;
pages = NULL;
cond_resched();
goto again;
}
return;
} }
} }
if (!will_compress && pages) { if (pages) {
/* /*
* the compression code ran but failed to make things smaller, * the compression code ran but failed to make things smaller,
* free any pages it allocated and our page pointer array * free any pages it allocated and our page pointer array
...@@ -607,43 +625,23 @@ static noinline void compress_file_range(struct inode *inode, ...@@ -607,43 +625,23 @@ static noinline void compress_file_range(struct inode *inode,
BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS; BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
} }
} }
if (will_compress) {
*num_added += 1;
/* the async work queues will take care of doing actual
* allocation on disk for these compressed pages,
* and will submit them to the elevator.
*/
add_async_extent(async_cow, start, num_bytes,
total_compressed, pages, nr_pages_ret,
compress_type);
if (start + num_bytes < end) {
start += num_bytes;
pages = NULL;
cond_resched();
goto again;
}
} else {
cleanup_and_bail_uncompressed: cleanup_and_bail_uncompressed:
/* /*
* No compression, but we still need to write the pages in * No compression, but we still need to write the pages in the file
* the file we've been given so far. redirty the locked * we've been given so far. redirty the locked page if it corresponds
* page if it corresponds to our extent and set things up * to our extent and set things up for the async work queue to run
* for the async work queue to run cow_file_range to do * cow_file_range to do the normal delalloc dance.
* the normal delalloc dance */
*/ if (page_offset(locked_page) >= start &&
if (page_offset(locked_page) >= start && page_offset(locked_page) <= end)
page_offset(locked_page) <= end) { __set_page_dirty_nobuffers(locked_page);
__set_page_dirty_nobuffers(locked_page); /* unlocked later on in the async handlers */
/* unlocked later on in the async handlers */
} if (redirty)
if (redirty) extent_range_redirty_for_io(inode, start, end);
extent_range_redirty_for_io(inode, start, end); add_async_extent(async_cow, start, end - start + 1, 0, NULL, 0,
add_async_extent(async_cow, start, end - start + 1, BTRFS_COMPRESS_NONE);
0, NULL, 0, BTRFS_COMPRESS_NONE); *num_added += 1;
*num_added += 1;
}
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册