aboutsummaryrefslogtreecommitdiffstats
path: root/fs/orangefs
diff options
context:
space:
mode:
authorMike Marshall <hubcap@omnibond.com>2016-02-04 13:48:16 -0500
committerMike Marshall <hubcap@omnibond.com>2016-02-04 13:48:16 -0500
commit2d4cae0d175acae2ea2efbc17b52b71d4ffd886d (patch)
tree754ff8b18dc325bf2e9c9b05a5e0d22d8683d640 /fs/orangefs
parent5090c9670de03511834bc894cfc9737e3d61a414 (diff)
Orangefs: clean up slab allocation.
A couple of caches were no longer needed: - iov_iter improvements to orangefs_devreq_write_iter eliminated the need for the dev_req_cache. - removal (months ago) of the old AIO code eliminated the need for the kiocb_cache. Also, deobfuscation of use of GFP_KERNEL when calling kmem_cache_(z)alloc for remaining caches. Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs/orangefs')
-rw-r--r--fs/orangefs/orangefs-cache.c92
-rw-r--r--fs/orangefs/orangefs-kernel.h15
-rw-r--r--fs/orangefs/orangefs-mod.c20
-rw-r--r--fs/orangefs/super.c3
4 files changed, 6 insertions, 124 deletions
diff --git a/fs/orangefs/orangefs-cache.c b/fs/orangefs/orangefs-cache.c
index e72ac2083ac0..3b3de91406ca 100644
--- a/fs/orangefs/orangefs-cache.c
+++ b/fs/orangefs/orangefs-cache.c
@@ -16,12 +16,6 @@ static DEFINE_SPINLOCK(next_tag_value_lock);
16/* a cache for orangefs upcall/downcall operations */ 16/* a cache for orangefs upcall/downcall operations */
17static struct kmem_cache *op_cache; 17static struct kmem_cache *op_cache;
18 18
19/* a cache for device (/dev/pvfs2-req) communication */
20static struct kmem_cache *dev_req_cache;
21
22/* a cache for orangefs_kiocb objects (i.e orangefs iocb structures ) */
23static struct kmem_cache *orangefs_kiocb_cache;
24
25int op_cache_initialize(void) 19int op_cache_initialize(void)
26{ 20{
27 op_cache = kmem_cache_create("orangefs_op_cache", 21 op_cache = kmem_cache_create("orangefs_op_cache",
@@ -111,7 +105,7 @@ struct orangefs_kernel_op_s *op_alloc(__s32 type)
111{ 105{
112 struct orangefs_kernel_op_s *new_op = NULL; 106 struct orangefs_kernel_op_s *new_op = NULL;
113 107
114 new_op = kmem_cache_zalloc(op_cache, ORANGEFS_CACHE_ALLOC_FLAGS); 108 new_op = kmem_cache_zalloc(op_cache, GFP_KERNEL);
115 if (new_op) { 109 if (new_op) {
116 INIT_LIST_HEAD(&new_op->list); 110 INIT_LIST_HEAD(&new_op->list);
117 spin_lock_init(&new_op->lock); 111 spin_lock_init(&new_op->lock);
@@ -148,7 +142,7 @@ struct orangefs_kernel_op_s *op_alloc(__s32 type)
148 new_op->upcall.gid = from_kgid(current_user_ns(), 142 new_op->upcall.gid = from_kgid(current_user_ns(),
149 current_fsgid()); 143 current_fsgid());
150 } else { 144 } else {
151 gossip_err("op_alloc: kmem_cache_alloc failed!\n"); 145 gossip_err("op_alloc: kmem_cache_zalloc failed!\n");
152 } 146 }
153 return new_op; 147 return new_op;
154} 148}
@@ -165,85 +159,3 @@ void __op_release(struct orangefs_kernel_op_s *orangefs_op)
165 gossip_err("NULL pointer in op_release\n"); 159 gossip_err("NULL pointer in op_release\n");
166 } 160 }
167} 161}
168
169int dev_req_cache_initialize(void)
170{
171 dev_req_cache = kmem_cache_create("orangefs_devreqcache",
172 MAX_DEV_REQ_DOWNSIZE,
173 0,
174 ORANGEFS_CACHE_CREATE_FLAGS,
175 NULL);
176
177 if (!dev_req_cache) {
178 gossip_err("Cannot create orangefs_dev_req_cache\n");
179 return -ENOMEM;
180 }
181 return 0;
182}
183
184int dev_req_cache_finalize(void)
185{
186 kmem_cache_destroy(dev_req_cache);
187 return 0;
188}
189
190void *dev_req_alloc(void)
191{
192 void *buffer;
193
194 buffer = kmem_cache_alloc(dev_req_cache, ORANGEFS_CACHE_ALLOC_FLAGS);
195 if (buffer == NULL)
196 gossip_err("Failed to allocate from dev_req_cache\n");
197 else
198 memset(buffer, 0, sizeof(MAX_DEV_REQ_DOWNSIZE));
199 return buffer;
200}
201
202void dev_req_release(void *buffer)
203{
204 if (buffer)
205 kmem_cache_free(dev_req_cache, buffer);
206 else
207 gossip_err("NULL pointer passed to dev_req_release\n");
208}
209
210int kiocb_cache_initialize(void)
211{
212 orangefs_kiocb_cache = kmem_cache_create("orangefs_kiocbcache",
213 sizeof(struct orangefs_kiocb_s),
214 0,
215 ORANGEFS_CACHE_CREATE_FLAGS,
216 NULL);
217
218 if (!orangefs_kiocb_cache) {
219 gossip_err("Cannot create orangefs_kiocb_cache!\n");
220 return -ENOMEM;
221 }
222 return 0;
223}
224
225int kiocb_cache_finalize(void)
226{
227 kmem_cache_destroy(orangefs_kiocb_cache);
228 return 0;
229}
230
231struct orangefs_kiocb_s *kiocb_alloc(void)
232{
233 struct orangefs_kiocb_s *x = NULL;
234
235 x = kmem_cache_alloc(orangefs_kiocb_cache, ORANGEFS_CACHE_ALLOC_FLAGS);
236 if (x == NULL)
237 gossip_err("kiocb_alloc: kmem_cache_alloc failed!\n");
238 else
239 memset(x, 0, sizeof(struct orangefs_kiocb_s));
240 return x;
241}
242
243void kiocb_release(struct orangefs_kiocb_s *x)
244{
245 if (x)
246 kmem_cache_free(orangefs_kiocb_cache, x);
247 else
248 gossip_err("kiocb_release: kmem_cache_free NULL pointer!\n");
249}
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 3e258554688d..d4db96223dac 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -128,7 +128,6 @@ struct client_debug_mask {
128#define ORANGEFS_CACHE_CREATE_FLAGS 0 128#define ORANGEFS_CACHE_CREATE_FLAGS 0
129#endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */ 129#endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */
130 130
131#define ORANGEFS_CACHE_ALLOC_FLAGS (GFP_KERNEL)
132#define ORANGEFS_GFP_FLAGS (GFP_KERNEL) 131#define ORANGEFS_GFP_FLAGS (GFP_KERNEL)
133#define ORANGEFS_BUFMAP_GFP_FLAGS (GFP_KERNEL) 132#define ORANGEFS_BUFMAP_GFP_FLAGS (GFP_KERNEL)
134 133
@@ -207,9 +206,6 @@ struct orangefs_kernel_op_s {
207 206
208 /* VFS aio fields */ 207 /* VFS aio fields */
209 208
210 /* used by the async I/O code to stash the orangefs_kiocb_s structure */
211 void *priv;
212
213 int attempts; 209 int attempts;
214 210
215 struct list_head list; 211 struct list_head list;
@@ -217,6 +213,7 @@ struct orangefs_kernel_op_s {
217 213
218#define set_op_state_waiting(op) ((op)->op_state = OP_VFS_STATE_WAITING) 214#define set_op_state_waiting(op) ((op)->op_state = OP_VFS_STATE_WAITING)
219#define set_op_state_inprogress(op) ((op)->op_state = OP_VFS_STATE_INPROGR) 215#define set_op_state_inprogress(op) ((op)->op_state = OP_VFS_STATE_INPROGR)
216#define set_op_state_given_up(op) ((op)->op_state = OP_VFS_STATE_GIVEN_UP)
220static inline void set_op_state_serviced(struct orangefs_kernel_op_s *op) 217static inline void set_op_state_serviced(struct orangefs_kernel_op_s *op)
221{ 218{
222 op->op_state = OP_VFS_STATE_SERVICED; 219 op->op_state = OP_VFS_STATE_SERVICED;
@@ -453,19 +450,9 @@ int op_cache_finalize(void);
453struct orangefs_kernel_op_s *op_alloc(__s32 type); 450struct orangefs_kernel_op_s *op_alloc(__s32 type);
454char *get_opname_string(struct orangefs_kernel_op_s *new_op); 451char *get_opname_string(struct orangefs_kernel_op_s *new_op);
455 452
456int dev_req_cache_initialize(void);
457int dev_req_cache_finalize(void);
458void *dev_req_alloc(void);
459void dev_req_release(void *);
460
461int orangefs_inode_cache_initialize(void); 453int orangefs_inode_cache_initialize(void);
462int orangefs_inode_cache_finalize(void); 454int orangefs_inode_cache_finalize(void);
463 455
464int kiocb_cache_initialize(void);
465int kiocb_cache_finalize(void);
466struct orangefs_kiocb_s *kiocb_alloc(void);
467void kiocb_release(struct orangefs_kiocb_s *ptr);
468
469/* 456/*
470 * defined in orangefs-mod.c 457 * defined in orangefs-mod.c
471 */ 458 */
diff --git a/fs/orangefs/orangefs-mod.c b/fs/orangefs/orangefs-mod.c
index e07874e26372..7639ab2df711 100644
--- a/fs/orangefs/orangefs-mod.c
+++ b/fs/orangefs/orangefs-mod.c
@@ -140,24 +140,16 @@ static int __init orangefs_init(void)
140 if (ret < 0) 140 if (ret < 0)
141 goto err; 141 goto err;
142 142
143 ret = dev_req_cache_initialize();
144 if (ret < 0)
145 goto cleanup_op;
146
147 ret = orangefs_inode_cache_initialize(); 143 ret = orangefs_inode_cache_initialize();
148 if (ret < 0) 144 if (ret < 0)
149 goto cleanup_req; 145 goto cleanup_op;
150
151 ret = kiocb_cache_initialize();
152 if (ret < 0)
153 goto cleanup_inode;
154 146
155 /* Initialize the orangefsdev subsystem. */ 147 /* Initialize the orangefsdev subsystem. */
156 ret = orangefs_dev_init(); 148 ret = orangefs_dev_init();
157 if (ret < 0) { 149 if (ret < 0) {
158 gossip_err("orangefs: could not initialize device subsystem %d!\n", 150 gossip_err("orangefs: could not initialize device subsystem %d!\n",
159 ret); 151 ret);
160 goto cleanup_kiocb; 152 goto cleanup_inode;
161 } 153 }
162 154
163 htable_ops_in_progress = 155 htable_ops_in_progress =
@@ -214,15 +206,9 @@ cleanup_progress_table:
214cleanup_device: 206cleanup_device:
215 orangefs_dev_cleanup(); 207 orangefs_dev_cleanup();
216 208
217cleanup_kiocb:
218 kiocb_cache_finalize();
219
220cleanup_inode: 209cleanup_inode:
221 orangefs_inode_cache_finalize(); 210 orangefs_inode_cache_finalize();
222 211
223cleanup_req:
224 dev_req_cache_finalize();
225
226cleanup_op: 212cleanup_op:
227 op_cache_finalize(); 213 op_cache_finalize();
228 214
@@ -247,9 +233,7 @@ static void __exit orangefs_exit(void)
247 for (i = 0; i < hash_table_size; i++) 233 for (i = 0; i < hash_table_size; i++)
248 BUG_ON(!list_empty(&htable_ops_in_progress[i])); 234 BUG_ON(!list_empty(&htable_ops_in_progress[i]));
249 235
250 kiocb_cache_finalize();
251 orangefs_inode_cache_finalize(); 236 orangefs_inode_cache_finalize();
252 dev_req_cache_finalize();
253 op_cache_finalize(); 237 op_cache_finalize();
254 238
255 kfree(htable_ops_in_progress); 239 kfree(htable_ops_in_progress);
diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
index a32981239ea6..93cc352be360 100644
--- a/fs/orangefs/super.c
+++ b/fs/orangefs/super.c
@@ -92,8 +92,7 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
92{ 92{
93 struct orangefs_inode_s *orangefs_inode; 93 struct orangefs_inode_s *orangefs_inode;
94 94
95 orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, 95 orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
96 ORANGEFS_CACHE_ALLOC_FLAGS);
97 if (orangefs_inode == NULL) { 96 if (orangefs_inode == NULL) {
98 gossip_err("Failed to allocate orangefs_inode\n"); 97 gossip_err("Failed to allocate orangefs_inode\n");
99 return NULL; 98 return NULL;