xfs: kmalloc/kfree conversion fixes
cover xfs: kmalloc/kfree conversion fixes
Hi Chandan,
These two patches are fixes for the two recently reported issues with the kmem removal patchset. They've passes fstests and fsmark scalability tests with 64kB directory block size, should should have been exercising >64kB allocations through xlog_kvmalloc(). These should (eventuallly) trigger the vmalloc() path and so should exercise the vfree path through kvfree() instead of crashing...
-Dave.
PATCH 1/2 xfs: xfs_btree_bload_prep_block() should use __GFP_NOFAIL
From: Dave Chinner <[email protected]>
This was missed in the conversion from KM* flags.
--- fs/xfs/libxfs/xfs_btree_staging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_btree_staging.c +1 -1
@@ -406,7 +406,7 @@ xfs_btree_bload_prep_block(/* Allocate a new incore btree root block. */ new_size = bbl->iroot_size (cur, level, nr_this_block, priv); - ifp->if_broot =kzalloc (new_size,GFP_KERNEL ); + ifp->if_broot =kzalloc (new_size,GFP_KERNEL | __GFP_NOFAIL); ifp->if_broot_bytes = (int )new_size;/* Initialize it and send it out. */
Signature · 1 line
2.43.0
PATCH 2/2 xfs: use kvfree() in xlog_cil_free_logvec()
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The xfs_log_vec items are allocated by xlog_kvmalloc(), and so need to be freed with kvfree. This was missed when coverting from the kmem_free() API.
--- fs/xfs/xfs_log_cil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_log_cil.c +1 -1
@@ -877,7 +877,7 @@ xlog_cil_free_logvec(while (!list_empty (lv_chain)) { lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);list_del_init (&lv->lv_list); -kfree (lv); +kvfree (lv); } }
Signature · 1 line
2.43.0
Re: [PATCH 2/2] xfs: use kvfree() in xlog_cil_free_logvec()
Quoted 18 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The
xfs_log_vecitems are allocated byxlog_kvmalloc(), and so need to be freed with kvfree. This was missed when coverting from thekmem_free()API.Reported-by Chandan Babu R <[email protected]>Fixes 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()")Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/xfs_log_cil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_log_cil.c +0
-0
fs/xfs/xfs_log_cil.c xlog_cil_free_logvec( · line 880
Quoted 5 lines
fs/xfs/xfs_log_cil.c +1
-1@@ -877,7 +877,7 @@ xlog_cil_free_logvec(while (!list_empty (lv_chain)) { lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);list_del_init (&lv->lv_list); -kfree (lv); +kvfree (lv);
Is it necessary to s/kfree/kvfree/ in xlog_cil_process_intents when we free the xfs_log_vec that's attached to a xfs_log_item?
--D
Quoted 7 lines
fs/xfs/xfs_log_cil.c +0
-0} }Signature · 1 line
2.43.0
Re: [PATCH 1/2] xfs: xfs_btree_bload_prep_block() should use __GFP_NOFAIL
In reply to Dave ChinnerQuoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
This was missed in the conversion from KM* flags.
Reported-by Dan Carpenter <[email protected]>Fixes 10634530f7ba ("xfs: convert kmem_zalloc() to kzalloc()")Signed-off-by Dave Chinner <[email protected]>
Looks correct to me,
--D
Quoted 21 lines
--- fs/xfs/libxfs/xfs_btree_staging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/libxfs/xfs_btree_staging.c +1
-1@@ -406,7 +406,7 @@ xfs_btree_bload_prep_block(/* Allocate a new incore btree root block. */ new_size = bbl->iroot_size (cur, level, nr_this_block, priv); - ifp->if_broot =kzalloc (new_size,GFP_KERNEL ); + ifp->if_broot =kzalloc (new_size,GFP_KERNEL | __GFP_NOFAIL); ifp->if_broot_bytes = (int )new_size;/* Initialize it and send it out. */ Signature · 1 line
2.43.0
Re: [PATCH 2/2] xfs: use kvfree() in xlog_cil_free_logvec()
In reply to Darrick J. WongQuoted 14 lines · Darrick J. Wong
Quoted 13 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The
xfs_log_vecitems are allocated byxlog_kvmalloc(), and so need to be freed with kvfree. This was missed when coverting from thekmem_free()API.Reported-by Chandan Babu R <[email protected]>Fixes 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()")Signed-off-by Dave Chinner <[email protected]>--- fs/xfs/xfs_log_cil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
fs/xfs/xfs_log_cil.c xlog_cil_free_logvec( · line 880
Quoted 10 lines
fs/xfs/xfs_log_cil.c +1
-1@@ -877,7 +877,7 @@ xlog_cil_free_logvec(while (!list_empty (lv_chain)) { lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);list_del_init (&lv->lv_list); -kfree (lv); +kvfree (lv);Is it necessary to s/kfree/kvfree/ in
xlog_cil_process_intentswhen we free thexfs_log_vecthat's attached to axfs_log_item?
Yes, it should, even though intents are pretty much guaranteed to be small enough they will never use vmalloc.
Good catch.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
PATCH v2 2/2 xfs: use kvfree() in xlog_cil_free_logvec()
In reply to Darrick J. WongFrom: Dave Chinner <[email protected]>
The xfs_log_vec items are allocated by xlog_kvmalloc(), and so need to be freed with kvfree. This was missed when coverting from the kmem_free() API.
---
Version 2:
- also fix kfree() in xlog_cil_process_intents().
- checked that kvfree() is used for all lip->li_lv_shadow freeing calls.
fs/xfs/xfs_log_cil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_log_cil.c +2 -2
@@ -877,7 +877,7 @@ xlog_cil_free_logvec(while (!list_empty (lv_chain)) { lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);list_del_init (&lv->lv_list); -kfree (lv); +kvfree (lv); } }
@@ -1717,7 +1717,7 @@ xlog_cil_process_intents(set_bit (XFS_LI_WHITEOUT , &ilip->li_flags);trace_xfs_cil_whiteout_mark (ilip); len += ilip->li_lv->lv_bytes; -kfree (ilip->li_lv); +kvfree (ilip->li_lv); ilip->li_lv =NULL ;xfs_trans_del_item (lip);
Re: [PATCH v2 2/2] xfs: use kvfree() in xlog_cil_free_logvec()
Quoted 9 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The
xfs_log_vecitems are allocated byxlog_kvmalloc(), and so need to be freed with kvfree. This was missed when coverting from thekmem_free()API.Reported-by Chandan Babu R <[email protected]>Fixes 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()")Signed-off-by Dave Chinner <[email protected]>
Looks good to me, will run this one through fstestsclod overnight...
--D
Quoted 33 lines
---
Version 2:
- also fixkfree()inxlog_cil_process_intents().
- checked thatkvfree()is used for alllip->li_lv_shadowfreeing calls.fs/xfs/xfs_log_cil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/xfs/xfs_log_cil.c +2
-2@@ -877,7 +877,7 @@ xlog_cil_free_logvec(while (!list_empty (lv_chain)) { lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);list_del_init (&lv->lv_list); -kfree (lv); +kvfree (lv); } }@@ -1717,7 +1717,7 @@ xlog_cil_process_intents(set_bit (XFS_LI_WHITEOUT , &ilip->li_flags);trace_xfs_cil_whiteout_mark (ilip); len += ilip->li_lv->lv_bytes; -kfree (ilip->li_lv); +kvfree (ilip->li_lv); ilip->li_lv =NULL ;xfs_trans_del_item (lip);
Re: [PATCH v2 2/2] xfs: use kvfree() in xlog_cil_free_logvec()
In reply to Dave ChinnerQuoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The
xfs_log_vecitems are allocated byxlog_kvmalloc(), and so need to be freed with kvfree. This was missed when coverting from thekmem_free()API.Reported-by Chandan Babu R <[email protected]>
I have changed the Reported-by tag value to Darrick (since he reported it first) when applying the patches to my local Git tree.
Signature · 1 line
Chandan
Re: [PATCH 1/2] xfs: xfs_btree_bload_prep_block() should use __GFP_NOFAIL
In reply to Dave ChinnerLooks good:
Re: [PATCH v2 2/2] xfs: use kvfree() in xlog_cil_free_logvec()
In reply to Dave ChinnerLooks good:
Darrick J. Wong
Tested-byRe: [PATCH v2 2/2] xfs: use kvfree() in xlog_cil_free_logvec()
In reply to Darrick J. WongQuoted 7 lines · Darrick J. Wong
Quoted 6 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The
xfs_log_vecitems are allocated byxlog_kvmalloc(), and so need to be freed with kvfree. This was missed when coverting from thekmem_free()API.
Quoted 6 lines
Quoted 3 lines
Reported-by Chandan Babu R <[email protected]>Fixes 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()")Signed-off-by Dave Chinner <[email protected]>Looks good to me, will run this one through fstestsclod overnight...
Reviewed-by Darrick J. Wong <[email protected]>
FWIW I didn't see any further crashes after applying this patch, so:
--D
Quoted 36 lines
--D
Quoted 33 lines
---
Version 2:
- also fixkfree()inxlog_cil_process_intents().
- checked thatkvfree()is used for alllip->li_lv_shadowfreeing calls.fs/xfs/xfs_log_cil.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/xfs/xfs_log_cil.c +2
-2@@ -877,7 +877,7 @@ xlog_cil_free_logvec(while (!list_empty (lv_chain)) { lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);list_del_init (&lv->lv_list); -kfree (lv); +kvfree (lv); } }@@ -1717,7 +1717,7 @@ xlog_cil_process_intents(set_bit (XFS_LI_WHITEOUT , &ilip->li_flags);trace_xfs_cil_whiteout_mark (ilip); len += ilip->li_lv->lv_bytes; -kfree (ilip->li_lv); +kvfree (ilip->li_lv); ilip->li_lv =NULL ;xfs_trans_del_item (lip);