Merge git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Feb 2010 03:56:21 +0000 (19:56 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Feb 2010 03:56:21 +0000 (19:56 -0800)
* git://git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-unstable:
  Btrfs: btrfs_mark_extent_written uses the wrong slot

1  2 
fs/btrfs/file.c

diff --combined fs/btrfs/file.c
index 9d08096299675548651069e4aa613712b827ba67,a7fd9f3a750abe05ebd586e6db1dfda729a64aff..6ed434ac037faac00117e5d633478bd7a2e0805b
@@@ -720,13 -720,15 +720,15 @@@ again
                                        inode->i_ino, orig_offset);
                BUG_ON(ret);
        }
-       fi = btrfs_item_ptr(leaf, path->slots[0],
-                          struct btrfs_file_extent_item);
        if (del_nr == 0) {
+               fi = btrfs_item_ptr(leaf, path->slots[0],
+                          struct btrfs_file_extent_item);
                btrfs_set_file_extent_type(leaf, fi,
                                           BTRFS_FILE_EXTENT_REG);
                btrfs_mark_buffer_dirty(leaf);
        } else {
+               fi = btrfs_item_ptr(leaf, del_slot - 1,
+                          struct btrfs_file_extent_item);
                btrfs_set_file_extent_type(leaf, fi,
                                           BTRFS_FILE_EXTENT_REG);
                btrfs_set_file_extent_num_bytes(leaf, fi,
@@@ -832,7 -834,7 +834,7 @@@ static ssize_t btrfs_file_write(struct 
        unsigned long last_index;
        int will_write;
  
 -      will_write = ((file->f_flags & O_SYNC) || IS_SYNC(inode) ||
 +      will_write = ((file->f_flags & O_DSYNC) || IS_SYNC(inode) ||
                      (file->f_flags & O_DIRECT));
  
        nrptrs = min((count + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE,
@@@ -999,7 -1001,7 +1001,7 @@@ out_nolock
                if (err)
                        num_written = err;
  
 -              if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) {
 +              if ((file->f_flags & O_DSYNC) || IS_SYNC(inode)) {
                        trans = btrfs_start_transaction(root, 1);
                        ret = btrfs_log_dentry_safe(trans, root,
                                                    file->f_dentry);