aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/direct.c
diff options
context:
space:
mode:
authorChuck Lever <cel@netapp.com>2006-03-20 13:44:28 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:28 -0500
commitd4cc948ba97980c55a308eab167a695109796456 (patch)
treefbf3b293b8ac129019723fe53dca0329c7552c13 /fs/nfs/direct.c
parentb8a32e2b8b7fefff994c89d398b6ac920a195b43 (diff)
NFS: update comments and function definitions in fs/nfs/direct.c
Update to latest coding style standards. Remove block comments on statically defined functions, and place function definitions all on one line. Test plan: Compile kernel with CONFIG_NFS and CONFIG_NFS_DIRECTIO. Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/direct.c')
-rw-r--r--fs/nfs/direct.c125
1 files changed, 15 insertions, 110 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 8096d326bd79..d38c3dc052a7 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -101,16 +101,7 @@ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_
101 return -EINVAL; 101 return -EINVAL;
102} 102}
103 103
104/** 104static inline int nfs_get_user_pages(int rw, unsigned long user_addr, size_t size, struct page ***pages)
105 * nfs_get_user_pages - find and set up pages underlying user's buffer
106 * rw: direction (read or write)
107 * user_addr: starting address of this segment of user's buffer
108 * count: size of this segment
109 * @pages: returned array of page struct pointers underlying user's buffer
110 */
111static inline int
112nfs_get_user_pages(int rw, unsigned long user_addr, size_t size,
113 struct page ***pages)
114{ 105{
115 int result = -ENOMEM; 106 int result = -ENOMEM;
116 unsigned long page_count; 107 unsigned long page_count;
@@ -147,14 +138,7 @@ nfs_get_user_pages(int rw, unsigned long user_addr, size_t size,
147 return result; 138 return result;
148} 139}
149 140
150/** 141static void nfs_free_user_pages(struct page **pages, int npages, int do_dirty)
151 * nfs_free_user_pages - tear down page struct array
152 * @pages: array of page struct pointers underlying target buffer
153 * @npages: number of pages in the array
154 * @do_dirty: dirty the pages as we release them
155 */
156static void
157nfs_free_user_pages(struct page **pages, int npages, int do_dirty)
158{ 142{
159 int i; 143 int i;
160 for (i = 0; i < npages; i++) { 144 for (i = 0; i < npages; i++) {
@@ -166,22 +150,13 @@ nfs_free_user_pages(struct page **pages, int npages, int do_dirty)
166 kfree(pages); 150 kfree(pages);
167} 151}
168 152
169/**
170 * nfs_direct_req_release - release nfs_direct_req structure for direct read
171 * @kref: kref object embedded in an nfs_direct_req structure
172 *
173 */
174static void nfs_direct_req_release(struct kref *kref) 153static void nfs_direct_req_release(struct kref *kref)
175{ 154{
176 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref); 155 struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref);
177 kmem_cache_free(nfs_direct_cachep, dreq); 156 kmem_cache_free(nfs_direct_cachep, dreq);
178} 157}
179 158
180/** 159/*
181 * nfs_direct_read_alloc - allocate nfs_read_data structures for direct read
182 * @count: count of bytes for the read request
183 * @rsize: local rsize setting
184 *
185 * Note we also set the number of requests we have in the dreq when we are 160 * Note we also set the number of requests we have in the dreq when we are
186 * done. This prevents races with I/O completion so we will always wait 161 * done. This prevents races with I/O completion so we will always wait
187 * until all requests have been dispatched and completed. 162 * until all requests have been dispatched and completed.
@@ -232,11 +207,7 @@ static struct nfs_direct_req *nfs_direct_read_alloc(size_t nbytes, unsigned int
232 return dreq; 207 return dreq;
233} 208}
234 209
235/** 210/*
236 * nfs_direct_read_result - handle a read reply for a direct read request
237 * @data: address of NFS READ operation control block
238 * @status: status of this NFS READ operation
239 *
240 * We must hold a reference to all the pages in this direct read request 211 * We must hold a reference to all the pages in this direct read request
241 * until the RPCs complete. This could be long *after* we are woken up in 212 * until the RPCs complete. This could be long *after* we are woken up in
242 * nfs_direct_read_wait (for instance, if someone hits ^C on a slow server). 213 * nfs_direct_read_wait (for instance, if someone hits ^C on a slow server).
@@ -265,21 +236,11 @@ static const struct rpc_call_ops nfs_read_direct_ops = {
265 .rpc_release = nfs_readdata_release, 236 .rpc_release = nfs_readdata_release,
266}; 237};
267 238
268/** 239/*
269 * nfs_direct_read_schedule - dispatch NFS READ operations for a direct read
270 * @dreq: address of nfs_direct_req struct for this request
271 * @inode: target inode
272 * @ctx: target file open context
273 * @user_addr: starting address of this segment of user's buffer
274 * @count: size of this segment
275 * @file_offset: offset in file to begin the operation
276 *
277 * For each nfs_read_data struct that was allocated on the list, dispatch 240 * For each nfs_read_data struct that was allocated on the list, dispatch
278 * an NFS READ operation 241 * an NFS READ operation
279 */ 242 */
280static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, 243static void nfs_direct_read_schedule(struct nfs_direct_req *dreq, struct inode *inode, struct nfs_open_context *ctx, unsigned long user_addr, size_t count, loff_t file_offset)
281 struct inode *inode, struct nfs_open_context *ctx,
282 unsigned long user_addr, size_t count, loff_t file_offset)
283{ 244{
284 struct list_head *list = &dreq->list; 245 struct list_head *list = &dreq->list;
285 struct page **pages = dreq->pages; 246 struct page **pages = dreq->pages;
@@ -337,11 +298,7 @@ static void nfs_direct_read_schedule(struct nfs_direct_req *dreq,
337 } while (count != 0); 298 } while (count != 0);
338} 299}
339 300
340/** 301/*
341 * nfs_direct_read_wait - wait for I/O completion for direct reads
342 * @dreq: request on which we are to wait
343 * @intr: whether or not this wait can be interrupted
344 *
345 * Collects and returns the final error value/byte-count. 302 * Collects and returns the final error value/byte-count.
346 */ 303 */
347static ssize_t nfs_direct_read_wait(struct nfs_direct_req *dreq, int intr) 304static ssize_t nfs_direct_read_wait(struct nfs_direct_req *dreq, int intr)
@@ -364,22 +321,7 @@ static ssize_t nfs_direct_read_wait(struct nfs_direct_req *dreq, int intr)
364 return (ssize_t) result; 321 return (ssize_t) result;
365} 322}
366 323
367/** 324static ssize_t nfs_direct_read_seg(struct inode *inode, struct nfs_open_context *ctx, unsigned long user_addr, size_t count, loff_t file_offset, struct page **pages, unsigned int nr_pages)
368 * nfs_direct_read_seg - Read in one iov segment. Generate separate
369 * read RPCs for each "rsize" bytes.
370 * @inode: target inode
371 * @ctx: target file open context
372 * @user_addr: starting address of this segment of user's buffer
373 * @count: size of this segment
374 * @file_offset: offset in file to begin the operation
375 * @pages: array of addresses of page structs defining user's buffer
376 * @nr_pages: number of pages in the array
377 *
378 */
379static ssize_t nfs_direct_read_seg(struct inode *inode,
380 struct nfs_open_context *ctx, unsigned long user_addr,
381 size_t count, loff_t file_offset, struct page **pages,
382 unsigned int nr_pages)
383{ 325{
384 ssize_t result; 326 ssize_t result;
385 sigset_t oldset; 327 sigset_t oldset;
@@ -404,22 +346,11 @@ static ssize_t nfs_direct_read_seg(struct inode *inode,
404 return result; 346 return result;
405} 347}
406 348
407/** 349/*
408 * nfs_direct_read - For each iov segment, map the user's buffer
409 * then generate read RPCs.
410 * @inode: target inode
411 * @ctx: target file open context
412 * @iov: array of vectors that define I/O buffer
413 * file_offset: offset in file to begin the operation
414 * nr_segs: size of iovec array
415 *
416 * We've already pushed out any non-direct writes so that this read 350 * We've already pushed out any non-direct writes so that this read
417 * will see them when we read from the server. 351 * will see them when we read from the server.
418 */ 352 */
419static ssize_t 353static ssize_t nfs_direct_read(struct inode *inode, struct nfs_open_context *ctx, const struct iovec *iov, loff_t file_offset, unsigned long nr_segs)
420nfs_direct_read(struct inode *inode, struct nfs_open_context *ctx,
421 const struct iovec *iov, loff_t file_offset,
422 unsigned long nr_segs)
423{ 354{
424 ssize_t tot_bytes = 0; 355 ssize_t tot_bytes = 0;
425 unsigned long seg = 0; 356 unsigned long seg = 0;
@@ -457,21 +388,7 @@ nfs_direct_read(struct inode *inode, struct nfs_open_context *ctx,
457 return tot_bytes; 388 return tot_bytes;
458} 389}
459 390
460/** 391static ssize_t nfs_direct_write_seg(struct inode *inode, struct nfs_open_context *ctx, unsigned long user_addr, size_t count, loff_t file_offset, struct page **pages, int nr_pages)
461 * nfs_direct_write_seg - Write out one iov segment. Generate separate
462 * write RPCs for each "wsize" bytes, then commit.
463 * @inode: target inode
464 * @ctx: target file open context
465 * user_addr: starting address of this segment of user's buffer
466 * count: size of this segment
467 * file_offset: offset in file to begin the operation
468 * @pages: array of addresses of page structs defining user's buffer
469 * nr_pages: size of pages array
470 */
471static ssize_t nfs_direct_write_seg(struct inode *inode,
472 struct nfs_open_context *ctx, unsigned long user_addr,
473 size_t count, loff_t file_offset, struct page **pages,
474 int nr_pages)
475{ 392{
476 const unsigned int wsize = NFS_SERVER(inode)->wsize; 393 const unsigned int wsize = NFS_SERVER(inode)->wsize;
477 size_t request; 394 size_t request;
@@ -573,22 +490,12 @@ sync_retry:
573 goto retry; 490 goto retry;
574} 491}
575 492
576/** 493/*
577 * nfs_direct_write - For each iov segment, map the user's buffer
578 * then generate write and commit RPCs.
579 * @inode: target inode
580 * @ctx: target file open context
581 * @iov: array of vectors that define I/O buffer
582 * file_offset: offset in file to begin the operation
583 * nr_segs: size of iovec array
584 *
585 * Upon return, generic_file_direct_IO invalidates any cached pages 494 * Upon return, generic_file_direct_IO invalidates any cached pages
586 * that non-direct readers might access, so they will pick up these 495 * that non-direct readers might access, so they will pick up these
587 * writes immediately. 496 * writes immediately.
588 */ 497 */
589static ssize_t nfs_direct_write(struct inode *inode, 498static ssize_t nfs_direct_write(struct inode *inode, struct nfs_open_context *ctx, const struct iovec *iov, loff_t file_offset, unsigned long nr_segs)
590 struct nfs_open_context *ctx, const struct iovec *iov,
591 loff_t file_offset, unsigned long nr_segs)
592{ 499{
593 ssize_t tot_bytes = 0; 500 ssize_t tot_bytes = 0;
594 unsigned long seg = 0; 501 unsigned long seg = 0;
@@ -649,8 +556,7 @@ static ssize_t nfs_direct_write(struct inode *inode,
649 * client must read the updated atime from the server back into its 556 * client must read the updated atime from the server back into its
650 * cache. 557 * cache.
651 */ 558 */
652ssize_t 559ssize_t nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos)
653nfs_file_direct_read(struct kiocb *iocb, char __user *buf, size_t count, loff_t pos)
654{ 560{
655 ssize_t retval = -EINVAL; 561 ssize_t retval = -EINVAL;
656 loff_t *ppos = &iocb->ki_pos; 562 loff_t *ppos = &iocb->ki_pos;
@@ -717,8 +623,7 @@ out:
717 * Note that O_APPEND is not supported for NFS direct writes, as there 623 * Note that O_APPEND is not supported for NFS direct writes, as there
718 * is no atomic O_APPEND write facility in the NFS protocol. 624 * is no atomic O_APPEND write facility in the NFS protocol.
719 */ 625 */
720ssize_t 626ssize_t nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos)
721nfs_file_direct_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t pos)
722{ 627{
723 ssize_t retval; 628 ssize_t retval;
724 struct file *file = iocb->ki_filp; 629 struct file *file = iocb->ki_filp;