read.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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. * We do an ugly hack here in order to return proper error codes to the
  10. * user program when a read request failed: since generic_file_read
  11. * only checks the return value of inode->i_op->readpage() which is always 0
  12. * for async RPC, we set the error bit of the page to 1 when an error occurs,
  13. * and make nfs_readpage transmit requests synchronously when encountering this.
  14. * This is only a small problem, though, since we now retry all operations
  15. * within the RPC code when root squashing is suspected.
  16. */
  17. #include <linux/config.h>
  18. #include <linux/time.h>
  19. #include <linux/kernel.h>
  20. #include <linux/errno.h>
  21. #include <linux/fcntl.h>
  22. #include <linux/stat.h>
  23. #include <linux/mm.h>
  24. #include <linux/slab.h>
  25. #include <linux/pagemap.h>
  26. #include <linux/sunrpc/clnt.h>
  27. #include <linux/nfs_fs.h>
  28. #include <linux/nfs_page.h>
  29. #include <linux/smp_lock.h>
  30. #include <asm/system.h>
  31. #include "iostat.h"
  32. #define NFSDBG_FACILITY NFSDBG_PAGECACHE
  33. static int nfs_pagein_one(struct list_head *, struct inode *);
  34. static const struct rpc_call_ops nfs_read_partial_ops;
  35. static const struct rpc_call_ops nfs_read_full_ops;
  36. static kmem_cache_t *nfs_rdata_cachep;
  37. static mempool_t *nfs_rdata_mempool;
  38. #define MIN_POOL_READ (32)
  39. struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
  40. {
  41. struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS);
  42. if (p) {
  43. memset(p, 0, sizeof(*p));
  44. INIT_LIST_HEAD(&p->pages);
  45. if (pagecount < NFS_PAGEVEC_SIZE)
  46. p->pagevec = &p->page_array[0];
  47. else {
  48. size_t size = ++pagecount * sizeof(struct page *);
  49. p->pagevec = kmalloc(size, GFP_NOFS);
  50. if (p->pagevec) {
  51. memset(p->pagevec, 0, size);
  52. } else {
  53. mempool_free(p, nfs_rdata_mempool);
  54. p = NULL;
  55. }
  56. }
  57. }
  58. return p;
  59. }
  60. void nfs_readdata_free(struct nfs_read_data *p)
  61. {
  62. if (p && (p->pagevec != &p->page_array[0]))
  63. kfree(p->pagevec);
  64. mempool_free(p, nfs_rdata_mempool);
  65. }
  66. void nfs_readdata_release(void *data)
  67. {
  68. nfs_readdata_free(data);
  69. }
  70. static
  71. unsigned int nfs_page_length(struct inode *inode, struct page *page)
  72. {
  73. loff_t i_size = i_size_read(inode);
  74. unsigned long idx;
  75. if (i_size <= 0)
  76. return 0;
  77. idx = (i_size - 1) >> PAGE_CACHE_SHIFT;
  78. if (page->index > idx)
  79. return 0;
  80. if (page->index != idx)
  81. return PAGE_CACHE_SIZE;
  82. return 1 + ((i_size - 1) & (PAGE_CACHE_SIZE - 1));
  83. }
  84. static
  85. int nfs_return_empty_page(struct page *page)
  86. {
  87. memclear_highpage_flush(page, 0, PAGE_CACHE_SIZE);
  88. SetPageUptodate(page);
  89. unlock_page(page);
  90. return 0;
  91. }
  92. /*
  93. * Read a page synchronously.
  94. */
  95. static int nfs_readpage_sync(struct nfs_open_context *ctx, struct inode *inode,
  96. struct page *page)
  97. {
  98. unsigned int rsize = NFS_SERVER(inode)->rsize;
  99. unsigned int count = PAGE_CACHE_SIZE;
  100. int result;
  101. struct nfs_read_data *rdata;
  102. rdata = nfs_readdata_alloc(1);
  103. if (!rdata)
  104. return -ENOMEM;
  105. memset(rdata, 0, sizeof(*rdata));
  106. rdata->flags = (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
  107. rdata->cred = ctx->cred;
  108. rdata->inode = inode;
  109. INIT_LIST_HEAD(&rdata->pages);
  110. rdata->args.fh = NFS_FH(inode);
  111. rdata->args.context = ctx;
  112. rdata->args.pages = &page;
  113. rdata->args.pgbase = 0UL;
  114. rdata->args.count = rsize;
  115. rdata->res.fattr = &rdata->fattr;
  116. dprintk("NFS: nfs_readpage_sync(%p)\n", page);
  117. /*
  118. * This works now because the socket layer never tries to DMA
  119. * into this buffer directly.
  120. */
  121. do {
  122. if (count < rsize)
  123. rdata->args.count = count;
  124. rdata->res.count = rdata->args.count;
  125. rdata->args.offset = page_offset(page) + rdata->args.pgbase;
  126. dprintk("NFS: nfs_proc_read(%s, (%s/%Ld), %Lu, %u)\n",
  127. NFS_SERVER(inode)->hostname,
  128. inode->i_sb->s_id,
  129. (long long)NFS_FILEID(inode),
  130. (unsigned long long)rdata->args.pgbase,
  131. rdata->args.count);
  132. lock_kernel();
  133. result = NFS_PROTO(inode)->read(rdata);
  134. unlock_kernel();
  135. /*
  136. * Even if we had a partial success we can't mark the page
  137. * cache valid.
  138. */
  139. if (result < 0) {
  140. if (result == -EISDIR)
  141. result = -EINVAL;
  142. goto io_error;
  143. }
  144. count -= result;
  145. rdata->args.pgbase += result;
  146. nfs_add_stats(inode, NFSIOS_SERVERREADBYTES, result);
  147. /* Note: result == 0 should only happen if we're caching
  148. * a write that extends the file and punches a hole.
  149. */
  150. if (rdata->res.eof != 0 || result == 0)
  151. break;
  152. } while (count);
  153. spin_lock(&inode->i_lock);
  154. NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
  155. spin_unlock(&inode->i_lock);
  156. if (count)
  157. memclear_highpage_flush(page, rdata->args.pgbase, count);
  158. SetPageUptodate(page);
  159. if (PageError(page))
  160. ClearPageError(page);
  161. result = 0;
  162. io_error:
  163. unlock_page(page);
  164. nfs_readdata_free(rdata);
  165. return result;
  166. }
  167. static int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
  168. struct page *page)
  169. {
  170. LIST_HEAD(one_request);
  171. struct nfs_page *new;
  172. unsigned int len;
  173. len = nfs_page_length(inode, page);
  174. if (len == 0)
  175. return nfs_return_empty_page(page);
  176. new = nfs_create_request(ctx, inode, page, 0, len);
  177. if (IS_ERR(new)) {
  178. unlock_page(page);
  179. return PTR_ERR(new);
  180. }
  181. if (len < PAGE_CACHE_SIZE)
  182. memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len);
  183. nfs_list_add_request(new, &one_request);
  184. nfs_pagein_one(&one_request, inode);
  185. return 0;
  186. }
  187. static void nfs_readpage_release(struct nfs_page *req)
  188. {
  189. unlock_page(req->wb_page);
  190. dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
  191. req->wb_context->dentry->d_inode->i_sb->s_id,
  192. (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
  193. req->wb_bytes,
  194. (long long)req_offset(req));
  195. nfs_clear_request(req);
  196. nfs_release_request(req);
  197. }
  198. /*
  199. * Set up the NFS read request struct
  200. */
  201. static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
  202. const struct rpc_call_ops *call_ops,
  203. unsigned int count, unsigned int offset)
  204. {
  205. struct inode *inode;
  206. int flags;
  207. data->req = req;
  208. data->inode = inode = req->wb_context->dentry->d_inode;
  209. data->cred = req->wb_context->cred;
  210. data->args.fh = NFS_FH(inode);
  211. data->args.offset = req_offset(req) + offset;
  212. data->args.pgbase = req->wb_pgbase + offset;
  213. data->args.pages = data->pagevec;
  214. data->args.count = count;
  215. data->args.context = req->wb_context;
  216. data->res.fattr = &data->fattr;
  217. data->res.count = count;
  218. data->res.eof = 0;
  219. nfs_fattr_init(&data->fattr);
  220. /* Set up the initial task struct. */
  221. flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
  222. rpc_init_task(&data->task, NFS_CLIENT(inode), flags, call_ops, data);
  223. NFS_PROTO(inode)->read_setup(data);
  224. data->task.tk_cookie = (unsigned long)inode;
  225. dprintk("NFS: %4d initiated read call (req %s/%Ld, %u bytes @ offset %Lu)\n",
  226. data->task.tk_pid,
  227. inode->i_sb->s_id,
  228. (long long)NFS_FILEID(inode),
  229. count,
  230. (unsigned long long)data->args.offset);
  231. }
  232. static void
  233. nfs_async_read_error(struct list_head *head)
  234. {
  235. struct nfs_page *req;
  236. while (!list_empty(head)) {
  237. req = nfs_list_entry(head->next);
  238. nfs_list_remove_request(req);
  239. SetPageError(req->wb_page);
  240. nfs_readpage_release(req);
  241. }
  242. }
  243. /*
  244. * Start an async read operation
  245. */
  246. static void nfs_execute_read(struct nfs_read_data *data)
  247. {
  248. struct rpc_clnt *clnt = NFS_CLIENT(data->inode);
  249. sigset_t oldset;
  250. rpc_clnt_sigmask(clnt, &oldset);
  251. lock_kernel();
  252. rpc_execute(&data->task);
  253. unlock_kernel();
  254. rpc_clnt_sigunmask(clnt, &oldset);
  255. }
  256. /*
  257. * Generate multiple requests to fill a single page.
  258. *
  259. * We optimize to reduce the number of read operations on the wire. If we
  260. * detect that we're reading a page, or an area of a page, that is past the
  261. * end of file, we do not generate NFS read operations but just clear the
  262. * parts of the page that would have come back zero from the server anyway.
  263. *
  264. * We rely on the cached value of i_size to make this determination; another
  265. * client can fill pages on the server past our cached end-of-file, but we
  266. * won't see the new data until our attribute cache is updated. This is more
  267. * or less conventional NFS client behavior.
  268. */
  269. static int nfs_pagein_multi(struct list_head *head, struct inode *inode)
  270. {
  271. struct nfs_page *req = nfs_list_entry(head->next);
  272. struct page *page = req->wb_page;
  273. struct nfs_read_data *data;
  274. unsigned int rsize = NFS_SERVER(inode)->rsize;
  275. unsigned int nbytes, offset;
  276. int requests = 0;
  277. LIST_HEAD(list);
  278. nfs_list_remove_request(req);
  279. nbytes = req->wb_bytes;
  280. for(;;) {
  281. data = nfs_readdata_alloc(1);
  282. if (!data)
  283. goto out_bad;
  284. INIT_LIST_HEAD(&data->pages);
  285. list_add(&data->pages, &list);
  286. requests++;
  287. if (nbytes <= rsize)
  288. break;
  289. nbytes -= rsize;
  290. }
  291. atomic_set(&req->wb_complete, requests);
  292. ClearPageError(page);
  293. offset = 0;
  294. nbytes = req->wb_bytes;
  295. do {
  296. data = list_entry(list.next, struct nfs_read_data, pages);
  297. list_del_init(&data->pages);
  298. data->pagevec[0] = page;
  299. if (nbytes > rsize) {
  300. nfs_read_rpcsetup(req, data, &nfs_read_partial_ops,
  301. rsize, offset);
  302. offset += rsize;
  303. nbytes -= rsize;
  304. } else {
  305. nfs_read_rpcsetup(req, data, &nfs_read_partial_ops,
  306. nbytes, offset);
  307. nbytes = 0;
  308. }
  309. nfs_execute_read(data);
  310. } while (nbytes != 0);
  311. return 0;
  312. out_bad:
  313. while (!list_empty(&list)) {
  314. data = list_entry(list.next, struct nfs_read_data, pages);
  315. list_del(&data->pages);
  316. nfs_readdata_free(data);
  317. }
  318. SetPageError(page);
  319. nfs_readpage_release(req);
  320. return -ENOMEM;
  321. }
  322. static int nfs_pagein_one(struct list_head *head, struct inode *inode)
  323. {
  324. struct nfs_page *req;
  325. struct page **pages;
  326. struct nfs_read_data *data;
  327. unsigned int count;
  328. if (NFS_SERVER(inode)->rsize < PAGE_CACHE_SIZE)
  329. return nfs_pagein_multi(head, inode);
  330. data = nfs_readdata_alloc(NFS_SERVER(inode)->rpages);
  331. if (!data)
  332. goto out_bad;
  333. INIT_LIST_HEAD(&data->pages);
  334. pages = data->pagevec;
  335. count = 0;
  336. while (!list_empty(head)) {
  337. req = nfs_list_entry(head->next);
  338. nfs_list_remove_request(req);
  339. nfs_list_add_request(req, &data->pages);
  340. ClearPageError(req->wb_page);
  341. *pages++ = req->wb_page;
  342. count += req->wb_bytes;
  343. }
  344. req = nfs_list_entry(data->pages.next);
  345. nfs_read_rpcsetup(req, data, &nfs_read_full_ops, count, 0);
  346. nfs_execute_read(data);
  347. return 0;
  348. out_bad:
  349. nfs_async_read_error(head);
  350. return -ENOMEM;
  351. }
  352. static int
  353. nfs_pagein_list(struct list_head *head, int rpages)
  354. {
  355. LIST_HEAD(one_request);
  356. struct nfs_page *req;
  357. int error = 0;
  358. unsigned int pages = 0;
  359. while (!list_empty(head)) {
  360. pages += nfs_coalesce_requests(head, &one_request, rpages);
  361. req = nfs_list_entry(one_request.next);
  362. error = nfs_pagein_one(&one_request, req->wb_context->dentry->d_inode);
  363. if (error < 0)
  364. break;
  365. }
  366. if (error >= 0)
  367. return pages;
  368. nfs_async_read_error(head);
  369. return error;
  370. }
  371. /*
  372. * Handle a read reply that fills part of a page.
  373. */
  374. static void nfs_readpage_result_partial(struct rpc_task *task, void *calldata)
  375. {
  376. struct nfs_read_data *data = calldata;
  377. struct nfs_page *req = data->req;
  378. struct page *page = req->wb_page;
  379. if (nfs_readpage_result(task, data) != 0)
  380. return;
  381. if (task->tk_status >= 0) {
  382. unsigned int request = data->args.count;
  383. unsigned int result = data->res.count;
  384. if (result < request) {
  385. memclear_highpage_flush(page,
  386. data->args.pgbase + result,
  387. request - result);
  388. }
  389. } else
  390. SetPageError(page);
  391. if (atomic_dec_and_test(&req->wb_complete)) {
  392. if (!PageError(page))
  393. SetPageUptodate(page);
  394. nfs_readpage_release(req);
  395. }
  396. }
  397. static const struct rpc_call_ops nfs_read_partial_ops = {
  398. .rpc_call_done = nfs_readpage_result_partial,
  399. .rpc_release = nfs_readdata_release,
  400. };
  401. /*
  402. * This is the callback from RPC telling us whether a reply was
  403. * received or some error occurred (timeout or socket shutdown).
  404. */
  405. static void nfs_readpage_result_full(struct rpc_task *task, void *calldata)
  406. {
  407. struct nfs_read_data *data = calldata;
  408. unsigned int count = data->res.count;
  409. if (nfs_readpage_result(task, data) != 0)
  410. return;
  411. while (!list_empty(&data->pages)) {
  412. struct nfs_page *req = nfs_list_entry(data->pages.next);
  413. struct page *page = req->wb_page;
  414. nfs_list_remove_request(req);
  415. if (task->tk_status >= 0) {
  416. if (count < PAGE_CACHE_SIZE) {
  417. if (count < req->wb_bytes)
  418. memclear_highpage_flush(page,
  419. req->wb_pgbase + count,
  420. req->wb_bytes - count);
  421. count = 0;
  422. } else
  423. count -= PAGE_CACHE_SIZE;
  424. SetPageUptodate(page);
  425. } else
  426. SetPageError(page);
  427. nfs_readpage_release(req);
  428. }
  429. }
  430. static const struct rpc_call_ops nfs_read_full_ops = {
  431. .rpc_call_done = nfs_readpage_result_full,
  432. .rpc_release = nfs_readdata_release,
  433. };
  434. /*
  435. * This is the callback from RPC telling us whether a reply was
  436. * received or some error occurred (timeout or socket shutdown).
  437. */
  438. int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data)
  439. {
  440. struct nfs_readargs *argp = &data->args;
  441. struct nfs_readres *resp = &data->res;
  442. int status;
  443. dprintk("NFS: %4d nfs_readpage_result, (status %d)\n",
  444. task->tk_pid, task->tk_status);
  445. status = NFS_PROTO(data->inode)->read_done(task, data);
  446. if (status != 0)
  447. return status;
  448. nfs_add_stats(data->inode, NFSIOS_SERVERREADBYTES, resp->count);
  449. /* Is this a short read? */
  450. if (task->tk_status >= 0 && resp->count < argp->count && !resp->eof) {
  451. nfs_inc_stats(data->inode, NFSIOS_SHORTREAD);
  452. /* Has the server at least made some progress? */
  453. if (resp->count != 0) {
  454. /* Yes, so retry the read at the end of the data */
  455. argp->offset += resp->count;
  456. argp->pgbase += resp->count;
  457. argp->count -= resp->count;
  458. rpc_restart_call(task);
  459. return -EAGAIN;
  460. }
  461. task->tk_status = -EIO;
  462. }
  463. spin_lock(&data->inode->i_lock);
  464. NFS_I(data->inode)->cache_validity |= NFS_INO_INVALID_ATIME;
  465. spin_unlock(&data->inode->i_lock);
  466. return 0;
  467. }
  468. /*
  469. * Read a page over NFS.
  470. * We read the page synchronously in the following case:
  471. * - The error flag is set for this page. This happens only when a
  472. * previous async read operation failed.
  473. */
  474. int nfs_readpage(struct file *file, struct page *page)
  475. {
  476. struct nfs_open_context *ctx;
  477. struct inode *inode = page->mapping->host;
  478. int error;
  479. dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
  480. page, PAGE_CACHE_SIZE, page->index);
  481. nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
  482. nfs_add_stats(inode, NFSIOS_READPAGES, 1);
  483. /*
  484. * Try to flush any pending writes to the file..
  485. *
  486. * NOTE! Because we own the page lock, there cannot
  487. * be any new pending writes generated at this point
  488. * for this page (other pages can be written to).
  489. */
  490. error = nfs_wb_page(inode, page);
  491. if (error)
  492. goto out_error;
  493. if (file == NULL) {
  494. ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
  495. if (ctx == NULL)
  496. return -EBADF;
  497. } else
  498. ctx = get_nfs_open_context((struct nfs_open_context *)
  499. file->private_data);
  500. if (!IS_SYNC(inode)) {
  501. error = nfs_readpage_async(ctx, inode, page);
  502. goto out;
  503. }
  504. error = nfs_readpage_sync(ctx, inode, page);
  505. if (error < 0 && IS_SWAPFILE(inode))
  506. printk("Aiee.. nfs swap-in of page failed!\n");
  507. out:
  508. put_nfs_open_context(ctx);
  509. return error;
  510. out_error:
  511. unlock_page(page);
  512. return error;
  513. }
  514. struct nfs_readdesc {
  515. struct list_head *head;
  516. struct nfs_open_context *ctx;
  517. };
  518. static int
  519. readpage_async_filler(void *data, struct page *page)
  520. {
  521. struct nfs_readdesc *desc = (struct nfs_readdesc *)data;
  522. struct inode *inode = page->mapping->host;
  523. struct nfs_page *new;
  524. unsigned int len;
  525. nfs_wb_page(inode, page);
  526. len = nfs_page_length(inode, page);
  527. if (len == 0)
  528. return nfs_return_empty_page(page);
  529. new = nfs_create_request(desc->ctx, inode, page, 0, len);
  530. if (IS_ERR(new)) {
  531. SetPageError(page);
  532. unlock_page(page);
  533. return PTR_ERR(new);
  534. }
  535. if (len < PAGE_CACHE_SIZE)
  536. memclear_highpage_flush(page, len, PAGE_CACHE_SIZE - len);
  537. nfs_list_add_request(new, desc->head);
  538. return 0;
  539. }
  540. int nfs_readpages(struct file *filp, struct address_space *mapping,
  541. struct list_head *pages, unsigned nr_pages)
  542. {
  543. LIST_HEAD(head);
  544. struct nfs_readdesc desc = {
  545. .head = &head,
  546. };
  547. struct inode *inode = mapping->host;
  548. struct nfs_server *server = NFS_SERVER(inode);
  549. int ret;
  550. dprintk("NFS: nfs_readpages (%s/%Ld %d)\n",
  551. inode->i_sb->s_id,
  552. (long long)NFS_FILEID(inode),
  553. nr_pages);
  554. nfs_inc_stats(inode, NFSIOS_VFSREADPAGES);
  555. if (filp == NULL) {
  556. desc.ctx = nfs_find_open_context(inode, NULL, FMODE_READ);
  557. if (desc.ctx == NULL)
  558. return -EBADF;
  559. } else
  560. desc.ctx = get_nfs_open_context((struct nfs_open_context *)
  561. filp->private_data);
  562. ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc);
  563. if (!list_empty(&head)) {
  564. int err = nfs_pagein_list(&head, server->rpages);
  565. if (!ret)
  566. nfs_add_stats(inode, NFSIOS_READPAGES, err);
  567. ret = err;
  568. }
  569. put_nfs_open_context(desc.ctx);
  570. return ret;
  571. }
  572. int nfs_init_readpagecache(void)
  573. {
  574. nfs_rdata_cachep = kmem_cache_create("nfs_read_data",
  575. sizeof(struct nfs_read_data),
  576. 0, SLAB_HWCACHE_ALIGN,
  577. NULL, NULL);
  578. if (nfs_rdata_cachep == NULL)
  579. return -ENOMEM;
  580. nfs_rdata_mempool = mempool_create_slab_pool(MIN_POOL_READ,
  581. nfs_rdata_cachep);
  582. if (nfs_rdata_mempool == NULL)
  583. return -ENOMEM;
  584. return 0;
  585. }
  586. void nfs_destroy_readpagecache(void)
  587. {
  588. mempool_destroy(nfs_rdata_mempool);
  589. if (kmem_cache_destroy(nfs_rdata_cachep))
  590. printk(KERN_INFO "nfs_read_data: not all structures were freed\n");
  591. }