@@ -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;
}
@@ -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;
};
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@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202412260634.uSDUNyYS-lkp@intel.com/ Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> --- fs/xfs/xfs_exchmaps_item.c | 6 +++--- fs/xfs/xfs_exchmaps_item.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)