From: robbieko <robbieko@synology.com>
To: linux-btrfs@vger.kernel.org
Cc: Robbie Ko <robbieko@synology.com>
Subject: [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref
Date: Wed, 12 Oct 2016 16:12:46 +0800 [thread overview]
Message-ID: <1476259970-1866-2-git-send-email-robbieko@synology.com> (raw)
In-Reply-To: <1476259970-1866-1-git-send-email-robbieko@synology.com>
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
next prev parent reply other threads:[~2016-10-12 8:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2016-10-12 9:09 ` [PATCH 1/5] Btrfs: incremental send, fix don't skip root inode in overwrite_ref 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476259970-1866-2-git-send-email-robbieko@synology.com \
--to=robbieko@synology.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).