Skip to content

Commit edea94a

Browse files
committed
cifs: Add mempools for cifs_io_request and cifs_io_subrequest structs
Add mempools for the allocation of cifs_io_request and cifs_io_subrequest structs for netfslib to use so that it can guarantee eventual allocation in writeback. Signed-off-by: David Howells <[email protected]> cc: Steve French <[email protected]> cc: Shyam Prasad N <[email protected]> cc: Rohith Surabattula <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected]
1 parent 3758c48 commit edea94a

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

fs/smb/client/cifsfs.c

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,13 @@ static struct kmem_cache *cifs_inode_cachep;
371371
static struct kmem_cache *cifs_req_cachep;
372372
static struct kmem_cache *cifs_mid_cachep;
373373
static struct kmem_cache *cifs_sm_req_cachep;
374+
static struct kmem_cache *cifs_io_request_cachep;
375+
static struct kmem_cache *cifs_io_subrequest_cachep;
374376
mempool_t *cifs_sm_req_poolp;
375377
mempool_t *cifs_req_poolp;
376378
mempool_t *cifs_mid_poolp;
379+
mempool_t cifs_io_request_pool;
380+
mempool_t cifs_io_subrequest_pool;
377381

378382
static struct inode *
379383
cifs_alloc_inode(struct super_block *sb)
@@ -1750,6 +1754,48 @@ static void destroy_mids(void)
17501754
kmem_cache_destroy(cifs_mid_cachep);
17511755
}
17521756

1757+
static int cifs_init_netfs(void)
1758+
{
1759+
cifs_io_request_cachep =
1760+
kmem_cache_create("cifs_io_request",
1761+
sizeof(struct netfs_io_request), 0,
1762+
SLAB_HWCACHE_ALIGN, NULL);
1763+
if (!cifs_io_request_cachep)
1764+
goto nomem_req;
1765+
1766+
if (mempool_init_slab_pool(&cifs_io_request_pool, 100, cifs_io_request_cachep) < 0)
1767+
goto nomem_reqpool;
1768+
1769+
cifs_io_subrequest_cachep =
1770+
kmem_cache_create("cifs_io_subrequest",
1771+
sizeof(struct cifs_io_subrequest), 0,
1772+
SLAB_HWCACHE_ALIGN, NULL);
1773+
if (!cifs_io_subrequest_cachep)
1774+
goto nomem_subreq;
1775+
1776+
if (mempool_init_slab_pool(&cifs_io_subrequest_pool, 100, cifs_io_subrequest_cachep) < 0)
1777+
goto nomem_subreqpool;
1778+
1779+
return 0;
1780+
1781+
nomem_subreqpool:
1782+
kmem_cache_destroy(cifs_io_subrequest_cachep);
1783+
nomem_subreq:
1784+
mempool_destroy(&cifs_io_request_pool);
1785+
nomem_reqpool:
1786+
kmem_cache_destroy(cifs_io_request_cachep);
1787+
nomem_req:
1788+
return -ENOMEM;
1789+
}
1790+
1791+
static void cifs_destroy_netfs(void)
1792+
{
1793+
mempool_destroy(&cifs_io_subrequest_pool);
1794+
kmem_cache_destroy(cifs_io_subrequest_cachep);
1795+
mempool_destroy(&cifs_io_request_pool);
1796+
kmem_cache_destroy(cifs_io_request_cachep);
1797+
}
1798+
17531799
static int __init
17541800
init_cifs(void)
17551801
{
@@ -1854,10 +1900,14 @@ init_cifs(void)
18541900
if (rc)
18551901
goto out_destroy_deferredclose_wq;
18561902

1857-
rc = init_mids();
1903+
rc = cifs_init_netfs();
18581904
if (rc)
18591905
goto out_destroy_inodecache;
18601906

1907+
rc = init_mids();
1908+
if (rc)
1909+
goto out_destroy_netfs;
1910+
18611911
rc = cifs_init_request_bufs();
18621912
if (rc)
18631913
goto out_destroy_mids;
@@ -1912,6 +1962,8 @@ init_cifs(void)
19121962
cifs_destroy_request_bufs();
19131963
out_destroy_mids:
19141964
destroy_mids();
1965+
out_destroy_netfs:
1966+
cifs_destroy_netfs();
19151967
out_destroy_inodecache:
19161968
cifs_destroy_inodecache();
19171969
out_destroy_deferredclose_wq:
@@ -1950,6 +2002,7 @@ exit_cifs(void)
19502002
#endif
19512003
cifs_destroy_request_bufs();
19522004
destroy_mids();
2005+
cifs_destroy_netfs();
19532006
cifs_destroy_inodecache();
19542007
destroy_workqueue(deferredclose_wq);
19552008
destroy_workqueue(cifsoplockd_wq);

fs/smb/client/cifsglob.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,8 @@ extern __u32 cifs_lock_secret;
20942094
extern mempool_t *cifs_sm_req_poolp;
20952095
extern mempool_t *cifs_req_poolp;
20962096
extern mempool_t *cifs_mid_poolp;
2097+
extern mempool_t cifs_io_request_pool;
2098+
extern mempool_t cifs_io_subrequest_pool;
20972099

20982100
/* Operations for different SMB versions */
20992101
#define SMB1_VERSION_STRING "1.0"

0 commit comments

Comments
 (0)