There's one case where we attempt to rmdir a directory prematurely.
Example:
Parent snapshot:
|---- a/ (ino 279)
|---- c (ino 282)
|---- del/ (ino 281)
|---- tmp/ (ino 280)
|---- long/ (ino 283)
Send snapshot:
|---- a/ (ino 279)
|---- long (ino 283)
|---- c/ (ino 282)
|---- tmp/ (ino 280)
While process inode 281, since inode 280 is waiting for inode 282,
rmdir_ino of struct waitng_dir_move for inode 280 will assigned to 281
and an orphan_dir_info will be created for node 281 in can_rmdir().
Such that, when process inode 282, we will do following steps.
First, move inode 282 from a/c to c
Second, move inode 280 from del/tmp to c/tmp
Third, try to remove inode 281
In Third step, we pass 283 (sctx->cur_ino + 1) as the send_progress to the
can_rmdir() function and that makes it return true when it shouldn't,
because the inode 283 wasn't processed yet and it's still a child of
the directory with inode number 281, which makes the receiver run into
an ENOTEMPTY error when attempting to remove the directory.
Signed-off-by: Robbie Ko <robbieko@xxxxxxxxxxxx>
---
V2:modify comment
fs/btrfs/send.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index bc9efbe..cd22f7d 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -3213,7 +3213,7 @@ static int apply_dir_move(struct send_ctx *sctx, struct pending_dir_move *pm)
/* already deleted */
goto finish;
}
- ret = can_rmdir(sctx, rmdir_ino, odi->gen, sctx->cur_ino + 1);
+ ret = can_rmdir(sctx, rmdir_ino, odi->gen, sctx->cur_ino);
if (ret < 0)
goto out;
if (!ret)
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in