* [PATCH 1/2] btrfs: Remove logic for !crc_check case
@ 2020-12-03 8:09 Nikolay Borisov
2020-12-03 8:09 ` [PATCH 2/2] btrfs: Always set NODATASUM/NODATACOW in __create_free_space_inode Nikolay Borisov
2020-12-03 16:33 ` [PATCH 1/2] btrfs: Remove logic for !crc_check case David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Borisov @ 2020-12-03 8:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
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 dependen on io_ctl::check_crc can be
removed.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
David,
Here are 2 patches that followup based on your feedback of the ino removal
feature, I have run a full xfstest run to validate them.
fs/btrfs/free-space-cache.c | 38 ++++++-------------------------------
fs/btrfs/free-space-cache.h | 1 -
2 files changed, 6 insertions(+), 33 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index cd5996350cf0..e83b3bdc4e46 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -364,16 +364,11 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
int write)
{
int num_pages;
- int check_crcs = 0;
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 */
- if (write && check_crcs &&
- (num_pages * sizeof(u32) + sizeof(u64)) > PAGE_SIZE)
+ if (write && (num_pages * sizeof(u32) + sizeof(u64)) > PAGE_SIZE)
return -ENOSPC;
memset(io_ctl, 0, sizeof(struct btrfs_io_ctl));
@@ -384,7 +379,6 @@ static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
io_ctl->num_pages = num_pages;
io_ctl->fs_info = btrfs_sb(inode->i_sb);
- io_ctl->check_crcs = check_crcs;
io_ctl->inode = inode;
return 0;
@@ -479,13 +473,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
* 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->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_pages);
- } else {
- io_ctl->cur += sizeof(u64);
- io_ctl->size -= sizeof(u64) * 2;
- }
+ io_ctl->cur += (sizeof(u32) * io_ctl->num_pages);
+ io_ctl->size -= sizeof(u64) + (sizeof(u32) * io_ctl->num_pages);
put_unaligned_le64(generation, io_ctl->cur);
io_ctl->cur += sizeof(u64);
@@ -499,14 +488,9 @@ 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
* chunk at the front of the first page.
*/
- if (io_ctl->check_crcs) {
- io_ctl->cur += 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;
- }
+ io_ctl->cur += sizeof(u32) * io_ctl->num_pages;
+ io_ctl->size -= sizeof(u64) +
+ (sizeof(u32) * io_ctl->num_pages);
cache_gen = get_unaligned_le64(io_ctl->cur);
if (cache_gen != generation) {
@@ -526,11 +510,6 @@ static void io_ctl_set_crc(struct btrfs_io_ctl *io_ctl, int index)
u32 crc = ~(u32)0;
unsigned offset = 0;
- if (!io_ctl->check_crcs) {
- io_ctl_unmap_page(io_ctl);
- return;
- }
-
if (index == 0)
offset = sizeof(u32) * io_ctl->num_pages;
@@ -548,11 +527,6 @@ static int io_ctl_check_crc(struct btrfs_io_ctl *io_ctl, int index)
u32 crc = ~(u32)0;
unsigned offset = 0;
- if (!io_ctl->check_crcs) {
- io_ctl_map_page(io_ctl, 0);
- return 0;
- }
-
if (index == 0)
offset = sizeof(u32) * io_ctl->num_pages;
diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h
index a65ed1967d5d..33687b0b8e7a 100644
--- a/fs/btrfs/free-space-cache.h
+++ b/fs/btrfs/free-space-cache.h
@@ -76,7 +76,6 @@ struct btrfs_io_ctl {
int num_pages;
int entries;
int bitmaps;
- unsigned check_crcs:1;
};
struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] btrfs: Always set NODATASUM/NODATACOW in __create_free_space_inode
2020-12-03 8:09 [PATCH 1/2] btrfs: Remove logic for !crc_check case Nikolay Borisov
@ 2020-12-03 8:09 ` Nikolay Borisov
2020-12-03 16:33 ` [PATCH 1/2] btrfs: Remove logic for !crc_check case David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2020-12-03 8:09 UTC (permalink / raw)
To: linux-btrfs; +Cc: Nikolay Borisov
Since it's being used solely for the freespace cache unconditionally
set the flags required for it.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/free-space-cache.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index e83b3bdc4e46..18112a63ea57 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -142,17 +142,15 @@ static int __create_free_space_inode(struct btrfs_root *root,
struct btrfs_free_space_header *header;
struct btrfs_inode_item *inode_item;
struct extent_buffer *leaf;
- u64 flags = BTRFS_INODE_NOCOMPRESS | BTRFS_INODE_PREALLOC;
+ /* We inline crc's for the free disk space cache */
+ u64 flags = BTRFS_INODE_NOCOMPRESS | BTRFS_INODE_PREALLOC |
+ BTRFS_INODE_NODATASUM | BTRFS_INODE_NODATACOW;
int ret;
ret = btrfs_insert_empty_inode(trans, root, path, ino);
if (ret)
return ret;
- /* We inline crc's for the free disk space cache */
- if (ino != BTRFS_FREE_INO_OBJECTID)
- flags |= BTRFS_INODE_NODATASUM | BTRFS_INODE_NODATACOW;
-
leaf = path->nodes[0];
inode_item = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_inode_item);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] btrfs: Remove logic for !crc_check case
2020-12-03 8:09 [PATCH 1/2] btrfs: Remove logic for !crc_check case Nikolay Borisov
2020-12-03 8:09 ` [PATCH 2/2] btrfs: Always set NODATASUM/NODATACOW in __create_free_space_inode Nikolay Borisov
@ 2020-12-03 16:33 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2020-12-03 16:33 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Thu, Dec 03, 2020 at 10:09:48AM +0200, Nikolay Borisov wrote:
> 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 dependen on io_ctl::check_crc can be
> removed.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> David,
>
> Here are 2 patches that followup based on your feedback of the ino removal
> feature, I have run a full xfstest run to validate them.
Thanks, added after the ino removal in misc-next.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-03 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-03 8:09 [PATCH 1/2] btrfs: Remove logic for !crc_check case Nikolay Borisov
2020-12-03 8:09 ` [PATCH 2/2] btrfs: Always set NODATASUM/NODATACOW in __create_free_space_inode Nikolay Borisov
2020-12-03 16:33 ` [PATCH 1/2] btrfs: Remove logic for !crc_check case David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox