aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/kmem.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/kmem.h')
-rw-r--r--fs/xfs/kmem.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
index 3a7371cab508..64db0e53edea 100644
--- a/fs/xfs/kmem.h
+++ b/fs/xfs/kmem.h
@@ -32,6 +32,7 @@ typedef unsigned __bitwise xfs_km_flags_t;
32#define KM_NOSLEEP ((__force xfs_km_flags_t)0x0002u) 32#define KM_NOSLEEP ((__force xfs_km_flags_t)0x0002u)
33#define KM_NOFS ((__force xfs_km_flags_t)0x0004u) 33#define KM_NOFS ((__force xfs_km_flags_t)0x0004u)
34#define KM_MAYFAIL ((__force xfs_km_flags_t)0x0008u) 34#define KM_MAYFAIL ((__force xfs_km_flags_t)0x0008u)
35#define KM_ZERO ((__force xfs_km_flags_t)0x0010u)
35 36
36/* 37/*
37 * We use a special process flag to avoid recursive callbacks into 38 * We use a special process flag to avoid recursive callbacks into
@@ -43,7 +44,7 @@ kmem_flags_convert(xfs_km_flags_t flags)
43{ 44{
44 gfp_t lflags; 45 gfp_t lflags;
45 46
46 BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL)); 47 BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL|KM_ZERO));
47 48
48 if (flags & KM_NOSLEEP) { 49 if (flags & KM_NOSLEEP) {
49 lflags = GFP_ATOMIC | __GFP_NOWARN; 50 lflags = GFP_ATOMIC | __GFP_NOWARN;
@@ -52,11 +53,14 @@ kmem_flags_convert(xfs_km_flags_t flags)
52 if ((current->flags & PF_FSTRANS) || (flags & KM_NOFS)) 53 if ((current->flags & PF_FSTRANS) || (flags & KM_NOFS))
53 lflags &= ~__GFP_FS; 54 lflags &= ~__GFP_FS;
54 } 55 }
56
57 if (flags & KM_ZERO)
58 lflags |= __GFP_ZERO;
59
55 return lflags; 60 return lflags;
56} 61}
57 62
58extern void *kmem_alloc(size_t, xfs_km_flags_t); 63extern void *kmem_alloc(size_t, xfs_km_flags_t);
59extern void *kmem_zalloc(size_t, xfs_km_flags_t);
60extern void *kmem_zalloc_large(size_t size, xfs_km_flags_t); 64extern void *kmem_zalloc_large(size_t size, xfs_km_flags_t);
61extern void *kmem_realloc(const void *, size_t, size_t, xfs_km_flags_t); 65extern void *kmem_realloc(const void *, size_t, size_t, xfs_km_flags_t);
62extern void kmem_free(const void *); 66extern void kmem_free(const void *);
@@ -64,6 +68,12 @@ extern void kmem_free(const void *);
64 68
65extern void *kmem_zalloc_greedy(size_t *, size_t, size_t); 69extern void *kmem_zalloc_greedy(size_t *, size_t, size_t);
66 70
71static inline void *
72kmem_zalloc(size_t size, xfs_km_flags_t flags)
73{
74 return kmem_alloc(size, flags | KM_ZERO);
75}
76
67/* 77/*
68 * Zone interfaces 78 * Zone interfaces
69 */ 79 */
@@ -102,6 +112,11 @@ kmem_zone_destroy(kmem_zone_t *zone)
102} 112}
103 113
104extern void *kmem_zone_alloc(kmem_zone_t *, xfs_km_flags_t); 114extern void *kmem_zone_alloc(kmem_zone_t *, xfs_km_flags_t);
105extern void *kmem_zone_zalloc(kmem_zone_t *, xfs_km_flags_t); 115
116static inline void *
117kmem_zone_zalloc(kmem_zone_t *zone, xfs_km_flags_t flags)
118{
119 return kmem_zone_alloc(zone, flags | KM_ZERO);
120}
106 121
107#endif /* __XFS_SUPPORT_KMEM_H__ */ 122#endif /* __XFS_SUPPORT_KMEM_H__ */