Merge branch 'chandan/prep-subpage-blocksize' into for-chris-4.6
authorDavid Sterba <dsterba@suse.com>
Fri, 26 Feb 2016 14:38:28 +0000 (15:38 +0100)
committerDavid Sterba <dsterba@suse.com>
Fri, 26 Feb 2016 14:38:28 +0000 (15:38 +0100)
# Conflicts:
# fs/btrfs/file.c

1  2 
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c

Simple merge
diff --cc 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;
        }
  
        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)
                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;
                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;
                }
        }
Simple merge
Simple merge