diff options
Diffstat (limited to 'fs/ntfs/file.c')
-rw-r--r-- | fs/ntfs/file.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 8804f093ba75..a1924a0d2ab0 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c | |||
@@ -98,9 +98,6 @@ static int ntfs_file_open(struct inode *vi, struct file *filp) | |||
98 | * the page at all. For a more detailed explanation see ntfs_truncate() in | 98 | * the page at all. For a more detailed explanation see ntfs_truncate() in |
99 | * fs/ntfs/inode.c. | 99 | * fs/ntfs/inode.c. |
100 | * | 100 | * |
101 | * @cached_page and @lru_pvec are just optimizations for dealing with multiple | ||
102 | * pages. | ||
103 | * | ||
104 | * Return 0 on success and -errno on error. In the case that an error is | 101 | * Return 0 on success and -errno on error. In the case that an error is |
105 | * encountered it is possible that the initialized size will already have been | 102 | * encountered it is possible that the initialized size will already have been |
106 | * incremented some way towards @new_init_size but it is guaranteed that if | 103 | * incremented some way towards @new_init_size but it is guaranteed that if |
@@ -110,8 +107,7 @@ static int ntfs_file_open(struct inode *vi, struct file *filp) | |||
110 | * Locking: i_mutex on the vfs inode corrseponsind to the ntfs inode @ni must be | 107 | * Locking: i_mutex on the vfs inode corrseponsind to the ntfs inode @ni must be |
111 | * held by the caller. | 108 | * held by the caller. |
112 | */ | 109 | */ |
113 | static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size, | 110 | static int ntfs_attr_extend_initialized(ntfs_inode *ni, const s64 new_init_size) |
114 | struct page **cached_page, struct pagevec *lru_pvec) | ||
115 | { | 111 | { |
116 | s64 old_init_size; | 112 | s64 old_init_size; |
117 | loff_t old_i_size; | 113 | loff_t old_i_size; |
@@ -403,18 +399,13 @@ static inline void ntfs_fault_in_pages_readable_iovec(const struct iovec *iov, | |||
403 | * 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 |
404 | * starting at index @index. | 400 | * starting at index @index. |
405 | * | 401 | * |
406 | * 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 |
407 | * caller's lru-buffering pagevec @lru_pvec. | ||
408 | * | ||
409 | * This is the same as mm/filemap.c::__grab_cache_page(), except that @nr_pages | ||
410 | * are obtained at once instead of just one page and that 0 is returned on | ||
411 | * success and -errno on error. | ||
412 | * | 403 | * |
413 | * Note, the page locks are obtained in ascending page index order. | 404 | * Note, the page locks are obtained in ascending page index order. |
414 | */ | 405 | */ |
415 | static inline int __ntfs_grab_cache_pages(struct address_space *mapping, | 406 | static inline int __ntfs_grab_cache_pages(struct address_space *mapping, |
416 | pgoff_t index, const unsigned nr_pages, struct page **pages, | 407 | pgoff_t index, const unsigned nr_pages, struct page **pages, |
417 | struct page **cached_page, struct pagevec *lru_pvec) | 408 | struct page **cached_page) |
418 | { | 409 | { |
419 | int err, nr; | 410 | int err, nr; |
420 | 411 | ||
@@ -430,7 +421,7 @@ static inline int __ntfs_grab_cache_pages(struct address_space *mapping, | |||
430 | goto err_out; | 421 | goto err_out; |
431 | } | 422 | } |
432 | } | 423 | } |
433 | err = add_to_page_cache(*cached_page, mapping, index, | 424 | err = add_to_page_cache_lru(*cached_page, mapping, index, |
434 | GFP_KERNEL); | 425 | GFP_KERNEL); |
435 | if (unlikely(err)) { | 426 | if (unlikely(err)) { |
436 | if (err == -EEXIST) | 427 | if (err == -EEXIST) |
@@ -438,9 +429,6 @@ static inline int __ntfs_grab_cache_pages(struct address_space *mapping, | |||
438 | goto err_out; | 429 | goto err_out; |
439 | } | 430 | } |
440 | pages[nr] = *cached_page; | 431 | pages[nr] = *cached_page; |
441 | page_cache_get(*cached_page); | ||
442 | if (unlikely(!pagevec_add(lru_pvec, *cached_page))) | ||
443 | __pagevec_lru_add_file(lru_pvec); | ||
444 | *cached_page = NULL; | 432 | *cached_page = NULL; |
445 | } | 433 | } |
446 | index++; | 434 | index++; |
@@ -1800,7 +1788,6 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, | |||
1800 | ssize_t status, written; | 1788 | ssize_t status, written; |
1801 | unsigned nr_pages; | 1789 | unsigned nr_pages; |
1802 | int err; | 1790 | int err; |
1803 | struct pagevec lru_pvec; | ||
1804 | 1791 | ||
1805 | 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, " |
1806 | "pos 0x%llx, count 0x%lx.", | 1793 | "pos 0x%llx, count 0x%lx.", |
@@ -1912,7 +1899,6 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, | |||
1912 | } | 1899 | } |
1913 | } | 1900 | } |
1914 | } | 1901 | } |
1915 | pagevec_init(&lru_pvec, 0); | ||
1916 | written = 0; | 1902 | written = 0; |
1917 | /* | 1903 | /* |
1918 | * 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 |
@@ -1925,8 +1911,7 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, | |||
1925 | ll = ni->initialized_size; | 1911 | ll = ni->initialized_size; |
1926 | read_unlock_irqrestore(&ni->size_lock, flags); | 1912 | read_unlock_irqrestore(&ni->size_lock, flags); |
1927 | if (pos > ll) { | 1913 | if (pos > ll) { |
1928 | err = ntfs_attr_extend_initialized(ni, pos, &cached_page, | 1914 | err = ntfs_attr_extend_initialized(ni, pos); |
1929 | &lru_pvec); | ||
1930 | if (err < 0) { | 1915 | if (err < 0) { |
1931 | ntfs_error(vol->sb, "Cannot perform write to inode " | 1916 | ntfs_error(vol->sb, "Cannot perform write to inode " |
1932 | "0x%lx, attribute type 0x%x, because " | 1917 | "0x%lx, attribute type 0x%x, because " |
@@ -2012,7 +1997,7 @@ static ssize_t ntfs_file_buffered_write(struct kiocb *iocb, | |||
2012 | ntfs_fault_in_pages_readable_iovec(iov, iov_ofs, bytes); | 1997 | ntfs_fault_in_pages_readable_iovec(iov, iov_ofs, bytes); |
2013 | /* Get and lock @do_pages starting at index @start_idx. */ | 1998 | /* Get and lock @do_pages starting at index @start_idx. */ |
2014 | status = __ntfs_grab_cache_pages(mapping, start_idx, do_pages, | 1999 | status = __ntfs_grab_cache_pages(mapping, start_idx, do_pages, |
2015 | pages, &cached_page, &lru_pvec); | 2000 | pages, &cached_page); |
2016 | if (unlikely(status)) | 2001 | if (unlikely(status)) |
2017 | break; | 2002 | break; |
2018 | /* | 2003 | /* |
@@ -2077,7 +2062,6 @@ err_out: | |||
2077 | *ppos = pos; | 2062 | *ppos = pos; |
2078 | if (cached_page) | 2063 | if (cached_page) |
2079 | page_cache_release(cached_page); | 2064 | page_cache_release(cached_page); |
2080 | pagevec_lru_add_file(&lru_pvec); | ||
2081 | ntfs_debug("Done. Returning %s (written 0x%lx, status %li).", | 2065 | ntfs_debug("Done. Returning %s (written 0x%lx, status %li).", |
2082 | written ? "written" : "status", (unsigned long)written, | 2066 | written ? "written" : "status", (unsigned long)written, |
2083 | (long)status); | 2067 | (long)status); |