aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/file.c
diff options
context:
space:
mode:
authorMinchan Kim <minchan.kim@gmail.com>2010-05-24 17:33:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-25 11:07:03 -0400
commit4c99000ac47cbd097e62f1b5cafad745622cedc3 (patch)
tree9912597a68403c8f02dfbb414e60e0cb3f6577d3 /fs/ntfs/file.c
parent2ec93b0bf35fe0fad05d2b7ef139d018768cca38 (diff)
ntfs: use add_to_page_cache_lru()
Quote from Nick piggin's about btrfs patch - http://www.mail-archive.com/linux-btrfs@vger.kernel.org/msg04472.html. "add_to_page_cache_lru is exported, so it should be used. Benefits over using a private pagevec: neater code, 128 bytes fewer stack used, percpu lru ordering is preserved, and finally don't need to flush pagevec before returning so batching may be shared with other LRU insertions." Let's use it instead of private pagevec in ntfs, too. Signed-off-by: Minchan Kim <minchan.kim@gmail.com> Acked-by: Anton Altaparmakov <aia21@cantab.net> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ntfs/file.c')
-rw-r--r--fs/ntfs/file.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index ed7a33470050..a1924a0d2ab0 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -399,18 +399,13 @@ static inline void ntfs_fault_in_pages_readable_iovec(const struct iovec *iov,
399 * Obtain @nr_pages locked page cache pages from the mapping @mapping and 399 * Obtain @nr_pages locked page cache pages from the mapping @mapping and
400 * starting at index @index. 400 * starting at index @index.
401 * 401 *
402 * If a page is newly created, increment its refcount and add it to the 402 * If a page is newly created, add it to lru list
403 * caller's lru-buffering pagevec @lru_pvec.
404 *
405 * This is the same as mm/filemap.c::__grab_cache_page(), except that @nr_pages
406 * are obtained at once instead of just one page and that 0 is returned on
407 * success and -errno on error.
408 * 403 *
409 * Note, the page locks are obtained in ascending page index order. 404 * Note, the page locks are obtained in ascending page index order.
410 */ 405 */
411static inline int __ntfs_grab_cache_pages(struct address_space *mapping, 406static inline int __ntfs_grab_cache_pages(struct address_space *mapping,
412 pgoff_t index, const unsigned nr_pages, struct page **pages, 407 pgoff_t index, const unsigned nr_pages, struct page **pages,
413 struct page **cached_page, struct pagevec *lru_pvec) 408 struct page **cached_page)
414{ 409{
415 int err, nr; 410 int err, nr;
416 411
@@ -426,7 +421,7 @@ static inline int __ntfs_grab_cache_pages(struct address_space *mapping,
426 goto err_out; 421 goto err_out;
427 } 422 }
428 } 423 }
429 err = add_to_page_cache(*cached_page, mapping, index, 424 err = add_to_page_cache_lru(*cached_page, mapping, index,
430 GFP_KERNEL); 425 GFP_KERNEL);
431 if (unlikely(err)) { 426 if (unlikely(err)) {
432 if (err == -EEXIST) 427 if (err == -EEXIST)
@@ -434,9 +429,6 @@ static inline int __ntfs_grab_cache_pages(struct address_space *mapping,
434 goto err_out; 429 goto err_out;
435 } 430 }
436 pages[nr] = *cached_page; 431 pages[nr] = *cached_page;
437 page_cache_get(*cached_page);
438 if (unlikely(!pagevec_add(lru_pvec, *cached_page)))
439 __pagevec_lru_add_file(lru_pvec);
440 *cached_page = NULL; 432 *cached_page = NULL;
441 } 433 }
442 index++; 434 index++;
@@ -1796,7 +1788,6 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
1796 ssize_t status, written; 1788 ssize_t status, written;
1797 unsigned nr_pages; 1789 unsigned nr_pages;
1798 int err; 1790 int err;
1799 struct pagevec lru_pvec;
1800 1791
1801 ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, " 1792 ntfs_debug("Entering for i_ino 0x%lx, attribute type 0x%x, "
1802 "pos 0x%llx, count 0x%lx.", 1793 "pos 0x%llx, count 0x%lx.",
@@ -1908,7 +1899,6 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
1908 } 1899 }
1909 } 1900 }
1910 } 1901 }
1911 pagevec_init(&lru_pvec, 0);
1912 written = 0; 1902 written = 0;
1913 /* 1903 /*
1914 * If the write starts beyond the initialized size, extend it up to the 1904 * If the write starts beyond the initialized size, extend it up to the
@@ -2007,7 +1997,7 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb,
2007 ntfs_fault_in_pages_readable_iovec(iov, iov_ofs, bytes); 1997 ntfs_fault_in_pages_readable_iovec(iov, iov_ofs, bytes);
2008 /* Get and lock @do_pages starting at index @start_idx. */ 1998 /* Get and lock @do_pages starting at index @start_idx. */
2009 status = __ntfs_grab_cache_pages(mapping, start_idx, do_pages, 1999 status = __ntfs_grab_cache_pages(mapping, start_idx, do_pages,
2010 pages, &cached_page, &lru_pvec); 2000 pages, &cached_page);
2011 if (unlikely(status)) 2001 if (unlikely(status))
2012 break; 2002 break;
2013 /* 2003 /*
@@ -2072,7 +2062,6 @@ err_out:
2072 *ppos = pos; 2062 *ppos = pos;
2073 if (cached_page) 2063 if (cached_page)
2074 page_cache_release(cached_page); 2064 page_cache_release(cached_page);
2075 pagevec_lru_add_file(&lru_pvec);
2076 ntfs_debug("Done. Returning %s (written 0x%lx, status %li).", 2065 ntfs_debug("Done. Returning %s (written 0x%lx, status %li).",
2077 written ? "written" : "status", (unsigned long)written, 2066 written ? "written" : "status", (unsigned long)written,
2078 (long)status); 2067 (long)status);