* [PATCH 1/2] Btrfs: remove unused code in full_send_tree
@ 2014-03-03 13:31 Liu Bo
2014-03-03 13:31 ` [PATCH 2/2] Btrfs: share the same code for __record_{new,deleted}_ref Liu Bo
2014-03-03 13:53 ` [PATCH 1/2] Btrfs: remove unused code in full_send_tree gHcAgree
0 siblings, 2 replies; 4+ messages in thread
From: Liu Bo @ 2014-03-03 13:31 UTC (permalink / raw)
To: linux-btrfs
It's unnecessary to update key's value, and remove it to keep code clean.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
fs/btrfs/send.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 3fe4d6e..a5f9626 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -5180,10 +5180,6 @@ static int full_send_tree(struct send_ctx *sctx)
if (ret < 0)
goto out;
- key.objectid = found_key.objectid;
- key.type = found_key.type;
- key.offset = found_key.offset + 1;
-
ret = btrfs_next_item(send_root, path);
if (ret < 0)
goto out;
--
1.8.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] Btrfs: share the same code for __record_{new,deleted}_ref
2014-03-03 13:31 [PATCH 1/2] Btrfs: remove unused code in full_send_tree Liu Bo
@ 2014-03-03 13:31 ` Liu Bo
2014-03-03 13:53 ` [PATCH 1/2] Btrfs: remove unused code in full_send_tree gHcAgree
1 sibling, 0 replies; 4+ messages in thread
From: Liu Bo @ 2014-03-03 13:31 UTC (permalink / raw)
To: linux-btrfs
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>
---
fs/btrfs/send.c | 49 +++++++++++++++++--------------------------------
1 file changed, 17 insertions(+), 32 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index a5f9626..2daa8d6 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -2584,7 +2584,7 @@ struct recorded_ref {
* everything mixed. So we first record all refs and later process them.
* This function is a helper to record one ref.
*/
-static int record_ref(struct list_head *head, u64 dir,
+static int __record_ref(struct list_head *head, u64 dir,
u64 dir_gen, struct fs_path *path)
{
struct recorded_ref *ref;
@@ -3369,9 +3369,8 @@ out:
return ret;
}
-static int __record_new_ref(int num, u64 dir, int index,
- struct fs_path *name,
- void *ctx)
+static int record_ref(struct btrfs_root *root, int num, u64 dir, int index,
+ struct fs_path *name, void *ctx, struct list_head *refs)
{
int ret = 0;
struct send_ctx *sctx = ctx;
@@ -3382,7 +3381,7 @@ static int __record_new_ref(int num, u64 dir, int index,
if (!p)
return -ENOMEM;
- ret = get_inode_info(sctx->send_root, dir, NULL, &gen, NULL, NULL,
+ ret = get_inode_info(root, dir, NULL, &gen, NULL, NULL,
NULL, NULL);
if (ret < 0)
goto out;
@@ -3394,7 +3393,7 @@ static int __record_new_ref(int num, u64 dir, int index,
if (ret < 0)
goto out;
- ret = record_ref(&sctx->new_refs, dir, gen, p);
+ ret = __record_ref(refs, dir, gen, p);
out:
if (ret)
@@ -3402,37 +3401,23 @@ out:
return ret;
}
+static int __record_new_ref(int num, u64 dir, int index,
+ struct fs_path *name,
+ void *ctx)
+{
+ struct send_ctx *sctx = ctx;
+ return record_ref(sctx->send_root, num, dir, index, name,
+ ctx, &sctx->new_refs);
+}
+
+
static int __record_deleted_ref(int num, u64 dir, int index,
struct fs_path *name,
void *ctx)
{
- int ret = 0;
struct send_ctx *sctx = ctx;
- struct fs_path *p;
- u64 gen;
-
- p = fs_path_alloc();
- if (!p)
- return -ENOMEM;
-
- ret = get_inode_info(sctx->parent_root, dir, NULL, &gen, NULL, NULL,
- NULL, NULL);
- if (ret < 0)
- goto out;
-
- ret = get_cur_path(sctx, dir, gen, p);
- if (ret < 0)
- goto out;
- ret = fs_path_add_path(p, name);
- if (ret < 0)
- goto out;
-
- ret = record_ref(&sctx->deleted_refs, dir, gen, p);
-
-out:
- if (ret)
- fs_path_free(p);
- return ret;
+ return record_ref(sctx->parent_root, num, dir, index, name,
+ ctx, &sctx->deleted_refs);
}
static int record_new_ref(struct send_ctx *sctx)
--
1.8.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Btrfs: remove unused code in full_send_tree
2014-03-03 13:31 [PATCH 1/2] Btrfs: remove unused code in full_send_tree Liu Bo
2014-03-03 13:31 ` [PATCH 2/2] Btrfs: share the same code for __record_{new,deleted}_ref Liu Bo
@ 2014-03-03 13:53 ` gHcAgree
2014-03-04 2:17 ` Liu Bo
1 sibling, 1 reply; 4+ messages in thread
From: gHcAgree @ 2014-03-03 13:53 UTC (permalink / raw)
To: Liu Bo, linux-btrfs
On 2014年03月03日 21:31, Liu Bo wrote:
> It's unnecessary to update key's value, and remove it to keep code clean.
>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> ---
> fs/btrfs/send.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 3fe4d6e..a5f9626 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -5180,10 +5180,6 @@ static int full_send_tree(struct send_ctx *sctx)
> if (ret < 0)
> goto out;
>
> - key.objectid = found_key.objectid;
> - key.type = found_key.type;
> - key.offset = found_key.offset + 1;
> -
> ret = btrfs_next_item(send_root, path);
> if (ret < 0)
> goto out;
Hi Liu and all,
I think the statements may better be reserved. I noticed that there is
an "goto join_trans" above. I think we may hit it in the next round and
exec from the "join_trans" down, then these 3 assignments effect.
Sorry, I am not very sure whether this situation could happen, please
ignore me if I am making noise.
-H.A.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] Btrfs: remove unused code in full_send_tree
2014-03-03 13:53 ` [PATCH 1/2] Btrfs: remove unused code in full_send_tree gHcAgree
@ 2014-03-04 2:17 ` Liu Bo
0 siblings, 0 replies; 4+ messages in thread
From: Liu Bo @ 2014-03-04 2:17 UTC (permalink / raw)
To: gHcAgree; +Cc: linux-btrfs
On Mon, Mar 03, 2014 at 09:53:45PM +0800, gHcAgree wrote:
>
> On 2014年03月03日 21:31, Liu Bo wrote:
> >It's unnecessary to update key's value, and remove it to keep code clean.
> >
> >Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> >---
> > fs/btrfs/send.c | 4 ----
> > 1 file changed, 4 deletions(-)
> >
> >diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> >index 3fe4d6e..a5f9626 100644
> >--- a/fs/btrfs/send.c
> >+++ b/fs/btrfs/send.c
> >@@ -5180,10 +5180,6 @@ static int full_send_tree(struct send_ctx *sctx)
> > if (ret < 0)
> > goto out;
> >- key.objectid = found_key.objectid;
> >- key.type = found_key.type;
> >- key.offset = found_key.offset + 1;
> >-
> > ret = btrfs_next_item(send_root, path);
> > if (ret < 0)
> > goto out;
> Hi Liu and all,
> I think the statements may better be reserved. I noticed that there
> is an "goto join_trans" above. I think we may hit it in the next
> round and exec from the "join_trans" down, then these 3 assignments
> effect.
Yeah, I think you're right, with btrfs-next, we should keep these assignments.
-liubo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-04 2:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-03 13:31 [PATCH 1/2] Btrfs: remove unused code in full_send_tree Liu Bo
2014-03-03 13:31 ` [PATCH 2/2] Btrfs: share the same code for __record_{new,deleted}_ref Liu Bo
2014-03-03 13:53 ` [PATCH 1/2] Btrfs: remove unused code in full_send_tree gHcAgree
2014-03-04 2:17 ` Liu Bo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox