Commit 39ea3798 authored by Steve French's avatar Steve French Committed by Steve French

[CIFS] CIFS buffer management improvements part 1

Signed-off-by: Steve French (sfrench@us.ibm.com)
parent 5b3783d4
......@@ -207,6 +207,9 @@ static kmem_cache_t *cifs_inode_cachep;
static kmem_cache_t *cifs_req_cachep;
static kmem_cache_t *cifs_mid_cachep;
kmem_cache_t *cifs_oplock_cachep;
#ifdef CIFS_EXPERIMENTAL
mempool_t *cifs_sm_req_poolp;
#endif /* CIFS_EXPERIMENTAL */
mempool_t *cifs_req_poolp;
mempool_t *cifs_mid_poolp;
......@@ -604,6 +607,33 @@ cifs_init_request_bufs(void)
kmem_cache_destroy(cifs_req_cachep);
return -ENOMEM;
}
#ifdef CIFS_EXPERIMENTAL
/* 120 bytes is enough for most SMB responses and handle
based requests (but not write response, nor is it
sufficient for path based requests). 120 bytes is 83
more than sizeof(struct smb_hdr) and smaller than 128 byte
cutoff which should make it easy to alloc off the slab
compared to 17K (5page) alloc of large cifs buffers */
cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
120, 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
if (cifs_sm_req_cachep == NULL) {
mempool_destroy(cifs_req_poolp);
kmem_cache_destroy(cifs_req_cachep);
return -ENOMEM;
}
cifs_sm_req_poolp = mempool_create(64,
mempool_alloc_slab,
mempool_free_slab,
cifs_sm_req_cachep);
if(cifs_sm_req_poolp == NULL) {
mempool_destroy(cifs_req_poolp);
kmem_cache_destroy(cifs_req_cachep);
kmem_cache_destroy(cifs_sm_req_cachep);
return -ENOMEM;
}
#endif /* CIFS_EXPERIMENTAL */
return 0;
}
......@@ -615,6 +645,12 @@ cifs_destroy_request_bufs(void)
if (kmem_cache_destroy(cifs_req_cachep))
printk(KERN_WARNING
"cifs_destroy_request_cache: error not all structures were freed\n");
#ifdef CIFS_EXPERIMENTAL
mempool_destroy(cifs_sm_req_poolp);
if (kmem_cache_destroy(cifs_sm_req_cachep))
printk(KERN_WARNING
"cifs_destroy_request_cache: cifs_small_rq free error\n");
#endif /* CIFS_EXPERIMENTAL */
}
static int
......
......@@ -330,6 +330,7 @@ struct oplock_q_entry {
#define MID_RESPONSE_RECEIVED 4
#define MID_RETRY_NEEDED 8 /* session closed while this request out */
#define MID_NO_RESP_NEEDED 0x10
#define MID_SMALL_BUFFER 0x20 /* 120 byte response buffer instead of 4K */
/*
*****************************************************************
......
......@@ -33,7 +33,7 @@
Knowing this helps avoid response buffer allocations and copy in some cases */
#define SMB_COM_CREATE_DIRECTORY 0x00 /* trivial response */
#define SMB_COM_DELETE_DIRECTORY 0x01 /* trivial response */
#define SMB_COM_CLOSE 0x04 /* trivial rsp, timestamp ignored */
#define SMB_COM_CLOSE 0x04 /* triv req/rsp, timestamp ignored */
#define SMB_COM_DELETE 0x06 /* trivial response */
#define SMB_COM_RENAME 0x07 /* trivial response */
#define SMB_COM_LOCKING_ANDX 0x24 /* trivial response */
......
......@@ -507,7 +507,7 @@ cifs_kcalloc(size_t size, int type)
}
static int
cifs_parse_mount_options(char *options, const char *devname, struct smb_vol *vol)
cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
{
char *value;
char *data;
......
/*
* fs/cifs/misc.c
*
* Copyright (C) International Business Machines Corp., 2002,2003
* Copyright (C) International Business Machines Corp., 2002,2004
* Author(s): Steve French (sfrench@us.ibm.com)
*
* This library is free software; you can redistribute it and/or modify
......@@ -29,6 +29,9 @@
#include "smberr.h"
#include "nterr.h"
#ifdef CIFS_EXPERIMENTAL
extern mempool_t *cifs_sm_req_poolp;
#endif /* CIFS_EXPERIMENTAL */
extern mempool_t *cifs_req_poolp;
extern struct task_struct * oplockThread;
......@@ -160,8 +163,10 @@ cifs_buf_get(void)
(struct smb_hdr *) mempool_alloc(cifs_req_poolp, SLAB_KERNEL | SLAB_NOFS);
/* clear the first few header bytes */
/* clear through bcc + 1, making an even 40 bytes */
if (ret_buf) {
memset(ret_buf, 0, sizeof (struct smb_hdr));
memset(ret_buf, 0, sizeof(struct smb_hdr) + 3 );
atomic_inc(&bufAllocCount);
}
......@@ -182,6 +187,44 @@ cifs_buf_release(void *buf_to_free)
return;
}
#ifdef CIFS_EXPERIMENTAL
struct smb_hdr *
cifs_small_buf_get(void)
{
struct smb_hdr *ret_buf = NULL;
/* We could use negotiated size instead of max_msgsize -
but it may be more efficient to always alloc same size
albeit slightly larger than necessary and maxbuffersize
defaults to this and can not be bigger */
ret_buf =
(struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, SLAB_KERNEL | SLAB_NOFS);
/* clear the first few header bytes */
/* clear through bcc + 1, making an even 40 bytes */
if (ret_buf) {
memset(ret_buf, 0, sizeof(struct smb_hdr) + 3);
atomic_inc(&smBufAllocCount);
}
return ret_buf;
}
void
cifs_small_buf_release(void *buf_to_free)
{
if (buf_to_free == NULL) {
cFYI(1, ("Null buffer passed to cifs_small_buf_release"));
return;
}
mempool_free(buf_to_free,cifs_sm_req_poolp);
atomic_dec(&smBufAllocCount);
return;
}
#endif /* CIFS_EXPERIMENTAL */
void
header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
const struct cifsTconInfo *treeCon, int word_count
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment