read.c 17 KB

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