All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] Btrfs: incremental send, fix serval case for root and gen
@ 2016-10-12  8:12 robbieko
  2016-10-12  8:12 ` [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref robbieko
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: robbieko @ 2016-10-12  8:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Robbie Ko

From: Robbie Ko <robbieko@synology.com>

Patch for fix btrfs incremental send. 
These patches base on v4.8.0-rc8

Robbie Ko (5):
  Btrfs: incremental send, fix don't skip root inode in overwrite_ref
  Btrfs: incremental send, add gen for is_waiting_for_rm when some
    corner case
  Btrfs: incremental send, add gen in waiting_dir_move for some corner
    case
  Btrfs: incremental send, add gen check in did_overwrite_ref
  Btrfs: incremental send, add gen check if has waiting_dir_move in the
    will_overwrite_ref

 fs/btrfs/send.c | 50 ++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 10 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref
  2016-10-12  8:12 [PATCH 0/5] Btrfs: incremental send, fix serval case for root and gen robbieko
@ 2016-10-12  8:12 ` robbieko
  2016-10-12  9:09   ` Filipe Manana
  2016-10-12  8:12 ` [PATCH 2/5] Btrfs: incremental send, add gen for is_waiting_for_rm when some corner case robbieko
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: robbieko @ 2016-10-12  8:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Robbie Ko

From: Robbie Ko <robbieko@synology.com>

When root dir item change, don't skip will_overwrite_ref,
because root inode always exist.

Example:
Parent snapshot:
|---- a1/ (ino 257, dir)
|---- a2/ (ino 258, dir)

Send snapshot:
|---- a2 (ino 257, file)

ERROR: rename o257-29-0 -> a2 failed: Is a directory

when process 257, first rmdir (ino 257,dir), and then mkfile o257-29-0,
and rename o257-29-0 -> a2, but now parent snapshot had a2(ino 258,dir),
we don't ignore it.

therefore is_inode_existent always return 1,
and will_overwrite_ref don't check gen for root inode.

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/send.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index a87675f..1862f8a 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1681,6 +1681,10 @@ static int is_inode_existent(struct send_ctx *sctx, u64 ino, u64 gen)
 {
 	int ret;
 
+	if (ino == BTRFS_FIRST_FREE_OBJECTID) {
+		return 1;
+	}
+
 	ret = get_cur_inode_state(sctx, ino, gen);
 	if (ret < 0)
 		goto out;
@@ -1866,7 +1870,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
 	 * not deleted and then re-created, if it was then we have no overwrite
 	 * and we can just unlink this entry.
 	 */
-	if (sctx->parent_root) {
+	if (sctx->parent_root && dir != BTRFS_FIRST_FREE_OBJECTID) {
 		ret = get_inode_info(sctx->parent_root, dir, NULL, &gen, NULL,
 				     NULL, NULL, NULL);
 		if (ret < 0 && ret != -ENOENT)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/5] Btrfs: incremental send, add gen for is_waiting_for_rm when some corner case
  2016-10-12  8:12 [PATCH 0/5] Btrfs: incremental send, fix serval case for root and gen robbieko
  2016-10-12  8:12 ` [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref robbieko
@ 2016-10-12  8:12 ` robbieko
  2016-10-12  9:11   ` Filipe Manana
  2016-10-12  8:12 ` [PATCH 3/5] Btrfs: incremental send, add gen in waiting_dir_move for " robbieko
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: robbieko @ 2016-10-12  8:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Robbie Ko

From: Robbie Ko <robbieko@synology.com>

There a one case for old_gen waiting_for_rm,
but new_gen use get_cur_path with the same inode.

Example:
    Parent snapshot:
    |---- dir258/ (ino 258, dir)
        |--- dir257/ (ino 257, dir)
    |---- dir259/ (ino 259, dir)

    Send snapshot:
    |---- file258 (ino 258, file)
    |---- new_dir259/ (ino 259, dir)
        |--- dir257/ (ino 257, dir)

utimes
mkdir o259-21-0
rename dir258 -> o258-15-0
utimes
mkfile o258-21-0
rename o258-21-0 -> file258
utimes
truncate o258-21-0 size=0
ERROR: truncate o258-21-0 failed: No such file or directory

dir258 will be delete, but dir257 is waiting for move,
so dir258 is waiting for rm, and then file258 be create,
and rename it, and then need to truncate it, so use get_cur_path
to get path, but is_waiting_for_rm olny check ino, dosen't check gen,
match dir258 is waiting for rm, so get error path o258-21-0.

therefore, add gen check in is_waiting_for_rm.

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/send.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 1862f8a..95d3718 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -311,7 +311,7 @@ static int is_waiting_for_move(struct send_ctx *sctx, u64 ino);
 static struct waiting_dir_move *
 get_waiting_dir_move(struct send_ctx *sctx, u64 ino);
 
-static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino);
+static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino, u64 dir_gen);
 
 static int need_send_hole(struct send_ctx *sctx)
 {
@@ -2293,7 +2293,7 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen,
 
 		fs_path_reset(name);
 
-		if (is_waiting_for_rm(sctx, ino)) {
+		if (is_waiting_for_rm(sctx, ino, gen)) {
 			ret = gen_unique_name(sctx, ino, gen, name);
 			if (ret < 0)
 				goto out;
@@ -2900,11 +2900,11 @@ get_orphan_dir_info(struct send_ctx *sctx, u64 dir_ino)
 	return NULL;
 }
 
-static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino)
+static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino, u64 dir_gen)
 {
 	struct orphan_dir_info *odi = get_orphan_dir_info(sctx, dir_ino);
 
-	return odi != NULL;
+	return (odi != NULL && odi->gen == dir_gen);
 }
 
 static void free_orphan_dir_info(struct send_ctx *sctx,
@@ -3167,7 +3167,7 @@ static int path_loop(struct send_ctx *sctx, struct fs_path *name,
 	while (ino != BTRFS_FIRST_FREE_OBJECTID) {
 		fs_path_reset(name);
 
-		if (is_waiting_for_rm(sctx, ino))
+		if (is_waiting_for_rm(sctx, ino, gen))
 			break;
 		if (is_waiting_for_move(sctx, ino)) {
 			if (*ancestor_ino == 0)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/5] Btrfs: incremental send, add gen in waiting_dir_move for some corner case
  2016-10-12  8:12 [PATCH 0/5] Btrfs: incremental send, fix serval case for root and gen robbieko
  2016-10-12  8:12 ` [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref robbieko
  2016-10-12  8:12 ` [PATCH 2/5] Btrfs: incremental send, add gen for is_waiting_for_rm when some corner case robbieko
@ 2016-10-12  8:12 ` robbieko
  2016-10-12  9:13   ` Filipe Manana
  2016-10-12  8:12 ` [PATCH 4/5] Btrfs: incremental send, add gen check in did_overwrite_ref robbieko
  2016-10-12  8:12 ` [PATCH 5/5] Btrfs: incremental send, add gen check if has waiting_dir_move in the will_overwrite_ref robbieko
  4 siblings, 1 reply; 11+ messages in thread
From: robbieko @ 2016-10-12  8:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Robbie Ko

From: Robbie Ko <robbieko@synology.com>

There a some case similar as before.
add compare generation with dir items,
and waiting_dir_move in the can_rmdir.

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/send.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 95d3718..d908624 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -237,6 +237,7 @@ struct pending_dir_move {
 struct waiting_dir_move {
 	struct rb_node node;
 	u64 ino;
+	u64 gen;
 	/*
 	 * There might be some directory that could not be removed because it
 	 * was waiting for this directory inode to be moved first. Therefore
@@ -2931,6 +2932,7 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen,
 	struct btrfs_key found_key;
 	struct btrfs_key loc;
 	struct btrfs_dir_item *di;
+	u64 gen;
 
 	/*
 	 * Don't try to rmdir the top/root subvolume dir.
@@ -2970,8 +2972,13 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen,
 				struct btrfs_dir_item);
 		btrfs_dir_item_key_to_cpu(path->nodes[0], di, &loc);
 
+		ret = get_inode_info(root, loc.objectid, NULL, &gen, NULL,
+				     NULL, NULL, NULL);
+		if (ret < 0)
+			goto out;
+
 		dm = get_waiting_dir_move(sctx, loc.objectid);
-		if (dm) {
+		if (dm && dm->gen == gen) {
 			struct orphan_dir_info *odi;
 
 			odi = add_orphan_dir_info(sctx, dir);
@@ -3011,7 +3018,7 @@ static int is_waiting_for_move(struct send_ctx *sctx, u64 ino)
 	return entry != NULL;
 }
 
-static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized)
+static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, u64 gen, bool orphanized)
 {
 	struct rb_node **p = &sctx->waiting_dir_moves.rb_node;
 	struct rb_node *parent = NULL;
@@ -3021,6 +3028,7 @@ static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized)
 	if (!dm)
 		return -ENOMEM;
 	dm->ino = ino;
+	dm->gen = gen;
 	dm->rmdir_ino = 0;
 	dm->orphanized = orphanized;
 
@@ -3118,7 +3126,7 @@ static int add_pending_dir_move(struct send_ctx *sctx,
 			goto out;
 	}
 
-	ret = add_waiting_dir_move(sctx, pm->ino, is_orphan);
+	ret = add_waiting_dir_move(sctx, pm->ino, pm->gen, is_orphan);
 	if (ret)
 		goto out;
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/5] Btrfs: incremental send, add gen check in did_overwrite_ref
  2016-10-12  8:12 [PATCH 0/5] Btrfs: incremental send, fix serval case for root and gen robbieko
                   ` (2 preceding siblings ...)
  2016-10-12  8:12 ` [PATCH 3/5] Btrfs: incremental send, add gen in waiting_dir_move for " robbieko
@ 2016-10-12  8:12 ` robbieko
  2016-10-12  9:14   ` Filipe Manana
  2016-10-12  8:12 ` [PATCH 5/5] Btrfs: incremental send, add gen check if has waiting_dir_move in the will_overwrite_ref robbieko
  4 siblings, 1 reply; 11+ messages in thread
From: robbieko @ 2016-10-12  8:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Robbie Ko

From: Robbie Ko <robbieko@synology.com>

There a some case similar as before.
add check parent generation in the did_overwrite_ref.

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/send.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index d908624..e090db2 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1939,6 +1939,19 @@ static int did_overwrite_ref(struct send_ctx *sctx,
 	if (ret <= 0)
 		goto out;
 
+	if (dir != BTRFS_FIRST_FREE_OBJECTID) {
+		ret = get_inode_info(sctx->send_root, dir, NULL, &gen, NULL,
+				     NULL, NULL, NULL);
+		if (ret < 0 && ret != -ENOENT)
+			goto out;
+		if (ret) {
+			ret = 0;
+			goto out;
+		}
+		if (gen != dir_gen)
+			goto out;
+	}
+
 	/* check if the ref was overwritten by another ref */
 	ret = lookup_dir_item_inode(sctx->send_root, dir, name, name_len,
 			&ow_inode, &other_type);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/5] Btrfs: incremental send, add gen check if has waiting_dir_move in the will_overwrite_ref
  2016-10-12  8:12 [PATCH 0/5] Btrfs: incremental send, fix serval case for root and gen robbieko
                   ` (3 preceding siblings ...)
  2016-10-12  8:12 ` [PATCH 4/5] Btrfs: incremental send, add gen check in did_overwrite_ref robbieko
@ 2016-10-12  8:12 ` robbieko
  2016-10-12  9:15   ` Filipe Manana
  4 siblings, 1 reply; 11+ messages in thread
From: robbieko @ 2016-10-12  8:12 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Robbie Ko

From: Robbie Ko <robbieko@synology.com>

There a some case similar as before.
add check generation if has waiting_dir_move in the will_overwrite_ref

Signed-off-by: Robbie Ko <robbieko@synology.com>
---
 fs/btrfs/send.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index e090db2..92b7518 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -1858,6 +1858,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
 	u64 gen;
 	u64 other_inode = 0;
 	u8 other_type = 0;
+	struct waiting_dir_move *dm = NULL;
 
 	if (!sctx->parent_root)
 		goto out;
@@ -1899,11 +1900,15 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
 	 * overwrite anything at this point in time.
 	 */
 	if (other_inode > sctx->send_progress ||
-	    is_waiting_for_move(sctx, other_inode)) {
+		((dm = get_waiting_dir_move(sctx, other_inode)) != NULL)) {
 		ret = get_inode_info(sctx->parent_root, other_inode, NULL,
 				who_gen, NULL, NULL, NULL, NULL);
 		if (ret < 0)
 			goto out;
+		if (dm && dm->gen != *who_gen) {
+			ret = 0;
+			goto out;
+		}
 
 		ret = 1;
 		*who_ino = other_inode;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref
  2016-10-12  8:12 ` [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref robbieko
@ 2016-10-12  9:09   ` Filipe Manana
  0 siblings, 0 replies; 11+ messages in thread
From: Filipe Manana @ 2016-10-12  9:09 UTC (permalink / raw)
  To: robbieko; +Cc: linux-btrfs

On Wed, Oct 12, 2016 at 9:12 AM, robbieko <robbieko@synology.com> wrote:
> From: Robbie Ko <robbieko@synology.com>
>
> When root dir item change, don't skip will_overwrite_ref,
> because root inode always exist.

What do you mean by root dir item change? You mean indoe 256 changed,
how did it change (and how can it change)?

>
> Example:
> Parent snapshot:
> |---- a1/ (ino 257, dir)
> |---- a2/ (ino 258, dir)
>
> Send snapshot:
> |---- a2 (ino 257, file)
>
> ERROR: rename o257-29-0 -> a2 failed: Is a directory
>
> when process 257, first rmdir (ino 257,dir), and then mkfile o257-29-0,
> and rename o257-29-0 -> a2, but now parent snapshot had a2(ino 258,dir),
> we don't ignore it.
>
> therefore is_inode_existent always return 1,
> and will_overwrite_ref don't check gen for root inode.

Please refer to change logs of past send fixes to have an idea on how
to describe and explain the problem (and fix).

Also, can you please start sending xfstests too?
Last batch of send fixes you've sent, I've asked you to do them, but
you totally ignored it and later on I had to do them myself and
rewrite all change logs (and remove some unnecessary code).

Thanks.

>
> Signed-off-by: Robbie Ko <robbieko@synology.com>
> ---
>  fs/btrfs/send.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index a87675f..1862f8a 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -1681,6 +1681,10 @@ static int is_inode_existent(struct send_ctx *sctx, u64 ino, u64 gen)
>  {
>         int ret;
>
> +       if (ino == BTRFS_FIRST_FREE_OBJECTID) {
> +               return 1;
> +       }
> +
>         ret = get_cur_inode_state(sctx, ino, gen);
>         if (ret < 0)
>                 goto out;
> @@ -1866,7 +1870,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
>          * not deleted and then re-created, if it was then we have no overwrite
>          * and we can just unlink this entry.
>          */
> -       if (sctx->parent_root) {
> +       if (sctx->parent_root && dir != BTRFS_FIRST_FREE_OBJECTID) {
>                 ret = get_inode_info(sctx->parent_root, dir, NULL, &gen, NULL,
>                                      NULL, NULL, NULL);
>                 if (ret < 0 && ret != -ENOENT)
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Filipe David Manana,

"People will forget what you said,
 people will forget what you did,
 but people will never forget how you made them feel."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/5] Btrfs: incremental send, add gen for is_waiting_for_rm when some corner case
  2016-10-12  8:12 ` [PATCH 2/5] Btrfs: incremental send, add gen for is_waiting_for_rm when some corner case robbieko
@ 2016-10-12  9:11   ` Filipe Manana
  0 siblings, 0 replies; 11+ messages in thread
From: Filipe Manana @ 2016-10-12  9:11 UTC (permalink / raw)
  To: robbieko; +Cc: linux-btrfs

On Wed, Oct 12, 2016 at 9:12 AM, robbieko <robbieko@synology.com> wrote:
> From: Robbie Ko <robbieko@synology.com>
>
> There a one case for old_gen waiting_for_rm,
> but new_gen use get_cur_path with the same inode.
>
> Example:
>     Parent snapshot:
>     |---- dir258/ (ino 258, dir)
>         |--- dir257/ (ino 257, dir)
>     |---- dir259/ (ino 259, dir)
>
>     Send snapshot:
>     |---- file258 (ino 258, file)
>     |---- new_dir259/ (ino 259, dir)
>         |--- dir257/ (ino 257, dir)
>
> utimes
> mkdir o259-21-0
> rename dir258 -> o258-15-0
> utimes
> mkfile o258-21-0
> rename o258-21-0 -> file258
> utimes
> truncate o258-21-0 size=0
> ERROR: truncate o258-21-0 failed: No such file or directory
>
> dir258 will be delete, but dir257 is waiting for move,
> so dir258 is waiting for rm, and then file258 be create,
> and rename it, and then need to truncate it, so use get_cur_path
> to get path, but is_waiting_for_rm olny check ino, dosen't check gen,
> match dir258 is waiting for rm, so get error path o258-21-0.
>
> therefore, add gen check in is_waiting_for_rm.

Same comments as for patch 1.

Can you please start sending xfstests too?
Last batch of send fixes you've sent, I've asked you to do them, but
you totally ignored it and later on I had to do them myself and
rewrite all change logs (and remove some unnecessary code).

Thanks.
>
> Signed-off-by: Robbie Ko <robbieko@synology.com>
> ---
>  fs/btrfs/send.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 1862f8a..95d3718 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -311,7 +311,7 @@ static int is_waiting_for_move(struct send_ctx *sctx, u64 ino);
>  static struct waiting_dir_move *
>  get_waiting_dir_move(struct send_ctx *sctx, u64 ino);
>
> -static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino);
> +static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino, u64 dir_gen);
>
>  static int need_send_hole(struct send_ctx *sctx)
>  {
> @@ -2293,7 +2293,7 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen,
>
>                 fs_path_reset(name);
>
> -               if (is_waiting_for_rm(sctx, ino)) {
> +               if (is_waiting_for_rm(sctx, ino, gen)) {
>                         ret = gen_unique_name(sctx, ino, gen, name);
>                         if (ret < 0)
>                                 goto out;
> @@ -2900,11 +2900,11 @@ get_orphan_dir_info(struct send_ctx *sctx, u64 dir_ino)
>         return NULL;
>  }
>
> -static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino)
> +static int is_waiting_for_rm(struct send_ctx *sctx, u64 dir_ino, u64 dir_gen)
>  {
>         struct orphan_dir_info *odi = get_orphan_dir_info(sctx, dir_ino);
>
> -       return odi != NULL;
> +       return (odi != NULL && odi->gen == dir_gen);
>  }
>
>  static void free_orphan_dir_info(struct send_ctx *sctx,
> @@ -3167,7 +3167,7 @@ static int path_loop(struct send_ctx *sctx, struct fs_path *name,
>         while (ino != BTRFS_FIRST_FREE_OBJECTID) {
>                 fs_path_reset(name);
>
> -               if (is_waiting_for_rm(sctx, ino))
> +               if (is_waiting_for_rm(sctx, ino, gen))
>                         break;
>                 if (is_waiting_for_move(sctx, ino)) {
>                         if (*ancestor_ino == 0)
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Filipe David Manana,

"People will forget what you said,
 people will forget what you did,
 but people will never forget how you made them feel."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/5] Btrfs: incremental send, add gen in waiting_dir_move for some corner case
  2016-10-12  8:12 ` [PATCH 3/5] Btrfs: incremental send, add gen in waiting_dir_move for " robbieko
@ 2016-10-12  9:13   ` Filipe Manana
  0 siblings, 0 replies; 11+ messages in thread
From: Filipe Manana @ 2016-10-12  9:13 UTC (permalink / raw)
  To: robbieko; +Cc: linux-btrfs

On Wed, Oct 12, 2016 at 9:12 AM, robbieko <robbieko@synology.com> wrote:
> From: Robbie Ko <robbieko@synology.com>
>
> There a some case similar as before.

As before what?
Each change log should be complete and the reader is not supposed to
guess what's the previous patch or commit this is referring to.
Imagine yourself or someone else reading the change log some time
after this is committed to a git tree. How does he/she figures out
what is "before", what commit or patch is it?

> add compare generation with dir items,
> and waiting_dir_move in the can_rmdir.

Please add some explanation of the problem and the fix.

Also, can you please start sending xfstests too?
Last batch of send fixes you've sent, I've asked you to do them, but
you totally ignored it and later on I had to do them myself and
rewrite all change logs (and remove some unnecessary code).

Thanks.

>
> Signed-off-by: Robbie Ko <robbieko@synology.com>
> ---
>  fs/btrfs/send.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index 95d3718..d908624 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -237,6 +237,7 @@ struct pending_dir_move {
>  struct waiting_dir_move {
>         struct rb_node node;
>         u64 ino;
> +       u64 gen;
>         /*
>          * There might be some directory that could not be removed because it
>          * was waiting for this directory inode to be moved first. Therefore
> @@ -2931,6 +2932,7 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen,
>         struct btrfs_key found_key;
>         struct btrfs_key loc;
>         struct btrfs_dir_item *di;
> +       u64 gen;
>
>         /*
>          * Don't try to rmdir the top/root subvolume dir.
> @@ -2970,8 +2972,13 @@ static int can_rmdir(struct send_ctx *sctx, u64 dir, u64 dir_gen,
>                                 struct btrfs_dir_item);
>                 btrfs_dir_item_key_to_cpu(path->nodes[0], di, &loc);
>
> +               ret = get_inode_info(root, loc.objectid, NULL, &gen, NULL,
> +                                    NULL, NULL, NULL);
> +               if (ret < 0)
> +                       goto out;
> +
>                 dm = get_waiting_dir_move(sctx, loc.objectid);
> -               if (dm) {
> +               if (dm && dm->gen == gen) {
>                         struct orphan_dir_info *odi;
>
>                         odi = add_orphan_dir_info(sctx, dir);
> @@ -3011,7 +3018,7 @@ static int is_waiting_for_move(struct send_ctx *sctx, u64 ino)
>         return entry != NULL;
>  }
>
> -static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized)
> +static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, u64 gen, bool orphanized)
>  {
>         struct rb_node **p = &sctx->waiting_dir_moves.rb_node;
>         struct rb_node *parent = NULL;
> @@ -3021,6 +3028,7 @@ static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino, bool orphanized)
>         if (!dm)
>                 return -ENOMEM;
>         dm->ino = ino;
> +       dm->gen = gen;
>         dm->rmdir_ino = 0;
>         dm->orphanized = orphanized;
>
> @@ -3118,7 +3126,7 @@ static int add_pending_dir_move(struct send_ctx *sctx,
>                         goto out;
>         }
>
> -       ret = add_waiting_dir_move(sctx, pm->ino, is_orphan);
> +       ret = add_waiting_dir_move(sctx, pm->ino, pm->gen, is_orphan);
>         if (ret)
>                 goto out;
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Filipe David Manana,

"People will forget what you said,
 people will forget what you did,
 but people will never forget how you made them feel."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/5] Btrfs: incremental send, add gen check in did_overwrite_ref
  2016-10-12  8:12 ` [PATCH 4/5] Btrfs: incremental send, add gen check in did_overwrite_ref robbieko
@ 2016-10-12  9:14   ` Filipe Manana
  0 siblings, 0 replies; 11+ messages in thread
From: Filipe Manana @ 2016-10-12  9:14 UTC (permalink / raw)
  To: robbieko; +Cc: linux-btrfs

On Wed, Oct 12, 2016 at 9:12 AM, robbieko <robbieko@synology.com> wrote:
> From: Robbie Ko <robbieko@synology.com>
>
> There a some case similar as before.

As before what?
Each change log should be complete and the reader is not supposed to
guess what's the previous patch or commit this is referring to.
Imagine yourself or someone else reading the change log some time
after this is committed to a git tree. How does he/she figures out
what is "before", what commit or patch is it?

> add check parent generation in the did_overwrite_ref.

Please add some explanation of what problem is being fixed and how.
This change log has absolutely no value.

Also, can you please start sending xfstests too?
Last batch of send fixes you've sent, I've asked you to do them, but
you totally ignored it and later on I had to do them myself and
rewrite all change logs (and remove some unnecessary code).

Thanks.

>
> Signed-off-by: Robbie Ko <robbieko@synology.com>
> ---
>  fs/btrfs/send.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index d908624..e090db2 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -1939,6 +1939,19 @@ static int did_overwrite_ref(struct send_ctx *sctx,
>         if (ret <= 0)
>                 goto out;
>
> +       if (dir != BTRFS_FIRST_FREE_OBJECTID) {
> +               ret = get_inode_info(sctx->send_root, dir, NULL, &gen, NULL,
> +                                    NULL, NULL, NULL);
> +               if (ret < 0 && ret != -ENOENT)
> +                       goto out;
> +               if (ret) {
> +                       ret = 0;
> +                       goto out;
> +               }
> +               if (gen != dir_gen)
> +                       goto out;
> +       }
> +
>         /* check if the ref was overwritten by another ref */
>         ret = lookup_dir_item_inode(sctx->send_root, dir, name, name_len,
>                         &ow_inode, &other_type);
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Filipe David Manana,

"People will forget what you said,
 people will forget what you did,
 but people will never forget how you made them feel."

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 5/5] Btrfs: incremental send, add gen check if has waiting_dir_move in the will_overwrite_ref
  2016-10-12  8:12 ` [PATCH 5/5] Btrfs: incremental send, add gen check if has waiting_dir_move in the will_overwrite_ref robbieko
@ 2016-10-12  9:15   ` Filipe Manana
  0 siblings, 0 replies; 11+ messages in thread
From: Filipe Manana @ 2016-10-12  9:15 UTC (permalink / raw)
  To: robbieko; +Cc: linux-btrfs

On Wed, Oct 12, 2016 at 9:12 AM, robbieko <robbieko@synology.com> wrote:
> From: Robbie Ko <robbieko@synology.com>
>
> There a some case similar as before.

As before what?
Each change log should be complete and the reader is not supposed to
guess what's the previous patch or commit this is referring to.
Imagine yourself or someone else reading the change log some time
after this is committed to a git tree. How does he/she figures out
what is "before", what commit or patch is it?

> add check generation if has waiting_dir_move in the will_overwrite_ref

Please add some explanation of what problem is being fixed and how.
This change log has absolutely no value.

Also, can you please start sending xfstests too?
Last batch of send fixes you've sent, I've asked you to do them, but
you totally ignored it and later on I had to do them myself and
rewrite all change logs (and remove some unnecessary code).

Thanks.

>
> Signed-off-by: Robbie Ko <robbieko@synology.com>
> ---
>  fs/btrfs/send.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
> index e090db2..92b7518 100644
> --- a/fs/btrfs/send.c
> +++ b/fs/btrfs/send.c
> @@ -1858,6 +1858,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
>         u64 gen;
>         u64 other_inode = 0;
>         u8 other_type = 0;
> +       struct waiting_dir_move *dm = NULL;
>
>         if (!sctx->parent_root)
>                 goto out;
> @@ -1899,11 +1900,15 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
>          * overwrite anything at this point in time.
>          */
>         if (other_inode > sctx->send_progress ||
> -           is_waiting_for_move(sctx, other_inode)) {
> +               ((dm = get_waiting_dir_move(sctx, other_inode)) != NULL)) {
>                 ret = get_inode_info(sctx->parent_root, other_inode, NULL,
>                                 who_gen, NULL, NULL, NULL, NULL);
>                 if (ret < 0)
>                         goto out;
> +               if (dm && dm->gen != *who_gen) {
> +                       ret = 0;
> +                       goto out;
> +               }
>
>                 ret = 1;
>                 *who_ino = other_inode;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Filipe David Manana,

"People will forget what you said,
 people will forget what you did,
 but people will never forget how you made them feel."

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-10-12 11:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-12  8:12 [PATCH 0/5] Btrfs: incremental send, fix serval case for root and gen robbieko
2016-10-12  8:12 ` [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref robbieko
2016-10-12  9:09   ` Filipe Manana
2016-10-12  8:12 ` [PATCH 2/5] Btrfs: incremental send, add gen for is_waiting_for_rm when some corner case robbieko
2016-10-12  9:11   ` Filipe Manana
2016-10-12  8:12 ` [PATCH 3/5] Btrfs: incremental send, add gen in waiting_dir_move for " robbieko
2016-10-12  9:13   ` Filipe Manana
2016-10-12  8:12 ` [PATCH 4/5] Btrfs: incremental send, add gen check in did_overwrite_ref robbieko
2016-10-12  9:14   ` Filipe Manana
2016-10-12  8:12 ` [PATCH 5/5] Btrfs: incremental send, add gen check if has waiting_dir_move in the will_overwrite_ref robbieko
2016-10-12  9:15   ` Filipe Manana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.