From: David Sterba Date: Fri, 26 Feb 2016 14:38:28 +0000 (+0100) Subject: Merge branch 'chandan/prep-subpage-blocksize' into for-chris-4.6 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5f1b5664d97842bc5dba40c2053bf95270b6ff7a;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git Merge branch 'chandan/prep-subpage-blocksize' into for-chris-4.6 # Conflicts: # fs/btrfs/file.c --- 5f1b5664d97842bc5dba40c2053bf95270b6ff7a diff --cc fs/btrfs/file.c index 098bb8f690c9,953f0ad17802..5a58e292bdad --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@@ -1761,11 -1778,13 +1778,13 @@@ static ssize_t btrfs_file_write_iter(st ssize_t err; loff_t pos; size_t count; + loff_t oldsize; + int clean_page = 0; - mutex_lock(&inode->i_mutex); + inode_lock(inode); err = generic_write_checks(iocb, from); if (err <= 0) { - mutex_unlock(&inode->i_mutex); + inode_unlock(inode); return err; } @@@ -1799,14 -1818,17 +1818,17 @@@ pos = iocb->ki_pos; count = iov_iter_count(from); start_pos = round_down(pos, root->sectorsize); - if (start_pos > i_size_read(inode)) { + oldsize = i_size_read(inode); + if (start_pos > oldsize) { /* Expand hole size to cover write data, preventing empty gap */ end_pos = round_up(pos + count, root->sectorsize); - err = btrfs_cont_expand(inode, i_size_read(inode), end_pos); + err = btrfs_cont_expand(inode, oldsize, end_pos); if (err) { - mutex_unlock(&inode->i_mutex); + inode_unlock(inode); goto out; } + if (start_pos > round_up(oldsize, root->sectorsize)) + clean_page = 1; } if (sync) @@@ -1818,9 -1840,12 +1840,12 @@@ num_written = __btrfs_buffered_write(file, from, pos); if (num_written > 0) iocb->ki_pos = pos + num_written; + if (clean_page) + pagecache_isize_extended(inode, oldsize, + i_size_read(inode)); } - mutex_unlock(&inode->i_mutex); + inode_unlock(inode); /* * We also have to set last_sub_trans to the current log transid, @@@ -2303,8 -2328,8 +2328,8 @@@ static int btrfs_punch_hole(struct inod if (ret) return ret; - mutex_lock(&inode->i_mutex); + inode_lock(inode); - ino_size = round_up(inode->i_size, PAGE_CACHE_SIZE); + ino_size = round_up(inode->i_size, root->sectorsize); ret = find_first_non_hole(inode, &offset, &len); if (ret < 0) goto out_only_mutex; @@@ -2338,12 -2362,12 +2362,12 @@@ goto out_only_mutex; } - /* zero back part of the first page */ + /* zero back part of the first block */ if (offset < ino_size) { - truncated_page = true; - ret = btrfs_truncate_page(inode, offset, 0, 0); + truncated_block = true; + ret = btrfs_truncate_block(inode, offset, 0, 0); if (ret) { - mutex_unlock(&inode->i_mutex); + inode_unlock(inode); return ret; } }