[PATCH 40/48] libxfs: change zone to cache for all kmem functions

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

 



From: Darrick J. Wong <djwong@xxxxxxxxxx>

Finish our zone->cache conversion by changing the field names and local
variables in kmem.[ch].

Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>
---
 include/kmem.h |    8 ++++----
 libxfs/init.c  |    6 +++---
 libxfs/kmem.c  |   40 ++++++++++++++++++++--------------------
 3 files changed, 27 insertions(+), 27 deletions(-)


diff --git a/include/kmem.h b/include/kmem.h
index 7aba4914..fd90a1bc 100644
--- a/include/kmem.h
+++ b/include/kmem.h
@@ -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);
 }
 
diff --git a/libxfs/init.c b/libxfs/init.c
index 1978a01f..b0be28e3 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -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);
diff --git a/libxfs/kmem.c b/libxfs/kmem.c
index a176a9d8..f4505696 100644
--- a/libxfs/kmem.c
+++ b/libxfs/kmem.c
@@ -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;
 }
 




[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