Skip to content

Commit 2d4cae0

Browse files
committed
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>
1 parent 5090c96 commit 2d4cae0

4 files changed

Lines changed: 6 additions & 124 deletions

File tree

‎fs/orangefs/orangefs-cache.c‎

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ static DEFINE_SPINLOCK(next_tag_value_lock);
1616
/* a cache for orangefs upcall/downcall operations */
1717
static struct kmem_cache *op_cache;
1818

19-
/* a cache for device (/dev/pvfs2-req) communication */
20-
static struct kmem_cache *dev_req_cache;
21-
22-
/* a cache for orangefs_kiocb objects (i.e orangefs iocb structures ) */
23-
static struct kmem_cache *orangefs_kiocb_cache;
24-
2519
int op_cache_initialize(void)
2620
{
2721
op_cache = kmem_cache_create("orangefs_op_cache",
@@ -111,7 +105,7 @@ struct orangefs_kernel_op_s *op_alloc(__s32 type)
111105
{
112106
struct orangefs_kernel_op_s *new_op = NULL;
113107

114-
new_op = kmem_cache_zalloc(op_cache, ORANGEFS_CACHE_ALLOC_FLAGS);
108+
new_op = kmem_cache_zalloc(op_cache, GFP_KERNEL);
115109
if (new_op) {
116110
INIT_LIST_HEAD(&new_op->list);
117111
spin_lock_init(&new_op->lock);
@@ -148,7 +142,7 @@ struct orangefs_kernel_op_s *op_alloc(__s32 type)
148142
new_op->upcall.gid = from_kgid(current_user_ns(),
149143
current_fsgid());
150144
} else {
151-
gossip_err("op_alloc: kmem_cache_alloc failed!\n");
145+
gossip_err("op_alloc: kmem_cache_zalloc failed!\n");
152146
}
153147
return new_op;
154148
}
@@ -165,85 +159,3 @@ void __op_release(struct orangefs_kernel_op_s *orangefs_op)
165159
gossip_err("NULL pointer in op_release\n");
166160
}
167161
}
168-
169-
int 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-
184-
int dev_req_cache_finalize(void)
185-
{
186-
kmem_cache_destroy(dev_req_cache);
187-
return 0;
188-
}
189-
190-
void *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-
202-
void 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-
210-
int 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-
225-
int kiocb_cache_finalize(void)
226-
{
227-
kmem_cache_destroy(orangefs_kiocb_cache);
228-
return 0;
229-
}
230-
231-
struct 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-
243-
void 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-
}

‎fs/orangefs/orangefs-kernel.h‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ struct client_debug_mask {
128128
#define ORANGEFS_CACHE_CREATE_FLAGS 0
129129
#endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */
130130

131-
#define ORANGEFS_CACHE_ALLOC_FLAGS (GFP_KERNEL)
132131
#define ORANGEFS_GFP_FLAGS (GFP_KERNEL)
133132
#define ORANGEFS_BUFMAP_GFP_FLAGS (GFP_KERNEL)
134133

@@ -207,16 +206,14 @@ struct orangefs_kernel_op_s {
207206

208207
/* VFS aio fields */
209208

210-
/* used by the async I/O code to stash the orangefs_kiocb_s structure */
211-
void *priv;
212-
213209
int attempts;
214210

215211
struct list_head list;
216212
};
217213

218214
#define set_op_state_waiting(op) ((op)->op_state = OP_VFS_STATE_WAITING)
219215
#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)
220217
static inline void set_op_state_serviced(struct orangefs_kernel_op_s *op)
221218
{
222219
op->op_state = OP_VFS_STATE_SERVICED;
@@ -453,19 +450,9 @@ int op_cache_finalize(void);
453450
struct orangefs_kernel_op_s *op_alloc(__s32 type);
454451
char *get_opname_string(struct orangefs_kernel_op_s *new_op);
455452

456-
int dev_req_cache_initialize(void);
457-
int dev_req_cache_finalize(void);
458-
void *dev_req_alloc(void);
459-
void dev_req_release(void *);
460-
461453
int orangefs_inode_cache_initialize(void);
462454
int orangefs_inode_cache_finalize(void);
463455

464-
int kiocb_cache_initialize(void);
465-
int kiocb_cache_finalize(void);
466-
struct orangefs_kiocb_s *kiocb_alloc(void);
467-
void kiocb_release(struct orangefs_kiocb_s *ptr);
468-
469456
/*
470457
* defined in orangefs-mod.c
471458
*/

‎fs/orangefs/orangefs-mod.c‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,16 @@ static int __init orangefs_init(void)
140140
if (ret < 0)
141141
goto err;
142142

143-
ret = dev_req_cache_initialize();
144-
if (ret < 0)
145-
goto cleanup_op;
146-
147143
ret = orangefs_inode_cache_initialize();
148144
if (ret < 0)
149-
goto cleanup_req;
150-
151-
ret = kiocb_cache_initialize();
152-
if (ret < 0)
153-
goto cleanup_inode;
145+
goto cleanup_op;
154146

155147
/* Initialize the orangefsdev subsystem. */
156148
ret = orangefs_dev_init();
157149
if (ret < 0) {
158150
gossip_err("orangefs: could not initialize device subsystem %d!\n",
159151
ret);
160-
goto cleanup_kiocb;
152+
goto cleanup_inode;
161153
}
162154

163155
htable_ops_in_progress =
@@ -214,15 +206,9 @@ static int __init orangefs_init(void)
214206
cleanup_device:
215207
orangefs_dev_cleanup();
216208

217-
cleanup_kiocb:
218-
kiocb_cache_finalize();
219-
220209
cleanup_inode:
221210
orangefs_inode_cache_finalize();
222211

223-
cleanup_req:
224-
dev_req_cache_finalize();
225-
226212
cleanup_op:
227213
op_cache_finalize();
228214

@@ -247,9 +233,7 @@ static void __exit orangefs_exit(void)
247233
for (i = 0; i < hash_table_size; i++)
248234
BUG_ON(!list_empty(&htable_ops_in_progress[i]));
249235

250-
kiocb_cache_finalize();
251236
orangefs_inode_cache_finalize();
252-
dev_req_cache_finalize();
253237
op_cache_finalize();
254238

255239
kfree(htable_ops_in_progress);

‎fs/orangefs/super.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
9292
{
9393
struct orangefs_inode_s *orangefs_inode;
9494

95-
orangefs_inode = kmem_cache_alloc(orangefs_inode_cache,
96-
ORANGEFS_CACHE_ALLOC_FLAGS);
95+
orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
9796
if (orangefs_inode == NULL) {
9897
gossip_err("Failed to allocate orangefs_inode\n");
9998
return NULL;

0 commit comments

Comments
 (0)