From: Josef Bacik <jbacik@redhat.com> Date: Tue, 10 Feb 2009 13:49:31 -0500 Subject: [mm] restore the KERNEL_DS optimisations Message-id: 1234291777-15344-19-git-send-email-jbacik@redhat.com O-Subject: [PATCH 18/24] [RHEL 5.4] mm: restore the KERNEL_DS optimisations Bugzilla: 445433 RH-Acked-by: Steven Whitehouse <swhiteho@redhat.com> RH-Acked-by: Jeff Layton <jlayton@redhat.com> This is a backport of upstream commit 674b892ede247ef4fb8d00918f02e29c32b9bbaf and is in reference to bz 445433. This is putting back the optimisations for nfsd that were taken out in an earlier patch in this series. This will help with the legacy code. Signed-off-by: Josef Bacik <jbacik@redhat.com> diff --git a/mm/filemap.c b/mm/filemap.c index 2529e95..a887f4d 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2332,7 +2332,7 @@ static ssize_t generic_perform_write_2copy(struct file *file, * cannot take a pagefault with the destination page locked. * So pin the source page to copy it. */ - if (!PageUptodate(page)) { + if (!PageUptodate(page) && !segment_eq(get_fs(), KERNEL_DS)) { unlock_page(page); src_page = alloc_page(GFP_KERNEL); @@ -2457,6 +2457,13 @@ static ssize_t generic_perform_write(struct file *file, const struct address_space_operations *a_ops = mapping->a_ops; long status = 0; ssize_t written = 0; + unsigned int flags = 0; + + /* + * Copies from kernel address space cannot fail (NFSD is a big user). + */ + if (segment_eq(get_fs(), KERNEL_DS)) + flags |= AOP_FLAG_UNINTERRUPTIBLE; do { struct page *page; @@ -2488,7 +2495,7 @@ again: break; } - status = a_ops->write_begin(file, mapping, pos, bytes, 0, + status = a_ops->write_begin(file, mapping, pos, bytes, flags, &page, &fsdata); if (unlikely(status)) break;