]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: remove kmem_alloc, kmem_zalloc, and kmem_free
authorDarrick J. Wong <djwong@kernel.org>
Mon, 22 Apr 2024 17:01:15 +0000 (10:01 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 3 Jun 2024 18:37:41 +0000 (11:37 -0700)
Remove all three of these helpers now that the kernel has dropped them.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
db/bmap_inflate.c
include/kmem.h
libxfs/defer_item.c
libxfs/init.c
libxfs/kmem.c
libxlog/xfs_log_recover.c
repair/bmap_repair.c

index c85d5dc0d64a233f089e291e4cc8f64dd78103f5..00e1aff665678c463141d3de464704f8a627fffc 100644 (file)
@@ -327,7 +327,7 @@ out_resv_list:
        /* Leak any unused blocks */
        list_for_each_entry_safe(resv, n, &bd.resv_list, list) {
                list_del(&resv->list);
-               kmem_free(resv);
+               kfree(resv);
        }
        return error;
 }
index 6818a404728f81279544f54fed84aadc88fa7eca..386b4a6be783d115fb36b11c1501f72252cfde0a 100644 (file)
@@ -50,15 +50,7 @@ kmem_cache_free(struct kmem_cache *cache, void *ptr)
        free(ptr);
 }
 
-extern void    *kmem_alloc(size_t, int);
 extern void    *kvmalloc(size_t, gfp_t);
-extern void    *kmem_zalloc(size_t, int);
-
-static inline void
-kmem_free(const void *ptr) {
-       free((void *)ptr);
-}
-
 extern void    *krealloc(void *, size_t, int);
 
 static inline void *kmalloc(size_t size, gfp_t flags)
@@ -70,7 +62,7 @@ static inline void *kmalloc(size_t size, gfp_t flags)
 
 static inline void kfree(const void *ptr)
 {
-       return kmem_free(ptr);
+       free((void *)ptr);
 }
 
 #endif
index d67032c262007aca4f364a81ffac74bc77dcb036..680a72664746d2df443cf5fa190ec6a0a845bd0e 100644 (file)
@@ -606,7 +606,7 @@ xfs_attr_free_item(
        if (attr->xattri_da_state)
                xfs_da_state_free(attr->xattri_da_state);
        if (attr->xattri_da_args->op_flags & XFS_DA_OP_RECOVERY)
-               kmem_free(attr);
+               kfree(attr);
        else
                kmem_cache_free(xfs_attr_intent_cache, attr);
 }
index 82618a07e60eb102fa8b553ab5fe5a32d37e5fbf..de91bbf3ca266ac8b3479e8b046bee5f0c478946 100644 (file)
@@ -893,7 +893,7 @@ libxfs_buftarg_free(
        struct xfs_buftarg      *btp)
 {
        cache_destroy(btp->bcache);
-       kmem_free(btp);
+       kfree(btp);
 }
 
 /*
index c264be018bdc09d558aa78d39c92c24c405349c1..a2a3935d00e866f6aa26b7e624f75efb4f232ca0 100644 (file)
@@ -66,9 +66,14 @@ kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
 }
 
 void *
-kmem_alloc(size_t size, int flags)
+kvmalloc(size_t size, gfp_t flags)
 {
-       void    *ptr = malloc(size);
+       void    *ptr;
+
+       if (flags & __GFP_ZERO)
+               ptr = calloc(1, size);
+       else
+               ptr = malloc(size);
 
        if (ptr == NULL) {
                fprintf(stderr, _("%s: malloc failed (%d bytes): %s\n"),
@@ -78,23 +83,6 @@ kmem_alloc(size_t size, int flags)
        return ptr;
 }
 
-void *
-kvmalloc(size_t size, gfp_t flags)
-{
-       if (flags & __GFP_ZERO)
-               return kmem_zalloc(size, 0);
-       return kmem_alloc(size, 0);
-}
-
-void *
-kmem_zalloc(size_t size, int flags)
-{
-       void    *ptr = kmem_alloc(size, flags);
-
-       memset(ptr, 0, size);
-       return ptr;
-}
-
 void *
 krealloc(void *ptr, size_t new_size, int flags)
 {
index 99f759d5cb03570e53aa3f1304f3e7f20a72538b..31b11fee9e471530722aaf5c929312b5367e3fa7 100644 (file)
@@ -991,7 +991,7 @@ xlog_recover_new_tid(
 {
        struct xlog_recover     *trans;
 
-       trans = kmem_zalloc(sizeof(struct xlog_recover), 0);
+       trans = kzalloc(sizeof(struct xlog_recover), 0);
        trans->r_log_tid   = tid;
        trans->r_lsn       = lsn;
        INIT_LIST_HEAD(&trans->r_itemq);
@@ -1006,7 +1006,7 @@ xlog_recover_add_item(
 {
        struct xlog_recover_item *item;
 
-       item = kmem_zalloc(sizeof(struct xlog_recover_item), 0);
+       item = kzalloc(sizeof(struct xlog_recover_item), 0);
        INIT_LIST_HEAD(&item->ri_list);
        list_add_tail(&item->ri_list, head);
 }
@@ -1085,7 +1085,7 @@ xlog_recover_add_to_trans(
                return 0;
        }
 
-       ptr = kmem_alloc(len, 0);
+       ptr = kmalloc(len, 0);
        memcpy(ptr, dp, len);
        in_f = (struct xfs_inode_log_format *)ptr;
 
@@ -1107,13 +1107,12 @@ xlog_recover_add_to_trans(
                "bad number of regions (%d) in inode log format",
                                  in_f->ilf_size);
                        ASSERT(0);
-                       kmem_free(ptr);
+                       kfree(ptr);
                        return XFS_ERROR(EIO);
                }
 
                item->ri_total = in_f->ilf_size;
-               item->ri_buf =
-                       kmem_zalloc(item->ri_total * sizeof(xfs_log_iovec_t),
+               item->ri_buf = kzalloc(item->ri_total * sizeof(xfs_log_iovec_t),
                                    0);
        }
        ASSERT(item->ri_total > item->ri_cnt);
@@ -1141,13 +1140,13 @@ xlog_recover_free_trans(
                /* Free the regions in the item. */
                list_del(&item->ri_list);
                for (i = 0; i < item->ri_cnt; i++)
-                       kmem_free(item->ri_buf[i].i_addr);
+                       kfree(item->ri_buf[i].i_addr);
                /* Free the item itself */
-               kmem_free(item->ri_buf);
-               kmem_free(item);
+               kfree(item->ri_buf);
+               kfree(item);
        }
        /* Free the transaction recover structure */
-       kmem_free(trans);
+       kfree(trans);
 }
 
 /*
index 845584f18450716a735a0720224f47bb4e91f560..317061aa564f563f7baab0f72d041c2bcea12083 100644 (file)
@@ -595,7 +595,7 @@ xrep_bmap(
        if (error)
                return error;
 
-       rb = kmem_zalloc(sizeof(struct xrep_bmap), KM_NOFS | KM_MAYFAIL);
+       rb = kzalloc(sizeof(struct xrep_bmap), 0);
        if (!rb)
                return ENOMEM;
        rb->sc = sc;
@@ -622,7 +622,7 @@ xrep_bmap(
 out_bitmap:
        free_slab(&rb->bmap_records);
 out_rb:
-       kmem_free(rb);
+       kfree(rb);
        return error;
 }