diff options
Diffstat (limited to 'fs/ntfs/file.c')
-rw-r--r-- | fs/ntfs/file.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 8804f093ba75..113ebd9f25a4 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); |
@@ -2149,7 +2133,6 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2149 | /** | 2133 | /** |
2150 | * ntfs_file_fsync - sync a file to disk | 2134 | * ntfs_file_fsync - sync a file to disk |
2151 | * @filp: file to be synced | 2135 | * @filp: file to be synced |
2152 | * @dentry: dentry describing the file to sync | ||
2153 | * @datasync: if non-zero only flush user data and not metadata | 2136 | * @datasync: if non-zero only flush user data and not metadata |
2154 | * | 2137 | * |
2155 | * Data integrity sync of a file to disk. Used for fsync, fdatasync, and msync | 2138 | * Data integrity sync of a file to disk. Used for fsync, fdatasync, and msync |
@@ -2165,19 +2148,15 @@ static ssize_t ntfs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
2165 | * Also, if @datasync is true, we do not wait on the inode to be written out | 2148 | * Also, if @datasync is true, we do not wait on the inode to be written out |
2166 | * but we always wait on the page cache pages to be written out. | 2149 | * but we always wait on the page cache pages to be written out. |
2167 | * | 2150 | * |
2168 | * Note: In the past @filp could be NULL so we ignore it as we don't need it | ||
2169 | * anyway. | ||
2170 | * | ||
2171 | * Locking: Caller must hold i_mutex on the inode. | 2151 | * Locking: Caller must hold i_mutex on the inode. |
2172 | * | 2152 | * |
2173 | * TODO: We should probably also write all attribute/index inodes associated | 2153 | * TODO: We should probably also write all attribute/index inodes associated |
2174 | * with this inode but since we have no simple way of getting to them we ignore | 2154 | * with this inode but since we have no simple way of getting to them we ignore |
2175 | * this problem for now. | 2155 | * this problem for now. |
2176 | */ | 2156 | */ |
2177 | static int ntfs_file_fsync(struct file *filp, struct dentry *dentry, | 2157 | static int ntfs_file_fsync(struct file *filp, int datasync) |
2178 | int datasync) | ||
2179 | { | 2158 | { |
2180 | struct inode *vi = dentry->d_inode; | 2159 | struct inode *vi = filp->f_mapping->host; |
2181 | int err, ret = 0; | 2160 | int err, ret = 0; |
2182 | 2161 | ||
2183 | ntfs_debug("Entering for inode 0x%lx.", vi->i_ino); | 2162 | ntfs_debug("Entering for inode 0x%lx.", vi->i_ino); |