diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2017-01-30 15:25:28 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-02-14 09:51:00 -0500 |
commit | e4c3b2dcd1449def1229efb138da7cb28c796c71 (patch) | |
tree | a969e93a86cd12a9c81c99b474b923a314ecbfd7 /fs/btrfs/inode.c | |
parent | f72ad18e996338a8033aeb981e645f8dbf4e22c1 (diff) |
Btrfs: kill trans in run_delalloc_nocow and btrfs_cross_ref_exist
run_delalloc_nocow has used trans in two places where they don't
actually need @trans.
For btrfs_lookup_file_extent, we search for file extents without COWing
anything, and for btrfs_cross_ref_exist, the only place where we need
@trans is deferencing it in order to get running_transaction which we
could easily get from the global fs_info.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ac5f8c404268..92416f3ea9a8 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1247,7 +1247,6 @@ static noinline int run_delalloc_nocow(struct inode *inode, | |||
1247 | { | 1247 | { |
1248 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 1248 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
1249 | struct btrfs_root *root = BTRFS_I(inode)->root; | 1249 | struct btrfs_root *root = BTRFS_I(inode)->root; |
1250 | struct btrfs_trans_handle *trans; | ||
1251 | struct extent_buffer *leaf; | 1250 | struct extent_buffer *leaf; |
1252 | struct btrfs_path *path; | 1251 | struct btrfs_path *path; |
1253 | struct btrfs_file_extent_item *fi; | 1252 | struct btrfs_file_extent_item *fi; |
@@ -1283,30 +1282,10 @@ static noinline int run_delalloc_nocow(struct inode *inode, | |||
1283 | 1282 | ||
1284 | nolock = btrfs_is_free_space_inode(inode); | 1283 | nolock = btrfs_is_free_space_inode(inode); |
1285 | 1284 | ||
1286 | if (nolock) | ||
1287 | trans = btrfs_join_transaction_nolock(root); | ||
1288 | else | ||
1289 | trans = btrfs_join_transaction(root); | ||
1290 | |||
1291 | if (IS_ERR(trans)) { | ||
1292 | extent_clear_unlock_delalloc(inode, start, end, end, | ||
1293 | locked_page, | ||
1294 | EXTENT_LOCKED | EXTENT_DELALLOC | | ||
1295 | EXTENT_DO_ACCOUNTING | | ||
1296 | EXTENT_DEFRAG, PAGE_UNLOCK | | ||
1297 | PAGE_CLEAR_DIRTY | | ||
1298 | PAGE_SET_WRITEBACK | | ||
1299 | PAGE_END_WRITEBACK); | ||
1300 | btrfs_free_path(path); | ||
1301 | return PTR_ERR(trans); | ||
1302 | } | ||
1303 | |||
1304 | trans->block_rsv = &fs_info->delalloc_block_rsv; | ||
1305 | |||
1306 | cow_start = (u64)-1; | 1285 | cow_start = (u64)-1; |
1307 | cur_offset = start; | 1286 | cur_offset = start; |
1308 | while (1) { | 1287 | while (1) { |
1309 | ret = btrfs_lookup_file_extent(trans, root, path, ino, | 1288 | ret = btrfs_lookup_file_extent(NULL, root, path, ino, |
1310 | cur_offset, 0); | 1289 | cur_offset, 0); |
1311 | if (ret < 0) | 1290 | if (ret < 0) |
1312 | goto error; | 1291 | goto error; |
@@ -1379,7 +1358,7 @@ next_slot: | |||
1379 | goto out_check; | 1358 | goto out_check; |
1380 | if (btrfs_extent_readonly(fs_info, disk_bytenr)) | 1359 | if (btrfs_extent_readonly(fs_info, disk_bytenr)) |
1381 | goto out_check; | 1360 | goto out_check; |
1382 | if (btrfs_cross_ref_exist(trans, root, ino, | 1361 | if (btrfs_cross_ref_exist(root, ino, |
1383 | found_key.offset - | 1362 | found_key.offset - |
1384 | extent_offset, disk_bytenr)) | 1363 | extent_offset, disk_bytenr)) |
1385 | goto out_check; | 1364 | goto out_check; |
@@ -1531,10 +1510,6 @@ out_check: | |||
1531 | } | 1510 | } |
1532 | 1511 | ||
1533 | error: | 1512 | error: |
1534 | err = btrfs_end_transaction(trans); | ||
1535 | if (!ret) | ||
1536 | ret = err; | ||
1537 | |||
1538 | if (ret && cur_offset < end) | 1513 | if (ret && cur_offset < end) |
1539 | extent_clear_unlock_delalloc(inode, cur_offset, end, end, | 1514 | extent_clear_unlock_delalloc(inode, cur_offset, end, end, |
1540 | locked_page, EXTENT_LOCKED | | 1515 | locked_page, EXTENT_LOCKED | |
@@ -7290,7 +7265,6 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, | |||
7290 | u64 *ram_bytes) | 7265 | u64 *ram_bytes) |
7291 | { | 7266 | { |
7292 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 7267 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
7293 | struct btrfs_trans_handle *trans; | ||
7294 | struct btrfs_path *path; | 7268 | struct btrfs_path *path; |
7295 | int ret; | 7269 | int ret; |
7296 | struct extent_buffer *leaf; | 7270 | struct extent_buffer *leaf; |
@@ -7393,15 +7367,9 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, | |||
7393 | * look for other files referencing this extent, if we | 7367 | * look for other files referencing this extent, if we |
7394 | * find any we must cow | 7368 | * find any we must cow |
7395 | */ | 7369 | */ |
7396 | trans = btrfs_join_transaction(root); | ||
7397 | if (IS_ERR(trans)) { | ||
7398 | ret = 0; | ||
7399 | goto out; | ||
7400 | } | ||
7401 | 7370 | ||
7402 | ret = btrfs_cross_ref_exist(trans, root, btrfs_ino(BTRFS_I(inode)), | 7371 | ret = btrfs_cross_ref_exist(root, btrfs_ino(BTRFS_I(inode)), |
7403 | key.offset - backref_offset, disk_bytenr); | 7372 | key.offset - backref_offset, disk_bytenr); |
7404 | btrfs_end_transaction(trans); | ||
7405 | if (ret) { | 7373 | if (ret) { |
7406 | ret = 0; | 7374 | ret = 0; |
7407 | goto out; | 7375 | goto out; |