2 * linux/fs/nfs/direct.c
4 * Copyright (C) 2003 by Chuck Lever <cel@netapp.com>
6 * High-performance uncached I/O for the Linux NFS client
8 * There are important applications whose performance or correctness
9 * depends on uncached access to file data. Database clusters
10 * (multiple copies of the same instance running on separate hosts)
11 * implement their own cache coherency protocol that subsumes file
12 * system cache protocols. Applications that process datasets
13 * considerably larger than the client's memory do not always benefit
14 * from a local cache. A streaming video server, for instance, has no
15 * need to cache the contents of a file.
17 * When an application requests uncached I/O, all read and write requests
18 * are made directly to the server; data stored or fetched via these
19 * requests is not cached in the Linux page cache. The client does not
20 * correct unaligned requests from applications. All requested bytes are
21 * held on permanent storage before a direct write system call returns to
24 * Solaris implements an uncached I/O facility called directio() that
25 * is used for backups and sequential I/O to very large files. Solaris
26 * also supports uncaching whole NFS partitions with "-o forcedirectio,"
27 * an undocumented mount option.
29 * Designed by Jeff Kimmel, Chuck Lever, and Trond Myklebust, with
30 * help from Andrew Morton.
32 * 18 Dec 2001 Initial implementation for 2.4 --cel
33 * 08 Jul 2002 Version for 2.4.19, with bug fixes --trondmy
34 * 08 Jun 2003 Port to 2.5 APIs --cel
35 * 31 Mar 2004 Handle direct I/O without VFS support --cel
36 * 15 Sep 2004 Parallel async reads --cel
37 * 04 May 2005 support O_DIRECT with aio --cel
41 #include <linux/errno.h>
42 #include <linux/sched.h>
43 #include <linux/kernel.h>
44 #include <linux/smp_lock.h>
45 #include <linux/file.h>
46 #include <linux/pagemap.h>
47 #include <linux/kref.h>
49 #include <linux/nfs_fs.h>
50 #include <linux/nfs_page.h>
51 #include <linux/sunrpc/clnt.h>
53 #include <asm/system.h>
54 #include <asm/uaccess.h>
55 #include <asm/atomic.h>
59 #define NFSDBG_FACILITY NFSDBG_VFS
61 static kmem_cache_t *nfs_direct_cachep;
64 * This represents a set of asynchronous requests that we're waiting on
66 struct nfs_direct_req {
67 struct kref kref; /* release manager */
70 struct nfs_open_context *ctx; /* file open context info */
71 struct kiocb * iocb; /* controlling i/o request */
72 struct inode * inode; /* target file of i/o */
74 /* completion state */
75 atomic_t io_count; /* i/os we're waiting for */
76 spinlock_t lock; /* protect completion state */
77 ssize_t count, /* bytes actually processed */
78 error; /* any reported error */
79 struct completion completion; /* wait for i/o completion */
82 struct list_head rewrite_list; /* saved nfs_write_data structs */
83 struct nfs_write_data * commit_data; /* special write_data for commits */
85 #define NFS_ODIRECT_DO_COMMIT (1) /* an unstable reply was received */
86 #define NFS_ODIRECT_RESCHED_WRITES (2) /* write verification failed */
87 struct nfs_writeverf verf; /* unstable write verifier */
90 static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode);
91 static const struct rpc_call_ops nfs_write_direct_ops;
93 static inline void get_dreq(struct nfs_direct_req *dreq)
95 atomic_inc(&dreq->io_count);
98 static inline int put_dreq(struct nfs_direct_req *dreq)
100 return atomic_dec_and_test(&dreq->io_count);
104 * "size" is never larger than rsize or wsize.
106 static inline int nfs_direct_count_pages(unsigned long user_addr, size_t size)
110 page_count = (user_addr + size + PAGE_SIZE - 1) >> PAGE_SHIFT;
111 page_count -= user_addr >> PAGE_SHIFT;
112 BUG_ON(page_count < 0);
117 static inline unsigned int nfs_max_pages(unsigned int size)
119 return (size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
123 * nfs_direct_IO - NFS address space operation for direct I/O
124 * @rw: direction (read or write)
125 * @iocb: target I/O control block
126 * @iov: array of vectors that define I/O buffer
127 * @pos: offset in file to begin the operation
128 * @nr_segs: size of iovec array
130 * The presence of this routine in the address space ops vector means
131 * the NFS client supports direct I/O. However, we shunt off direct
132 * read and write requests before the VFS gets them, so this method
133 * should never be called.
135 ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t pos, unsigned long nr_segs)
137 dprintk("NFS: nfs_direct_IO (%s) off/no(%Ld/%lu) EINVAL\n",
138 iocb->ki_filp->f_dentry->d_name.name,
139 (long long) pos, nr_segs);
144 static void nfs_direct_dirty_pages(struct page **pages, int npages)
147 for (i = 0; i < npages; i++) {
148 struct page *page = pages[i];
149 if (!PageCompound(page))
150 set_page_dirty_lock(page);
154 static void nfs_direct_release_pages(struct page **pages, int npages)
157 for (i = 0; i < npages; i++)
158 page_cache_release(pages[i]);
161 static inline struct nfs_direct_req *nfs_direct_req_alloc(void)
163 struct nfs_direct_req *dreq;
165 dreq = kmem_cache_alloc(nfs_direct_cachep, SLAB_KERNEL);
169 kref_init(&dreq->kref);
170 kref_get(&dreq->kref);
171 init_completion(&dreq->completion);
172 INIT_LIST_HEAD(&dreq->rewrite_list);
175 spin_lock_init(&dreq->lock);
176 atomic_set(&dreq->io_count, 0);
184 static void nfs_direct_req_release(struct kref *kref)
186 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref);
188 if (dreq->ctx != NULL)
189 put_nfs_open_context(dreq->ctx);
190 kmem_cache_free(nfs_direct_cachep, dreq);
194 * Collects and returns the final error value/byte-count.
196 static ssize_t nfs_direct_wait(struct nfs_direct_req *dreq)
198 ssize_t result = -EIOCBQUEUED;
200 /* Async requests don't wait here */
204 result = wait_for_completion_interruptible(&dreq->completion);
207 result = dreq->error;
209 result = dreq->count;
212 kref_put(&dreq->kref, nfs_direct_req_release);
213 return (ssize_t) result;
217 * Synchronous I/O uses a stack-allocated iocb. Thus we can't trust
218 * the iocb is still valid here if this is a synchronous request.
220 static void nfs_direct_complete(struct nfs_direct_req *dreq)
223 long res = (long) dreq->error;
225 res = (long) dreq->count;
226 aio_complete(dreq->iocb, res, 0);
228 complete_all(&dreq->completion);
230 kref_put(&dreq->kref, nfs_direct_req_release);
234 * We must hold a reference to all the pages in this direct read request
235 * until the RPCs complete. This could be long *after* we are woken up in
236 * nfs_direct_wait (for instance, if someone hits ^C on a slow server).
238 static void nfs_direct_read_result(struct rpc_task *task, void *calldata)
240 struct nfs_read_data *data = calldata;
241 struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
243 if (nfs_readpage_result(task, data) != 0)
246 nfs_direct_dirty_pages(data->pagevec, data->npages);
247 nfs_direct_release_pages(data->pagevec, data->npages);
249 spin_lock(&dreq->lock);
251 if (likely(task->tk_status >= 0))
252 dreq->count += data->res.count;
254 dreq->error = task->tk_status;
256 spin_unlock(&dreq->lock);
259 nfs_direct_complete(dreq);
262 static const struct rpc_call_ops nfs_read_direct_ops = {
263 .rpc_call_done = nfs_direct_read_result,
264 .rpc_release = nfs_readdata_release,
268 * For each rsize'd chunk of the user's buffer, dispatch an NFS READ
269 * operation. If nfs_readdata_alloc() or get_user_pages() fails,
270 * bail and stop sending more reads. Read length accounting is
271 * handled automatically by nfs_direct_read_result(). Otherwise, if
272 * no requests have been sent, just return an error.
274 static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned long user_addr, size_t count, loff_t pos)
276 struct nfs_open_context *ctx = dreq->ctx;
277 struct inode *inode = ctx->dentry->d_inode;
278 size_t rsize = NFS_SERVER(inode)->rsize;
279 unsigned int rpages = nfs_max_pages(rsize);
286 pgbase = user_addr & ~PAGE_MASK;
288 struct nfs_read_data *data;
292 data = nfs_readdata_alloc(rpages);
300 data->npages = nfs_direct_count_pages(user_addr, bytes);
301 down_read(¤t->mm->mmap_sem);
302 result = get_user_pages(current, current->mm, user_addr,
303 data->npages, 1, 0, data->pagevec, NULL);
304 up_read(¤t->mm->mmap_sem);
305 if (unlikely(result < data->npages)) {
307 nfs_direct_release_pages(data->pagevec, result);
308 nfs_readdata_release(data);
314 data->req = (struct nfs_page *) dreq;
316 data->cred = ctx->cred;
317 data->args.fh = NFS_FH(inode);
318 data->args.context = ctx;
319 data->args.offset = pos;
320 data->args.pgbase = pgbase;
321 data->args.pages = data->pagevec;
322 data->args.count = bytes;
323 data->res.fattr = &data->fattr;
325 data->res.count = bytes;
327 rpc_init_task(&data->task, NFS_CLIENT(inode), RPC_TASK_ASYNC,
328 &nfs_read_direct_ops, data);
329 NFS_PROTO(inode)->read_setup(data);
331 data->task.tk_cookie = (unsigned long) inode;
334 rpc_execute(&data->task);
337 dfprintk(VFS, "NFS: %5u initiated direct read call (req %s/%Ld, %zu bytes @ offset %Lu)\n",
340 (long long)NFS_FILEID(inode),
342 (unsigned long long)data->args.offset);
348 pgbase &= ~PAGE_MASK;
351 } while (count != 0);
354 nfs_direct_complete(dreq);
358 return result < 0 ? (ssize_t) result : -EFAULT;
361 static ssize_t nfs_direct_read(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t pos)
365 struct inode *inode = iocb->ki_filp->f_mapping->host;
366 struct rpc_clnt *clnt = NFS_CLIENT(inode);
367 struct nfs_direct_req *dreq;
369 dreq = nfs_direct_req_alloc();
374 dreq->ctx = get_nfs_open_context((struct nfs_open_context *)iocb->ki_filp->private_data);
375 if (!is_sync_kiocb(iocb))
378 nfs_add_stats(inode, NFSIOS_DIRECTREADBYTES, count);
379 rpc_clnt_sigmask(clnt, &oldset);
380 result = nfs_direct_read_schedule(dreq, user_addr, count, pos);
382 result = nfs_direct_wait(dreq);
383 rpc_clnt_sigunmask(clnt, &oldset);
388 static void nfs_direct_free_writedata(struct nfs_direct_req *dreq)
390 while (!list_empty(&dreq->rewrite_list)) {
391 struct nfs_write_data *data = list_entry(dreq->rewrite_list.next, struct nfs_write_data, pages);
392 list_del(&data->pages);
393 nfs_direct_release_pages(data->pagevec, data->npages);
394 nfs_writedata_release(data);
398 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
399 static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
401 struct inode *inode = dreq->inode;
403 struct nfs_write_data *data;
408 list_for_each(p, &dreq->rewrite_list) {
409 data = list_entry(p, struct nfs_write_data, pages);
416 nfs_fattr_init(&data->fattr);
417 data->res.count = data->args.count;
418 memset(&data->verf, 0, sizeof(data->verf));
421 * Reuse data->task; data->args should not have changed
422 * since the original request was sent.
424 rpc_init_task(&data->task, NFS_CLIENT(inode), RPC_TASK_ASYNC,
425 &nfs_write_direct_ops, data);
426 NFS_PROTO(inode)->write_setup(data, FLUSH_STABLE);
428 data->task.tk_priority = RPC_PRIORITY_NORMAL;
429 data->task.tk_cookie = (unsigned long) inode;
432 * We're called via an RPC callback, so BKL is already held.
434 rpc_execute(&data->task);
436 dprintk("NFS: %5u rescheduled direct write call (req %s/%Ld, %u bytes @ offset %Lu)\n",
439 (long long)NFS_FILEID(inode),
441 (unsigned long long)data->args.offset);
445 nfs_direct_write_complete(dreq, inode);
448 static void nfs_direct_commit_result(struct rpc_task *task, void *calldata)
450 struct nfs_write_data *data = calldata;
451 struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
453 /* Call the NFS version-specific code */
454 if (NFS_PROTO(data->inode)->commit_done(task, data) != 0)
456 if (unlikely(task->tk_status < 0)) {
457 dreq->error = task->tk_status;
458 dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
460 if (memcmp(&dreq->verf, &data->verf, sizeof(data->verf))) {
461 dprintk("NFS: %5u commit verify failed\n", task->tk_pid);
462 dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
465 dprintk("NFS: %5u commit returned %d\n", task->tk_pid, task->tk_status);
466 nfs_direct_write_complete(dreq, data->inode);
469 static const struct rpc_call_ops nfs_commit_direct_ops = {
470 .rpc_call_done = nfs_direct_commit_result,
471 .rpc_release = nfs_commit_release,
474 static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
476 struct nfs_write_data *data = dreq->commit_data;
478 data->inode = dreq->inode;
479 data->cred = dreq->ctx->cred;
481 data->args.fh = NFS_FH(data->inode);
482 data->args.offset = 0;
483 data->args.count = 0;
485 data->res.fattr = &data->fattr;
486 data->res.verf = &data->verf;
488 rpc_init_task(&data->task, NFS_CLIENT(dreq->inode), RPC_TASK_ASYNC,
489 &nfs_commit_direct_ops, data);
490 NFS_PROTO(data->inode)->commit_setup(data, 0);
492 data->task.tk_priority = RPC_PRIORITY_NORMAL;
493 data->task.tk_cookie = (unsigned long)data->inode;
494 /* Note: task.tk_ops->rpc_release will free dreq->commit_data */
495 dreq->commit_data = NULL;
497 dprintk("NFS: %5u initiated commit call\n", data->task.tk_pid);
500 rpc_execute(&data->task);
504 static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode)
506 int flags = dreq->flags;
510 case NFS_ODIRECT_DO_COMMIT:
511 nfs_direct_commit_schedule(dreq);
513 case NFS_ODIRECT_RESCHED_WRITES:
514 nfs_direct_write_reschedule(dreq);
517 nfs_end_data_update(inode);
518 if (dreq->commit_data != NULL)
519 nfs_commit_free(dreq->commit_data);
520 nfs_direct_free_writedata(dreq);
521 nfs_direct_complete(dreq);
525 static void nfs_alloc_commit_data(struct nfs_direct_req *dreq)
527 dreq->commit_data = nfs_commit_alloc(0);
528 if (dreq->commit_data != NULL)
529 dreq->commit_data->req = (struct nfs_page *) dreq;
532 static inline void nfs_alloc_commit_data(struct nfs_direct_req *dreq)
534 dreq->commit_data = NULL;
537 static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode)
539 nfs_end_data_update(inode);
540 nfs_direct_free_writedata(dreq);
541 nfs_direct_complete(dreq);
545 static void nfs_direct_write_result(struct rpc_task *task, void *calldata)
547 struct nfs_write_data *data = calldata;
548 struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
549 int status = task->tk_status;
551 if (nfs_writeback_done(task, data) != 0)
554 spin_lock(&dreq->lock);
556 if (likely(status >= 0))
557 dreq->count += data->res.count;
559 dreq->error = task->tk_status;
561 if (data->res.verf->committed != NFS_FILE_SYNC) {
562 switch (dreq->flags) {
564 memcpy(&dreq->verf, &data->verf, sizeof(dreq->verf));
565 dreq->flags = NFS_ODIRECT_DO_COMMIT;
567 case NFS_ODIRECT_DO_COMMIT:
568 if (memcmp(&dreq->verf, &data->verf, sizeof(dreq->verf))) {
569 dprintk("NFS: %5u write verify failed\n", task->tk_pid);
570 dreq->flags = NFS_ODIRECT_RESCHED_WRITES;
575 spin_unlock(&dreq->lock);
579 * NB: Return the value of the first error return code. Subsequent
580 * errors after the first one are ignored.
582 static void nfs_direct_write_release(void *calldata)
584 struct nfs_write_data *data = calldata;
585 struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
588 nfs_direct_write_complete(dreq, data->inode);
591 static const struct rpc_call_ops nfs_write_direct_ops = {
592 .rpc_call_done = nfs_direct_write_result,
593 .rpc_release = nfs_direct_write_release,
597 * For each wsize'd chunk of the user's buffer, dispatch an NFS WRITE
598 * operation. If nfs_writedata_alloc() or get_user_pages() fails,
599 * bail and stop sending more writes. Write length accounting is
600 * handled automatically by nfs_direct_write_result(). Otherwise, if
601 * no requests have been sent, just return an error.
603 static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned long user_addr, size_t count, loff_t pos, int sync)
605 struct nfs_open_context *ctx = dreq->ctx;
606 struct inode *inode = ctx->dentry->d_inode;
607 size_t wsize = NFS_SERVER(inode)->wsize;
608 unsigned int wpages = nfs_max_pages(wsize);
615 pgbase = user_addr & ~PAGE_MASK;
617 struct nfs_write_data *data;
621 data = nfs_writedata_alloc(wpages);
629 data->npages = nfs_direct_count_pages(user_addr, bytes);
630 down_read(¤t->mm->mmap_sem);
631 result = get_user_pages(current, current->mm, user_addr,
632 data->npages, 0, 0, data->pagevec, NULL);
633 up_read(¤t->mm->mmap_sem);
634 if (unlikely(result < data->npages)) {
636 nfs_direct_release_pages(data->pagevec, result);
637 nfs_writedata_release(data);
643 list_move_tail(&data->pages, &dreq->rewrite_list);
645 data->req = (struct nfs_page *) dreq;
647 data->cred = ctx->cred;
648 data->args.fh = NFS_FH(inode);
649 data->args.context = ctx;
650 data->args.offset = pos;
651 data->args.pgbase = pgbase;
652 data->args.pages = data->pagevec;
653 data->args.count = bytes;
654 data->res.fattr = &data->fattr;
655 data->res.count = bytes;
656 data->res.verf = &data->verf;
658 rpc_init_task(&data->task, NFS_CLIENT(inode), RPC_TASK_ASYNC,
659 &nfs_write_direct_ops, data);
660 NFS_PROTO(inode)->write_setup(data, sync);
662 data->task.tk_priority = RPC_PRIORITY_NORMAL;
663 data->task.tk_cookie = (unsigned long) inode;
666 rpc_execute(&data->task);
669 dfprintk(VFS, "NFS: %5u initiated direct write call (req %s/%Ld, %zu bytes @ offset %Lu)\n",
672 (long long)NFS_FILEID(inode),
674 (unsigned long long)data->args.offset);
680 pgbase &= ~PAGE_MASK;
683 } while (count != 0);
686 nfs_direct_write_complete(dreq, inode);
690 return result < 0 ? (ssize_t) result : -EFAULT;
693 static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, size_t count, loff_t pos)
697 struct inode *inode = iocb->ki_filp->f_mapping->host;
698 struct rpc_clnt *clnt = NFS_CLIENT(inode);
699 struct nfs_direct_req *dreq;
700 size_t wsize = NFS_SERVER(inode)->wsize;
703 dreq = nfs_direct_req_alloc();
706 nfs_alloc_commit_data(dreq);
708 if (dreq->commit_data == NULL || count < wsize)
712 dreq->ctx = get_nfs_open_context((struct nfs_open_context *)iocb->ki_filp->private_data);
713 if (!is_sync_kiocb(iocb))
716 nfs_add_stats(inode, NFSIOS_DIRECTWRITTENBYTES, count);
718 nfs_begin_data_update(inode);
720 rpc_clnt_sigmask(clnt, &oldset);
721 result = nfs_direct_write_schedule(dreq, user_addr, count, pos, sync);
723 result = nfs_direct_wait(dreq);
724 rpc_clnt_sigunmask(clnt, &oldset);
730 * nfs_file_direct_read - file direct read operation for NFS files
731 * @iocb: target I/O control block
732 * @buf: user's buffer into which to read data
733 * @count: number of bytes to read
734 * @pos: byte offset in file where reading starts
736 * We use this function for direct reads instead of calling
737 * generic_file_aio_read() in order to avoid gfar's check to see if
738 * the request starts before the end of the file. For that check
739 * to work, we must generate a GETATTR before each direct read, and
740 * even then there is a window between the GETATTR and the subsequent
741 * READ where the file size could change. Our preference is simply
742 * to do all reads the application wants, and the server will take
743 * care of managing the end of file boundary.
745 * This function also eliminates unnecessarily updating the file's
746 * atime locally, as the NFS server sets the file's atime, and this
747 * client must read the updated atime from the server back into its
750 ssize_t nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos)
752 ssize_t retval = -EINVAL;
753 struct file *file = iocb->ki_filp;
754 struct address_space *mapping = file->f_mapping;
756 dprintk("nfs: direct read(%s/%s, %lu@%Ld)\n",
757 file->f_dentry->d_parent->d_name.name,
758 file->f_dentry->d_name.name,
759 (unsigned long) count, (long long) pos);
764 if (!access_ok(VERIFY_WRITE, buf, count))
770 retval = nfs_sync_mapping(mapping);
774 retval = nfs_direct_read(iocb, (unsigned long) buf, count, pos);
776 iocb->ki_pos = pos + retval;
783 * nfs_file_direct_write - file direct write operation for NFS files
784 * @iocb: target I/O control block
785 * @buf: user's buffer from which to write data
786 * @count: number of bytes to write
787 * @pos: byte offset in file where writing starts
789 * We use this function for direct writes instead of calling
790 * generic_file_aio_write() in order to avoid taking the inode
791 * semaphore and updating the i_size. The NFS server will set
792 * the new i_size and this client must read the updated size
793 * back into its cache. We let the server do generic write
794 * parameter checking and report problems.
796 * We also avoid an unnecessary invocation of generic_osync_inode(),
797 * as it is fairly meaningless to sync the metadata of an NFS file.
799 * We eliminate local atime updates, see direct read above.
801 * We avoid unnecessary page cache invalidations for normal cached
802 * readers of this file.
804 * Note that O_APPEND is not supported for NFS direct writes, as there
805 * is no atomic O_APPEND write facility in the NFS protocol.
807 ssize_t nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos)
810 struct file *file = iocb->ki_filp;
811 struct address_space *mapping = file->f_mapping;
813 dfprintk(VFS, "nfs: direct write(%s/%s, %lu@%Ld)\n",
814 file->f_dentry->d_parent->d_name.name,
815 file->f_dentry->d_name.name,
816 (unsigned long) count, (long long) pos);
818 retval = generic_write_checks(file, &pos, &count, 0);
823 if ((ssize_t) count < 0)
830 if (!access_ok(VERIFY_READ, buf, count))
833 retval = nfs_sync_mapping(mapping);
837 retval = nfs_direct_write(iocb, (unsigned long) buf, count, pos);
840 * XXX: nfs_end_data_update() already ensures this file's
841 * cached data is subsequently invalidated. Do we really
842 * need to call invalidate_inode_pages2() again here?
844 * For aio writes, this invalidation will almost certainly
845 * occur before the writes complete. Kind of racey.
847 if (mapping->nrpages)
848 invalidate_inode_pages2(mapping);
851 iocb->ki_pos = pos + retval;
858 * nfs_init_directcache - create a slab cache for nfs_direct_req structures
861 int __init nfs_init_directcache(void)
863 nfs_direct_cachep = kmem_cache_create("nfs_direct_cache",
864 sizeof(struct nfs_direct_req),
865 0, (SLAB_RECLAIM_ACCOUNT|
868 if (nfs_direct_cachep == NULL)
875 * nfs_destroy_directcache - destroy the slab cache for nfs_direct_req structures
878 void nfs_destroy_directcache(void)
880 if (kmem_cache_destroy(nfs_direct_cachep))
881 printk(KERN_INFO "nfs_direct_cache: not all structures were freed\n");