aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2012-10-11 16:17:34 -0400
committerChris Mason <chris.mason@fusionio.com>2012-12-16 20:46:22 -0500
commita95249b392c3ab843d7b25ab6817ecc9ea0b82ee (patch)
tree85489b441816bb50fb05f21057dd6e7a4374482b /fs
parente99761514999f64aff1985460967f93d9e8417f4 (diff)
Btrfs: don't bother copying if we're only logging the inode
We don't copy inode items anwyay, we just copy them straight into the log from the in memory inode. So if we know we're only logging the inode, don't bother dropping anything, just try to insert it and either if it succeeds or we get EEXIST we can update the inode item in the log and carry on. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/tree-log.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f05fca778cb4..ab7168ee618f 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2996,6 +2996,26 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
2996 2996
2997} 2997}
2998 2998
2999static int log_inode_item(struct btrfs_trans_handle *trans,
3000 struct btrfs_root *log, struct btrfs_path *path,
3001 struct inode *inode)
3002{
3003 struct btrfs_inode_item *inode_item;
3004 struct btrfs_key key;
3005 int ret;
3006
3007 memcpy(&key, &BTRFS_I(inode)->location, sizeof(key));
3008 ret = btrfs_insert_empty_item(trans, log, path, &key,
3009 sizeof(*inode_item));
3010 if (ret && ret != -EEXIST)
3011 return ret;
3012 inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
3013 struct btrfs_inode_item);
3014 fill_inode_item(trans, path->nodes[0], inode_item, inode, 0);
3015 btrfs_release_path(path);
3016 return 0;
3017}
3018
2999static noinline int copy_items(struct btrfs_trans_handle *trans, 3019static noinline int copy_items(struct btrfs_trans_handle *trans,
3000 struct inode *inode, 3020 struct inode *inode,
3001 struct btrfs_path *dst_path, 3021 struct btrfs_path *dst_path,
@@ -3433,17 +3453,24 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans,
3433 &BTRFS_I(inode)->runtime_flags); 3453 &BTRFS_I(inode)->runtime_flags);
3434 ret = btrfs_truncate_inode_items(trans, log, 3454 ret = btrfs_truncate_inode_items(trans, log,
3435 inode, 0, 0); 3455 inode, 0, 0);
3436 } else { 3456 } else if (test_and_clear_bit(BTRFS_INODE_COPY_EVERYTHING,
3457 &BTRFS_I(inode)->runtime_flags)) {
3437 if (inode_only == LOG_INODE_ALL) 3458 if (inode_only == LOG_INODE_ALL)
3438 fast_search = true; 3459 fast_search = true;
3439 if (test_and_clear_bit(BTRFS_INODE_COPY_EVERYTHING, 3460 max_key.type = BTRFS_XATTR_ITEM_KEY;
3440 &BTRFS_I(inode)->runtime_flags))
3441 max_key.type = BTRFS_XATTR_ITEM_KEY;
3442 else
3443 max_key.type = BTRFS_INODE_ITEM_KEY;
3444 ret = drop_objectid_items(trans, log, path, ino, 3461 ret = drop_objectid_items(trans, log, path, ino,
3445 max_key.type); 3462 max_key.type);
3463 } else {
3464 if (inode_only == LOG_INODE_ALL)
3465 fast_search = true;
3466 ret = log_inode_item(trans, log, dst_path, inode);
3467 if (ret) {
3468 err = ret;
3469 goto out_unlock;
3470 }
3471 goto log_extents;
3446 } 3472 }
3473
3447 } 3474 }
3448 if (ret) { 3475 if (ret) {
3449 err = ret; 3476 err = ret;
@@ -3522,6 +3549,7 @@ next_slot:
3522 ins_nr = 0; 3549 ins_nr = 0;
3523 } 3550 }
3524 3551
3552log_extents:
3525 if (fast_search) { 3553 if (fast_search) {
3526 btrfs_release_path(path); 3554 btrfs_release_path(path);
3527 btrfs_release_path(dst_path); 3555 btrfs_release_path(dst_path);