]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/btrfs/ioctl.c
Merge branch 'component-for-staging' of git://ftp.arm.linux.org.uk/~rmk/linux-arm...
[karo-tx-linux.git] / fs / btrfs / ioctl.c
index 0d321c23069a0aa9ea1aeac570bdf837cf208d24..47aceb494d1d456da8940c5e7a1d3eed3fa4adc5 100644 (file)
@@ -136,19 +136,22 @@ static unsigned int btrfs_flags_to_ioctl(unsigned int flags)
 void btrfs_update_iflags(struct inode *inode)
 {
        struct btrfs_inode *ip = BTRFS_I(inode);
-
-       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
+       unsigned int new_fl = 0;
 
        if (ip->flags & BTRFS_INODE_SYNC)
-               inode->i_flags |= S_SYNC;
+               new_fl |= S_SYNC;
        if (ip->flags & BTRFS_INODE_IMMUTABLE)
-               inode->i_flags |= S_IMMUTABLE;
+               new_fl |= S_IMMUTABLE;
        if (ip->flags & BTRFS_INODE_APPEND)
-               inode->i_flags |= S_APPEND;
+               new_fl |= S_APPEND;
        if (ip->flags & BTRFS_INODE_NOATIME)
-               inode->i_flags |= S_NOATIME;
+               new_fl |= S_NOATIME;
        if (ip->flags & BTRFS_INODE_DIRSYNC)
-               inode->i_flags |= S_DIRSYNC;
+               new_fl |= S_DIRSYNC;
+
+       set_mask_bits(&inode->i_flags,
+                     S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME | S_DIRSYNC,
+                     new_fl);
 }
 
 /*
@@ -3139,7 +3142,6 @@ out:
 static void clone_update_extent_map(struct inode *inode,
                                    const struct btrfs_trans_handle *trans,
                                    const struct btrfs_path *path,
-                                   struct btrfs_file_extent_item *fi,
                                    const u64 hole_offset,
                                    const u64 hole_len)
 {
@@ -3154,7 +3156,11 @@ static void clone_update_extent_map(struct inode *inode,
                return;
        }
 
-       if (fi) {
+       if (path) {
+               struct btrfs_file_extent_item *fi;
+
+               fi = btrfs_item_ptr(path->nodes[0], path->slots[0],
+                                   struct btrfs_file_extent_item);
                btrfs_extent_item_to_extent_map(inode, path, fi, false, em);
                em->generation = -1;
                if (btrfs_file_extent_type(path->nodes[0], fi) ==
@@ -3508,18 +3514,15 @@ process_slot:
                                            btrfs_item_ptr_offset(leaf, slot),
                                            size);
                                inode_add_bytes(inode, datal);
-                               extent = btrfs_item_ptr(leaf, slot,
-                                               struct btrfs_file_extent_item);
                        }
 
                        /* If we have an implicit hole (NO_HOLES feature). */
                        if (drop_start < new_key.offset)
                                clone_update_extent_map(inode, trans,
-                                               path, NULL, drop_start,
+                                               NULL, drop_start,
                                                new_key.offset - drop_start);
 
-                       clone_update_extent_map(inode, trans, path,
-                                               extent, 0, 0);
+                       clone_update_extent_map(inode, trans, path, 0, 0);
 
                        btrfs_mark_buffer_dirty(leaf);
                        btrfs_release_path(path);
@@ -3562,12 +3565,10 @@ process_slot:
                        btrfs_end_transaction(trans, root);
                        goto out;
                }
+               clone_update_extent_map(inode, trans, NULL, last_dest_end,
+                                       destoff + len - last_dest_end);
                ret = clone_finish_inode_update(trans, inode, destoff + len,
                                                destoff, olen);
-               if (ret)
-                       goto out;
-               clone_update_extent_map(inode, trans, path, NULL, last_dest_end,
-                                       destoff + len - last_dest_end);
        }
 
 out: