4 * Write file data over NFS.
6 * Copyright (C) 1996, 1997, Olaf Kirch <okir@monad.swb.de>
9 #include <linux/types.h>
10 #include <linux/slab.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"
30 #define NFSDBG_FACILITY NFSDBG_PAGECACHE
32 #define MIN_POOL_WRITE (32)
33 #define MIN_POOL_COMMIT (4)
36 * Local function declarations
38 static void nfs_pageio_init_write(struct nfs_pageio_descriptor
*desc
,
39 struct inode
*inode
, int ioflags
);
40 static void nfs_redirty_request(struct nfs_page
*req
);
41 static const struct rpc_call_ops nfs_write_partial_ops
;
42 static const struct rpc_call_ops nfs_write_full_ops
;
43 static const struct rpc_call_ops nfs_commit_ops
;
45 static struct kmem_cache
*nfs_wdata_cachep
;
46 static mempool_t
*nfs_wdata_mempool
;
47 static mempool_t
*nfs_commit_mempool
;
49 struct nfs_write_data
*nfs_commitdata_alloc(void)
51 struct nfs_write_data
*p
= mempool_alloc(nfs_commit_mempool
, GFP_NOFS
);
54 memset(p
, 0, sizeof(*p
));
55 INIT_LIST_HEAD(&p
->pages
);
56 p
->res
.seq_res
.sr_slotid
= NFS4_MAX_SLOT_TABLE
;
61 void nfs_commit_free(struct nfs_write_data
*p
)
63 if (p
&& (p
->pagevec
!= &p
->page_array
[0]))
65 mempool_free(p
, nfs_commit_mempool
);
68 struct nfs_write_data
*nfs_writedata_alloc(unsigned int pagecount
)
70 struct nfs_write_data
*p
= mempool_alloc(nfs_wdata_mempool
, GFP_NOFS
);
73 memset(p
, 0, sizeof(*p
));
74 INIT_LIST_HEAD(&p
->pages
);
75 p
->npages
= pagecount
;
76 p
->res
.seq_res
.sr_slotid
= NFS4_MAX_SLOT_TABLE
;
77 if (pagecount
<= ARRAY_SIZE(p
->page_array
))
78 p
->pagevec
= p
->page_array
;
80 p
->pagevec
= kcalloc(pagecount
, sizeof(struct page
*), GFP_NOFS
);
82 mempool_free(p
, nfs_wdata_mempool
);
90 static void nfs_writedata_free(struct nfs_write_data
*p
)
92 if (p
&& (p
->pagevec
!= &p
->page_array
[0]))
94 mempool_free(p
, nfs_wdata_mempool
);
97 void nfs_writedata_release(void *data
)
99 struct nfs_write_data
*wdata
= data
;
101 put_nfs_open_context(wdata
->args
.context
);
102 nfs_writedata_free(wdata
);
105 static void nfs_context_set_write_error(struct nfs_open_context
*ctx
, int error
)
109 set_bit(NFS_CONTEXT_ERROR_WRITE
, &ctx
->flags
);
112 static struct nfs_page
*nfs_page_find_request_locked(struct page
*page
)
114 struct nfs_page
*req
= NULL
;
116 if (PagePrivate(page
)) {
117 req
= (struct nfs_page
*)page_private(page
);
119 kref_get(&req
->wb_kref
);
124 static struct nfs_page
*nfs_page_find_request(struct page
*page
)
126 struct inode
*inode
= page
->mapping
->host
;
127 struct nfs_page
*req
= NULL
;
129 spin_lock(&inode
->i_lock
);
130 req
= nfs_page_find_request_locked(page
);
131 spin_unlock(&inode
->i_lock
);
135 /* Adjust the file length if we're writing beyond the end */
136 static void nfs_grow_file(struct page
*page
, unsigned int offset
, unsigned int count
)
138 struct inode
*inode
= page
->mapping
->host
;
142 spin_lock(&inode
->i_lock
);
143 i_size
= i_size_read(inode
);
144 end_index
= (i_size
- 1) >> PAGE_CACHE_SHIFT
;
145 if (i_size
> 0 && page
->index
< end_index
)
147 end
= ((loff_t
)page
->index
<< PAGE_CACHE_SHIFT
) + ((loff_t
)offset
+count
);
150 i_size_write(inode
, end
);
151 nfs_inc_stats(inode
, NFSIOS_EXTENDWRITE
);
153 spin_unlock(&inode
->i_lock
);
156 /* A writeback failed: mark the page as bad, and invalidate the page cache */
157 static void nfs_set_pageerror(struct page
*page
)
160 nfs_zap_mapping(page
->mapping
->host
, page
->mapping
);
163 /* We can set the PG_uptodate flag if we see that a write request
164 * covers the full page.
166 static void nfs_mark_uptodate(struct page
*page
, unsigned int base
, unsigned int count
)
168 if (PageUptodate(page
))
172 if (count
!= nfs_page_length(page
))
174 SetPageUptodate(page
);
177 static int wb_priority(struct writeback_control
*wbc
)
179 if (wbc
->for_reclaim
)
180 return FLUSH_HIGHPRI
| FLUSH_STABLE
;
181 if (wbc
->for_kupdate
)
187 * NFS congestion control
190 int nfs_congestion_kb
;
192 #define NFS_CONGESTION_ON_THRESH (nfs_congestion_kb >> (PAGE_SHIFT-10))
193 #define NFS_CONGESTION_OFF_THRESH \
194 (NFS_CONGESTION_ON_THRESH - (NFS_CONGESTION_ON_THRESH >> 2))
196 static int nfs_set_page_writeback(struct page
*page
)
198 int ret
= test_set_page_writeback(page
);
201 struct inode
*inode
= page
->mapping
->host
;
202 struct nfs_server
*nfss
= NFS_SERVER(inode
);
204 if (atomic_long_inc_return(&nfss
->writeback
) >
205 NFS_CONGESTION_ON_THRESH
) {
206 set_bdi_congested(&nfss
->backing_dev_info
,
213 static void nfs_end_page_writeback(struct page
*page
)
215 struct inode
*inode
= page
->mapping
->host
;
216 struct nfs_server
*nfss
= NFS_SERVER(inode
);
218 end_page_writeback(page
);
219 if (atomic_long_dec_return(&nfss
->writeback
) < NFS_CONGESTION_OFF_THRESH
)
220 clear_bdi_congested(&nfss
->backing_dev_info
, BLK_RW_ASYNC
);
224 * Find an associated nfs write request, and prepare to flush it out
225 * May return an error if the user signalled nfs_wait_on_request().
227 static int nfs_page_async_flush(struct nfs_pageio_descriptor
*pgio
,
230 struct inode
*inode
= page
->mapping
->host
;
231 struct nfs_page
*req
;
234 spin_lock(&inode
->i_lock
);
236 req
= nfs_page_find_request_locked(page
);
238 spin_unlock(&inode
->i_lock
);
241 if (nfs_set_page_tag_locked(req
))
243 /* Note: If we hold the page lock, as is the case in nfs_writepage,
244 * then the call to nfs_set_page_tag_locked() will always
245 * succeed provided that someone hasn't already marked the
246 * request as dirty (in which case we don't care).
248 spin_unlock(&inode
->i_lock
);
249 ret
= nfs_wait_on_request(req
);
250 nfs_release_request(req
);
253 spin_lock(&inode
->i_lock
);
255 if (test_bit(PG_CLEAN
, &req
->wb_flags
)) {
256 spin_unlock(&inode
->i_lock
);
259 if (nfs_set_page_writeback(page
) != 0) {
260 spin_unlock(&inode
->i_lock
);
263 spin_unlock(&inode
->i_lock
);
264 if (!nfs_pageio_add_request(pgio
, req
)) {
265 nfs_redirty_request(req
);
266 return pgio
->pg_error
;
271 static int nfs_do_writepage(struct page
*page
, struct writeback_control
*wbc
, struct nfs_pageio_descriptor
*pgio
)
273 struct inode
*inode
= page
->mapping
->host
;
275 nfs_inc_stats(inode
, NFSIOS_VFSWRITEPAGE
);
276 nfs_add_stats(inode
, NFSIOS_WRITEPAGES
, 1);
278 nfs_pageio_cond_complete(pgio
, page
->index
);
279 return nfs_page_async_flush(pgio
, page
);
283 * Write an mmapped page to the server.
285 static int nfs_writepage_locked(struct page
*page
, struct writeback_control
*wbc
)
287 struct nfs_pageio_descriptor pgio
;
290 nfs_pageio_init_write(&pgio
, page
->mapping
->host
, wb_priority(wbc
));
291 err
= nfs_do_writepage(page
, wbc
, &pgio
);
292 nfs_pageio_complete(&pgio
);
295 if (pgio
.pg_error
< 0)
296 return pgio
.pg_error
;
300 int nfs_writepage(struct page
*page
, struct writeback_control
*wbc
)
304 ret
= nfs_writepage_locked(page
, wbc
);
309 static int nfs_writepages_callback(struct page
*page
, struct writeback_control
*wbc
, void *data
)
313 ret
= nfs_do_writepage(page
, wbc
, data
);
318 int nfs_writepages(struct address_space
*mapping
, struct writeback_control
*wbc
)
320 struct inode
*inode
= mapping
->host
;
321 unsigned long *bitlock
= &NFS_I(inode
)->flags
;
322 struct nfs_pageio_descriptor pgio
;
325 /* Stop dirtying of new pages while we sync */
326 err
= wait_on_bit_lock(bitlock
, NFS_INO_FLUSHING
,
327 nfs_wait_bit_killable
, TASK_KILLABLE
);
331 nfs_inc_stats(inode
, NFSIOS_VFSWRITEPAGES
);
333 nfs_pageio_init_write(&pgio
, inode
, wb_priority(wbc
));
334 err
= write_cache_pages(mapping
, wbc
, nfs_writepages_callback
, &pgio
);
335 nfs_pageio_complete(&pgio
);
337 clear_bit_unlock(NFS_INO_FLUSHING
, bitlock
);
338 smp_mb__after_clear_bit();
339 wake_up_bit(bitlock
, NFS_INO_FLUSHING
);
352 * Insert a write request into an inode
354 static int nfs_inode_add_request(struct inode
*inode
, struct nfs_page
*req
)
356 struct nfs_inode
*nfsi
= NFS_I(inode
);
359 error
= radix_tree_preload(GFP_NOFS
);
363 /* Lock the request! */
364 nfs_lock_request_dontget(req
);
366 spin_lock(&inode
->i_lock
);
367 error
= radix_tree_insert(&nfsi
->nfs_page_tree
, req
->wb_index
, req
);
371 if (nfs_have_delegation(inode
, FMODE_WRITE
))
374 SetPagePrivate(req
->wb_page
);
375 set_page_private(req
->wb_page
, (unsigned long)req
);
377 kref_get(&req
->wb_kref
);
378 radix_tree_tag_set(&nfsi
->nfs_page_tree
, req
->wb_index
,
379 NFS_PAGE_TAG_LOCKED
);
380 spin_unlock(&inode
->i_lock
);
381 radix_tree_preload_end();
387 * Remove a write request from an inode
389 static void nfs_inode_remove_request(struct nfs_page
*req
)
391 struct inode
*inode
= req
->wb_context
->path
.dentry
->d_inode
;
392 struct nfs_inode
*nfsi
= NFS_I(inode
);
394 BUG_ON (!NFS_WBACK_BUSY(req
));
396 spin_lock(&inode
->i_lock
);
397 set_page_private(req
->wb_page
, 0);
398 ClearPagePrivate(req
->wb_page
);
399 radix_tree_delete(&nfsi
->nfs_page_tree
, req
->wb_index
);
402 spin_unlock(&inode
->i_lock
);
405 spin_unlock(&inode
->i_lock
);
406 nfs_clear_request(req
);
407 nfs_release_request(req
);
411 nfs_mark_request_dirty(struct nfs_page
*req
)
413 __set_page_dirty_nobuffers(req
->wb_page
);
416 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
418 * Add a request to the inode's commit list.
421 nfs_mark_request_commit(struct nfs_page
*req
)
423 struct inode
*inode
= req
->wb_context
->path
.dentry
->d_inode
;
424 struct nfs_inode
*nfsi
= NFS_I(inode
);
426 spin_lock(&inode
->i_lock
);
427 set_bit(PG_CLEAN
, &(req
)->wb_flags
);
428 radix_tree_tag_set(&nfsi
->nfs_page_tree
,
430 NFS_PAGE_TAG_COMMIT
);
431 spin_unlock(&inode
->i_lock
);
432 inc_zone_page_state(req
->wb_page
, NR_UNSTABLE_NFS
);
433 inc_bdi_stat(req
->wb_page
->mapping
->backing_dev_info
, BDI_RECLAIMABLE
);
434 __mark_inode_dirty(inode
, I_DIRTY_DATASYNC
);
438 nfs_clear_request_commit(struct nfs_page
*req
)
440 struct page
*page
= req
->wb_page
;
442 if (test_and_clear_bit(PG_CLEAN
, &(req
)->wb_flags
)) {
443 dec_zone_page_state(page
, NR_UNSTABLE_NFS
);
444 dec_bdi_stat(page
->mapping
->backing_dev_info
, BDI_RECLAIMABLE
);
451 int nfs_write_need_commit(struct nfs_write_data
*data
)
453 return data
->verf
.committed
!= NFS_FILE_SYNC
;
457 int nfs_reschedule_unstable_write(struct nfs_page
*req
)
459 if (test_and_clear_bit(PG_NEED_COMMIT
, &req
->wb_flags
)) {
460 nfs_mark_request_commit(req
);
463 if (test_and_clear_bit(PG_NEED_RESCHED
, &req
->wb_flags
)) {
464 nfs_mark_request_dirty(req
);
471 nfs_mark_request_commit(struct nfs_page
*req
)
476 nfs_clear_request_commit(struct nfs_page
*req
)
482 int nfs_write_need_commit(struct nfs_write_data
*data
)
488 int nfs_reschedule_unstable_write(struct nfs_page
*req
)
495 * Wait for a request to complete.
497 * Interruptible by fatal signals only.
499 static int nfs_wait_on_requests_locked(struct inode
*inode
, pgoff_t idx_start
, unsigned int npages
)
501 struct nfs_inode
*nfsi
= NFS_I(inode
);
502 struct nfs_page
*req
;
503 pgoff_t idx_end
, next
;
504 unsigned int res
= 0;
510 idx_end
= idx_start
+ npages
- 1;
513 while (radix_tree_gang_lookup_tag(&nfsi
->nfs_page_tree
, (void **)&req
, next
, 1, NFS_PAGE_TAG_LOCKED
)) {
514 if (req
->wb_index
> idx_end
)
517 next
= req
->wb_index
+ 1;
518 BUG_ON(!NFS_WBACK_BUSY(req
));
520 kref_get(&req
->wb_kref
);
521 spin_unlock(&inode
->i_lock
);
522 error
= nfs_wait_on_request(req
);
523 nfs_release_request(req
);
524 spin_lock(&inode
->i_lock
);
532 static void nfs_cancel_commit_list(struct list_head
*head
)
534 struct nfs_page
*req
;
536 while(!list_empty(head
)) {
537 req
= nfs_list_entry(head
->next
);
538 nfs_list_remove_request(req
);
539 nfs_clear_request_commit(req
);
540 nfs_inode_remove_request(req
);
541 nfs_unlock_request(req
);
545 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
547 nfs_need_commit(struct nfs_inode
*nfsi
)
549 return radix_tree_tagged(&nfsi
->nfs_page_tree
, NFS_PAGE_TAG_COMMIT
);
553 * nfs_scan_commit - Scan an inode for commit requests
554 * @inode: NFS inode to scan
555 * @dst: destination list
556 * @idx_start: lower bound of page->index to scan.
557 * @npages: idx_start + npages sets the upper bound to scan.
559 * Moves requests from the inode's 'commit' request list.
560 * The requests are *not* checked to ensure that they form a contiguous set.
563 nfs_scan_commit(struct inode
*inode
, struct list_head
*dst
, pgoff_t idx_start
, unsigned int npages
)
565 struct nfs_inode
*nfsi
= NFS_I(inode
);
567 if (!nfs_need_commit(nfsi
))
570 return nfs_scan_list(nfsi
, dst
, idx_start
, npages
, NFS_PAGE_TAG_COMMIT
);
573 static inline int nfs_need_commit(struct nfs_inode
*nfsi
)
578 static inline int nfs_scan_commit(struct inode
*inode
, struct list_head
*dst
, pgoff_t idx_start
, unsigned int npages
)
585 * Search for an existing write request, and attempt to update
586 * it to reflect a new dirty region on a given page.
588 * If the attempt fails, then the existing request is flushed out
591 static struct nfs_page
*nfs_try_to_update_request(struct inode
*inode
,
596 struct nfs_page
*req
;
601 if (!PagePrivate(page
))
604 end
= offset
+ bytes
;
605 spin_lock(&inode
->i_lock
);
608 req
= nfs_page_find_request_locked(page
);
612 rqend
= req
->wb_offset
+ req
->wb_bytes
;
614 * Tell the caller to flush out the request if
615 * the offsets are non-contiguous.
616 * Note: nfs_flush_incompatible() will already
617 * have flushed out requests having wrong owners.
620 || end
< req
->wb_offset
)
623 if (nfs_set_page_tag_locked(req
))
626 /* The request is locked, so wait and then retry */
627 spin_unlock(&inode
->i_lock
);
628 error
= nfs_wait_on_request(req
);
629 nfs_release_request(req
);
632 spin_lock(&inode
->i_lock
);
635 if (nfs_clear_request_commit(req
))
636 radix_tree_tag_clear(&NFS_I(inode
)->nfs_page_tree
,
637 req
->wb_index
, NFS_PAGE_TAG_COMMIT
);
639 /* Okay, the request matches. Update the region */
640 if (offset
< req
->wb_offset
) {
641 req
->wb_offset
= offset
;
642 req
->wb_pgbase
= offset
;
645 req
->wb_bytes
= end
- req
->wb_offset
;
647 req
->wb_bytes
= rqend
- req
->wb_offset
;
649 spin_unlock(&inode
->i_lock
);
652 spin_unlock(&inode
->i_lock
);
653 nfs_release_request(req
);
654 error
= nfs_wb_page(inode
, page
);
656 return ERR_PTR(error
);
660 * Try to update an existing write request, or create one if there is none.
662 * Note: Should always be called with the Page Lock held to prevent races
663 * if we have to add a new request. Also assumes that the caller has
664 * already called nfs_flush_incompatible() if necessary.
666 static struct nfs_page
* nfs_setup_write_request(struct nfs_open_context
* ctx
,
667 struct page
*page
, unsigned int offset
, unsigned int bytes
)
669 struct inode
*inode
= page
->mapping
->host
;
670 struct nfs_page
*req
;
673 req
= nfs_try_to_update_request(inode
, page
, offset
, bytes
);
676 req
= nfs_create_request(ctx
, inode
, page
, offset
, bytes
);
679 error
= nfs_inode_add_request(inode
, req
);
681 nfs_release_request(req
);
682 req
= ERR_PTR(error
);
688 static int nfs_writepage_setup(struct nfs_open_context
*ctx
, struct page
*page
,
689 unsigned int offset
, unsigned int count
)
691 struct nfs_page
*req
;
693 req
= nfs_setup_write_request(ctx
, page
, offset
, count
);
696 /* Update file length */
697 nfs_grow_file(page
, offset
, count
);
698 nfs_mark_uptodate(page
, req
->wb_pgbase
, req
->wb_bytes
);
699 nfs_clear_page_tag_locked(req
);
703 int nfs_flush_incompatible(struct file
*file
, struct page
*page
)
705 struct nfs_open_context
*ctx
= nfs_file_open_context(file
);
706 struct nfs_page
*req
;
707 int do_flush
, status
;
709 * Look for a request corresponding to this page. If there
710 * is one, and it belongs to another file, we flush it out
711 * before we try to copy anything into the page. Do this
712 * due to the lack of an ACCESS-type call in NFSv2.
713 * Also do the same if we find a request from an existing
717 req
= nfs_page_find_request(page
);
720 do_flush
= req
->wb_page
!= page
|| req
->wb_context
!= ctx
;
721 nfs_release_request(req
);
724 status
= nfs_wb_page(page
->mapping
->host
, page
);
725 } while (status
== 0);
730 * If the page cache is marked as unsafe or invalid, then we can't rely on
731 * the PageUptodate() flag. In this case, we will need to turn off
732 * write optimisations that depend on the page contents being correct.
734 static int nfs_write_pageuptodate(struct page
*page
, struct inode
*inode
)
736 return PageUptodate(page
) &&
737 !(NFS_I(inode
)->cache_validity
& (NFS_INO_REVAL_PAGECACHE
|NFS_INO_INVALID_DATA
));
741 * Update and possibly write a cached page of an NFS file.
743 * XXX: Keep an eye on generic_file_read to make sure it doesn't do bad
744 * things with a page scheduled for an RPC call (e.g. invalidate it).
746 int nfs_updatepage(struct file
*file
, struct page
*page
,
747 unsigned int offset
, unsigned int count
)
749 struct nfs_open_context
*ctx
= nfs_file_open_context(file
);
750 struct inode
*inode
= page
->mapping
->host
;
753 nfs_inc_stats(inode
, NFSIOS_VFSUPDATEPAGE
);
755 dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n",
756 file
->f_path
.dentry
->d_parent
->d_name
.name
,
757 file
->f_path
.dentry
->d_name
.name
, count
,
758 (long long)(page_offset(page
) + offset
));
760 /* If we're not using byte range locks, and we know the page
761 * is up to date, it may be more efficient to extend the write
762 * to cover the entire page in order to avoid fragmentation
765 if (nfs_write_pageuptodate(page
, inode
) &&
766 inode
->i_flock
== NULL
&&
767 !(file
->f_flags
& O_SYNC
)) {
768 count
= max(count
+ offset
, nfs_page_length(page
));
772 status
= nfs_writepage_setup(ctx
, page
, offset
, count
);
774 nfs_set_pageerror(page
);
776 __set_page_dirty_nobuffers(page
);
778 dprintk("NFS: nfs_updatepage returns %d (isize %lld)\n",
779 status
, (long long)i_size_read(inode
));
783 static void nfs_writepage_release(struct nfs_page
*req
)
786 if (PageError(req
->wb_page
) || !nfs_reschedule_unstable_write(req
)) {
787 nfs_end_page_writeback(req
->wb_page
);
788 nfs_inode_remove_request(req
);
790 nfs_end_page_writeback(req
->wb_page
);
791 nfs_clear_page_tag_locked(req
);
794 static int flush_task_priority(int how
)
796 switch (how
& (FLUSH_HIGHPRI
|FLUSH_LOWPRI
)) {
798 return RPC_PRIORITY_HIGH
;
800 return RPC_PRIORITY_LOW
;
802 return RPC_PRIORITY_NORMAL
;
806 * Set up the argument/result storage required for the RPC call.
808 static int nfs_write_rpcsetup(struct nfs_page
*req
,
809 struct nfs_write_data
*data
,
810 const struct rpc_call_ops
*call_ops
,
811 unsigned int count
, unsigned int offset
,
814 struct inode
*inode
= req
->wb_context
->path
.dentry
->d_inode
;
815 int flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
816 int priority
= flush_task_priority(how
);
817 struct rpc_task
*task
;
818 struct rpc_message msg
= {
819 .rpc_argp
= &data
->args
,
820 .rpc_resp
= &data
->res
,
821 .rpc_cred
= req
->wb_context
->cred
,
823 struct rpc_task_setup task_setup_data
= {
824 .rpc_client
= NFS_CLIENT(inode
),
827 .callback_ops
= call_ops
,
828 .callback_data
= data
,
829 .workqueue
= nfsiod_workqueue
,
831 .priority
= priority
,
834 /* Set up the RPC argument and reply structs
835 * NB: take care not to mess about with data->commit et al. */
838 data
->inode
= inode
= req
->wb_context
->path
.dentry
->d_inode
;
839 data
->cred
= msg
.rpc_cred
;
841 data
->args
.fh
= NFS_FH(inode
);
842 data
->args
.offset
= req_offset(req
) + offset
;
843 data
->args
.pgbase
= req
->wb_pgbase
+ offset
;
844 data
->args
.pages
= data
->pagevec
;
845 data
->args
.count
= count
;
846 data
->args
.context
= get_nfs_open_context(req
->wb_context
);
847 data
->args
.stable
= NFS_UNSTABLE
;
848 if (how
& FLUSH_STABLE
) {
849 data
->args
.stable
= NFS_DATA_SYNC
;
850 if (!nfs_need_commit(NFS_I(inode
)))
851 data
->args
.stable
= NFS_FILE_SYNC
;
854 data
->res
.fattr
= &data
->fattr
;
855 data
->res
.count
= count
;
856 data
->res
.verf
= &data
->verf
;
857 nfs_fattr_init(&data
->fattr
);
859 /* Set up the initial task struct. */
860 NFS_PROTO(inode
)->write_setup(data
, &msg
);
862 dprintk("NFS: %5u initiated write call "
863 "(req %s/%lld, %u bytes @ offset %llu)\n",
866 (long long)NFS_FILEID(inode
),
868 (unsigned long long)data
->args
.offset
);
870 task
= rpc_run_task(&task_setup_data
);
872 return PTR_ERR(task
);
877 /* If a nfs_flush_* function fails, it should remove reqs from @head and
878 * call this on each, which will prepare them to be retried on next
879 * writeback using standard nfs.
881 static void nfs_redirty_request(struct nfs_page
*req
)
883 nfs_mark_request_dirty(req
);
884 nfs_end_page_writeback(req
->wb_page
);
885 nfs_clear_page_tag_locked(req
);
889 * Generate multiple small requests to write out a single
890 * contiguous dirty area on one page.
892 static int nfs_flush_multi(struct inode
*inode
, struct list_head
*head
, unsigned int npages
, size_t count
, int how
)
894 struct nfs_page
*req
= nfs_list_entry(head
->next
);
895 struct page
*page
= req
->wb_page
;
896 struct nfs_write_data
*data
;
897 size_t wsize
= NFS_SERVER(inode
)->wsize
, nbytes
;
903 nfs_list_remove_request(req
);
907 size_t len
= min(nbytes
, wsize
);
909 data
= nfs_writedata_alloc(1);
912 list_add(&data
->pages
, &list
);
915 } while (nbytes
!= 0);
916 atomic_set(&req
->wb_complete
, requests
);
918 ClearPageError(page
);
924 data
= list_entry(list
.next
, struct nfs_write_data
, pages
);
925 list_del_init(&data
->pages
);
927 data
->pagevec
[0] = page
;
931 ret2
= nfs_write_rpcsetup(req
, data
, &nfs_write_partial_ops
,
937 } while (nbytes
!= 0);
942 while (!list_empty(&list
)) {
943 data
= list_entry(list
.next
, struct nfs_write_data
, pages
);
944 list_del(&data
->pages
);
945 nfs_writedata_release(data
);
947 nfs_redirty_request(req
);
952 * Create an RPC task for the given write request and kick it.
953 * The page must have been locked by the caller.
955 * It may happen that the page we're passed is not marked dirty.
956 * This is the case if nfs_updatepage detects a conflicting request
957 * that has been written but not committed.
959 static int nfs_flush_one(struct inode
*inode
, struct list_head
*head
, unsigned int npages
, size_t count
, int how
)
961 struct nfs_page
*req
;
963 struct nfs_write_data
*data
;
965 data
= nfs_writedata_alloc(npages
);
969 pages
= data
->pagevec
;
970 while (!list_empty(head
)) {
971 req
= nfs_list_entry(head
->next
);
972 nfs_list_remove_request(req
);
973 nfs_list_add_request(req
, &data
->pages
);
974 ClearPageError(req
->wb_page
);
975 *pages
++ = req
->wb_page
;
977 req
= nfs_list_entry(data
->pages
.next
);
979 /* Set up the argument struct */
980 return nfs_write_rpcsetup(req
, data
, &nfs_write_full_ops
, count
, 0, how
);
982 while (!list_empty(head
)) {
983 req
= nfs_list_entry(head
->next
);
984 nfs_list_remove_request(req
);
985 nfs_redirty_request(req
);
990 static void nfs_pageio_init_write(struct nfs_pageio_descriptor
*pgio
,
991 struct inode
*inode
, int ioflags
)
993 size_t wsize
= NFS_SERVER(inode
)->wsize
;
995 if (wsize
< PAGE_CACHE_SIZE
)
996 nfs_pageio_init(pgio
, inode
, nfs_flush_multi
, wsize
, ioflags
);
998 nfs_pageio_init(pgio
, inode
, nfs_flush_one
, wsize
, ioflags
);
1002 * Handle a write reply that flushed part of a page.
1004 static void nfs_writeback_done_partial(struct rpc_task
*task
, void *calldata
)
1006 struct nfs_write_data
*data
= calldata
;
1008 dprintk("NFS: %5u write(%s/%lld %d@%lld)",
1010 data
->req
->wb_context
->path
.dentry
->d_inode
->i_sb
->s_id
,
1012 NFS_FILEID(data
->req
->wb_context
->path
.dentry
->d_inode
),
1013 data
->req
->wb_bytes
, (long long)req_offset(data
->req
));
1015 nfs_writeback_done(task
, data
);
1018 static void nfs_writeback_release_partial(void *calldata
)
1020 struct nfs_write_data
*data
= calldata
;
1021 struct nfs_page
*req
= data
->req
;
1022 struct page
*page
= req
->wb_page
;
1023 int status
= data
->task
.tk_status
;
1026 nfs_set_pageerror(page
);
1027 nfs_context_set_write_error(req
->wb_context
, status
);
1028 dprintk(", error = %d\n", status
);
1032 if (nfs_write_need_commit(data
)) {
1033 struct inode
*inode
= page
->mapping
->host
;
1035 spin_lock(&inode
->i_lock
);
1036 if (test_bit(PG_NEED_RESCHED
, &req
->wb_flags
)) {
1037 /* Do nothing we need to resend the writes */
1038 } else if (!test_and_set_bit(PG_NEED_COMMIT
, &req
->wb_flags
)) {
1039 memcpy(&req
->wb_verf
, &data
->verf
, sizeof(req
->wb_verf
));
1040 dprintk(" defer commit\n");
1041 } else if (memcmp(&req
->wb_verf
, &data
->verf
, sizeof(req
->wb_verf
))) {
1042 set_bit(PG_NEED_RESCHED
, &req
->wb_flags
);
1043 clear_bit(PG_NEED_COMMIT
, &req
->wb_flags
);
1044 dprintk(" server reboot detected\n");
1046 spin_unlock(&inode
->i_lock
);
1051 if (atomic_dec_and_test(&req
->wb_complete
))
1052 nfs_writepage_release(req
);
1053 nfs_writedata_release(calldata
);
1056 #if defined(CONFIG_NFS_V4_1)
1057 void nfs_write_prepare(struct rpc_task
*task
, void *calldata
)
1059 struct nfs_write_data
*data
= calldata
;
1060 struct nfs_client
*clp
= (NFS_SERVER(data
->inode
))->nfs_client
;
1062 if (nfs4_setup_sequence(clp
, &data
->args
.seq_args
,
1063 &data
->res
.seq_res
, 1, task
))
1065 rpc_call_start(task
);
1067 #endif /* CONFIG_NFS_V4_1 */
1069 static const struct rpc_call_ops nfs_write_partial_ops
= {
1070 #if defined(CONFIG_NFS_V4_1)
1071 .rpc_call_prepare
= nfs_write_prepare
,
1072 #endif /* CONFIG_NFS_V4_1 */
1073 .rpc_call_done
= nfs_writeback_done_partial
,
1074 .rpc_release
= nfs_writeback_release_partial
,
1078 * Handle a write reply that flushes a whole page.
1080 * FIXME: There is an inherent race with invalidate_inode_pages and
1081 * writebacks since the page->count is kept > 1 for as long
1082 * as the page has a write request pending.
1084 static void nfs_writeback_done_full(struct rpc_task
*task
, void *calldata
)
1086 struct nfs_write_data
*data
= calldata
;
1088 nfs_writeback_done(task
, data
);
1091 static void nfs_writeback_release_full(void *calldata
)
1093 struct nfs_write_data
*data
= calldata
;
1094 int status
= data
->task
.tk_status
;
1096 /* Update attributes as result of writeback. */
1097 while (!list_empty(&data
->pages
)) {
1098 struct nfs_page
*req
= nfs_list_entry(data
->pages
.next
);
1099 struct page
*page
= req
->wb_page
;
1101 nfs_list_remove_request(req
);
1103 dprintk("NFS: %5u write (%s/%lld %d@%lld)",
1105 req
->wb_context
->path
.dentry
->d_inode
->i_sb
->s_id
,
1106 (long long)NFS_FILEID(req
->wb_context
->path
.dentry
->d_inode
),
1108 (long long)req_offset(req
));
1111 nfs_set_pageerror(page
);
1112 nfs_context_set_write_error(req
->wb_context
, status
);
1113 dprintk(", error = %d\n", status
);
1114 goto remove_request
;
1117 if (nfs_write_need_commit(data
)) {
1118 memcpy(&req
->wb_verf
, &data
->verf
, sizeof(req
->wb_verf
));
1119 nfs_mark_request_commit(req
);
1120 nfs_end_page_writeback(page
);
1121 dprintk(" marked for commit\n");
1126 nfs_end_page_writeback(page
);
1127 nfs_inode_remove_request(req
);
1129 nfs_clear_page_tag_locked(req
);
1131 nfs_writedata_release(calldata
);
1134 static const struct rpc_call_ops nfs_write_full_ops
= {
1135 #if defined(CONFIG_NFS_V4_1)
1136 .rpc_call_prepare
= nfs_write_prepare
,
1137 #endif /* CONFIG_NFS_V4_1 */
1138 .rpc_call_done
= nfs_writeback_done_full
,
1139 .rpc_release
= nfs_writeback_release_full
,
1144 * This function is called when the WRITE call is complete.
1146 int nfs_writeback_done(struct rpc_task
*task
, struct nfs_write_data
*data
)
1148 struct nfs_writeargs
*argp
= &data
->args
;
1149 struct nfs_writeres
*resp
= &data
->res
;
1150 struct nfs_server
*server
= NFS_SERVER(data
->inode
);
1153 dprintk("NFS: %5u nfs_writeback_done (status %d)\n",
1154 task
->tk_pid
, task
->tk_status
);
1157 * ->write_done will attempt to use post-op attributes to detect
1158 * conflicting writes by other clients. A strict interpretation
1159 * of close-to-open would allow us to continue caching even if
1160 * another writer had changed the file, but some applications
1161 * depend on tighter cache coherency when writing.
1163 status
= NFS_PROTO(data
->inode
)->write_done(task
, data
);
1166 nfs_add_stats(data
->inode
, NFSIOS_SERVERWRITTENBYTES
, resp
->count
);
1168 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
1169 if (resp
->verf
->committed
< argp
->stable
&& task
->tk_status
>= 0) {
1170 /* We tried a write call, but the server did not
1171 * commit data to stable storage even though we
1173 * Note: There is a known bug in Tru64 < 5.0 in which
1174 * the server reports NFS_DATA_SYNC, but performs
1175 * NFS_FILE_SYNC. We therefore implement this checking
1176 * as a dprintk() in order to avoid filling syslog.
1178 static unsigned long complain
;
1180 if (time_before(complain
, jiffies
)) {
1181 dprintk("NFS: faulty NFS server %s:"
1182 " (committed = %d) != (stable = %d)\n",
1183 server
->nfs_client
->cl_hostname
,
1184 resp
->verf
->committed
, argp
->stable
);
1185 complain
= jiffies
+ 300 * HZ
;
1189 /* Is this a short write? */
1190 if (task
->tk_status
>= 0 && resp
->count
< argp
->count
) {
1191 static unsigned long complain
;
1193 nfs_inc_stats(data
->inode
, NFSIOS_SHORTWRITE
);
1195 /* Has the server at least made some progress? */
1196 if (resp
->count
!= 0) {
1197 /* Was this an NFSv2 write or an NFSv3 stable write? */
1198 if (resp
->verf
->committed
!= NFS_UNSTABLE
) {
1199 /* Resend from where the server left off */
1200 argp
->offset
+= resp
->count
;
1201 argp
->pgbase
+= resp
->count
;
1202 argp
->count
-= resp
->count
;
1204 /* Resend as a stable write in order to avoid
1205 * headaches in the case of a server crash.
1207 argp
->stable
= NFS_FILE_SYNC
;
1209 nfs4_restart_rpc(task
, server
->nfs_client
);
1212 if (time_before(complain
, jiffies
)) {
1214 "NFS: Server wrote zero bytes, expected %u.\n",
1216 complain
= jiffies
+ 300 * HZ
;
1218 /* Can't do anything about it except throw an error. */
1219 task
->tk_status
= -EIO
;
1221 nfs4_sequence_free_slot(server
->nfs_client
, &data
->res
.seq_res
);
1226 #if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
1227 void nfs_commitdata_release(void *data
)
1229 struct nfs_write_data
*wdata
= data
;
1231 put_nfs_open_context(wdata
->args
.context
);
1232 nfs_commit_free(wdata
);
1236 * Set up the argument/result storage required for the RPC call.
1238 static int nfs_commit_rpcsetup(struct list_head
*head
,
1239 struct nfs_write_data
*data
,
1242 struct nfs_page
*first
= nfs_list_entry(head
->next
);
1243 struct inode
*inode
= first
->wb_context
->path
.dentry
->d_inode
;
1244 int flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
1245 int priority
= flush_task_priority(how
);
1246 struct rpc_task
*task
;
1247 struct rpc_message msg
= {
1248 .rpc_argp
= &data
->args
,
1249 .rpc_resp
= &data
->res
,
1250 .rpc_cred
= first
->wb_context
->cred
,
1252 struct rpc_task_setup task_setup_data
= {
1253 .task
= &data
->task
,
1254 .rpc_client
= NFS_CLIENT(inode
),
1255 .rpc_message
= &msg
,
1256 .callback_ops
= &nfs_commit_ops
,
1257 .callback_data
= data
,
1258 .workqueue
= nfsiod_workqueue
,
1260 .priority
= priority
,
1263 /* Set up the RPC argument and reply structs
1264 * NB: take care not to mess about with data->commit et al. */
1266 list_splice_init(head
, &data
->pages
);
1268 data
->inode
= inode
;
1269 data
->cred
= msg
.rpc_cred
;
1271 data
->args
.fh
= NFS_FH(data
->inode
);
1272 /* Note: we always request a commit of the entire inode */
1273 data
->args
.offset
= 0;
1274 data
->args
.count
= 0;
1275 data
->args
.context
= get_nfs_open_context(first
->wb_context
);
1276 data
->res
.count
= 0;
1277 data
->res
.fattr
= &data
->fattr
;
1278 data
->res
.verf
= &data
->verf
;
1279 nfs_fattr_init(&data
->fattr
);
1281 /* Set up the initial task struct. */
1282 NFS_PROTO(inode
)->commit_setup(data
, &msg
);
1284 dprintk("NFS: %5u initiated commit call\n", data
->task
.tk_pid
);
1286 task
= rpc_run_task(&task_setup_data
);
1288 return PTR_ERR(task
);
1294 * Commit dirty pages
1297 nfs_commit_list(struct inode
*inode
, struct list_head
*head
, int how
)
1299 struct nfs_write_data
*data
;
1300 struct nfs_page
*req
;
1302 data
= nfs_commitdata_alloc();
1307 /* Set up the argument struct */
1308 return nfs_commit_rpcsetup(head
, data
, how
);
1310 while (!list_empty(head
)) {
1311 req
= nfs_list_entry(head
->next
);
1312 nfs_list_remove_request(req
);
1313 nfs_mark_request_commit(req
);
1314 dec_zone_page_state(req
->wb_page
, NR_UNSTABLE_NFS
);
1315 dec_bdi_stat(req
->wb_page
->mapping
->backing_dev_info
,
1317 nfs_clear_page_tag_locked(req
);
1323 * COMMIT call returned
1325 static void nfs_commit_done(struct rpc_task
*task
, void *calldata
)
1327 struct nfs_write_data
*data
= calldata
;
1329 dprintk("NFS: %5u nfs_commit_done (status %d)\n",
1330 task
->tk_pid
, task
->tk_status
);
1332 /* Call the NFS version-specific code */
1333 if (NFS_PROTO(data
->inode
)->commit_done(task
, data
) != 0)
1337 static void nfs_commit_release(void *calldata
)
1339 struct nfs_write_data
*data
= calldata
;
1340 struct nfs_page
*req
;
1341 int status
= data
->task
.tk_status
;
1343 while (!list_empty(&data
->pages
)) {
1344 req
= nfs_list_entry(data
->pages
.next
);
1345 nfs_list_remove_request(req
);
1346 nfs_clear_request_commit(req
);
1348 dprintk("NFS: commit (%s/%lld %d@%lld)",
1349 req
->wb_context
->path
.dentry
->d_inode
->i_sb
->s_id
,
1350 (long long)NFS_FILEID(req
->wb_context
->path
.dentry
->d_inode
),
1352 (long long)req_offset(req
));
1354 nfs_context_set_write_error(req
->wb_context
, status
);
1355 nfs_inode_remove_request(req
);
1356 dprintk(", error = %d\n", status
);
1360 /* Okay, COMMIT succeeded, apparently. Check the verifier
1361 * returned by the server against all stored verfs. */
1362 if (!memcmp(req
->wb_verf
.verifier
, data
->verf
.verifier
, sizeof(data
->verf
.verifier
))) {
1363 /* We have a match */
1364 nfs_inode_remove_request(req
);
1368 /* We have a mismatch. Write the page again */
1369 dprintk(" mismatch\n");
1370 nfs_mark_request_dirty(req
);
1372 nfs_clear_page_tag_locked(req
);
1374 nfs_commitdata_release(calldata
);
1377 static const struct rpc_call_ops nfs_commit_ops
= {
1378 #if defined(CONFIG_NFS_V4_1)
1379 .rpc_call_prepare
= nfs_write_prepare
,
1380 #endif /* CONFIG_NFS_V4_1 */
1381 .rpc_call_done
= nfs_commit_done
,
1382 .rpc_release
= nfs_commit_release
,
1385 int nfs_commit_inode(struct inode
*inode
, int how
)
1390 spin_lock(&inode
->i_lock
);
1391 res
= nfs_scan_commit(inode
, &head
, 0, 0);
1392 spin_unlock(&inode
->i_lock
);
1394 int error
= nfs_commit_list(inode
, &head
, how
);
1401 static inline int nfs_commit_list(struct inode
*inode
, struct list_head
*head
, int how
)
1407 long nfs_sync_mapping_wait(struct address_space
*mapping
, struct writeback_control
*wbc
, int how
)
1409 struct inode
*inode
= mapping
->host
;
1410 pgoff_t idx_start
, idx_end
;
1411 unsigned int npages
= 0;
1413 int nocommit
= how
& FLUSH_NOCOMMIT
;
1417 if (wbc
->range_cyclic
)
1420 idx_start
= wbc
->range_start
>> PAGE_CACHE_SHIFT
;
1421 idx_end
= wbc
->range_end
>> PAGE_CACHE_SHIFT
;
1422 if (idx_end
> idx_start
) {
1423 pgoff_t l_npages
= 1 + idx_end
- idx_start
;
1425 if (sizeof(npages
) != sizeof(l_npages
) &&
1426 (pgoff_t
)npages
!= l_npages
)
1430 how
&= ~FLUSH_NOCOMMIT
;
1431 spin_lock(&inode
->i_lock
);
1433 ret
= nfs_wait_on_requests_locked(inode
, idx_start
, npages
);
1438 pages
= nfs_scan_commit(inode
, &head
, idx_start
, npages
);
1441 if (how
& FLUSH_INVALIDATE
) {
1442 spin_unlock(&inode
->i_lock
);
1443 nfs_cancel_commit_list(&head
);
1445 spin_lock(&inode
->i_lock
);
1448 pages
+= nfs_scan_commit(inode
, &head
, 0, 0);
1449 spin_unlock(&inode
->i_lock
);
1450 ret
= nfs_commit_list(inode
, &head
, how
);
1451 spin_lock(&inode
->i_lock
);
1454 spin_unlock(&inode
->i_lock
);
1458 static int __nfs_write_mapping(struct address_space
*mapping
, struct writeback_control
*wbc
, int how
)
1462 ret
= nfs_writepages(mapping
, wbc
);
1465 ret
= nfs_sync_mapping_wait(mapping
, wbc
, how
);
1470 __mark_inode_dirty(mapping
->host
, I_DIRTY_PAGES
);
1474 /* Two pass sync: first using WB_SYNC_NONE, then WB_SYNC_ALL */
1475 static int nfs_write_mapping(struct address_space
*mapping
, int how
)
1477 struct writeback_control wbc
= {
1478 .bdi
= mapping
->backing_dev_info
,
1479 .sync_mode
= WB_SYNC_ALL
,
1480 .nr_to_write
= LONG_MAX
,
1482 .range_end
= LLONG_MAX
,
1483 .for_writepages
= 1,
1486 return __nfs_write_mapping(mapping
, &wbc
, how
);
1490 * flush the inode to disk.
1492 int nfs_wb_all(struct inode
*inode
)
1494 return nfs_write_mapping(inode
->i_mapping
, 0);
1497 int nfs_wb_nocommit(struct inode
*inode
)
1499 return nfs_write_mapping(inode
->i_mapping
, FLUSH_NOCOMMIT
);
1502 int nfs_wb_page_cancel(struct inode
*inode
, struct page
*page
)
1504 struct nfs_page
*req
;
1505 loff_t range_start
= page_offset(page
);
1506 loff_t range_end
= range_start
+ (loff_t
)(PAGE_CACHE_SIZE
- 1);
1507 struct writeback_control wbc
= {
1508 .bdi
= page
->mapping
->backing_dev_info
,
1509 .sync_mode
= WB_SYNC_ALL
,
1510 .nr_to_write
= LONG_MAX
,
1511 .range_start
= range_start
,
1512 .range_end
= range_end
,
1516 BUG_ON(!PageLocked(page
));
1518 req
= nfs_page_find_request(page
);
1521 if (test_bit(PG_CLEAN
, &req
->wb_flags
)) {
1522 nfs_release_request(req
);
1525 if (nfs_lock_request_dontget(req
)) {
1526 nfs_inode_remove_request(req
);
1528 * In case nfs_inode_remove_request has marked the
1529 * page as being dirty
1531 cancel_dirty_page(page
, PAGE_CACHE_SIZE
);
1532 nfs_unlock_request(req
);
1535 ret
= nfs_wait_on_request(req
);
1539 if (!PagePrivate(page
))
1541 ret
= nfs_sync_mapping_wait(page
->mapping
, &wbc
, FLUSH_INVALIDATE
);
1546 static int nfs_wb_page_priority(struct inode
*inode
, struct page
*page
,
1549 loff_t range_start
= page_offset(page
);
1550 loff_t range_end
= range_start
+ (loff_t
)(PAGE_CACHE_SIZE
- 1);
1551 struct writeback_control wbc
= {
1552 .bdi
= page
->mapping
->backing_dev_info
,
1553 .sync_mode
= WB_SYNC_ALL
,
1554 .nr_to_write
= LONG_MAX
,
1555 .range_start
= range_start
,
1556 .range_end
= range_end
,
1561 if (clear_page_dirty_for_io(page
)) {
1562 ret
= nfs_writepage_locked(page
, &wbc
);
1565 } else if (!PagePrivate(page
))
1567 ret
= nfs_sync_mapping_wait(page
->mapping
, &wbc
, how
);
1570 } while (PagePrivate(page
));
1573 __mark_inode_dirty(inode
, I_DIRTY_PAGES
);
1578 * Write back all requests on one page - we do this before reading it.
1580 int nfs_wb_page(struct inode
*inode
, struct page
* page
)
1582 return nfs_wb_page_priority(inode
, page
, FLUSH_STABLE
);
1585 int __init
nfs_init_writepagecache(void)
1587 nfs_wdata_cachep
= kmem_cache_create("nfs_write_data",
1588 sizeof(struct nfs_write_data
),
1589 0, SLAB_HWCACHE_ALIGN
,
1591 if (nfs_wdata_cachep
== NULL
)
1594 nfs_wdata_mempool
= mempool_create_slab_pool(MIN_POOL_WRITE
,
1596 if (nfs_wdata_mempool
== NULL
)
1599 nfs_commit_mempool
= mempool_create_slab_pool(MIN_POOL_COMMIT
,
1601 if (nfs_commit_mempool
== NULL
)
1605 * NFS congestion size, scale with available memory.
1617 * This allows larger machines to have larger/more transfers.
1618 * Limit the default to 256M
1620 nfs_congestion_kb
= (16*int_sqrt(totalram_pages
)) << (PAGE_SHIFT
-10);
1621 if (nfs_congestion_kb
> 256*1024)
1622 nfs_congestion_kb
= 256*1024;
1627 void nfs_destroy_writepagecache(void)
1629 mempool_destroy(nfs_commit_mempool
);
1630 mempool_destroy(nfs_wdata_mempool
);
1631 kmem_cache_destroy(nfs_wdata_cachep
);