]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: change zone to cache for all kmem functions
authorDarrick J. Wong <djwong@kernel.org>
Thu, 6 Jan 2022 22:13:23 +0000 (14:13 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 20 Jan 2022 00:02:53 +0000 (16:02 -0800)
Finish our zone->cache conversion by changing the field names and local
variables in kmem.[ch].

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
include/kmem.h
libxfs/init.c
libxfs/kmem.c

index 7aba491460ea324ad98d107889889e0ecd541d68..fd90a1bc451a278d3ef514350c8880f8fa30b82d 100644 (file)
@@ -15,10 +15,10 @@ bool kmem_found_leaks(void);
 #define KM_NOLOCKDEP   0x0020u
 
 struct kmem_cache {
-       int             zone_unitsize;  /* Size in bytes of zone unit */
+       int             cache_unitsize; /* Size in bytes of cache unit */
        int             allocated;      /* debug: How many allocated? */
        unsigned int    align;
-       const char      *zone_name;     /* tag name */
+       const char      *cache_name;    /* tag name */
        void            (*ctor)(void *);
 };
 
@@ -40,9 +40,9 @@ extern void   *kmem_cache_alloc(struct kmem_cache *, gfp_t);
 extern void    *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
 
 static inline void
-kmem_cache_free(struct kmem_cache *zone, void *ptr)
+kmem_cache_free(struct kmem_cache *cache, void *ptr)
 {
-       zone->allocated--;
+       cache->allocated--;
        free(ptr);
 }
 
index 1978a01f4e551464564bb1bf6cca845c49e9f8fd..b0be28e3bbd83ce28b06b199c3793e71a7601136 100644 (file)
@@ -226,14 +226,14 @@ check_open(char *path, int flags, char **rawfile, char **blockfile)
 }
 
 /*
- * Initialize/destroy all of the zone allocators we use.
+ * Initialize/destroy all of the cache allocators we use.
  */
 static void
 init_caches(void)
 {
        int             error;
 
-       /* initialise zone allocation */
+       /* initialise cache allocation */
        xfs_buf_cache = kmem_cache_create("xfs_buffer",
                        sizeof(struct xfs_buf), 0, 0, NULL);
        xfs_inode_cache = kmem_cache_create("xfs_inode",
@@ -1028,7 +1028,7 @@ libxfs_destroy(
        kmem_start_leak_check();
        libxfs_close_devices(li);
 
-       /* Free everything from the buffer cache before freeing buffer zone */
+       /* Free everything from the buffer cache before freeing buffer cache */
        libxfs_bcache_purge();
        libxfs_bcache_free();
        cache_destroy(libxfs_bcache);
index a176a9d81f3fe9be3d0af29a97383b52e4660e6d..f4505696a31fd4ef03f082590f6cb286ec9cfe9b 100644 (file)
@@ -25,13 +25,13 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align,
        struct kmem_cache       *ptr = malloc(sizeof(struct kmem_cache));
 
        if (ptr == NULL) {
-               fprintf(stderr, _("%s: zone init failed (%s, %d bytes): %s\n"),
+               fprintf(stderr, _("%s: cache init failed (%s, %d bytes): %s\n"),
                        progname, name, (int)sizeof(struct kmem_cache),
                        strerror(errno));
                exit(1);
        }
-       ptr->zone_unitsize = size;
-       ptr->zone_name = name;
+       ptr->cache_unitsize = size;
+       ptr->cache_name = name;
        ptr->allocated = 0;
        ptr->align = align;
        ptr->ctor = ctor;
@@ -40,50 +40,50 @@ kmem_cache_create(const char *name, unsigned int size, unsigned int align,
 }
 
 void
-kmem_cache_destroy(struct kmem_cache *zone)
+kmem_cache_destroy(struct kmem_cache *cache)
 {
-       if (getenv("LIBXFS_LEAK_CHECK") && zone->allocated) {
+       if (getenv("LIBXFS_LEAK_CHECK") && cache->allocated) {
                leaked = true;
-               fprintf(stderr, "zone %s freed with %d items allocated\n",
-                               zone->zone_name, zone->allocated);
+               fprintf(stderr, "cache %s freed with %d items allocated\n",
+                               cache->cache_name, cache->allocated);
        }
-       free(zone);
+       free(cache);
 }
 
 void *
-kmem_cache_alloc(struct kmem_cache *zone, gfp_t flags)
+kmem_cache_alloc(struct kmem_cache *cache, gfp_t flags)
 {
        void    *ptr = NULL;
 
-       if (zone->align) {
+       if (cache->align) {
                int ret;
 
-               ret = posix_memalign(&ptr, zone->align, zone->zone_unitsize);
+               ret = posix_memalign(&ptr, cache->align, cache->cache_unitsize);
                if (ret)
                        errno = ret;
        } else {
-               ptr = malloc(zone->zone_unitsize);
+               ptr = malloc(cache->cache_unitsize);
        }
 
        if (ptr == NULL) {
-               fprintf(stderr, _("%s: zone alloc failed (%s, %d bytes): %s\n"),
-                       progname, zone->zone_name, zone->zone_unitsize,
+               fprintf(stderr, _("%s: cache alloc failed (%s, %d bytes): %s\n"),
+                       progname, cache->cache_name, cache->cache_unitsize,
                        strerror(errno));
                exit(1);
        }
 
-       if (zone->ctor)
-               zone->ctor(ptr);
-       zone->allocated++;
+       if (cache->ctor)
+               cache->ctor(ptr);
+       cache->allocated++;
        return ptr;
 }
 
 void *
-kmem_cache_zalloc(struct kmem_cache *zone, gfp_t flags)
+kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
 {
-       void    *ptr = kmem_cache_alloc(zone, flags);
+       void    *ptr = kmem_cache_alloc(cache, flags);
 
-       memset(ptr, 0, zone->zone_unitsize);
+       memset(ptr, 0, cache->cache_unitsize);
        return ptr;
 }