[PATCH] xfs: Use refcount_t instead of atomic_t for xmi_refcount

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use an API that resembles more the actual use of xmi_refcount.

Found by cocci:
    fs/xfs/xfs_exchmaps_item.c:57:5-24: WARNING: atomic_dec_and_test
variation before object free at line 58.

Fixes: 6c08f434bd33 ("xfs: introduce a file mapping exchange log intent item")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202412260634.uSDUNyYS-lkp@xxxxxxxxx/
Signed-off-by: Pei Xiao <xiaopei01@xxxxxxxxxx>
---
 fs/xfs/xfs_exchmaps_item.c | 6 +++---
 fs/xfs/xfs_exchmaps_item.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_exchmaps_item.c b/fs/xfs/xfs_exchmaps_item.c
index 264a121c5e16..5975a16c54e3 100644
--- a/fs/xfs/xfs_exchmaps_item.c
+++ b/fs/xfs/xfs_exchmaps_item.c
@@ -57,8 +57,8 @@ STATIC void
 xfs_xmi_release(
 	struct xfs_xmi_log_item	*xmi_lip)
 {
-	ASSERT(atomic_read(&xmi_lip->xmi_refcount) > 0);
-	if (atomic_dec_and_test(&xmi_lip->xmi_refcount)) {
+	ASSERT(refcount_read(&xmi_lip->xmi_refcount) > 0);
+	if (refcount_dec_and_test(&xmi_lip->xmi_refcount)) {
 		xfs_trans_ail_delete(&xmi_lip->xmi_item, 0);
 		xfs_xmi_item_free(xmi_lip);
 	}
@@ -138,7 +138,7 @@ xfs_xmi_init(
 
 	xfs_log_item_init(mp, &xmi_lip->xmi_item, XFS_LI_XMI, &xfs_xmi_item_ops);
 	xmi_lip->xmi_format.xmi_id = (uintptr_t)(void *)xmi_lip;
-	atomic_set(&xmi_lip->xmi_refcount, 2);
+	refcount_set(&xmi_lip->xmi_refcount, 2);
 
 	return xmi_lip;
 }
diff --git a/fs/xfs/xfs_exchmaps_item.h b/fs/xfs/xfs_exchmaps_item.h
index efa368d25d09..b8be3bca3155 100644
--- a/fs/xfs/xfs_exchmaps_item.h
+++ b/fs/xfs/xfs_exchmaps_item.h
@@ -38,7 +38,7 @@ struct kmem_cache;
  */
 struct xfs_xmi_log_item {
 	struct xfs_log_item		xmi_item;
-	atomic_t			xmi_refcount;
+	refcount_t			xmi_refcount;
 	struct xfs_xmi_log_format	xmi_format;
 };
 
-- 
2.25.1





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux