read.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /*
  2. * linux/fs/nfs/read.c
  3. *
  4. * Block I/O for NFS
  5. *
  6. * Partial copy of Linus' read cache modifications to fs/nfs/file.c
  7. * modified for async RPC by okir@monad.swb.de
  8. */
  9. #include <linux/time.h>
  10. #include <linux/kernel.h>
  11. #include <linux/errno.h>
  12. #include <linux/fcntl.h>
  13. #include <linux/stat.h>
  14. #include <linux/mm.h>
  15. #include <linux/slab.h>
  16. #include <linux/pagemap.h>
  17. #include <linux/sunrpc/clnt.h>
  18. #include <linux/nfs_fs.h>
  19. #include <linux/nfs_page.h>
  20. #include <asm/system.h>
  21. #include "nfs4_fs.h"
  22. #include "internal.h"
  23. #include "iostat.h"
  24. #include "fscache.h"
  25. #define NFSDBG_FACILITY NFSDBG_PAGECACHE
  26. static int nfs_pagein_multi(struct inode *, struct list_head *, unsigned int, size_t, int);
  27. static int nfs_pagein_one(struct inode *, struct list_head *, unsigned int, size_t, int);
  28. static const struct rpc_call_ops nfs_read_partial_ops;
  29. static const struct rpc_call_ops nfs_read_full_ops;
  30. static struct kmem_cache *nfs_rdata_cachep;
  31. static mempool_t *nfs_rdata_mempool;
  32. #define MIN_POOL_READ (32)
  33. struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
  34. {
  35. struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_NOFS);
  36. if (p) {
  37. memset(p, 0, sizeof(*p));
  38. INIT_LIST_HEAD(&p->pages);
  39. p->npages = pagecount;
  40. p->res.seq_res.sr_slotid = NFS4_MAX_SLOT_TABLE;
  41. if (pagecount <= ARRAY_SIZE(p->page_array))
  42. p->pagevec = p->page_array;
  43. else {
  44. p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS);
  45. if (!p->pagevec) {
  46. mempool_free(p, nfs_rdata_mempool);
  47. p = NULL;
  48. }
  49. }
  50. }
  51. return p;
  52. }
  53. void nfs_readdata_free(struct nfs_read_data *p)
  54. {
  55. if (p && (p->pagevec != &p->page_array[0]))
  56. kfree(p->pagevec);
  57. mempool_free(p, nfs_rdata_mempool);
  58. }
  59. static void nfs_readdata_release(struct nfs_read_data *rdata)
  60. {
  61. put_nfs_open_context(rdata->args.context);
  62. nfs_readdata_free(rdata);
  63. }
  64. static
  65. int nfs_return_empty_page(struct page *page)
  66. {
  67. zero_user(page, 0, PAGE_CACHE_SIZE);
  68. SetPageUptodate(page);
  69. unlock_page(page);
  70. return 0;
  71. }
  72. static void nfs_readpage_truncate_uninitialised_page(struct nfs_read_data *data)
  73. {
  74. unsigned int remainder = data->args.count - data->res.count;
  75. unsigned int base = data->args.pgbase + data->res.count;
  76. unsigned int pglen;
  77. struct page **pages;
  78. if (data->res.eof == 0 || remainder == 0)
  79. return;
  80. /*
  81. * Note: "remainder" can never be negative, since we check for
  82. * this in the XDR code.
  83. */
  84. pages = &data->args.pages[base >> PAGE_CACHE_SHIFT];
  85. base &= ~PAGE_CACHE_MASK;
  86. pglen = PAGE_CACHE_SIZE - base;
  87. for (;;) {
  88. if (remainder <= pglen) {
  89. zero_user(*pages, base, remainder);
  90. break;
  91. }
  92. zero_user(*pages, base, pglen);
  93. pages++;
  94. remainder -= pglen;
  95. pglen = PAGE_CACHE_SIZE;
  96. base = 0;
  97. }
  98. }
  99. int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
  100. struct page *page)
  101. {
  102. LIST_HEAD(one_request);
  103. struct nfs_page *new;
  104. unsigned int len;
  105. len = nfs_page_length(page);
  106. if (len == 0)
  107. return nfs_return_empty_page(page);
  108. new = nfs_create_request(ctx, inode, page, 0, len);
  109. if (IS_ERR(new)) {
  110. unlock_page(page);
  111. return PTR_ERR(new);
  112. }
  113. if (len < PAGE_CACHE_SIZE)
  114. zero_user_segment(page, len, PAGE_CACHE_SIZE);
  115. nfs_list_add_request(new, &one_request);
  116. if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE)
  117. nfs_pagein_multi(inode, &one_request, 1, len, 0);
  118. else
  119. nfs_pagein_one(inode, &one_request, 1, len, 0);
  120. return 0;
  121. }
  122. static void nfs_readpage_release(struct nfs_page *req)
  123. {
  124. struct inode *d_inode = req->wb_context->path.dentry->d_inode;
  125. if (PageUptodate(req->wb_page))
  126. nfs_readpage_to_fscache(d_inode, req->wb_page, 0);
  127. unlock_page(req->wb_page);
  128. dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
  129. req->wb_context->path.dentry->d_inode->i_sb->s_id,
  130. (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
  131. req->wb_bytes,
  132. (long long)req_offset(req));
  133. nfs_clear_request(req);
  134. nfs_release_request(req);
  135. }
  136. /*
  137. * Set up the NFS read request struct
  138. */
  139. static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
  140. const struct rpc_call_ops *call_ops,
  141. unsigned int count, unsigned int offset)
  142. {
  143. struct inode *inode = req->wb_context->path.dentry->d_inode;
  144. int swap_flags = IS_SWAPFILE(inode) ? NFS_RPC_SWAPFLAGS : 0;
  145. struct rpc_task *task;
  146. struct rpc_message msg = {
  147. .rpc_argp = &data->args,
  148. .rpc_resp = &data->res,
  149. .rpc_cred = req->wb_context->cred,
  150. };
  151. struct rpc_task_setup task_setup_data = {
  152. .task = &data->task,
  153. .rpc_client = NFS_CLIENT(inode),
  154. .rpc_message = &msg,
  155. .callback_ops = call_ops,
  156. .callback_data = data,
  157. .workqueue = nfsiod_workqueue,
  158. .flags = RPC_TASK_ASYNC | swap_flags,
  159. };
  160. data->req = req;
  161. data->inode = inode;
  162. data->cred = msg.rpc_cred;
  163. data->args.fh = NFS_FH(inode);
  164. data->args.offset = req_offset(req) + offset;
  165. data->args.pgbase = req->wb_pgbase + offset;
  166. data->args.pages = data->pagevec;
  167. data->args.count = count;
  168. data->args.context = get_nfs_open_context(req->wb_context);
  169. data->res.fattr = &data->fattr;
  170. data->res.count = count;
  171. data->res.eof = 0;
  172. nfs_fattr_init(&data->fattr);
  173. /* Set up the initial task struct. */
  174. NFS_PROTO(inode)->read_setup(data, &msg);
  175. dprintk("NFS: %5u initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n",
  176. data->task.tk_pid,
  177. inode->i_sb->s_id,
  178. (long long)NFS_FILEID(inode),
  179. count,
  180. (unsigned long long)data->args.offset);
  181. task = rpc_run_task(&task_setup_data);
  182. if (IS_ERR(task))
  183. return PTR_ERR(task);
  184. rpc_put_task(task);
  185. return 0;
  186. }
  187. static void
  188. nfs_async_read_error(struct list_head *head)
  189. {
  190. struct nfs_page *req;
  191. while (!list_empty(head)) {
  192. req = nfs_list_entry(head->next);
  193. nfs_list_remove_request(req);
  194. SetPageError(req->wb_page);
  195. nfs_readpage_release(req);
  196. }
  197. }
  198. /*
  199. * Generate multiple requests to fill a single page.
  200. *
  201. * We optimize to reduce the number of read operations on the wire. If we
  202. * detect that we're reading a page, or an area of a page, that is past the
  203. * end of file, we do not generate NFS read operations but just clear the
  204. * parts of the page that would have come back zero from the server anyway.
  205. *
  206. * We rely on the cached value of i_size to make this determination; another
  207. * client can fill pages on the server past our cached end-of-file, but we
  208. * won't see the new data until our attribute cache is updated. This is more
  209. * or less conventional NFS client behavior.
  210. */
  211. static int nfs_pagein_multi(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int flags)
  212. {
  213. struct nfs_page *req = nfs_list_entry(head->next);
  214. struct page *page = req->wb_page;
  215. struct nfs_read_data *data;
  216. size_t rsize = NFS_SERVER(inode)->rsize, nbytes;
  217. unsigned int offset;
  218. int requests = 0;
  219. int ret = 0;
  220. LIST_HEAD(list);
  221. nfs_list_remove_request(req);
  222. nbytes = count;
  223. do {
  224. size_t len = min(nbytes,rsize);
  225. data = nfs_readdata_alloc(1);
  226. if (!data)
  227. goto out_bad;
  228. list_add(&data->pages, &list);
  229. requests++;
  230. nbytes -= len;
  231. } while(nbytes != 0);
  232. atomic_set(&req->wb_complete, requests);
  233. ClearPageError(page);
  234. offset = 0;
  235. nbytes = count;
  236. do {
  237. int ret2;
  238. data = list_entry(list.next, struct nfs_read_data, pages);
  239. list_del_init(&data->pages);
  240. data->pagevec[0] = page;
  241. if (nbytes < rsize)
  242. rsize = nbytes;
  243. ret2 = nfs_read_rpcsetup(req, data, &nfs_read_partial_ops,
  244. rsize, offset);
  245. if (ret == 0)
  246. ret = ret2;
  247. offset += rsize;
  248. nbytes -= rsize;
  249. } while (nbytes != 0);
  250. return ret;
  251. out_bad:
  252. while (!list_empty(&list)) {
  253. data = list_entry(list.next, struct nfs_read_data, pages);
  254. list_del(&data->pages);
  255. nfs_readdata_free(data);
  256. }
  257. SetPageError(page);
  258. nfs_readpage_release(req);
  259. return -ENOMEM;
  260. }
  261. static int nfs_pagein_one(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int flags)
  262. {
  263. struct nfs_page *req;
  264. struct page **pages;
  265. struct nfs_read_data *data;
  266. int ret = -ENOMEM;
  267. data = nfs_readdata_alloc(npages);
  268. if (!data)
  269. goto out_bad;
  270. pages = data->pagevec;
  271. while (!list_empty(head)) {
  272. req = nfs_list_entry(head->next);
  273. nfs_list_remove_request(req);
  274. nfs_list_add_request(req, &data->pages);
  275. ClearPageError(req->wb_page);
  276. *pages++ = req->wb_page;
  277. }
  278. req = nfs_list_entry(data->pages.next);
  279. return nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0);
  280. out_bad:
  281. nfs_async_read_error(head);
  282. return ret;
  283. }
  284. /*
  285. * This is the callback from RPC telling us whether a reply was
  286. * received or some error occurred (timeout or socket shutdown).
  287. */
  288. int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
  289. {
  290. int status;
  291. dprintk("NFS: %s: %5u, (status %d)\n", __func__, task->tk_pid,
  292. task->tk_status);
  293. status = NFS_PROTO(data->inode)->read_done(task, data);
  294. if (status != 0)
  295. return status;
  296. nfs_add_stats(data->inode, NFSIOS_SERVERREADBYTES, data->res.count);
  297. if (task->tk_status == -ESTALE) {
  298. set_bit(NFS_INO_STALE, &NFS_I(data->inode)->flags);
  299. nfs_mark_for_revalidate(data->inode);
  300. }
  301. return 0;
  302. }
  303. static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data)
  304. {
  305. struct nfs_readargs *argp = &data->args;
  306. struct nfs_readres *resp = &data->res;
  307. if (resp->eof || resp->count == argp->count)
  308. goto out;
  309. /* This is a short read! */
  310. nfs_inc_stats(data->inode, NFSIOS_SHORTREAD);
  311. /* Has the server at least made some progress? */
  312. if (resp->count == 0)
  313. goto out;
  314. /* Yes, so retry the read at the end of the data */
  315. argp->offset += resp->count;
  316. argp->pgbase += resp->count;
  317. argp->count -= resp->count;
  318. nfs4_restart_rpc(task, NFS_SERVER(data->inode)->nfs_client);
  319. return;
  320. out:
  321. nfs4_sequence_free_slot(NFS_SERVER(data->inode)->nfs_client,
  322. &data->res.seq_res);
  323. return;
  324. }
  325. /*
  326. * Handle a read reply that fills part of a page.
  327. */
  328. static void nfs_readpage_result_partial(struct rpc_task *task, void *calldata)
  329. {
  330. struct nfs_read_data *data = calldata;
  331. if (nfs_readpage_result(task, data) != 0)
  332. return;
  333. if (task->tk_status < 0)
  334. return;
  335. nfs_readpage_truncate_uninitialised_page(data);
  336. nfs_readpage_retry(task, data);
  337. }
  338. static void nfs_readpage_release_partial(void *calldata)
  339. {
  340. struct nfs_read_data *data = calldata;
  341. struct nfs_page *req = data->req;
  342. struct page *page = req->wb_page;
  343. int status = data->task.tk_status;
  344. if (status < 0)
  345. SetPageError(page);
  346. if (atomic_dec_and_test(&req->wb_complete)) {
  347. if (!PageError(page))
  348. SetPageUptodate(page);
  349. nfs_readpage_release(req);
  350. }
  351. nfs_readdata_release(calldata);
  352. }
  353. #if defined(CONFIG_NFS_V4_1)
  354. void nfs_read_prepare(struct rpc_task *task, void *calldata)
  355. {
  356. struct nfs_read_data *data = calldata;
  357. if (nfs4_setup_sequence(NFS_SERVER(data->inode)->nfs_client,
  358. &data->args.seq_args, &data->res.seq_res,
  359. 0, task))
  360. return;
  361. rpc_call_start(task);
  362. }
  363. #endif /* CONFIG_NFS_V4_1 */
  364. static const struct rpc_call_ops nfs_read_partial_ops = {
  365. #if defined(CONFIG_NFS_V4_1)
  366. .rpc_call_prepare = nfs_read_prepare,
  367. #endif /* CONFIG_NFS_V4_1 */
  368. .rpc_call_done = nfs_readpage_result_partial,
  369. .rpc_release = nfs_readpage_release_partial,
  370. };
  371. static void nfs_readpage_set_pages_uptodate(struct nfs_read_data *data)
  372. {
  373. unsigned int count = data->res.count;
  374. unsigned int base = data->args.pgbase;
  375. struct page **pages;
  376. if (data->res.eof)
  377. count = data->args.count;
  378. if (unlikely(count == 0))
  379. return;
  380. pages = &data->args.pages[base >> PAGE_CACHE_SHIFT];
  381. base &= ~PAGE_CACHE_MASK;
  382. count += base;
  383. for (;count >= PAGE_CACHE_SIZE; count -= PAGE_CACHE_SIZE, pages++)
  384. SetPageUptodate(*pages);
  385. if (count == 0)
  386. return;
  387. /* Was this a short read? */
  388. if (data->res.eof || data->res.count == data->args.count)
  389. SetPageUptodate(*pages);
  390. }
  391. /*
  392. * This is the callback from RPC telling us whether a reply was
  393. * received or some error occurred (timeout or socket shutdown).
  394. */
  395. static void nfs_readpage_result_full(struct rpc_task *task, void *calldata)
  396. {
  397. struct nfs_read_data *data = calldata;
  398. if (nfs_readpage_result(task, data) != 0)
  399. return;
  400. if (task->tk_status < 0)
  401. return;
  402. /*
  403. * Note: nfs_readpage_retry may change the values of
  404. * data->args. In the multi-page case, we therefore need
  405. * to ensure that we call nfs_readpage_set_pages_uptodate()
  406. * first.
  407. */
  408. nfs_readpage_truncate_uninitialised_page(data);
  409. nfs_readpage_set_pages_uptodate(data);
  410. nfs_readpage_retry(task, data);
  411. }
  412. static void nfs_readpage_release_full(void *calldata)
  413. {
  414. struct nfs_read_data *data = calldata;
  415. while (!list_empty(&data->pages)) {
  416. struct nfs_page *req = nfs_list_entry(data->pages.next);
  417. nfs_list_remove_request(req);
  418. nfs_readpage_release(req);
  419. }
  420. nfs_readdata_release(calldata);
  421. }
  422. static const struct rpc_call_ops nfs_read_full_ops = {
  423. #if defined(CONFIG_NFS_V4_1)
  424. .rpc_call_prepare = nfs_read_prepare,
  425. #endif /* CONFIG_NFS_V4_1 */
  426. .rpc_call_done = nfs_readpage_result_full,
  427. .rpc_release = nfs_readpage_release_full,
  428. };
  429. /*
  430. * Read a page over NFS.
  431. * We read the page synchronously in the following case:
  432. * - The error flag is set for this page. This happens only when a
  433. * previous async read operation failed.
  434. */
  435. int nfs_readpage(struct file *file, struct page *page)
  436. {
  437. struct nfs_open_context *ctx;
  438. struct inode *inode = page->mapping->host;
  439. int error;
  440. dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
  441. page, PAGE_CACHE_SIZE, page->index);
  442. nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
  443. nfs_add_stats(inode, NFSIOS_READPAGES, 1);
  444. /*
  445. * Try to flush any pending writes to the file..
  446. *
  447. * NOTE! Because we own the page lock, there cannot
  448. * be any new pending writes generated at this point
  449. * for this page (other pages can be written to).
  450. */
  451. error = nfs_wb_page(inode, page);
  452. if (error)
  453. goto out_unlock;
  454. if (PageUptodate(page))
  455. goto out_unlock;
  456. error = -ESTALE;
  457. if (NFS_STALE(inode))
  458. goto out_unlock;
  459. if (file == NULL) {
  460. error = -EBADF;
  461. ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
  462. if (ctx == NULL)
  463. goto out_unlock;
  464. } else
  465. ctx = get_nfs_open_context(nfs_file_open_context(file));
  466. if (!IS_SYNC(inode)) {
  467. error = nfs_readpage_from_fscache(ctx, inode, page);
  468. if (error == 0)
  469. goto out;
  470. }
  471. error = nfs_readpage_async(ctx, inode, page);
  472. out:
  473. put_nfs_open_context(ctx);
  474. return error;
  475. out_unlock:
  476. unlock_page(page);
  477. return error;
  478. }
  479. struct nfs_readdesc {
  480. struct nfs_pageio_descriptor *pgio;
  481. struct nfs_open_context *ctx;
  482. };
  483. static int
  484. readpage_async_filler(void *data, struct page *page)
  485. {
  486. struct nfs_readdesc *desc = (struct nfs_readdesc *)data;
  487. struct inode *inode = page->mapping->host;
  488. struct nfs_page *new;
  489. unsigned int len;
  490. int error;
  491. len = nfs_page_length(page);
  492. if (len == 0)
  493. return nfs_return_empty_page(page);
  494. new = nfs_create_request(desc->ctx, inode, page, 0, len);
  495. if (IS_ERR(new))
  496. goto out_error;
  497. if (len < PAGE_CACHE_SIZE)
  498. zero_user_segment(page, len, PAGE_CACHE_SIZE);
  499. if (!nfs_pageio_add_request(desc->pgio, new)) {
  500. error = desc->pgio->pg_error;
  501. goto out_unlock;
  502. }
  503. return 0;
  504. out_error:
  505. error = PTR_ERR(new);
  506. SetPageError(page);
  507. out_unlock:
  508. unlock_page(page);
  509. return error;
  510. }
  511. int nfs_readpages(struct file *filp, struct address_space *mapping,
  512. struct list_head *pages, unsigned nr_pages)
  513. {
  514. struct nfs_pageio_descriptor pgio;
  515. struct nfs_readdesc desc = {
  516. .pgio = &pgio,
  517. };
  518. struct inode *inode = mapping->host;
  519. struct nfs_server *server = NFS_SERVER(inode);
  520. size_t rsize = server->rsize;
  521. unsigned long npages;
  522. int ret = -ESTALE;
  523. dprintk("NFS: nfs_readpages (%s/%Ld %d)\n",
  524. inode->i_sb->s_id,
  525. (long long)NFS_FILEID(inode),
  526. nr_pages);
  527. nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);
  528. if (NFS_STALE(inode))
  529. goto out;
  530. if (filp == NULL) {
  531. desc.ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
  532. if (desc.ctx == NULL)
  533. return -EBADF;
  534. } else
  535. desc.ctx = get_nfs_open_context(nfs_file_open_context(filp));
  536. /* attempt to read as many of the pages as possible from the cache
  537. * - this returns -ENOBUFS immediately if the cookie is negative
  538. */
  539. ret = nfs_readpages_from_fscache(desc.ctx, inode, mapping,
  540. pages, &nr_pages);
  541. if (ret == 0)
  542. goto read_complete; /* all pages were read */
  543. if (rsize < PAGE_CACHE_SIZE)
  544. nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0);
  545. else
  546. nfs_pageio_init(&pgio, inode, nfs_pagein_one, rsize, 0);
  547. ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);
  548. nfs_pageio_complete(&pgio);
  549. npages = (pgio.pg_bytes_written + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
  550. nfs_add_stats(inode, NFSIOS_READPAGES, npages);
  551. read_complete:
  552. put_nfs_open_context(desc.ctx);
  553. out:
  554. return ret;
  555. }
  556. int __init nfs_init_readpagecache(void)
  557. {
  558. nfs_rdata_cachep = kmem_cache_create("nfs_read_data",
  559. sizeof(struct nfs_read_data),
  560. 0, SLAB_HWCACHE_ALIGN,
  561. NULL);
  562. if (nfs_rdata_cachep == NULL)
  563. return -ENOMEM;
  564. nfs_rdata_mempool = mempool_create_slab_pool(MIN_POOL_READ,
  565. nfs_rdata_cachep);
  566. if (nfs_rdata_mempool == NULL)
  567. return -ENOMEM;
  568. return 0;
  569. }
  570. void nfs_destroy_readpagecache(void)
  571. {
  572. mempool_destroy(nfs_rdata_mempool);
  573. kmem_cache_destroy(nfs_rdata_cachep);
  574. }