* [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations
@ 2022-10-13 10:36 fdmanana
2022-10-13 10:36 ` [PATCH 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: fdmanana @ 2022-10-13 10:36 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
We are still doing an atomic memory allocation for tree mod log operations
which is not needed anymore after we switch extent buffer locks to rw
semaphores. This replaces that atomic allocation with a GFP_NOFS one, and
then removes redundant gfp_t argument for btrfs_tree_mod_log_insert_key().
Filipe Manana (2):
btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys
btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key()
fs/btrfs/ctree.c | 16 ++++++++--------
fs/btrfs/tree-mod-log.c | 4 ++--
fs/btrfs/tree-mod-log.h | 2 +-
3 files changed, 11 insertions(+), 11 deletions(-)
--
2.35.1
^ permalink raw reply [flat|nested] 10+ messages in thread* [PATCH 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys 2022-10-13 10:36 [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations fdmanana @ 2022-10-13 10:36 ` fdmanana 2022-10-13 10:36 ` [PATCH 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fdmanana ` (2 subsequent siblings) 3 siblings, 0 replies; 10+ messages in thread From: fdmanana @ 2022-10-13 10:36 UTC (permalink / raw) To: linux-btrfs From: Filipe Manana <fdmanana@suse.com> When fixing up the first key of each node above the current level, at fixup_low_keys(), we are doing a GFP_ATOMIC allocation for inserting an operation record for the tree mod log. However we can do just fine with GFP_NOFS nowadays. The need for GFP_ATOMIC was for the old days when we had custom locks with spinning behaviour for extent buffers and we were in spinning mode while at fixup_low_keys(). Now we use rw semaphores for extent buffer locks, so we can safely use GFP_NOFS. Signed-off-by: Filipe Manana <fdmanana@suse.com> --- fs/btrfs/ctree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index b39b339fbf96..5d4add61f0a0 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2400,7 +2400,7 @@ static void fixup_low_keys(struct btrfs_path *path, break; t = path->nodes[i]; ret = btrfs_tree_mod_log_insert_key(t, tslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_ATOMIC); + BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); BUG_ON(ret < 0); btrfs_set_node_key(t, key, tslot); btrfs_mark_buffer_dirty(path->nodes[i]); -- 2.35.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() 2022-10-13 10:36 [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations fdmanana 2022-10-13 10:36 ` [PATCH 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana @ 2022-10-13 10:36 ` fdmanana 2022-10-14 13:30 ` David Sterba 2022-10-14 13:30 ` [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations David Sterba 2022-10-14 13:44 ` [PATCH v2 " fdmanana 3 siblings, 1 reply; 10+ messages in thread From: fdmanana @ 2022-10-13 10:36 UTC (permalink / raw) To: linux-btrfs From: Filipe Manana <fdmanana@suse.com> All callers of btrfs_tree_mod_log_insert_key() are now passing a GFP_NOFS gfp_t flag to it, so remove the flag and use it directly within the body of btrfs_tree_mod_log_insert_key(). Signed-off-by: Filipe Manana <fdmanana@suse.com> --- fs/btrfs/ctree.c | 16 ++++++++-------- fs/btrfs/tree-mod-log.c | 4 ++-- fs/btrfs/tree-mod-log.h | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 5d4add61f0a0..861ac12815b7 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -471,7 +471,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, } else { WARN_ON(trans->transid != btrfs_header_generation(parent)); btrfs_tree_mod_log_insert_key(parent, parent_slot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); btrfs_set_node_blockptr(parent, parent_slot, cow->start); btrfs_set_node_ptr_generation(parent, parent_slot, @@ -1000,7 +1000,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, struct btrfs_disk_key right_key; btrfs_node_key(right, &right_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &right_key, pslot + 1); btrfs_mark_buffer_dirty(parent); @@ -1046,7 +1046,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, struct btrfs_disk_key mid_key; btrfs_node_key(mid, &mid_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &mid_key, pslot); btrfs_mark_buffer_dirty(parent); @@ -1148,7 +1148,7 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans, orig_slot += left_nr; btrfs_node_key(mid, &disk_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &disk_key, pslot); btrfs_mark_buffer_dirty(parent); @@ -1202,7 +1202,7 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans, btrfs_node_key(right, &disk_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &disk_key, pslot + 1); btrfs_mark_buffer_dirty(parent); @@ -2400,7 +2400,7 @@ static void fixup_low_keys(struct btrfs_path *path, break; t = path->nodes[i]; ret = btrfs_tree_mod_log_insert_key(t, tslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(t, key, tslot); btrfs_mark_buffer_dirty(path->nodes[i]); @@ -2761,7 +2761,7 @@ static void insert_ptr(struct btrfs_trans_handle *trans, } if (level) { ret = btrfs_tree_mod_log_insert_key(lower, slot, - BTRFS_MOD_LOG_KEY_ADD, GFP_NOFS); + BTRFS_MOD_LOG_KEY_ADD); BUG_ON(ret < 0); } btrfs_set_node_key(lower, key, slot); @@ -4201,7 +4201,7 @@ static void del_ptr(struct btrfs_root *root, struct btrfs_path *path, (nritems - slot - 1)); } else if (level) { ret = btrfs_tree_mod_log_insert_key(parent, slot, - BTRFS_MOD_LOG_KEY_REMOVE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REMOVE); BUG_ON(ret < 0); } diff --git a/fs/btrfs/tree-mod-log.c b/fs/btrfs/tree-mod-log.c index 8a3a14686d3e..6606534fc36a 100644 --- a/fs/btrfs/tree-mod-log.c +++ b/fs/btrfs/tree-mod-log.c @@ -220,7 +220,7 @@ static struct tree_mod_elem *alloc_tree_mod_elem(struct extent_buffer *eb, } int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, - enum btrfs_mod_log_op op, gfp_t flags) + enum btrfs_mod_log_op op) { struct tree_mod_elem *tm; int ret; @@ -228,7 +228,7 @@ int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, if (!tree_mod_need_log(eb->fs_info, eb)) return 0; - tm = alloc_tree_mod_elem(eb, slot, op, flags); + tm = alloc_tree_mod_elem(eb, slot, op, GFP_NOFS); if (!tm) return -ENOMEM; diff --git a/fs/btrfs/tree-mod-log.h b/fs/btrfs/tree-mod-log.h index 12605d19621b..8cffe0bc2a39 100644 --- a/fs/btrfs/tree-mod-log.h +++ b/fs/btrfs/tree-mod-log.h @@ -32,7 +32,7 @@ int btrfs_tree_mod_log_insert_root(struct extent_buffer *old_root, struct extent_buffer *new_root, bool log_removal); int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, - enum btrfs_mod_log_op op, gfp_t flags); + enum btrfs_mod_log_op op); int btrfs_tree_mod_log_free_eb(struct extent_buffer *eb); struct extent_buffer *btrfs_tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path, -- 2.35.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() 2022-10-13 10:36 ` [PATCH 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fdmanana @ 2022-10-14 13:30 ` David Sterba 2022-10-14 13:47 ` Filipe Manana 0 siblings, 1 reply; 10+ messages in thread From: David Sterba @ 2022-10-14 13:30 UTC (permalink / raw) To: fdmanana; +Cc: linux-btrfs On Thu, Oct 13, 2022 at 11:36:26AM +0100, fdmanana@kernel.org wrote: >index 8a3a14686d3e..6606534fc36a 100644 > --- a/fs/btrfs/tree-mod-log.c > +++ b/fs/btrfs/tree-mod-log.c > @@ -220,7 +220,7 @@ static struct tree_mod_elem *alloc_tree_mod_elem(struct extent_buffer *eb, > } > > int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, > - enum btrfs_mod_log_op op, gfp_t flags) > + enum btrfs_mod_log_op op) > { > struct tree_mod_elem *tm; > int ret; > @@ -228,7 +228,7 @@ int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, > if (!tree_mod_need_log(eb->fs_info, eb)) > return 0; > > - tm = alloc_tree_mod_elem(eb, slot, op, flags); > + tm = alloc_tree_mod_elem(eb, slot, op, GFP_NOFS); And after that alloc_tree_mod_elem is also called only with GFP_NOFS. > if (!tm) > return -ENOMEM; > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() 2022-10-14 13:30 ` David Sterba @ 2022-10-14 13:47 ` Filipe Manana 0 siblings, 0 replies; 10+ messages in thread From: Filipe Manana @ 2022-10-14 13:47 UTC (permalink / raw) To: dsterba; +Cc: linux-btrfs On Fri, Oct 14, 2022 at 2:30 PM David Sterba <dsterba@suse.cz> wrote: > > On Thu, Oct 13, 2022 at 11:36:26AM +0100, fdmanana@kernel.org wrote: > >index 8a3a14686d3e..6606534fc36a 100644 > > --- a/fs/btrfs/tree-mod-log.c > > +++ b/fs/btrfs/tree-mod-log.c > > @@ -220,7 +220,7 @@ static struct tree_mod_elem *alloc_tree_mod_elem(struct extent_buffer *eb, > > } > > > > int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, > > - enum btrfs_mod_log_op op, gfp_t flags) > > + enum btrfs_mod_log_op op) > > { > > struct tree_mod_elem *tm; > > int ret; > > @@ -228,7 +228,7 @@ int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, > > if (!tree_mod_need_log(eb->fs_info, eb)) > > return 0; > > > > - tm = alloc_tree_mod_elem(eb, slot, op, flags); > > + tm = alloc_tree_mod_elem(eb, slot, op, GFP_NOFS); > > And after that alloc_tree_mod_elem is also called only with GFP_NOFS. Indeed. Just sent a v2 with that change as well. Thanks. > > > if (!tm) > > return -ENOMEM; > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations 2022-10-13 10:36 [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations fdmanana 2022-10-13 10:36 ` [PATCH 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana 2022-10-13 10:36 ` [PATCH 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fdmanana @ 2022-10-14 13:30 ` David Sterba 2022-10-14 13:44 ` [PATCH v2 " fdmanana 3 siblings, 0 replies; 10+ messages in thread From: David Sterba @ 2022-10-14 13:30 UTC (permalink / raw) To: fdmanana; +Cc: linux-btrfs On Thu, Oct 13, 2022 at 11:36:24AM +0100, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > We are still doing an atomic memory allocation for tree mod log operations > which is not needed anymore after we switch extent buffer locks to rw > semaphores. This replaces that atomic allocation with a GFP_NOFS one, and > then removes redundant gfp_t argument for btrfs_tree_mod_log_insert_key(). > > Filipe Manana (2): > btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys > btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() Added to misc-next, thanks. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations 2022-10-13 10:36 [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations fdmanana ` (2 preceding siblings ...) 2022-10-14 13:30 ` [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations David Sterba @ 2022-10-14 13:44 ` fdmanana 2022-10-14 13:44 ` [PATCH v2 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana ` (2 more replies) 3 siblings, 3 replies; 10+ messages in thread From: fdmanana @ 2022-10-14 13:44 UTC (permalink / raw) To: linux-btrfs From: Filipe Manana <fdmanana@suse.com> We are still doing an atomic memory allocation for tree mod log operations which is not needed anymore after we switch extent buffer locks to rw semaphores. This replaces that atomic allocation with a GFP_NOFS one, and then removes redundant gfp_t argument for btrfs_tree_mod_log_insert_key(). V2: Updated patch 2/2 to also remove the allocation flag from alloc_tree_mod_elem(). Filipe Manana (2): btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fs/btrfs/ctree.c | 16 ++++++++-------- fs/btrfs/tree-mod-log.c | 19 +++++++++---------- fs/btrfs/tree-mod-log.h | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) -- 2.35.1 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys 2022-10-14 13:44 ` [PATCH v2 " fdmanana @ 2022-10-14 13:44 ` fdmanana 2022-10-14 13:44 ` [PATCH v2 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fdmanana 2022-10-14 14:04 ` [PATCH v2 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations David Sterba 2 siblings, 0 replies; 10+ messages in thread From: fdmanana @ 2022-10-14 13:44 UTC (permalink / raw) To: linux-btrfs From: Filipe Manana <fdmanana@suse.com> When fixing up the first key of each node above the current level, at fixup_low_keys(), we are doing a GFP_ATOMIC allocation for inserting an operation record for the tree mod log. However we can do just fine with GFP_NOFS nowadays. The need for GFP_ATOMIC was for the old days when we had custom locks with spinning behaviour for extent buffers and we were in spinning mode while at fixup_low_keys(). Now we use rw semaphores for extent buffer locks, so we can safely use GFP_NOFS. Signed-off-by: Filipe Manana <fdmanana@suse.com> --- fs/btrfs/ctree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index b39b339fbf96..5d4add61f0a0 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2400,7 +2400,7 @@ static void fixup_low_keys(struct btrfs_path *path, break; t = path->nodes[i]; ret = btrfs_tree_mod_log_insert_key(t, tslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_ATOMIC); + BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); BUG_ON(ret < 0); btrfs_set_node_key(t, key, tslot); btrfs_mark_buffer_dirty(path->nodes[i]); -- 2.35.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() 2022-10-14 13:44 ` [PATCH v2 " fdmanana 2022-10-14 13:44 ` [PATCH v2 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana @ 2022-10-14 13:44 ` fdmanana 2022-10-14 14:04 ` [PATCH v2 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations David Sterba 2 siblings, 0 replies; 10+ messages in thread From: fdmanana @ 2022-10-14 13:44 UTC (permalink / raw) To: linux-btrfs From: Filipe Manana <fdmanana@suse.com> All callers of btrfs_tree_mod_log_insert_key() are now passing a GFP_NOFS flag to it, so remove the flag from it and from alloc_tree_mod_elem() and use it directly within alloc_tree_mod_elem(). Signed-off-by: Filipe Manana <fdmanana@suse.com> --- fs/btrfs/ctree.c | 16 ++++++++-------- fs/btrfs/tree-mod-log.c | 19 +++++++++---------- fs/btrfs/tree-mod-log.h | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 5d4add61f0a0..861ac12815b7 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -471,7 +471,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, } else { WARN_ON(trans->transid != btrfs_header_generation(parent)); btrfs_tree_mod_log_insert_key(parent, parent_slot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); btrfs_set_node_blockptr(parent, parent_slot, cow->start); btrfs_set_node_ptr_generation(parent, parent_slot, @@ -1000,7 +1000,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, struct btrfs_disk_key right_key; btrfs_node_key(right, &right_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &right_key, pslot + 1); btrfs_mark_buffer_dirty(parent); @@ -1046,7 +1046,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, struct btrfs_disk_key mid_key; btrfs_node_key(mid, &mid_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &mid_key, pslot); btrfs_mark_buffer_dirty(parent); @@ -1148,7 +1148,7 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans, orig_slot += left_nr; btrfs_node_key(mid, &disk_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &disk_key, pslot); btrfs_mark_buffer_dirty(parent); @@ -1202,7 +1202,7 @@ static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans, btrfs_node_key(right, &disk_key, 0); ret = btrfs_tree_mod_log_insert_key(parent, pslot + 1, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(parent, &disk_key, pslot + 1); btrfs_mark_buffer_dirty(parent); @@ -2400,7 +2400,7 @@ static void fixup_low_keys(struct btrfs_path *path, break; t = path->nodes[i]; ret = btrfs_tree_mod_log_insert_key(t, tslot, - BTRFS_MOD_LOG_KEY_REPLACE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REPLACE); BUG_ON(ret < 0); btrfs_set_node_key(t, key, tslot); btrfs_mark_buffer_dirty(path->nodes[i]); @@ -2761,7 +2761,7 @@ static void insert_ptr(struct btrfs_trans_handle *trans, } if (level) { ret = btrfs_tree_mod_log_insert_key(lower, slot, - BTRFS_MOD_LOG_KEY_ADD, GFP_NOFS); + BTRFS_MOD_LOG_KEY_ADD); BUG_ON(ret < 0); } btrfs_set_node_key(lower, key, slot); @@ -4201,7 +4201,7 @@ static void del_ptr(struct btrfs_root *root, struct btrfs_path *path, (nritems - slot - 1)); } else if (level) { ret = btrfs_tree_mod_log_insert_key(parent, slot, - BTRFS_MOD_LOG_KEY_REMOVE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REMOVE); BUG_ON(ret < 0); } diff --git a/fs/btrfs/tree-mod-log.c b/fs/btrfs/tree-mod-log.c index 8a3a14686d3e..18b4699bcb11 100644 --- a/fs/btrfs/tree-mod-log.c +++ b/fs/btrfs/tree-mod-log.c @@ -197,12 +197,11 @@ static inline bool tree_mod_need_log(const struct btrfs_fs_info *fs_info, static struct tree_mod_elem *alloc_tree_mod_elem(struct extent_buffer *eb, int slot, - enum btrfs_mod_log_op op, - gfp_t flags) + enum btrfs_mod_log_op op) { struct tree_mod_elem *tm; - tm = kzalloc(sizeof(*tm), flags); + tm = kzalloc(sizeof(*tm), GFP_NOFS); if (!tm) return NULL; @@ -220,7 +219,7 @@ static struct tree_mod_elem *alloc_tree_mod_elem(struct extent_buffer *eb, } int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, - enum btrfs_mod_log_op op, gfp_t flags) + enum btrfs_mod_log_op op) { struct tree_mod_elem *tm; int ret; @@ -228,7 +227,7 @@ int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, if (!tree_mod_need_log(eb->fs_info, eb)) return 0; - tm = alloc_tree_mod_elem(eb, slot, op, flags); + tm = alloc_tree_mod_elem(eb, slot, op); if (!tm) return -ENOMEM; @@ -276,7 +275,7 @@ int btrfs_tree_mod_log_insert_move(struct extent_buffer *eb, for (i = 0; i + dst_slot < src_slot && i < nr_items; i++) { tm_list[i] = alloc_tree_mod_elem(eb, i + dst_slot, - BTRFS_MOD_LOG_KEY_REMOVE_WHILE_MOVING, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REMOVE_WHILE_MOVING); if (!tm_list[i]) { ret = -ENOMEM; goto free_tms; @@ -364,7 +363,7 @@ int btrfs_tree_mod_log_insert_root(struct extent_buffer *old_root, } for (i = 0; i < nritems; i++) { tm_list[i] = alloc_tree_mod_elem(old_root, i, - BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING); if (!tm_list[i]) { ret = -ENOMEM; goto free_tms; @@ -502,14 +501,14 @@ int btrfs_tree_mod_log_eb_copy(struct extent_buffer *dst, tm_list_rem = tm_list + nr_items; for (i = 0; i < nr_items; i++) { tm_list_rem[i] = alloc_tree_mod_elem(src, i + src_offset, - BTRFS_MOD_LOG_KEY_REMOVE, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REMOVE); if (!tm_list_rem[i]) { ret = -ENOMEM; goto free_tms; } tm_list_add[i] = alloc_tree_mod_elem(dst, i + dst_offset, - BTRFS_MOD_LOG_KEY_ADD, GFP_NOFS); + BTRFS_MOD_LOG_KEY_ADD); if (!tm_list_add[i]) { ret = -ENOMEM; goto free_tms; @@ -564,7 +563,7 @@ int btrfs_tree_mod_log_free_eb(struct extent_buffer *eb) for (i = 0; i < nritems; i++) { tm_list[i] = alloc_tree_mod_elem(eb, i, - BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING, GFP_NOFS); + BTRFS_MOD_LOG_KEY_REMOVE_WHILE_FREEING); if (!tm_list[i]) { ret = -ENOMEM; goto free_tms; diff --git a/fs/btrfs/tree-mod-log.h b/fs/btrfs/tree-mod-log.h index 12605d19621b..8cffe0bc2a39 100644 --- a/fs/btrfs/tree-mod-log.h +++ b/fs/btrfs/tree-mod-log.h @@ -32,7 +32,7 @@ int btrfs_tree_mod_log_insert_root(struct extent_buffer *old_root, struct extent_buffer *new_root, bool log_removal); int btrfs_tree_mod_log_insert_key(struct extent_buffer *eb, int slot, - enum btrfs_mod_log_op op, gfp_t flags); + enum btrfs_mod_log_op op); int btrfs_tree_mod_log_free_eb(struct extent_buffer *eb); struct extent_buffer *btrfs_tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path, -- 2.35.1 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations 2022-10-14 13:44 ` [PATCH v2 " fdmanana 2022-10-14 13:44 ` [PATCH v2 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana 2022-10-14 13:44 ` [PATCH v2 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fdmanana @ 2022-10-14 14:04 ` David Sterba 2 siblings, 0 replies; 10+ messages in thread From: David Sterba @ 2022-10-14 14:04 UTC (permalink / raw) To: fdmanana; +Cc: linux-btrfs On Fri, Oct 14, 2022 at 02:44:31PM +0100, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > We are still doing an atomic memory allocation for tree mod log operations > which is not needed anymore after we switch extent buffer locks to rw > semaphores. This replaces that atomic allocation with a GFP_NOFS one, and > then removes redundant gfp_t argument for btrfs_tree_mod_log_insert_key(). > > V2: Updated patch 2/2 to also remove the allocation flag from > alloc_tree_mod_elem(). Updated to v2 in misc-next, thanks. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2022-10-14 14:09 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-10-13 10:36 [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations fdmanana 2022-10-13 10:36 ` [PATCH 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana 2022-10-13 10:36 ` [PATCH 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fdmanana 2022-10-14 13:30 ` David Sterba 2022-10-14 13:47 ` Filipe Manana 2022-10-14 13:30 ` [PATCH 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations David Sterba 2022-10-14 13:44 ` [PATCH v2 " fdmanana 2022-10-14 13:44 ` [PATCH v2 1/2] btrfs: switch GFP_ATOMIC to GFP_NOFS when fixing up low keys fdmanana 2022-10-14 13:44 ` [PATCH v2 2/2] btrfs: remove gfp_t flag from btrfs_tree_mod_log_insert_key() fdmanana 2022-10-14 14:04 ` [PATCH v2 0/2] btrfs: drop no longer needed atomic allocation for tree mod log operations David Sterba
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).