revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / fs / nfs / write.c
blob3c9fbf934623c195ae9b38545a6fd5950171a341
1 /*
2 * linux/fs/nfs/write.c
4 * Write file data over NFS.
6 * Copyright (C) 1996, 1997, Olaf Kirch <okir@monad.swb.de>
7 */
9 #include <linux/types.h>
10 #include <linux/slab.h>
11 #include <linux/mm.h>
12 #include <linux/pagemap.h>
13 #include <linux/file.h>
14 #include <linux/writeback.h>
15 #include <linux/swap.h>
17 #include <linux/sunrpc/clnt.h>
18 #include <linux/nfs_fs.h>
19 #include <linux/nfs_mount.h>
20 #include <linux/nfs_page.h>
21 #include <linux/backing-dev.h>
23 #include <asm/uaccess.h>
25 #include "delegation.h"
26 #include "internal.h"
27 #include "iostat.h"
29 #define NFSDBG_FACILITY NFSDBG_PAGECACHE
31 #define MIN_POOL_WRITE (32)
32 #define MIN_POOL_COMMIT (4)
35 * Local function declarations
37 static struct nfs_page * nfs_update_request(struct nfs_open_context*,
38 struct page *,
39 unsigned int, unsigned int);
40 static void nfs_pageio_init_write(struct nfs_pageio_descriptor *desc,
41 struct inode *inode, int ioflags);
42 static const struct rpc_call_ops nfs_write_partial_ops;
43 static const struct rpc_call_ops nfs_write_full_ops;
44 static const struct rpc_call_ops nfs_commit_ops;
46 static struct kmem_cache *nfs_wdata_cachep;
47 static mempool_t *nfs_wdata_mempool;
48 static mempool_t *nfs_commit_mempool;
50 struct nfs_write_data *nfs_commit_alloc(void)
52 struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOFS);
54 if (p) {
55 memset(p, 0, sizeof(*p));
56 INIT_LIST_HEAD(&p->pages);
58 return p;
61 static void nfs_commit_rcu_free(struct rcu_head *head)
63 struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu);
64 if (p && (p->pagevec != &p->page_array[0]))
65 kfree(p->pagevec);
66 mempool_free(p, nfs_commit_mempool);
69 void nfs_commit_free(struct nfs_write_data *wdata)
71 call_rcu_bh(&wdata->task.u.tk_rcu, nfs_commit_rcu_free);
74 struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
76 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS);
78 if (p) {
79 memset(p, 0, sizeof(*p));
80 INIT_LIST_HEAD(&p->pages);
81 p->npages = pagecount;
82 if (pagecount <= ARRAY_SIZE(p->page_array))
83 p->pagevec = p->page_array;
84 else {
85 p->pagevec = kcalloc(pagecount, sizeof(struct page *), GFP_NOFS);
86 if (!p->pagevec) {
87 mempool_free(p, nfs_wdata_mempool);
88 p = NULL;
92 return p;
95 static void nfs_writedata_rcu_free(struct rcu_head *head)
97 struct nfs_write_data *p = container_of(head, struct nfs_write_data, task.u.tk_rcu);
98 if (p && (p->pagevec != &p->page_array[0]))
99 kfree(p->pagevec);
100 mempool_free(p, nfs_wdata_mempool);
103 static void nfs_writedata_free(struct nfs_write_data *wdata)
105 call_rcu_bh(&wdata->task.u.tk_rcu, nfs_writedata_rcu_free);
108 void nfs_writedata_release(void *wdata)
110 nfs_writedata_free(wdata);
113 static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
115 ctx->error = error;
116 smp_wmb();
117 set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
120 static struct nfs_page *nfs_page_find_request_locked(struct page *page)
122 struct nfs_page *req = NULL;
124 if (PagePrivate(page)) {
125 req = (struct nfs_page *)page_private(page);
126 if (req != NULL)
127 kref_get(&req->wb_kref);
129 return req;
132 static struct nfs_page *nfs_page_find_request(struct page *page)
134 struct inode *inode = page->mapping->host;
135 struct nfs_page *req = NULL;
137 spin_lock(&inode->i_lock);
138 req = nfs_page_find_request_locked(page);
139 spin_unlock(&inode->i_lock);
140 return req;
143 /* Adjust the file length if we're writing beyond the end */
144 static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count)
146 struct inode *inode = page->mapping->host;
147 loff_t end, i_size = i_size_read(inode);
148 pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
150 if (i_size > 0 && page->index < end_index)
151 return;
152 end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count);
153 if (i_size >= end)
154 return;
155 nfs_inc_stats(inode, NFSIOS_EXTENDWRITE);
156 i_size_write(inode, end);
159 /* A writeback failed: mark the page as bad, and invalidate the page cache */
160 static void nfs_set_pageerror(struct page *page)
162 SetPageError(page);
163 nfs_zap_mapping(page->mapping->host, page->mapping);
166 /* We can set the PG_uptodate flag if we see that a write request
167 * covers the full page.
169 static void nfs_mark_uptodate(struct page *page, unsigned int base, unsigned int count)
171 if (PageUptodate(page))
172 return;
173 if (base != 0)
174 return;
175 if (count != nfs_page_length(page))
176 return;
177 SetPageUptodate(page);
180 static int nfs_writepage_setup(struct nfs_open_context *ctx, struct page *page,
181 unsigned int offset, unsigned int count)
183 struct nfs_page *req;
184 int ret;
186 for (;;) {
187 req = nfs_update_request(ctx, page, offset, count);
188 if (!IS_ERR(req))
189 break;
190 ret = PTR_ERR(req);
191 if (ret != -EBUSY)
192 return ret;
193 ret = nfs_wb_page(page->mapping->host, page);
194 if (ret != 0)
195 return ret;
197 /* Update file length */
198 nfs_grow_file(page, offset, count);
199 nfs_unlock_request(req);
200 return 0;
203 static int wb_priority(struct writeback_control *wbc)
205 if (wbc->for_reclaim)
206 return FLUSH_HIGHPRI | FLUSH_STABLE;
207 if (wbc->for_kupdate)
208 return FLUSH_LOWPRI;
209 return 0;
213 * NFS congestion control
216 int nfs_congestion_kb;
218 #define NFS_CONGESTION_ON_THRESH (nfs_congestion_kb >> (PAGE_SHIFT-10))
219 #define NFS_CONGESTION_OFF_THRESH \
220 (NFS_CONGESTION_ON_THRESH - (NFS_CONGESTION_ON_THRESH >> 2))
222 static int nfs_set_page_writeback(struct page *page)
224 int ret = test_set_page_writeback(page);
226 if (!ret) {
227 struct inode *inode = page->mapping->host;
228 struct nfs_server *nfss = NFS_SERVER(inode);
230 if (atomic_long_inc_return(&nfss->writeback) >
231 NFS_CONGESTION_ON_THRESH)
232 set_bdi_congested(&nfss->backing_dev_info, WRITE);
234 return ret;
237 static void nfs_end_page_writeback(struct page *page)
239 struct inode *inode = page->mapping->host;
240 struct nfs_server *nfss = NFS_SERVER(inode);
242 end_page_writeback(page);
243 if (atomic_long_dec_return(&nfss->writeback) < NFS_CONGESTION_OFF_THRESH)
244 clear_bdi_congested(&nfss->backing_dev_info, WRITE);
248 * Find an associated nfs write request, and prepare to flush it out
249 * May return an error if the user signalled nfs_wait_on_request().
251 static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
252 struct page *page)
254 struct inode *inode = page->mapping->host;
255 struct nfs_inode *nfsi = NFS_I(inode);
256 struct nfs_page *req;
257 int ret;
259 spin_lock(&inode->i_lock);
260 for(;;) {
261 req = nfs_page_find_request_locked(page);
262 if (req == NULL) {
263 spin_unlock(&inode->i_lock);
264 return 0;
266 if (nfs_lock_request_dontget(req))
267 break;
268 /* Note: If we hold the page lock, as is the case in nfs_writepage,
269 * then the call to nfs_lock_request_dontget() will always
270 * succeed provided that someone hasn't already marked the
271 * request as dirty (in which case we don't care).
273 spin_unlock(&inode->i_lock);
274 ret = nfs_wait_on_request(req);
275 nfs_release_request(req);
276 if (ret != 0)
277 return ret;
278 spin_lock(&inode->i_lock);
280 if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) {
281 /* This request is marked for commit */
282 spin_unlock(&inode->i_lock);
283 nfs_unlock_request(req);
284 nfs_pageio_complete(pgio);
285 return 0;
287 if (nfs_set_page_writeback(page) != 0) {
288 spin_unlock(&inode->i_lock);
289 BUG();
291 radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index,
292 NFS_PAGE_TAG_LOCKED);
293 spin_unlock(&inode->i_lock);
294 nfs_pageio_add_request(pgio, req);
295 return 0;
298 static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
300 struct inode *inode = page->mapping->host;
302 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
303 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
305 nfs_pageio_cond_complete(pgio, page->index);
306 return nfs_page_async_flush(pgio, page);
310 * Write an mmapped page to the server.
312 static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc)
314 struct nfs_pageio_descriptor pgio;
315 int err;
317 nfs_pageio_init_write(&pgio, page->mapping->host, wb_priority(wbc));
318 err = nfs_do_writepage(page, wbc, &pgio);
319 nfs_pageio_complete(&pgio);
320 if (err < 0)
321 return err;
322 if (pgio.pg_error < 0)
323 return pgio.pg_error;
324 return 0;
327 int nfs_writepage(struct page *page, struct writeback_control *wbc)
329 int ret;
331 ret = nfs_writepage_locked(page, wbc);
332 unlock_page(page);
333 return ret;
336 static int nfs_writepages_callback(struct page *page, struct writeback_control *wbc, void *data)
338 int ret;
340 ret = nfs_do_writepage(page, wbc, data);
341 unlock_page(page);
342 return ret;
345 int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
347 struct inode *inode = mapping->host;
348 struct nfs_pageio_descriptor pgio;
349 int err;
351 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES);
353 nfs_pageio_init_write(&pgio, inode, wb_priority(wbc));
354 err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio);
355 nfs_pageio_complete(&pgio);
356 if (err < 0)
357 return err;
358 if (pgio.pg_error < 0)
359 return pgio.pg_error;
360 return 0;
364 * Insert a write request into an inode
366 static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
368 struct nfs_inode *nfsi = NFS_I(inode);
369 int error;
371 error = radix_tree_insert(&nfsi->nfs_page_tree, req->wb_index, req);
372 BUG_ON(error);
373 if (!nfsi->npages) {
374 igrab(inode);
375 if (nfs_have_delegation(inode, FMODE_WRITE))
376 nfsi->change_attr++;
378 SetPagePrivate(req->wb_page);
379 set_page_private(req->wb_page, (unsigned long)req);
380 nfsi->npages++;
381 kref_get(&req->wb_kref);
385 * Remove a write request from an inode
387 static void nfs_inode_remove_request(struct nfs_page *req)
389 struct inode *inode = req->wb_context->path.dentry->d_inode;
390 struct nfs_inode *nfsi = NFS_I(inode);
392 BUG_ON (!NFS_WBACK_BUSY(req));
394 spin_lock(&inode->i_lock);
395 set_page_private(req->wb_page, 0);
396 ClearPagePrivate(req->wb_page);
397 radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index);
398 nfsi->npages--;
399 if (!nfsi->npages) {
400 spin_unlock(&inode->i_lock);
401 iput(inode);
402 } else
403 spin_unlock(&inode->i_lock);
404 nfs_clear_request(req);
405 nfs_release_request(req);
408 static void
409 nfs_redirty_request(struct nfs_page *req)
411 __set_page_dirty_nobuffers(req->wb_page);
415 * Check if a request is dirty
417 static inline int
418 nfs_dirty_request(struct nfs_page *req)
420 struct page *page = req->wb_page;
422 if (page == NULL || test_bit(PG_NEED_COMMIT, &req->wb_flags))
423 return 0;
424 return !PageWriteback(req->wb_page);
427 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
429 * Add a request to the inode's commit list.
431 static void
432 nfs_mark_request_commit(struct nfs_page *req)
434 struct inode *inode = req->wb_context->path.dentry->d_inode;
435 struct nfs_inode *nfsi = NFS_I(inode);
437 spin_lock(&inode->i_lock);
438 nfsi->ncommit++;
439 set_bit(PG_NEED_COMMIT, &(req)->wb_flags);
440 radix_tree_tag_set(&nfsi->nfs_page_tree,
441 req->wb_index,
442 NFS_PAGE_TAG_COMMIT);
443 spin_unlock(&inode->i_lock);
444 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
445 inc_bdi_stat(req->wb_page->mapping->backing_dev_info, BDI_RECLAIMABLE);
446 __mark_inode_dirty(inode, I_DIRTY_DATASYNC);
449 static inline
450 int nfs_write_need_commit(struct nfs_write_data *data)
452 return data->verf.committed != NFS_FILE_SYNC;
455 static inline
456 int nfs_reschedule_unstable_write(struct nfs_page *req)
458 if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) {
459 nfs_mark_request_commit(req);
460 return 1;
462 if (test_and_clear_bit(PG_NEED_RESCHED, &req->wb_flags)) {
463 nfs_redirty_request(req);
464 return 1;
466 return 0;
468 #else
469 static inline void
470 nfs_mark_request_commit(struct nfs_page *req)
474 static inline
475 int nfs_write_need_commit(struct nfs_write_data *data)
477 return 0;
480 static inline
481 int nfs_reschedule_unstable_write(struct nfs_page *req)
483 return 0;
485 #endif
488 * Wait for a request to complete.
490 * Interruptible by signals only if mounted with intr flag.
492 static int nfs_wait_on_requests_locked(struct inode *inode, pgoff_t idx_start, unsigned int npages)
494 struct nfs_inode *nfsi = NFS_I(inode);
495 struct nfs_page *req;
496 pgoff_t idx_end, next;
497 unsigned int res = 0;
498 int error;
500 if (npages == 0)
501 idx_end = ~0;
502 else
503 idx_end = idx_start + npages - 1;
505 next = idx_start;
506 while (radix_tree_gang_lookup_tag(&nfsi->nfs_page_tree, (void **)&req, next, 1, NFS_PAGE_TAG_LOCKED)) {
507 if (req->wb_index > idx_end)
508 break;
510 next = req->wb_index + 1;
511 BUG_ON(!NFS_WBACK_BUSY(req));
513 kref_get(&req->wb_kref);
514 spin_unlock(&inode->i_lock);
515 error = nfs_wait_on_request(req);
516 nfs_release_request(req);
517 spin_lock(&inode->i_lock);
518 if (error < 0)
519 return error;
520 res++;
522 return res;
525 static void nfs_cancel_commit_list(struct list_head *head)
527 struct nfs_page *req;
529 while(!list_empty(head)) {
530 req = nfs_list_entry(head->next);
531 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
532 dec_bdi_stat(req->wb_page->mapping->backing_dev_info,
533 BDI_RECLAIMABLE);
534 nfs_list_remove_request(req);
535 clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
536 nfs_inode_remove_request(req);
537 nfs_unlock_request(req);
541 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
543 * nfs_scan_commit - Scan an inode for commit requests
544 * @inode: NFS inode to scan
545 * @dst: destination list
546 * @idx_start: lower bound of page->index to scan.
547 * @npages: idx_start + npages sets the upper bound to scan.
549 * Moves requests from the inode's 'commit' request list.
550 * The requests are *not* checked to ensure that they form a contiguous set.
552 static int
553 nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, unsigned int npages)
555 struct nfs_inode *nfsi = NFS_I(inode);
556 int res = 0;
558 if (nfsi->ncommit != 0) {
559 res = nfs_scan_list(nfsi, dst, idx_start, npages,
560 NFS_PAGE_TAG_COMMIT);
561 nfsi->ncommit -= res;
563 return res;
565 #else
566 static inline int nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, unsigned int npages)
568 return 0;
570 #endif
573 * Try to update any existing write request, or create one if there is none.
574 * In order to match, the request's credentials must match those of
575 * the calling process.
577 * Note: Should always be called with the Page Lock held!
579 static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx,
580 struct page *page, unsigned int offset, unsigned int bytes)
582 struct address_space *mapping = page->mapping;
583 struct inode *inode = mapping->host;
584 struct nfs_page *req, *new = NULL;
585 pgoff_t rqend, end;
587 end = offset + bytes;
589 for (;;) {
590 /* Loop over all inode entries and see if we find
591 * A request for the page we wish to update
593 if (new) {
594 if (radix_tree_preload(GFP_NOFS)) {
595 nfs_release_request(new);
596 return ERR_PTR(-ENOMEM);
600 spin_lock(&inode->i_lock);
601 req = nfs_page_find_request_locked(page);
602 if (req) {
603 if (!nfs_lock_request_dontget(req)) {
604 int error;
606 spin_unlock(&inode->i_lock);
607 error = nfs_wait_on_request(req);
608 nfs_release_request(req);
609 if (error < 0) {
610 if (new) {
611 radix_tree_preload_end();
612 nfs_release_request(new);
614 return ERR_PTR(error);
616 continue;
618 spin_unlock(&inode->i_lock);
619 if (new) {
620 radix_tree_preload_end();
621 nfs_release_request(new);
623 break;
626 if (new) {
627 nfs_lock_request_dontget(new);
628 nfs_inode_add_request(inode, new);
629 spin_unlock(&inode->i_lock);
630 radix_tree_preload_end();
631 req = new;
632 goto zero_page;
634 spin_unlock(&inode->i_lock);
636 new = nfs_create_request(ctx, inode, page, offset, bytes);
637 if (IS_ERR(new))
638 return new;
641 /* We have a request for our page.
642 * If the creds don't match, or the
643 * page addresses don't match,
644 * tell the caller to wait on the conflicting
645 * request.
647 rqend = req->wb_offset + req->wb_bytes;
648 if (req->wb_context != ctx
649 || req->wb_page != page
650 || !nfs_dirty_request(req)
651 || offset > rqend || end < req->wb_offset) {
652 nfs_unlock_request(req);
653 return ERR_PTR(-EBUSY);
656 /* Okay, the request matches. Update the region */
657 if (offset < req->wb_offset) {
658 req->wb_offset = offset;
659 req->wb_pgbase = offset;
660 req->wb_bytes = max(end, rqend) - req->wb_offset;
661 goto zero_page;
664 if (end > rqend)
665 req->wb_bytes = end - req->wb_offset;
667 return req;
668 zero_page:
669 /* If this page might potentially be marked as up to date,
670 * then we need to zero any uninitalised data. */
671 if (req->wb_pgbase == 0 && req->wb_bytes != PAGE_CACHE_SIZE
672 && !PageUptodate(req->wb_page))
673 zero_user_segment(req->wb_page, req->wb_bytes, PAGE_CACHE_SIZE);
674 return req;
677 int nfs_flush_incompatible(struct file *file, struct page *page)
679 struct nfs_open_context *ctx = nfs_file_open_context(file);
680 struct nfs_page *req;
681 int do_flush, status;
683 * Look for a request corresponding to this page. If there
684 * is one, and it belongs to another file, we flush it out
685 * before we try to copy anything into the page. Do this
686 * due to the lack of an ACCESS-type call in NFSv2.
687 * Also do the same if we find a request from an existing
688 * dropped page.
690 do {
691 req = nfs_page_find_request(page);
692 if (req == NULL)
693 return 0;
694 do_flush = req->wb_page != page || req->wb_context != ctx
695 || !nfs_dirty_request(req);
696 nfs_release_request(req);
697 if (!do_flush)
698 return 0;
699 status = nfs_wb_page(page->mapping->host, page);
700 } while (status == 0);
701 return status;
705 * Update and possibly write a cached page of an NFS file.
707 * XXX: Keep an eye on generic_file_read to make sure it doesn't do bad
708 * things with a page scheduled for an RPC call (e.g. invalidate it).
710 int nfs_updatepage(struct file *file, struct page *page,
711 unsigned int offset, unsigned int count)
713 struct nfs_open_context *ctx = nfs_file_open_context(file);
714 struct inode *inode = page->mapping->host;
715 int status = 0;
717 nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
719 dprintk("NFS: nfs_updatepage(%s/%s %d@%Ld)\n",
720 file->f_path.dentry->d_parent->d_name.name,
721 file->f_path.dentry->d_name.name, count,
722 (long long)(page_offset(page) +offset));
724 /* If we're not using byte range locks, and we know the page
725 * is entirely in cache, it may be more efficient to avoid
726 * fragmenting write requests.
728 if (PageUptodate(page) && inode->i_flock == NULL && !(file->f_mode & O_SYNC)) {
729 count = max(count + offset, nfs_page_length(page));
730 offset = 0;
733 status = nfs_writepage_setup(ctx, page, offset, count);
734 __set_page_dirty_nobuffers(page);
736 dprintk("NFS: nfs_updatepage returns %d (isize %Ld)\n",
737 status, (long long)i_size_read(inode));
738 if (status < 0)
739 nfs_set_pageerror(page);
740 return status;
743 static void nfs_writepage_release(struct nfs_page *req)
746 if (PageError(req->wb_page)) {
747 nfs_end_page_writeback(req->wb_page);
748 nfs_inode_remove_request(req);
749 } else if (!nfs_reschedule_unstable_write(req)) {
750 /* Set the PG_uptodate flag */
751 nfs_mark_uptodate(req->wb_page, req->wb_pgbase, req->wb_bytes);
752 nfs_end_page_writeback(req->wb_page);
753 nfs_inode_remove_request(req);
754 } else
755 nfs_end_page_writeback(req->wb_page);
756 nfs_clear_page_tag_locked(req);
759 static inline int flush_task_priority(int how)
761 switch (how & (FLUSH_HIGHPRI|FLUSH_LOWPRI)) {
762 case FLUSH_HIGHPRI:
763 return RPC_PRIORITY_HIGH;
764 case FLUSH_LOWPRI:
765 return RPC_PRIORITY_LOW;
767 return RPC_PRIORITY_NORMAL;
771 * Set up the argument/result storage required for the RPC call.
773 static void nfs_write_rpcsetup(struct nfs_page *req,
774 struct nfs_write_data *data,
775 const struct rpc_call_ops *call_ops,
776 unsigned int count, unsigned int offset,
777 int how)
779 struct inode *inode;
780 int flags;
782 /* Set up the RPC argument and reply structs
783 * NB: take care not to mess about with data->commit et al. */
785 data->req = req;
786 data->inode = inode = req->wb_context->path.dentry->d_inode;
787 data->cred = req->wb_context->cred;
789 data->args.fh = NFS_FH(inode);
790 data->args.offset = req_offset(req) + offset;
791 data->args.pgbase = req->wb_pgbase + offset;
792 data->args.pages = data->pagevec;
793 data->args.count = count;
794 data->args.context = req->wb_context;
796 data->res.fattr = &data->fattr;
797 data->res.count = count;
798 data->res.verf = &data->verf;
799 nfs_fattr_init(&data->fattr);
801 /* Set up the initial task struct. */
802 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
803 rpc_init_task(&data->task, NFS_CLIENT(inode), flags, call_ops, data);
804 NFS_PROTO(inode)->write_setup(data, how);
806 data->task.tk_priority = flush_task_priority(how);
807 data->task.tk_cookie = (unsigned long)inode;
809 dprintk("NFS: %5u initiated write call "
810 "(req %s/%Ld, %u bytes @ offset %Lu)\n",
811 data->task.tk_pid,
812 inode->i_sb->s_id,
813 (long long)NFS_FILEID(inode),
814 count,
815 (unsigned long long)data->args.offset);
818 static void nfs_execute_write(struct nfs_write_data *data)
820 struct rpc_clnt *clnt = NFS_CLIENT(data->inode);
821 sigset_t oldset;
823 rpc_clnt_sigmask(clnt, &oldset);
824 rpc_execute(&data->task);
825 rpc_clnt_sigunmask(clnt, &oldset);
829 * Generate multiple small requests to write out a single
830 * contiguous dirty area on one page.
832 static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int how)
834 struct nfs_page *req = nfs_list_entry(head->next);
835 struct page *page = req->wb_page;
836 struct nfs_write_data *data;
837 size_t wsize = NFS_SERVER(inode)->wsize, nbytes;
838 unsigned int offset;
839 int requests = 0;
840 LIST_HEAD(list);
842 nfs_list_remove_request(req);
844 nbytes = count;
845 do {
846 size_t len = min(nbytes, wsize);
848 data = nfs_writedata_alloc(1);
849 if (!data)
850 goto out_bad;
851 list_add(&data->pages, &list);
852 requests++;
853 nbytes -= len;
854 } while (nbytes != 0);
855 atomic_set(&req->wb_complete, requests);
857 ClearPageError(page);
858 offset = 0;
859 nbytes = count;
860 do {
861 data = list_entry(list.next, struct nfs_write_data, pages);
862 list_del_init(&data->pages);
864 data->pagevec[0] = page;
866 if (nbytes < wsize)
867 wsize = nbytes;
868 nfs_write_rpcsetup(req, data, &nfs_write_partial_ops,
869 wsize, offset, how);
870 offset += wsize;
871 nbytes -= wsize;
872 nfs_execute_write(data);
873 } while (nbytes != 0);
875 return 0;
877 out_bad:
878 while (!list_empty(&list)) {
879 data = list_entry(list.next, struct nfs_write_data, pages);
880 list_del(&data->pages);
881 nfs_writedata_release(data);
883 nfs_redirty_request(req);
884 nfs_end_page_writeback(req->wb_page);
885 nfs_clear_page_tag_locked(req);
886 return -ENOMEM;
890 * Create an RPC task for the given write request and kick it.
891 * The page must have been locked by the caller.
893 * It may happen that the page we're passed is not marked dirty.
894 * This is the case if nfs_updatepage detects a conflicting request
895 * that has been written but not committed.
897 static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned int npages, size_t count, int how)
899 struct nfs_page *req;
900 struct page **pages;
901 struct nfs_write_data *data;
903 data = nfs_writedata_alloc(npages);
904 if (!data)
905 goto out_bad;
907 pages = data->pagevec;
908 while (!list_empty(head)) {
909 req = nfs_list_entry(head->next);
910 nfs_list_remove_request(req);
911 nfs_list_add_request(req, &data->pages);
912 ClearPageError(req->wb_page);
913 *pages++ = req->wb_page;
915 req = nfs_list_entry(data->pages.next);
917 /* Set up the argument struct */
918 nfs_write_rpcsetup(req, data, &nfs_write_full_ops, count, 0, how);
920 nfs_execute_write(data);
921 return 0;
922 out_bad:
923 while (!list_empty(head)) {
924 req = nfs_list_entry(head->next);
925 nfs_list_remove_request(req);
926 nfs_redirty_request(req);
927 nfs_end_page_writeback(req->wb_page);
928 nfs_clear_page_tag_locked(req);
930 return -ENOMEM;
933 static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
934 struct inode *inode, int ioflags)
936 int wsize = NFS_SERVER(inode)->wsize;
938 if (wsize < PAGE_CACHE_SIZE)
939 nfs_pageio_init(pgio, inode, nfs_flush_multi, wsize, ioflags);
940 else
941 nfs_pageio_init(pgio, inode, nfs_flush_one, wsize, ioflags);
945 * Handle a write reply that flushed part of a page.
947 static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
949 struct nfs_write_data *data = calldata;
950 struct nfs_page *req = data->req;
951 struct page *page = req->wb_page;
953 dprintk("NFS: write (%s/%Ld %d@%Ld)",
954 req->wb_context->path.dentry->d_inode->i_sb->s_id,
955 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
956 req->wb_bytes,
957 (long long)req_offset(req));
959 if (nfs_writeback_done(task, data) != 0)
960 return;
962 if (task->tk_status < 0) {
963 nfs_set_pageerror(page);
964 nfs_context_set_write_error(req->wb_context, task->tk_status);
965 dprintk(", error = %d\n", task->tk_status);
966 goto out;
969 if (nfs_write_need_commit(data)) {
970 struct inode *inode = page->mapping->host;
972 spin_lock(&inode->i_lock);
973 if (test_bit(PG_NEED_RESCHED, &req->wb_flags)) {
974 /* Do nothing we need to resend the writes */
975 } else if (!test_and_set_bit(PG_NEED_COMMIT, &req->wb_flags)) {
976 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
977 dprintk(" defer commit\n");
978 } else if (memcmp(&req->wb_verf, &data->verf, sizeof(req->wb_verf))) {
979 set_bit(PG_NEED_RESCHED, &req->wb_flags);
980 clear_bit(PG_NEED_COMMIT, &req->wb_flags);
981 dprintk(" server reboot detected\n");
983 spin_unlock(&inode->i_lock);
984 } else
985 dprintk(" OK\n");
987 out:
988 if (atomic_dec_and_test(&req->wb_complete))
989 nfs_writepage_release(req);
992 static const struct rpc_call_ops nfs_write_partial_ops = {
993 .rpc_call_done = nfs_writeback_done_partial,
994 .rpc_release = nfs_writedata_release,
998 * Handle a write reply that flushes a whole page.
1000 * FIXME: There is an inherent race with invalidate_inode_pages and
1001 * writebacks since the page->count is kept > 1 for as long
1002 * as the page has a write request pending.
1004 static void nfs_writeback_done_full(struct rpc_task *task, void *calldata)
1006 struct nfs_write_data *data = calldata;
1007 struct nfs_page *req;
1008 struct page *page;
1010 if (nfs_writeback_done(task, data) != 0)
1011 return;
1013 /* Update attributes as result of writeback. */
1014 while (!list_empty(&data->pages)) {
1015 req = nfs_list_entry(data->pages.next);
1016 nfs_list_remove_request(req);
1017 page = req->wb_page;
1019 dprintk("NFS: write (%s/%Ld %d@%Ld)",
1020 req->wb_context->path.dentry->d_inode->i_sb->s_id,
1021 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
1022 req->wb_bytes,
1023 (long long)req_offset(req));
1025 if (task->tk_status < 0) {
1026 nfs_set_pageerror(page);
1027 nfs_context_set_write_error(req->wb_context, task->tk_status);
1028 dprintk(", error = %d\n", task->tk_status);
1029 goto remove_request;
1032 if (nfs_write_need_commit(data)) {
1033 memcpy(&req->wb_verf, &data->verf, sizeof(req->wb_verf));
1034 nfs_mark_request_commit(req);
1035 nfs_end_page_writeback(page);
1036 dprintk(" marked for commit\n");
1037 goto next;
1039 /* Set the PG_uptodate flag? */
1040 nfs_mark_uptodate(page, req->wb_pgbase, req->wb_bytes);
1041 dprintk(" OK\n");
1042 remove_request:
1043 nfs_end_page_writeback(page);
1044 nfs_inode_remove_request(req);
1045 next:
1046 nfs_clear_page_tag_locked(req);
1050 static const struct rpc_call_ops nfs_write_full_ops = {
1051 .rpc_call_done = nfs_writeback_done_full,
1052 .rpc_release = nfs_writedata_release,
1057 * This function is called when the WRITE call is complete.
1059 int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
1061 struct nfs_writeargs *argp = &data->args;
1062 struct nfs_writeres *resp = &data->res;
1063 int status;
1065 dprintk("NFS: %5u nfs_writeback_done (status %d)\n",
1066 task->tk_pid, task->tk_status);
1069 * ->write_done will attempt to use post-op attributes to detect
1070 * conflicting writes by other clients. A strict interpretation
1071 * of close-to-open would allow us to continue caching even if
1072 * another writer had changed the file, but some applications
1073 * depend on tighter cache coherency when writing.
1075 status = NFS_PROTO(data->inode)->write_done(task, data);
1076 if (status != 0)
1077 return status;
1078 nfs_add_stats(data->inode, NFSIOS_SERVERWRITTENBYTES, resp->count);
1080 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
1081 if (resp->verf->committed < argp->stable && task->tk_status >= 0) {
1082 /* We tried a write call, but the server did not
1083 * commit data to stable storage even though we
1084 * requested it.
1085 * Note: There is a known bug in Tru64 < 5.0 in which
1086 * the server reports NFS_DATA_SYNC, but performs
1087 * NFS_FILE_SYNC. We therefore implement this checking
1088 * as a dprintk() in order to avoid filling syslog.
1090 static unsigned long complain;
1092 if (time_before(complain, jiffies)) {
1093 dprintk("NFS: faulty NFS server %s:"
1094 " (committed = %d) != (stable = %d)\n",
1095 NFS_SERVER(data->inode)->nfs_client->cl_hostname,
1096 resp->verf->committed, argp->stable);
1097 complain = jiffies + 300 * HZ;
1100 #endif
1101 /* Is this a short write? */
1102 if (task->tk_status >= 0 && resp->count < argp->count) {
1103 static unsigned long complain;
1105 nfs_inc_stats(data->inode, NFSIOS_SHORTWRITE);
1107 /* Has the server at least made some progress? */
1108 if (resp->count != 0) {
1109 /* Was this an NFSv2 write or an NFSv3 stable write? */
1110 if (resp->verf->committed != NFS_UNSTABLE) {
1111 /* Resend from where the server left off */
1112 argp->offset += resp->count;
1113 argp->pgbase += resp->count;
1114 argp->count -= resp->count;
1115 } else {
1116 /* Resend as a stable write in order to avoid
1117 * headaches in the case of a server crash.
1119 argp->stable = NFS_FILE_SYNC;
1121 rpc_restart_call(task);
1122 return -EAGAIN;
1124 if (time_before(complain, jiffies)) {
1125 printk(KERN_WARNING
1126 "NFS: Server wrote zero bytes, expected %u.\n",
1127 argp->count);
1128 complain = jiffies + 300 * HZ;
1130 /* Can't do anything about it except throw an error. */
1131 task->tk_status = -EIO;
1133 return 0;
1137 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
1138 void nfs_commit_release(void *wdata)
1140 nfs_commit_free(wdata);
1144 * Set up the argument/result storage required for the RPC call.
1146 static void nfs_commit_rpcsetup(struct list_head *head,
1147 struct nfs_write_data *data,
1148 int how)
1150 struct nfs_page *first;
1151 struct inode *inode;
1152 int flags;
1154 /* Set up the RPC argument and reply structs
1155 * NB: take care not to mess about with data->commit et al. */
1157 list_splice_init(head, &data->pages);
1158 first = nfs_list_entry(data->pages.next);
1159 inode = first->wb_context->path.dentry->d_inode;
1161 data->inode = inode;
1162 data->cred = first->wb_context->cred;
1164 data->args.fh = NFS_FH(data->inode);
1165 /* Note: we always request a commit of the entire inode */
1166 data->args.offset = 0;
1167 data->args.count = 0;
1168 data->res.count = 0;
1169 data->res.fattr = &data->fattr;
1170 data->res.verf = &data->verf;
1171 nfs_fattr_init(&data->fattr);
1173 /* Set up the initial task struct. */
1174 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
1175 rpc_init_task(&data->task, NFS_CLIENT(inode), flags, &nfs_commit_ops, data);
1176 NFS_PROTO(inode)->commit_setup(data, how);
1178 data->task.tk_priority = flush_task_priority(how);
1179 data->task.tk_cookie = (unsigned long)inode;
1181 dprintk("NFS: %5u initiated commit call\n", data->task.tk_pid);
1185 * Commit dirty pages
1187 static int
1188 nfs_commit_list(struct inode *inode, struct list_head *head, int how)
1190 struct nfs_write_data *data;
1191 struct nfs_page *req;
1193 data = nfs_commit_alloc();
1195 if (!data)
1196 goto out_bad;
1198 /* Set up the argument struct */
1199 nfs_commit_rpcsetup(head, data, how);
1201 nfs_execute_write(data);
1202 return 0;
1203 out_bad:
1204 while (!list_empty(head)) {
1205 req = nfs_list_entry(head->next);
1206 nfs_list_remove_request(req);
1207 nfs_mark_request_commit(req);
1208 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
1209 dec_bdi_stat(req->wb_page->mapping->backing_dev_info,
1210 BDI_RECLAIMABLE);
1211 nfs_clear_page_tag_locked(req);
1213 return -ENOMEM;
1217 * COMMIT call returned
1219 static void nfs_commit_done(struct rpc_task *task, void *calldata)
1221 struct nfs_write_data *data = calldata;
1222 struct nfs_page *req;
1224 dprintk("NFS: %5u nfs_commit_done (status %d)\n",
1225 task->tk_pid, task->tk_status);
1227 /* Call the NFS version-specific code */
1228 if (NFS_PROTO(data->inode)->commit_done(task, data) != 0)
1229 return;
1231 while (!list_empty(&data->pages)) {
1232 req = nfs_list_entry(data->pages.next);
1233 nfs_list_remove_request(req);
1234 clear_bit(PG_NEED_COMMIT, &(req)->wb_flags);
1235 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
1236 dec_bdi_stat(req->wb_page->mapping->backing_dev_info,
1237 BDI_RECLAIMABLE);
1239 dprintk("NFS: commit (%s/%Ld %d@%Ld)",
1240 req->wb_context->path.dentry->d_inode->i_sb->s_id,
1241 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
1242 req->wb_bytes,
1243 (long long)req_offset(req));
1244 if (task->tk_status < 0) {
1245 nfs_context_set_write_error(req->wb_context, task->tk_status);
1246 nfs_inode_remove_request(req);
1247 dprintk(", error = %d\n", task->tk_status);
1248 goto next;
1251 /* Okay, COMMIT succeeded, apparently. Check the verifier
1252 * returned by the server against all stored verfs. */
1253 if (!memcmp(req->wb_verf.verifier, data->verf.verifier, sizeof(data->verf.verifier))) {
1254 /* We have a match */
1255 /* Set the PG_uptodate flag */
1256 nfs_mark_uptodate(req->wb_page, req->wb_pgbase,
1257 req->wb_bytes);
1258 nfs_inode_remove_request(req);
1259 dprintk(" OK\n");
1260 goto next;
1262 /* We have a mismatch. Write the page again */
1263 dprintk(" mismatch\n");
1264 nfs_redirty_request(req);
1265 next:
1266 nfs_clear_page_tag_locked(req);
1270 static const struct rpc_call_ops nfs_commit_ops = {
1271 .rpc_call_done = nfs_commit_done,
1272 .rpc_release = nfs_commit_release,
1275 int nfs_commit_inode(struct inode *inode, int how)
1277 LIST_HEAD(head);
1278 int res;
1280 spin_lock(&inode->i_lock);
1281 res = nfs_scan_commit(inode, &head, 0, 0);
1282 spin_unlock(&inode->i_lock);
1283 if (res) {
1284 int error = nfs_commit_list(inode, &head, how);
1285 if (error < 0)
1286 return error;
1288 return res;
1290 #else
1291 static inline int nfs_commit_list(struct inode *inode, struct list_head *head, int how)
1293 return 0;
1295 #endif
1297 long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_control *wbc, int how)
1299 struct inode *inode = mapping->host;
1300 pgoff_t idx_start, idx_end;
1301 unsigned int npages = 0;
1302 LIST_HEAD(head);
1303 int nocommit = how & FLUSH_NOCOMMIT;
1304 long pages, ret;
1306 /* FIXME */
1307 if (wbc->range_cyclic)
1308 idx_start = 0;
1309 else {
1310 idx_start = wbc->range_start >> PAGE_CACHE_SHIFT;
1311 idx_end = wbc->range_end >> PAGE_CACHE_SHIFT;
1312 if (idx_end > idx_start) {
1313 pgoff_t l_npages = 1 + idx_end - idx_start;
1314 npages = l_npages;
1315 if (sizeof(npages) != sizeof(l_npages) &&
1316 (pgoff_t)npages != l_npages)
1317 npages = 0;
1320 how &= ~FLUSH_NOCOMMIT;
1321 spin_lock(&inode->i_lock);
1322 do {
1323 ret = nfs_wait_on_requests_locked(inode, idx_start, npages);
1324 if (ret != 0)
1325 continue;
1326 if (nocommit)
1327 break;
1328 pages = nfs_scan_commit(inode, &head, idx_start, npages);
1329 if (pages == 0)
1330 break;
1331 if (how & FLUSH_INVALIDATE) {
1332 spin_unlock(&inode->i_lock);
1333 nfs_cancel_commit_list(&head);
1334 ret = pages;
1335 spin_lock(&inode->i_lock);
1336 continue;
1338 pages += nfs_scan_commit(inode, &head, 0, 0);
1339 spin_unlock(&inode->i_lock);
1340 ret = nfs_commit_list(inode, &head, how);
1341 spin_lock(&inode->i_lock);
1343 } while (ret >= 0);
1344 spin_unlock(&inode->i_lock);
1345 return ret;
1348 static int __nfs_write_mapping(struct address_space *mapping, struct writeback_control *wbc, int how)
1350 int ret;
1352 ret = nfs_writepages(mapping, wbc);
1353 if (ret < 0)
1354 goto out;
1355 ret = nfs_sync_mapping_wait(mapping, wbc, how);
1356 if (ret < 0)
1357 goto out;
1358 return 0;
1359 out:
1360 __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
1361 return ret;
1364 /* Two pass sync: first using WB_SYNC_NONE, then WB_SYNC_ALL */
1365 static int nfs_write_mapping(struct address_space *mapping, int how)
1367 struct writeback_control wbc = {
1368 .bdi = mapping->backing_dev_info,
1369 .sync_mode = WB_SYNC_NONE,
1370 .nr_to_write = LONG_MAX,
1371 .for_writepages = 1,
1372 .range_cyclic = 1,
1374 int ret;
1376 ret = __nfs_write_mapping(mapping, &wbc, how);
1377 if (ret < 0)
1378 return ret;
1379 wbc.sync_mode = WB_SYNC_ALL;
1380 return __nfs_write_mapping(mapping, &wbc, how);
1384 * flush the inode to disk.
1386 int nfs_wb_all(struct inode *inode)
1388 return nfs_write_mapping(inode->i_mapping, 0);
1391 int nfs_wb_nocommit(struct inode *inode)
1393 return nfs_write_mapping(inode->i_mapping, FLUSH_NOCOMMIT);
1396 int nfs_wb_page_cancel(struct inode *inode, struct page *page)
1398 struct nfs_page *req;
1399 loff_t range_start = page_offset(page);
1400 loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1);
1401 struct writeback_control wbc = {
1402 .bdi = page->mapping->backing_dev_info,
1403 .sync_mode = WB_SYNC_ALL,
1404 .nr_to_write = LONG_MAX,
1405 .range_start = range_start,
1406 .range_end = range_end,
1408 int ret = 0;
1410 BUG_ON(!PageLocked(page));
1411 for (;;) {
1412 req = nfs_page_find_request(page);
1413 if (req == NULL)
1414 goto out;
1415 if (test_bit(PG_NEED_COMMIT, &req->wb_flags)) {
1416 nfs_release_request(req);
1417 break;
1419 if (nfs_lock_request_dontget(req)) {
1420 nfs_inode_remove_request(req);
1422 * In case nfs_inode_remove_request has marked the
1423 * page as being dirty
1425 cancel_dirty_page(page, PAGE_CACHE_SIZE);
1426 nfs_unlock_request(req);
1427 break;
1429 ret = nfs_wait_on_request(req);
1430 if (ret < 0)
1431 goto out;
1433 if (!PagePrivate(page))
1434 return 0;
1435 ret = nfs_sync_mapping_wait(page->mapping, &wbc, FLUSH_INVALIDATE);
1436 out:
1437 return ret;
1440 static int nfs_wb_page_priority(struct inode *inode, struct page *page,
1441 int how)
1443 loff_t range_start = page_offset(page);
1444 loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1);
1445 struct writeback_control wbc = {
1446 .bdi = page->mapping->backing_dev_info,
1447 .sync_mode = WB_SYNC_ALL,
1448 .nr_to_write = LONG_MAX,
1449 .range_start = range_start,
1450 .range_end = range_end,
1452 int ret;
1454 BUG_ON(!PageLocked(page));
1455 if (clear_page_dirty_for_io(page)) {
1456 ret = nfs_writepage_locked(page, &wbc);
1457 if (ret < 0)
1458 goto out;
1460 if (!PagePrivate(page))
1461 return 0;
1462 ret = nfs_sync_mapping_wait(page->mapping, &wbc, how);
1463 if (ret >= 0)
1464 return 0;
1465 out:
1466 __mark_inode_dirty(inode, I_DIRTY_PAGES);
1467 return ret;
1471 * Write back all requests on one page - we do this before reading it.
1473 int nfs_wb_page(struct inode *inode, struct page* page)
1475 return nfs_wb_page_priority(inode, page, FLUSH_STABLE);
1478 int __init nfs_init_writepagecache(void)
1480 nfs_wdata_cachep = kmem_cache_create("nfs_write_data",
1481 sizeof(struct nfs_write_data),
1482 0, SLAB_HWCACHE_ALIGN,
1483 NULL);
1484 if (nfs_wdata_cachep == NULL)
1485 return -ENOMEM;
1487 nfs_wdata_mempool = mempool_create_slab_pool(MIN_POOL_WRITE,
1488 nfs_wdata_cachep);
1489 if (nfs_wdata_mempool == NULL)
1490 return -ENOMEM;
1492 nfs_commit_mempool = mempool_create_slab_pool(MIN_POOL_COMMIT,
1493 nfs_wdata_cachep);
1494 if (nfs_commit_mempool == NULL)
1495 return -ENOMEM;
1498 * NFS congestion size, scale with available memory.
1500 * 64MB: 8192k
1501 * 128MB: 11585k
1502 * 256MB: 16384k
1503 * 512MB: 23170k
1504 * 1GB: 32768k
1505 * 2GB: 46340k
1506 * 4GB: 65536k
1507 * 8GB: 92681k
1508 * 16GB: 131072k
1510 * This allows larger machines to have larger/more transfers.
1511 * Limit the default to 256M
1513 nfs_congestion_kb = (16*int_sqrt(totalram_pages)) << (PAGE_SHIFT-10);
1514 if (nfs_congestion_kb > 256*1024)
1515 nfs_congestion_kb = 256*1024;
1517 return 0;
1520 void nfs_destroy_writepagecache(void)
1522 mempool_destroy(nfs_commit_mempool);
1523 mempool_destroy(nfs_wdata_mempool);
1524 kmem_cache_destroy(nfs_wdata_cachep);