diff options
author | Goldwyn Rodrigues <rgoldwyn@suse.com> | 2020-09-24 11:39:13 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-12-08 15:53:46 +0100 |
commit | 5e8b9ef30392bb80f418cf4340b8c9c54039d5dc (patch) | |
tree | b4b714dbbbc905111c4641413c844cc8884e6dfc | |
parent | 4e4cabece9f9c6b8dde8baf8f81e90222aa4989b (diff) |
btrfs: move pos increment and pagecache extension to btrfs_buffered_write
While we do this, correct the call to pagecache_isize_extended:
- pagecache_isize_extended needs to be called to the start of the write
as opposed to i_size
- we don't need to check range before the call, this is done in the
function
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/file.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 6c12f5703faa..e80d7293b3d7 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1581,6 +1581,7 @@ static noinline ssize_t btrfs_buffered_write(struct kiocb *iocb, int ret = 0; bool only_release_metadata = false; bool force_page_uptodate = false; + loff_t old_isize = i_size_read(inode); nrptrs = min(DIV_ROUND_UP(iov_iter_count(i), PAGE_SIZE), PAGE_SIZE / (sizeof(struct page *))); @@ -1779,6 +1780,10 @@ again: } extent_changeset_free(data_reserved); + if (num_written > 0) { + pagecache_isize_extended(inode, old_isize, iocb->ki_pos); + iocb->ki_pos += num_written; + } return num_written ? num_written : ret; } @@ -1901,7 +1906,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, loff_t pos; size_t count; loff_t oldsize; - int clean_page = 0; if (!(iocb->ki_flags & IOCB_DIRECT) && (iocb->ki_flags & IOCB_NOWAIT)) @@ -1983,8 +1987,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, inode_unlock(inode); goto out; } - if (start_pos > round_up(oldsize, fs_info->sectorsize)) - clean_page = 1; } if (sync) @@ -2027,11 +2029,6 @@ static ssize_t btrfs_file_write_iter(struct kiocb *iocb, current->journal_info = NULL; } else { num_written = btrfs_buffered_write(iocb, from); - if (num_written > 0) - iocb->ki_pos = pos + num_written; - if (clean_page) - pagecache_isize_extended(inode, oldsize, - i_size_read(inode)); } inode_unlock(inode); |