diff options
Diffstat (limited to 'fs/btrfs/ioctl.c')
-rw-r--r-- | fs/btrfs/ioctl.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 3351b1b24574..538f65a79ec5 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -2177,6 +2177,11 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2177 | if (!(src_file->f_mode & FMODE_READ)) | 2177 | if (!(src_file->f_mode & FMODE_READ)) |
2178 | goto out_fput; | 2178 | goto out_fput; |
2179 | 2179 | ||
2180 | /* don't make the dst file partly checksummed */ | ||
2181 | if ((BTRFS_I(src)->flags & BTRFS_INODE_NODATASUM) != | ||
2182 | (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)) | ||
2183 | goto out_fput; | ||
2184 | |||
2180 | ret = -EISDIR; | 2185 | ret = -EISDIR; |
2181 | if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode)) | 2186 | if (S_ISDIR(src->i_mode) || S_ISDIR(inode->i_mode)) |
2182 | goto out_fput; | 2187 | goto out_fput; |
@@ -2226,6 +2231,10 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2226 | goto out_unlock; | 2231 | goto out_unlock; |
2227 | } | 2232 | } |
2228 | 2233 | ||
2234 | /* truncate page cache pages from target inode range */ | ||
2235 | truncate_inode_pages_range(&inode->i_data, destoff, | ||
2236 | PAGE_CACHE_ALIGN(destoff + len) - 1); | ||
2237 | |||
2229 | /* do any pending delalloc/csum calc on src, one way or | 2238 | /* do any pending delalloc/csum calc on src, one way or |
2230 | another, and lock file content */ | 2239 | another, and lock file content */ |
2231 | while (1) { | 2240 | while (1) { |
@@ -2242,10 +2251,6 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2242 | btrfs_wait_ordered_range(src, off, len); | 2251 | btrfs_wait_ordered_range(src, off, len); |
2243 | } | 2252 | } |
2244 | 2253 | ||
2245 | /* truncate page cache pages from target inode range */ | ||
2246 | truncate_inode_pages_range(&inode->i_data, off, | ||
2247 | ALIGN(off + len, PAGE_CACHE_SIZE) - 1); | ||
2248 | |||
2249 | /* clone data */ | 2254 | /* clone data */ |
2250 | key.objectid = btrfs_ino(src); | 2255 | key.objectid = btrfs_ino(src); |
2251 | key.type = BTRFS_EXTENT_DATA_KEY; | 2256 | key.type = BTRFS_EXTENT_DATA_KEY; |
@@ -2323,7 +2328,12 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2323 | else | 2328 | else |
2324 | new_key.offset = destoff; | 2329 | new_key.offset = destoff; |
2325 | 2330 | ||
2326 | trans = btrfs_start_transaction(root, 1); | 2331 | /* |
2332 | * 1 - adjusting old extent (we may have to split it) | ||
2333 | * 1 - add new extent | ||
2334 | * 1 - inode update | ||
2335 | */ | ||
2336 | trans = btrfs_start_transaction(root, 3); | ||
2327 | if (IS_ERR(trans)) { | 2337 | if (IS_ERR(trans)) { |
2328 | ret = PTR_ERR(trans); | 2338 | ret = PTR_ERR(trans); |
2329 | goto out; | 2339 | goto out; |
@@ -2442,7 +2452,6 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2442 | if (endoff > inode->i_size) | 2452 | if (endoff > inode->i_size) |
2443 | btrfs_i_size_write(inode, endoff); | 2453 | btrfs_i_size_write(inode, endoff); |
2444 | 2454 | ||
2445 | BTRFS_I(inode)->flags = BTRFS_I(src)->flags; | ||
2446 | ret = btrfs_update_inode(trans, root, inode); | 2455 | ret = btrfs_update_inode(trans, root, inode); |
2447 | BUG_ON(ret); | 2456 | BUG_ON(ret); |
2448 | btrfs_end_transaction(trans, root); | 2457 | btrfs_end_transaction(trans, root); |