aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/fs-writeback.c5
-rw-r--r--fs/hugetlbfs/inode.c4
-rw-r--r--fs/nfs/Kconfig8
-rw-r--r--fs/nfs/direct.c82
-rw-r--r--fs/nfs/file.c28
-rw-r--r--fs/nfs/inode.c4
-rw-r--r--fs/nfs/internal.h7
-rw-r--r--fs/nfs/pagelist.c4
-rw-r--r--fs/nfs/read.c6
-rw-r--r--fs/nfs/write.c89
-rw-r--r--fs/super.c2
11 files changed, 156 insertions, 83 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 50d0b78130a1..be3efc4f64f4 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -52,11 +52,6 @@ struct wb_writeback_work {
52 struct completion *done; /* set if the caller waits */ 52 struct completion *done; /* set if the caller waits */
53}; 53};
54 54
55/*
56 * We don't actually have pdflush, but this one is exported though /proc...
57 */
58int nr_pdflush_threads;
59
60/** 55/**
61 * writeback_in_progress - determine whether there is writeback in progress 56 * writeback_in_progress - determine whether there is writeback in progress
62 * @bdi: the device's backing_dev_info structure. 57 * @bdi: the device's backing_dev_info structure.
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index e13e9bdb0bf5..8349a899912e 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -416,8 +416,8 @@ hugetlb_vmtruncate_list(struct prio_tree_root *root, pgoff_t pgoff)
416 else 416 else
417 v_offset = 0; 417 v_offset = 0;
418 418
419 __unmap_hugepage_range(vma, 419 unmap_hugepage_range(vma, vma->vm_start + v_offset,
420 vma->vm_start + v_offset, vma->vm_end, NULL); 420 vma->vm_end, NULL);
421 } 421 }
422} 422}
423 423
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index 195c1ea6151a..db7ad719628a 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -86,6 +86,14 @@ config NFS_V4
86 86
87 If unsure, say Y. 87 If unsure, say Y.
88 88
89config NFS_SWAP
90 bool "Provide swap over NFS support"
91 default n
92 depends on NFS_FS
93 select SUNRPC_SWAP
94 help
95 This option enables swapon to work on files located on NFS mounts.
96
89config NFS_V4_1 97config NFS_V4_1
90 bool "NFS client support for NFSv4.1 (EXPERIMENTAL)" 98 bool "NFS client support for NFSv4.1 (EXPERIMENTAL)"
91 depends on NFS_V4 && EXPERIMENTAL 99 depends on NFS_V4 && EXPERIMENTAL
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index b7b4f80968b5..1ba385b7c90d 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -115,17 +115,28 @@ static inline int put_dreq(struct nfs_direct_req *dreq)
115 * @nr_segs: size of iovec array 115 * @nr_segs: size of iovec array
116 * 116 *
117 * The presence of this routine in the address space ops vector means 117 * The presence of this routine in the address space ops vector means
118 * the NFS client supports direct I/O. However, we shunt off direct 118 * the NFS client supports direct I/O. However, for most direct IO, we
119 * read and write requests before the VFS gets them, so this method 119 * shunt off direct read and write requests before the VFS gets them,
120 * should never be called. 120 * so this method is only ever called for swap.
121 */ 121 */
122ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t pos, unsigned long nr_segs) 122ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t pos, unsigned long nr_segs)
123{ 123{
124#ifndef CONFIG_NFS_SWAP
124 dprintk("NFS: nfs_direct_IO (%s) off/no(%Ld/%lu) EINVAL\n", 125 dprintk("NFS: nfs_direct_IO (%s) off/no(%Ld/%lu) EINVAL\n",
125 iocb->ki_filp->f_path.dentry->d_name.name, 126 iocb->ki_filp->f_path.dentry->d_name.name,
126 (long long) pos, nr_segs); 127 (long long) pos, nr_segs);
127 128
128 return -EINVAL; 129 return -EINVAL;
130#else
131 VM_BUG_ON(iocb->ki_left != PAGE_SIZE);
132 VM_BUG_ON(iocb->ki_nbytes != PAGE_SIZE);
133
134 if (rw == READ || rw == KERNEL_READ)
135 return nfs_file_direct_read(iocb, iov, nr_segs, pos,
136 rw == READ ? true : false);
137 return nfs_file_direct_write(iocb, iov, nr_segs, pos,
138 rw == WRITE ? true : false);
139#endif /* CONFIG_NFS_SWAP */
129} 140}
130 141
131static void nfs_direct_release_pages(struct page **pages, unsigned int npages) 142static void nfs_direct_release_pages(struct page **pages, unsigned int npages)
@@ -303,7 +314,7 @@ static const struct nfs_pgio_completion_ops nfs_direct_read_completion_ops = {
303 */ 314 */
304static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *desc, 315static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *desc,
305 const struct iovec *iov, 316 const struct iovec *iov,
306 loff_t pos) 317 loff_t pos, bool uio)
307{ 318{
308 struct nfs_direct_req *dreq = desc->pg_dreq; 319 struct nfs_direct_req *dreq = desc->pg_dreq;
309 struct nfs_open_context *ctx = dreq->ctx; 320 struct nfs_open_context *ctx = dreq->ctx;
@@ -331,12 +342,20 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *de
331 GFP_KERNEL); 342 GFP_KERNEL);
332 if (!pagevec) 343 if (!pagevec)
333 break; 344 break;
334 down_read(&current->mm->mmap_sem); 345 if (uio) {
335 result = get_user_pages(current, current->mm, user_addr, 346 down_read(&current->mm->mmap_sem);
347 result = get_user_pages(current, current->mm, user_addr,
336 npages, 1, 0, pagevec, NULL); 348 npages, 1, 0, pagevec, NULL);
337 up_read(&current->mm->mmap_sem); 349 up_read(&current->mm->mmap_sem);
338 if (result < 0) 350 if (result < 0)
339 break; 351 break;
352 } else {
353 WARN_ON(npages != 1);
354 result = get_kernel_page(user_addr, 1, pagevec);
355 if (WARN_ON(result != 1))
356 break;
357 }
358
340 if ((unsigned)result < npages) { 359 if ((unsigned)result < npages) {
341 bytes = result * PAGE_SIZE; 360 bytes = result * PAGE_SIZE;
342 if (bytes <= pgbase) { 361 if (bytes <= pgbase) {
@@ -386,7 +405,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *de
386static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq, 405static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
387 const struct iovec *iov, 406 const struct iovec *iov,
388 unsigned long nr_segs, 407 unsigned long nr_segs,
389 loff_t pos) 408 loff_t pos, bool uio)
390{ 409{
391 struct nfs_pageio_descriptor desc; 410 struct nfs_pageio_descriptor desc;
392 ssize_t result = -EINVAL; 411 ssize_t result = -EINVAL;
@@ -400,7 +419,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
400 419
401 for (seg = 0; seg < nr_segs; seg++) { 420 for (seg = 0; seg < nr_segs; seg++) {
402 const struct iovec *vec = &iov[seg]; 421 const struct iovec *vec = &iov[seg];
403 result = nfs_direct_read_schedule_segment(&desc, vec, pos); 422 result = nfs_direct_read_schedule_segment(&desc, vec, pos, uio);
404 if (result < 0) 423 if (result < 0)
405 break; 424 break;
406 requested_bytes += result; 425 requested_bytes += result;
@@ -426,7 +445,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
426} 445}
427 446
428static ssize_t nfs_direct_read(struct kiocb *iocb, const struct iovec *iov, 447static ssize_t nfs_direct_read(struct kiocb *iocb, const struct iovec *iov,
429 unsigned long nr_segs, loff_t pos) 448 unsigned long nr_segs, loff_t pos, bool uio)
430{ 449{
431 ssize_t result = -ENOMEM; 450 ssize_t result = -ENOMEM;
432 struct inode *inode = iocb->ki_filp->f_mapping->host; 451 struct inode *inode = iocb->ki_filp->f_mapping->host;
@@ -444,7 +463,7 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, const struct iovec *iov,
444 if (!is_sync_kiocb(iocb)) 463 if (!is_sync_kiocb(iocb))
445 dreq->iocb = iocb; 464 dreq->iocb = iocb;
446 465
447 result = nfs_direct_read_schedule_iovec(dreq, iov, nr_segs, pos); 466 result = nfs_direct_read_schedule_iovec(dreq, iov, nr_segs, pos, uio);
448 if (!result) 467 if (!result)
449 result = nfs_direct_wait(dreq); 468 result = nfs_direct_wait(dreq);
450 NFS_I(inode)->read_io += result; 469 NFS_I(inode)->read_io += result;
@@ -610,7 +629,7 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode
610 */ 629 */
611static ssize_t nfs_direct_write_schedule_segment(struct nfs_pageio_descriptor *desc, 630static ssize_t nfs_direct_write_schedule_segment(struct nfs_pageio_descriptor *desc,
612 const struct iovec *iov, 631 const struct iovec *iov,
613 loff_t pos) 632 loff_t pos, bool uio)
614{ 633{
615 struct nfs_direct_req *dreq = desc->pg_dreq; 634 struct nfs_direct_req *dreq = desc->pg_dreq;
616 struct nfs_open_context *ctx = dreq->ctx; 635 struct nfs_open_context *ctx = dreq->ctx;
@@ -638,12 +657,19 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_pageio_descriptor *d
638 if (!pagevec) 657 if (!pagevec)
639 break; 658 break;
640 659
641 down_read(&current->mm->mmap_sem); 660 if (uio) {
642 result = get_user_pages(current, current->mm, user_addr, 661 down_read(&current->mm->mmap_sem);
643 npages, 0, 0, pagevec, NULL); 662 result = get_user_pages(current, current->mm, user_addr,
644 up_read(&current->mm->mmap_sem); 663 npages, 0, 0, pagevec, NULL);
645 if (result < 0) 664 up_read(&current->mm->mmap_sem);
646 break; 665 if (result < 0)
666 break;
667 } else {
668 WARN_ON(npages != 1);
669 result = get_kernel_page(user_addr, 0, pagevec);
670 if (WARN_ON(result != 1))
671 break;
672 }
647 673
648 if ((unsigned)result < npages) { 674 if ((unsigned)result < npages) {
649 bytes = result * PAGE_SIZE; 675 bytes = result * PAGE_SIZE;
@@ -774,7 +800,7 @@ static const struct nfs_pgio_completion_ops nfs_direct_write_completion_ops = {
774static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, 800static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
775 const struct iovec *iov, 801 const struct iovec *iov,
776 unsigned long nr_segs, 802 unsigned long nr_segs,
777 loff_t pos) 803 loff_t pos, bool uio)
778{ 804{
779 struct nfs_pageio_descriptor desc; 805 struct nfs_pageio_descriptor desc;
780 struct inode *inode = dreq->inode; 806 struct inode *inode = dreq->inode;
@@ -790,7 +816,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
790 816
791 for (seg = 0; seg < nr_segs; seg++) { 817 for (seg = 0; seg < nr_segs; seg++) {
792 const struct iovec *vec = &iov[seg]; 818 const struct iovec *vec = &iov[seg];
793 result = nfs_direct_write_schedule_segment(&desc, vec, pos); 819 result = nfs_direct_write_schedule_segment(&desc, vec, pos, uio);
794 if (result < 0) 820 if (result < 0)
795 break; 821 break;
796 requested_bytes += result; 822 requested_bytes += result;
@@ -818,7 +844,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
818 844
819static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov, 845static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov,
820 unsigned long nr_segs, loff_t pos, 846 unsigned long nr_segs, loff_t pos,
821 size_t count) 847 size_t count, bool uio)
822{ 848{
823 ssize_t result = -ENOMEM; 849 ssize_t result = -ENOMEM;
824 struct inode *inode = iocb->ki_filp->f_mapping->host; 850 struct inode *inode = iocb->ki_filp->f_mapping->host;
@@ -836,7 +862,7 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, const struct iovec *iov,
836 if (!is_sync_kiocb(iocb)) 862 if (!is_sync_kiocb(iocb))
837 dreq->iocb = iocb; 863 dreq->iocb = iocb;
838 864
839 result = nfs_direct_write_schedule_iovec(dreq, iov, nr_segs, pos); 865 result = nfs_direct_write_schedule_iovec(dreq, iov, nr_segs, pos, uio);
840 if (!result) 866 if (!result)
841 result = nfs_direct_wait(dreq); 867 result = nfs_direct_wait(dreq);
842out_release: 868out_release:
@@ -867,7 +893,7 @@ out:
867 * cache. 893 * cache.
868 */ 894 */
869ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov, 895ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov,
870 unsigned long nr_segs, loff_t pos) 896 unsigned long nr_segs, loff_t pos, bool uio)
871{ 897{
872 ssize_t retval = -EINVAL; 898 ssize_t retval = -EINVAL;
873 struct file *file = iocb->ki_filp; 899 struct file *file = iocb->ki_filp;
@@ -892,7 +918,7 @@ ssize_t nfs_file_direct_read(struct kiocb *iocb, const struct iovec *iov,
892 918
893 task_io_account_read(count); 919 task_io_account_read(count);
894 920
895 retval = nfs_direct_read(iocb, iov, nr_segs, pos); 921 retval = nfs_direct_read(iocb, iov, nr_segs, pos, uio);
896 if (retval > 0) 922 if (retval > 0)
897 iocb->ki_pos = pos + retval; 923 iocb->ki_pos = pos + retval;
898 924
@@ -923,7 +949,7 @@ out:
923 * is no atomic O_APPEND write facility in the NFS protocol. 949 * is no atomic O_APPEND write facility in the NFS protocol.
924 */ 950 */
925ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov, 951ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
926 unsigned long nr_segs, loff_t pos) 952 unsigned long nr_segs, loff_t pos, bool uio)
927{ 953{
928 ssize_t retval = -EINVAL; 954 ssize_t retval = -EINVAL;
929 struct file *file = iocb->ki_filp; 955 struct file *file = iocb->ki_filp;
@@ -955,7 +981,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, const struct iovec *iov,
955 981
956 task_io_account_write(count); 982 task_io_account_write(count);
957 983
958 retval = nfs_direct_write(iocb, iov, nr_segs, pos, count); 984 retval = nfs_direct_write(iocb, iov, nr_segs, pos, count, uio);
959 if (retval > 0) { 985 if (retval > 0) {
960 struct inode *inode = mapping->host; 986 struct inode *inode = mapping->host;
961 987
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index b039a17ee941..75d6d0a3d32e 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -180,7 +180,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov,
180 ssize_t result; 180 ssize_t result;
181 181
182 if (iocb->ki_filp->f_flags & O_DIRECT) 182 if (iocb->ki_filp->f_flags & O_DIRECT)
183 return nfs_file_direct_read(iocb, iov, nr_segs, pos); 183 return nfs_file_direct_read(iocb, iov, nr_segs, pos, true);
184 184
185 dprintk("NFS: read(%s/%s, %lu@%lu)\n", 185 dprintk("NFS: read(%s/%s, %lu@%lu)\n",
186 dentry->d_parent->d_name.name, dentry->d_name.name, 186 dentry->d_parent->d_name.name, dentry->d_name.name,
@@ -439,7 +439,7 @@ static void nfs_invalidate_page(struct page *page, unsigned long offset)
439 if (offset != 0) 439 if (offset != 0)
440 return; 440 return;
441 /* Cancel any unstarted writes on this page */ 441 /* Cancel any unstarted writes on this page */
442 nfs_wb_page_cancel(page->mapping->host, page); 442 nfs_wb_page_cancel(page_file_mapping(page)->host, page);
443 443
444 nfs_fscache_invalidate_page(page, page->mapping->host); 444 nfs_fscache_invalidate_page(page, page->mapping->host);
445} 445}
@@ -484,7 +484,7 @@ static int nfs_release_page(struct page *page, gfp_t gfp)
484 */ 484 */
485static int nfs_launder_page(struct page *page) 485static int nfs_launder_page(struct page *page)
486{ 486{
487 struct inode *inode = page->mapping->host; 487 struct inode *inode = page_file_mapping(page)->host;
488 struct nfs_inode *nfsi = NFS_I(inode); 488 struct nfs_inode *nfsi = NFS_I(inode);
489 489
490 dfprintk(PAGECACHE, "NFS: launder_page(%ld, %llu)\n", 490 dfprintk(PAGECACHE, "NFS: launder_page(%ld, %llu)\n",
@@ -494,6 +494,20 @@ static int nfs_launder_page(struct page *page)
494 return nfs_wb_page(inode, page); 494 return nfs_wb_page(inode, page);
495} 495}
496 496
497#ifdef CONFIG_NFS_SWAP
498static int nfs_swap_activate(struct swap_info_struct *sis, struct file *file,
499 sector_t *span)
500{
501 *span = sis->pages;
502 return xs_swapper(NFS_CLIENT(file->f_mapping->host)->cl_xprt, 1);
503}
504
505static void nfs_swap_deactivate(struct file *file)
506{
507 xs_swapper(NFS_CLIENT(file->f_mapping->host)->cl_xprt, 0);
508}
509#endif
510
497const struct address_space_operations nfs_file_aops = { 511const struct address_space_operations nfs_file_aops = {
498 .readpage = nfs_readpage, 512 .readpage = nfs_readpage,
499 .readpages = nfs_readpages, 513 .readpages = nfs_readpages,
@@ -508,6 +522,10 @@ const struct address_space_operations nfs_file_aops = {
508 .migratepage = nfs_migrate_page, 522 .migratepage = nfs_migrate_page,
509 .launder_page = nfs_launder_page, 523 .launder_page = nfs_launder_page,
510 .error_remove_page = generic_error_remove_page, 524 .error_remove_page = generic_error_remove_page,
525#ifdef CONFIG_NFS_SWAP
526 .swap_activate = nfs_swap_activate,
527 .swap_deactivate = nfs_swap_deactivate,
528#endif
511}; 529};
512 530
513/* 531/*
@@ -533,7 +551,7 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
533 nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page); 551 nfs_fscache_wait_on_page_write(NFS_I(dentry->d_inode), page);
534 552
535 lock_page(page); 553 lock_page(page);
536 mapping = page->mapping; 554 mapping = page_file_mapping(page);
537 if (mapping != dentry->d_inode->i_mapping) 555 if (mapping != dentry->d_inode->i_mapping)
538 goto out_unlock; 556 goto out_unlock;
539 557
@@ -582,7 +600,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
582 size_t count = iov_length(iov, nr_segs); 600 size_t count = iov_length(iov, nr_segs);
583 601
584 if (iocb->ki_filp->f_flags & O_DIRECT) 602 if (iocb->ki_filp->f_flags & O_DIRECT)
585 return nfs_file_direct_write(iocb, iov, nr_segs, pos); 603 return nfs_file_direct_write(iocb, iov, nr_segs, pos, true);
586 604
587 dprintk("NFS: write(%s/%s, %lu@%Ld)\n", 605 dprintk("NFS: write(%s/%s, %lu@%Ld)\n",
588 dentry->d_parent->d_name.name, dentry->d_name.name, 606 dentry->d_parent->d_name.name, dentry->d_name.name,
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 2ed6138f32ad..c6e895f0fbf3 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -897,6 +897,10 @@ int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping)
897 struct nfs_inode *nfsi = NFS_I(inode); 897 struct nfs_inode *nfsi = NFS_I(inode);
898 int ret = 0; 898 int ret = 0;
899 899
900 /* swapfiles are not supposed to be shared. */
901 if (IS_SWAPFILE(inode))
902 goto out;
903
900 if (nfs_mapping_need_revalidate_inode(inode)) { 904 if (nfs_mapping_need_revalidate_inode(inode)) {
901 ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode); 905 ret = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
902 if (ret < 0) 906 if (ret < 0)
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 8865538b26b6..31fdb03225cd 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -554,13 +554,14 @@ void nfs_super_set_maxbytes(struct super_block *sb, __u64 maxfilesize)
554static inline 554static inline
555unsigned int nfs_page_length(struct page *page) 555unsigned int nfs_page_length(struct page *page)
556{ 556{
557 loff_t i_size = i_size_read(page->mapping->host); 557 loff_t i_size = i_size_read(page_file_mapping(page)->host);
558 558
559 if (i_size > 0) { 559 if (i_size > 0) {
560 pgoff_t page_index = page_file_index(page);
560 pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 561 pgoff_t end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
561 if (page->index < end_index) 562 if (page_index < end_index)
562 return PAGE_CACHE_SIZE; 563 return PAGE_CACHE_SIZE;
563 if (page->index == end_index) 564 if (page_index == end_index)
564 return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1; 565 return ((i_size - 1) & ~PAGE_CACHE_MASK) + 1;
565 } 566 }
566 return 0; 567 return 0;
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 1e7d8879dae6..1a6732ed04a4 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -71,7 +71,7 @@ void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos)
71static inline struct nfs_page * 71static inline struct nfs_page *
72nfs_page_alloc(void) 72nfs_page_alloc(void)
73{ 73{
74 struct nfs_page *p = kmem_cache_zalloc(nfs_page_cachep, GFP_KERNEL); 74 struct nfs_page *p = kmem_cache_zalloc(nfs_page_cachep, GFP_NOIO);
75 if (p) 75 if (p)
76 INIT_LIST_HEAD(&p->wb_list); 76 INIT_LIST_HEAD(&p->wb_list);
77 return p; 77 return p;
@@ -118,7 +118,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
118 * long write-back delay. This will be adjusted in 118 * long write-back delay. This will be adjusted in
119 * update_nfs_request below if the region is not locked. */ 119 * update_nfs_request below if the region is not locked. */
120 req->wb_page = page; 120 req->wb_page = page;
121 req->wb_index = page->index; 121 req->wb_index = page_file_index(page);
122 page_cache_get(page); 122 page_cache_get(page);
123 req->wb_offset = offset; 123 req->wb_offset = offset;
124 req->wb_pgbase = offset; 124 req->wb_pgbase = offset;
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 6935e401ad76..b6bdb18e892c 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -527,11 +527,11 @@ static const struct rpc_call_ops nfs_read_common_ops = {
527int nfs_readpage(struct file *file, struct page *page) 527int nfs_readpage(struct file *file, struct page *page)
528{ 528{
529 struct nfs_open_context *ctx; 529 struct nfs_open_context *ctx;
530 struct inode *inode = page->mapping->host; 530 struct inode *inode = page_file_mapping(page)->host;
531 int error; 531 int error;
532 532
533 dprintk("NFS: nfs_readpage (%p %ld@%lu)\n", 533 dprintk("NFS: nfs_readpage (%p %ld@%lu)\n",
534 page, PAGE_CACHE_SIZE, page->index); 534 page, PAGE_CACHE_SIZE, page_file_index(page));
535 nfs_inc_stats(inode, NFSIOS_VFSREADPAGE); 535 nfs_inc_stats(inode, NFSIOS_VFSREADPAGE);
536 nfs_add_stats(inode, NFSIOS_READPAGES, 1); 536 nfs_add_stats(inode, NFSIOS_READPAGES, 1);
537 537
@@ -585,7 +585,7 @@ static int
585readpage_async_filler(void *data, struct page *page) 585readpage_async_filler(void *data, struct page *page)
586{ 586{
587 struct nfs_readdesc *desc = (struct nfs_readdesc *)data; 587 struct nfs_readdesc *desc = (struct nfs_readdesc *)data;
588 struct inode *inode = page->mapping->host; 588 struct inode *inode = page_file_mapping(page)->host;
589 struct nfs_page *new; 589 struct nfs_page *new;
590 unsigned int len; 590 unsigned int len;
591 int error; 591 int error;
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index e4a2ad2059bd..5829d0ce7cfb 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -52,7 +52,7 @@ static mempool_t *nfs_commit_mempool;
52 52
53struct nfs_commit_data *nfs_commitdata_alloc(void) 53struct nfs_commit_data *nfs_commitdata_alloc(void)
54{ 54{
55 struct nfs_commit_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOFS); 55 struct nfs_commit_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOIO);
56 56
57 if (p) { 57 if (p) {
58 memset(p, 0, sizeof(*p)); 58 memset(p, 0, sizeof(*p));
@@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(nfs_commit_free);
70 70
71struct nfs_write_header *nfs_writehdr_alloc(void) 71struct nfs_write_header *nfs_writehdr_alloc(void)
72{ 72{
73 struct nfs_write_header *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS); 73 struct nfs_write_header *p = mempool_alloc(nfs_wdata_mempool, GFP_NOIO);
74 74
75 if (p) { 75 if (p) {
76 struct nfs_pgio_header *hdr = &p->header; 76 struct nfs_pgio_header *hdr = &p->header;
@@ -142,25 +142,38 @@ static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
142 set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); 142 set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
143} 143}
144 144
145static struct nfs_page *nfs_page_find_request_locked(struct page *page) 145static struct nfs_page *
146nfs_page_find_request_locked(struct nfs_inode *nfsi, struct page *page)
146{ 147{
147 struct nfs_page *req = NULL; 148 struct nfs_page *req = NULL;
148 149
149 if (PagePrivate(page)) { 150 if (PagePrivate(page))
150 req = (struct nfs_page *)page_private(page); 151 req = (struct nfs_page *)page_private(page);
151 if (req != NULL) 152 else if (unlikely(PageSwapCache(page))) {
152 kref_get(&req->wb_kref); 153 struct nfs_page *freq, *t;
154
155 /* Linearly search the commit list for the correct req */
156 list_for_each_entry_safe(freq, t, &nfsi->commit_info.list, wb_list) {
157 if (freq->wb_page == page) {
158 req = freq;
159 break;
160 }
161 }
153 } 162 }
163
164 if (req)
165 kref_get(&req->wb_kref);
166
154 return req; 167 return req;
155} 168}
156 169
157static struct nfs_page *nfs_page_find_request(struct page *page) 170static struct nfs_page *nfs_page_find_request(struct page *page)
158{ 171{
159 struct inode *inode = page->mapping->host; 172 struct inode *inode = page_file_mapping(page)->host;
160 struct nfs_page *req = NULL; 173 struct nfs_page *req = NULL;
161 174
162 spin_lock(&inode->i_lock); 175 spin_lock(&inode->i_lock);
163 req = nfs_page_find_request_locked(page); 176 req = nfs_page_find_request_locked(NFS_I(inode), page);
164 spin_unlock(&inode->i_lock); 177 spin_unlock(&inode->i_lock);
165 return req; 178 return req;
166} 179}
@@ -168,16 +181,16 @@ static struct nfs_page *nfs_page_find_request(struct page *page)
168/* Adjust the file length if we're writing beyond the end */ 181/* Adjust the file length if we're writing beyond the end */
169static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count) 182static void nfs_grow_file(struct page *page, unsigned int offset, unsigned int count)
170{ 183{
171 struct inode *inode = page->mapping->host; 184 struct inode *inode = page_file_mapping(page)->host;
172 loff_t end, i_size; 185 loff_t end, i_size;
173 pgoff_t end_index; 186 pgoff_t end_index;
174 187
175 spin_lock(&inode->i_lock); 188 spin_lock(&inode->i_lock);
176 i_size = i_size_read(inode); 189 i_size = i_size_read(inode);
177 end_index = (i_size - 1) >> PAGE_CACHE_SHIFT; 190 end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
178 if (i_size > 0 && page->index < end_index) 191 if (i_size > 0 && page_file_index(page) < end_index)
179 goto out; 192 goto out;
180 end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + ((loff_t)offset+count); 193 end = page_file_offset(page) + ((loff_t)offset+count);
181 if (i_size >= end) 194 if (i_size >= end)
182 goto out; 195 goto out;
183 i_size_write(inode, end); 196 i_size_write(inode, end);
@@ -190,7 +203,7 @@ out:
190static void nfs_set_pageerror(struct page *page) 203static void nfs_set_pageerror(struct page *page)
191{ 204{
192 SetPageError(page); 205 SetPageError(page);
193 nfs_zap_mapping(page->mapping->host, page->mapping); 206 nfs_zap_mapping(page_file_mapping(page)->host, page_file_mapping(page));
194} 207}
195 208
196/* We can set the PG_uptodate flag if we see that a write request 209/* We can set the PG_uptodate flag if we see that a write request
@@ -231,7 +244,7 @@ static int nfs_set_page_writeback(struct page *page)
231 int ret = test_set_page_writeback(page); 244 int ret = test_set_page_writeback(page);
232 245
233 if (!ret) { 246 if (!ret) {
234 struct inode *inode = page->mapping->host; 247 struct inode *inode = page_file_mapping(page)->host;
235 struct nfs_server *nfss = NFS_SERVER(inode); 248 struct nfs_server *nfss = NFS_SERVER(inode);
236 249
237 if (atomic_long_inc_return(&nfss->writeback) > 250 if (atomic_long_inc_return(&nfss->writeback) >
@@ -245,7 +258,7 @@ static int nfs_set_page_writeback(struct page *page)
245 258
246static void nfs_end_page_writeback(struct page *page) 259static void nfs_end_page_writeback(struct page *page)
247{ 260{
248 struct inode *inode = page->mapping->host; 261 struct inode *inode = page_file_mapping(page)->host;
249 struct nfs_server *nfss = NFS_SERVER(inode); 262 struct nfs_server *nfss = NFS_SERVER(inode);
250 263
251 end_page_writeback(page); 264 end_page_writeback(page);
@@ -255,13 +268,13 @@ static void nfs_end_page_writeback(struct page *page)
255 268
256static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblock) 269static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblock)
257{ 270{
258 struct inode *inode = page->mapping->host; 271 struct inode *inode = page_file_mapping(page)->host;
259 struct nfs_page *req; 272 struct nfs_page *req;
260 int ret; 273 int ret;
261 274
262 spin_lock(&inode->i_lock); 275 spin_lock(&inode->i_lock);
263 for (;;) { 276 for (;;) {
264 req = nfs_page_find_request_locked(page); 277 req = nfs_page_find_request_locked(NFS_I(inode), page);
265 if (req == NULL) 278 if (req == NULL)
266 break; 279 break;
267 if (nfs_lock_request(req)) 280 if (nfs_lock_request(req))
@@ -316,13 +329,13 @@ out:
316 329
317static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio) 330static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio)
318{ 331{
319 struct inode *inode = page->mapping->host; 332 struct inode *inode = page_file_mapping(page)->host;
320 int ret; 333 int ret;
321 334
322 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE); 335 nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
323 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1); 336 nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
324 337
325 nfs_pageio_cond_complete(pgio, page->index); 338 nfs_pageio_cond_complete(pgio, page_file_index(page));
326 ret = nfs_page_async_flush(pgio, page, wbc->sync_mode == WB_SYNC_NONE); 339 ret = nfs_page_async_flush(pgio, page, wbc->sync_mode == WB_SYNC_NONE);
327 if (ret == -EAGAIN) { 340 if (ret == -EAGAIN) {
328 redirty_page_for_writepage(wbc, page); 341 redirty_page_for_writepage(wbc, page);
@@ -339,7 +352,7 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc
339 struct nfs_pageio_descriptor pgio; 352 struct nfs_pageio_descriptor pgio;
340 int err; 353 int err;
341 354
342 NFS_PROTO(page->mapping->host)->write_pageio_init(&pgio, 355 NFS_PROTO(page_file_mapping(page)->host)->write_pageio_init(&pgio,
343 page->mapping->host, 356 page->mapping->host,
344 wb_priority(wbc), 357 wb_priority(wbc),
345 &nfs_async_write_completion_ops); 358 &nfs_async_write_completion_ops);
@@ -416,9 +429,15 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
416 spin_lock(&inode->i_lock); 429 spin_lock(&inode->i_lock);
417 if (!nfsi->npages && NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE)) 430 if (!nfsi->npages && NFS_PROTO(inode)->have_delegation(inode, FMODE_WRITE))
418 inode->i_version++; 431 inode->i_version++;
419 set_bit(PG_MAPPED, &req->wb_flags); 432 /*
420 SetPagePrivate(req->wb_page); 433 * Swap-space should not get truncated. Hence no need to plug the race
421 set_page_private(req->wb_page, (unsigned long)req); 434 * with invalidate/truncate.
435 */
436 if (likely(!PageSwapCache(req->wb_page))) {
437 set_bit(PG_MAPPED, &req->wb_flags);
438 SetPagePrivate(req->wb_page);
439 set_page_private(req->wb_page, (unsigned long)req);
440 }
422 nfsi->npages++; 441 nfsi->npages++;
423 kref_get(&req->wb_kref); 442 kref_get(&req->wb_kref);
424 spin_unlock(&inode->i_lock); 443 spin_unlock(&inode->i_lock);
@@ -435,9 +454,11 @@ static void nfs_inode_remove_request(struct nfs_page *req)
435 BUG_ON (!NFS_WBACK_BUSY(req)); 454 BUG_ON (!NFS_WBACK_BUSY(req));
436 455
437 spin_lock(&inode->i_lock); 456 spin_lock(&inode->i_lock);
438 set_page_private(req->wb_page, 0); 457 if (likely(!PageSwapCache(req->wb_page))) {
439 ClearPagePrivate(req->wb_page); 458 set_page_private(req->wb_page, 0);
440 clear_bit(PG_MAPPED, &req->wb_flags); 459 ClearPagePrivate(req->wb_page);
460 clear_bit(PG_MAPPED, &req->wb_flags);
461 }
441 nfsi->npages--; 462 nfsi->npages--;
442 spin_unlock(&inode->i_lock); 463 spin_unlock(&inode->i_lock);
443 nfs_release_request(req); 464 nfs_release_request(req);
@@ -474,7 +495,7 @@ nfs_request_add_commit_list(struct nfs_page *req, struct list_head *dst,
474 spin_unlock(cinfo->lock); 495 spin_unlock(cinfo->lock);
475 if (!cinfo->dreq) { 496 if (!cinfo->dreq) {
476 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 497 inc_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
477 inc_bdi_stat(req->wb_page->mapping->backing_dev_info, 498 inc_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info,
478 BDI_RECLAIMABLE); 499 BDI_RECLAIMABLE);
479 __mark_inode_dirty(req->wb_context->dentry->d_inode, 500 __mark_inode_dirty(req->wb_context->dentry->d_inode,
480 I_DIRTY_DATASYNC); 501 I_DIRTY_DATASYNC);
@@ -541,7 +562,7 @@ static void
541nfs_clear_page_commit(struct page *page) 562nfs_clear_page_commit(struct page *page)
542{ 563{
543 dec_zone_page_state(page, NR_UNSTABLE_NFS); 564 dec_zone_page_state(page, NR_UNSTABLE_NFS);
544 dec_bdi_stat(page->mapping->backing_dev_info, BDI_RECLAIMABLE); 565 dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE);
545} 566}
546 567
547static void 568static void
@@ -733,7 +754,7 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
733 spin_lock(&inode->i_lock); 754 spin_lock(&inode->i_lock);
734 755
735 for (;;) { 756 for (;;) {
736 req = nfs_page_find_request_locked(page); 757 req = nfs_page_find_request_locked(NFS_I(inode), page);
737 if (req == NULL) 758 if (req == NULL)
738 goto out_unlock; 759 goto out_unlock;
739 760
@@ -792,7 +813,7 @@ out_err:
792static struct nfs_page * nfs_setup_write_request(struct nfs_open_context* ctx, 813static struct nfs_page * nfs_setup_write_request(struct nfs_open_context* ctx,
793 struct page *page, unsigned int offset, unsigned int bytes) 814 struct page *page, unsigned int offset, unsigned int bytes)
794{ 815{
795 struct inode *inode = page->mapping->host; 816 struct inode *inode = page_file_mapping(page)->host;
796 struct nfs_page *req; 817 struct nfs_page *req;
797 818
798 req = nfs_try_to_update_request(inode, page, offset, bytes); 819 req = nfs_try_to_update_request(inode, page, offset, bytes);
@@ -845,7 +866,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page)
845 nfs_release_request(req); 866 nfs_release_request(req);
846 if (!do_flush) 867 if (!do_flush)
847 return 0; 868 return 0;
848 status = nfs_wb_page(page->mapping->host, page); 869 status = nfs_wb_page(page_file_mapping(page)->host, page);
849 } while (status == 0); 870 } while (status == 0);
850 return status; 871 return status;
851} 872}
@@ -875,7 +896,7 @@ int nfs_updatepage(struct file *file, struct page *page,
875 unsigned int offset, unsigned int count) 896 unsigned int offset, unsigned int count)
876{ 897{
877 struct nfs_open_context *ctx = nfs_file_open_context(file); 898 struct nfs_open_context *ctx = nfs_file_open_context(file);
878 struct inode *inode = page->mapping->host; 899 struct inode *inode = page_file_mapping(page)->host;
879 int status = 0; 900 int status = 0;
880 901
881 nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE); 902 nfs_inc_stats(inode, NFSIOS_VFSUPDATEPAGE);
@@ -883,7 +904,7 @@ int nfs_updatepage(struct file *file, struct page *page,
883 dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n", 904 dprintk("NFS: nfs_updatepage(%s/%s %d@%lld)\n",
884 file->f_path.dentry->d_parent->d_name.name, 905 file->f_path.dentry->d_parent->d_name.name,
885 file->f_path.dentry->d_name.name, count, 906 file->f_path.dentry->d_name.name, count,
886 (long long)(page_offset(page) + offset)); 907 (long long)(page_file_offset(page) + offset));
887 908
888 /* If we're not using byte range locks, and we know the page 909 /* If we're not using byte range locks, and we know the page
889 * is up to date, it may be more efficient to extend the write 910 * is up to date, it may be more efficient to extend the write
@@ -1474,7 +1495,7 @@ void nfs_retry_commit(struct list_head *page_list,
1474 nfs_mark_request_commit(req, lseg, cinfo); 1495 nfs_mark_request_commit(req, lseg, cinfo);
1475 if (!cinfo->dreq) { 1496 if (!cinfo->dreq) {
1476 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS); 1497 dec_zone_page_state(req->wb_page, NR_UNSTABLE_NFS);
1477 dec_bdi_stat(req->wb_page->mapping->backing_dev_info, 1498 dec_bdi_stat(page_file_mapping(req->wb_page)->backing_dev_info,
1478 BDI_RECLAIMABLE); 1499 BDI_RECLAIMABLE);
1479 } 1500 }
1480 nfs_unlock_and_release_request(req); 1501 nfs_unlock_and_release_request(req);
@@ -1731,7 +1752,7 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page)
1731 */ 1752 */
1732int nfs_wb_page(struct inode *inode, struct page *page) 1753int nfs_wb_page(struct inode *inode, struct page *page)
1733{ 1754{
1734 loff_t range_start = page_offset(page); 1755 loff_t range_start = page_file_offset(page);
1735 loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1); 1756 loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1);
1736 struct writeback_control wbc = { 1757 struct writeback_control wbc = {
1737 .sync_mode = WB_SYNC_ALL, 1758 .sync_mode = WB_SYNC_ALL,
diff --git a/fs/super.c b/fs/super.c
index 4c5d82f56ec4..4bf714459a4b 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -62,7 +62,7 @@ static int prune_super(struct shrinker *shrink, struct shrink_control *sc)
62 return -1; 62 return -1;
63 63
64 if (!grab_super_passive(sb)) 64 if (!grab_super_passive(sb))
65 return !sc->nr_to_scan ? 0 : -1; 65 return -1;
66 66
67 if (sb->s_op && sb->s_op->nr_cached_objects) 67 if (sb->s_op && sb->s_op->nr_cached_objects)
68 fs_objects = sb->s_op->nr_cached_objects(sb); 68 fs_objects = sb->s_op->nr_cached_objects(sb);