diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2014-03-03 08:31:03 -0500 |
---|---|---|
committer | Josef Bacik <jbacik@fb.com> | 2014-03-10 15:17:19 -0400 |
commit | a4d96d6254590df5eb9a6ac32434ed9d33a46d19 (patch) | |
tree | 6da238debb0ce20c5d591d8207b893c2dc121aa8 /fs/btrfs/send.c | |
parent | fcbd2154d16431395e86a48859a5b547c33c09ad (diff) |
Btrfs: share the same code for __record_{new,deleted}_ref
This has no functional change, only picks out the same part of two functions,
and makes it shared.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Diffstat (limited to 'fs/btrfs/send.c')
-rw-r--r-- | fs/btrfs/send.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 9d057ef5adef..112eb647b5cd 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c | |||
@@ -2615,7 +2615,7 @@ struct recorded_ref { | |||
2615 | * everything mixed. So we first record all refs and later process them. | 2615 | * everything mixed. So we first record all refs and later process them. |
2616 | * This function is a helper to record one ref. | 2616 | * This function is a helper to record one ref. |
2617 | */ | 2617 | */ |
2618 | static int record_ref(struct list_head *head, u64 dir, | 2618 | static int __record_ref(struct list_head *head, u64 dir, |
2619 | u64 dir_gen, struct fs_path *path) | 2619 | u64 dir_gen, struct fs_path *path) |
2620 | { | 2620 | { |
2621 | struct recorded_ref *ref; | 2621 | struct recorded_ref *ref; |
@@ -3555,9 +3555,8 @@ out: | |||
3555 | return ret; | 3555 | return ret; |
3556 | } | 3556 | } |
3557 | 3557 | ||
3558 | static int __record_new_ref(int num, u64 dir, int index, | 3558 | static int record_ref(struct btrfs_root *root, int num, u64 dir, int index, |
3559 | struct fs_path *name, | 3559 | struct fs_path *name, void *ctx, struct list_head *refs) |
3560 | void *ctx) | ||
3561 | { | 3560 | { |
3562 | int ret = 0; | 3561 | int ret = 0; |
3563 | struct send_ctx *sctx = ctx; | 3562 | struct send_ctx *sctx = ctx; |
@@ -3568,7 +3567,7 @@ static int __record_new_ref(int num, u64 dir, int index, | |||
3568 | if (!p) | 3567 | if (!p) |
3569 | return -ENOMEM; | 3568 | return -ENOMEM; |
3570 | 3569 | ||
3571 | ret = get_inode_info(sctx->send_root, dir, NULL, &gen, NULL, NULL, | 3570 | ret = get_inode_info(root, dir, NULL, &gen, NULL, NULL, |
3572 | NULL, NULL); | 3571 | NULL, NULL); |
3573 | if (ret < 0) | 3572 | if (ret < 0) |
3574 | goto out; | 3573 | goto out; |
@@ -3580,7 +3579,7 @@ static int __record_new_ref(int num, u64 dir, int index, | |||
3580 | if (ret < 0) | 3579 | if (ret < 0) |
3581 | goto out; | 3580 | goto out; |
3582 | 3581 | ||
3583 | ret = record_ref(&sctx->new_refs, dir, gen, p); | 3582 | ret = __record_ref(refs, dir, gen, p); |
3584 | 3583 | ||
3585 | out: | 3584 | out: |
3586 | if (ret) | 3585 | if (ret) |
@@ -3588,37 +3587,23 @@ out: | |||
3588 | return ret; | 3587 | return ret; |
3589 | } | 3588 | } |
3590 | 3589 | ||
3590 | static int __record_new_ref(int num, u64 dir, int index, | ||
3591 | struct fs_path *name, | ||
3592 | void *ctx) | ||
3593 | { | ||
3594 | struct send_ctx *sctx = ctx; | ||
3595 | return record_ref(sctx->send_root, num, dir, index, name, | ||
3596 | ctx, &sctx->new_refs); | ||
3597 | } | ||
3598 | |||
3599 | |||
3591 | static int __record_deleted_ref(int num, u64 dir, int index, | 3600 | static int __record_deleted_ref(int num, u64 dir, int index, |
3592 | struct fs_path *name, | 3601 | struct fs_path *name, |
3593 | void *ctx) | 3602 | void *ctx) |
3594 | { | 3603 | { |
3595 | int ret = 0; | ||
3596 | struct send_ctx *sctx = ctx; | 3604 | struct send_ctx *sctx = ctx; |
3597 | struct fs_path *p; | 3605 | return record_ref(sctx->parent_root, num, dir, index, name, |
3598 | u64 gen; | 3606 | ctx, &sctx->deleted_refs); |
3599 | |||
3600 | p = fs_path_alloc(); | ||
3601 | if (!p) | ||
3602 | return -ENOMEM; | ||
3603 | |||
3604 | ret = get_inode_info(sctx->parent_root, dir, NULL, &gen, NULL, NULL, | ||
3605 | NULL, NULL); | ||
3606 | if (ret < 0) | ||
3607 | goto out; | ||
3608 | |||
3609 | ret = get_cur_path(sctx, dir, gen, p); | ||
3610 | if (ret < 0) | ||
3611 | goto out; | ||
3612 | ret = fs_path_add_path(p, name); | ||
3613 | if (ret < 0) | ||
3614 | goto out; | ||
3615 | |||
3616 | ret = record_ref(&sctx->deleted_refs, dir, gen, p); | ||
3617 | |||
3618 | out: | ||
3619 | if (ret) | ||
3620 | fs_path_free(p); | ||
3621 | return ret; | ||
3622 | } | 3607 | } |
3623 | 3608 | ||
3624 | static int record_new_ref(struct send_ctx *sctx) | 3609 | static int record_new_ref(struct send_ctx *sctx) |