Btrfs: fix the file clone ioctl for preallocated extents
authorChris Mason <chris.mason@oracle.com>
Sun, 28 Jun 2009 01:07:03 +0000 (21:07 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 2 Jul 2009 17:41:16 +0000 (13:41 -0400)
fs/btrfs/ioctl.c

index eff18f5b53620f20a392f9c57a80c8897c61d317..9f4db848db10dcb24c40ebe2529b3ff609c9cc1b 100644 (file)
@@ -1028,7 +1028,8 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
                                                struct btrfs_file_extent_item);
                        comp = btrfs_file_extent_compression(leaf, extent);
                        type = btrfs_file_extent_type(leaf, extent);
-                       if (type == BTRFS_FILE_EXTENT_REG) {
+                       if (type == BTRFS_FILE_EXTENT_REG ||
+                           type == BTRFS_FILE_EXTENT_PREALLOC) {
                                disko = btrfs_file_extent_disk_bytenr(leaf,
                                                                      extent);
                                diskl = btrfs_file_extent_disk_num_bytes(leaf,
@@ -1051,7 +1052,8 @@ static long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
                        new_key.objectid = inode->i_ino;
                        new_key.offset = key.offset + destoff - off;
 
-                       if (type == BTRFS_FILE_EXTENT_REG) {
+                       if (type == BTRFS_FILE_EXTENT_REG ||
+                           type == BTRFS_FILE_EXTENT_PREALLOC) {
                                ret = btrfs_insert_empty_item(trans, root, path,
                                                              &new_key, size);
                                if (ret)