Commit 7dbdb443 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: remove crc_check logic from free space

Following removal of the ino cache io_ctl_init will be called only on
behalf of the freespace inode. In this case we always want to check
CRCs so conditional code that depended on io_ctl::check_crc can be
removed.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 5297199a
...@@ -305,16 +305,11 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode, ...@@ -305,16 +305,11 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
int write) int write)
{ {
int num_pages; int num_pages;
int check_crcs = 0;
num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE); num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FREE_INO_OBJECTID)
check_crcs = 1;
/* Make sure we can fit our crcs and generation into the first page */ /* Make sure we can fit our crcs and generation into the first page */
if (write && check_crcs && if (write && (num_pages * sizeof(u32) + sizeof(u64)) > PAGE_SIZE)
(num_pages * sizeof(u32) + sizeof(u64)) > PAGE_SIZE)
return -ENOSPC; return -ENOSPC;
memset(io_ctl, 0, sizeof(struct btrfs_io_ctl)); memset(io_ctl, 0, sizeof(struct btrfs_io_ctl));
...@@ -325,7 +320,6 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode, ...@@ -325,7 +320,6 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
io_ctl->num_pages = num_pages; io_ctl->num_pages = num_pages;
io_ctl->fs_info = btrfs_sb(inode->i_sb); io_ctl->fs_info = btrfs_sb(inode->i_sb);
io_ctl->check_crcs = check_crcs;
io_ctl->inode = inode; io_ctl->inode = inode;
return 0; return 0;
...@@ -420,13 +414,8 @@ static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation) ...@@ -420,13 +414,8 @@ static void io_ctl_set_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
* Skip the csum areas. If we don't check crcs then we just have a * Skip the csum areas. If we don't check crcs then we just have a
* 64bit chunk at the front of the first page. * 64bit chunk at the front of the first page.
*/ */
if (io_ctl->check_crcs) {
io_ctl->cur += (sizeof(u32) * io_ctl->num_pages); io_ctl->cur += (sizeof(u32) * io_ctl->num_pages);
io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_pages); io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_pages);
} else {
io_ctl->cur += sizeof(u64);
io_ctl->size -= sizeof(u64) * 2;
}
put_unaligned_le64(generation, io_ctl->cur); put_unaligned_le64(generation, io_ctl->cur);
io_ctl->cur += sizeof(u64); io_ctl->cur += sizeof(u64);
...@@ -440,14 +429,8 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation) ...@@ -440,14 +429,8 @@ static int io_ctl_check_generation(struct btrfs_io_ctl *io_ctl, u64 generation)
* Skip the crc area. If we don't check crcs then we just have a 64bit * Skip the crc area. If we don't check crcs then we just have a 64bit
* chunk at the front of the first page. * chunk at the front of the first page.
*/ */
if (io_ctl->check_crcs) {
io_ctl->cur += sizeof(u32) * io_ctl->num_pages; io_ctl->cur += sizeof(u32) * io_ctl->num_pages;
io_ctl->size -= sizeof(u64) + io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_pages);
(sizeof(u32) * io_ctl->num_pages);
} else {
io_ctl->cur += sizeof(u64);
io_ctl->size -= sizeof(u64) * 2;
}
cache_gen = get_unaligned_le64(io_ctl->cur); cache_gen = get_unaligned_le64(io_ctl->cur);
if (cache_gen != generation) { if (cache_gen != generation) {
...@@ -467,11 +450,6 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index) ...@@ -467,11 +450,6 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
u32 crc = ~(u32)0; u32 crc = ~(u32)0;
unsigned offset = 0; unsigned offset = 0;
if (!io_ctl->check_crcs) {
io_ctl_unmap_page(io_ctl);
return;
}
if (index == 0) if (index == 0)
offset = sizeof(u32) * io_ctl->num_pages; offset = sizeof(u32) * io_ctl->num_pages;
...@@ -489,11 +467,6 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index) ...@@ -489,11 +467,6 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
u32 crc = ~(u32)0; u32 crc = ~(u32)0;
unsigned offset = 0; unsigned offset = 0;
if (!io_ctl->check_crcs) {
io_ctl_map_page(io_ctl, 0);
return 0;
}
if (index == 0) if (index == 0)
offset = sizeof(u32) * io_ctl->num_pages; offset = sizeof(u32) * io_ctl->num_pages;
......
...@@ -76,7 +76,6 @@ struct btrfs_io_ctl { ...@@ -76,7 +76,6 @@ struct btrfs_io_ctl {
int num_pages; int num_pages;
int entries; int entries;
int bitmaps; int bitmaps;
unsigned check_crcs:1;
}; };
struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group, struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment