All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: john terragon <jterragon@gmail.com>
Cc: Andrei Borzenkov <arvidjaar@gmail.com>,
	sys <system@lechevalier.se>,
	Btrfs BTRFS <linux-btrfs@vger.kernel.org>
Subject: Re: hierarchical, tree-like structure of snapshots
Date: Thu, 31 Dec 2020 16:36:50 -0500	[thread overview]
Message-ID: <20201231213650.GT31381@hungrycats.org> (raw)
In-Reply-To: <CANg_oxztFRbw+NqHbnvvK6HS3g67hDkSgk6TpMbd-zgYSv9URw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4922 bytes --]

On Thu, Dec 31, 2020 at 09:48:54PM +0100, john terragon wrote:
> On Thu, Dec 31, 2020 at 8:42 PM Andrei Borzenkov <arvidjaar@gmail.com> wrote:
> >
> 
> >
> > How exactly you create subvolume with the same content? There are many
> > possible interpretations.
> >
> 
> Zygo wrote that any subvol could be used with -p. So, out of
> curiosity, I did the following
> 
> 1) btrfs sub create X
> 2) I unpacked some source (linux kernel) in X
> 3) btrfs sub create W
> 4) I unpacked the same source in W (so X and W have the same content
> but they are independent)
> 5) btrfs sub snap -r X X_RO
> 6) btrfs sub snap -r W W_RO
> 7) btrfs send W_RO | btrfs receive /mnt/btrfs2
> 8) btrfs send -p W_RO X_RO | btrfs receive /mnt/btrfs2
> 
> And this is the exact output of 8)
> 
> At subvol X_RO
> At snapshot X_RO
> ERROR: chown o257-1648413-0 failed: No such file or directory

Yeah, I only checked that send completed without error and produced a
smaller stream.

I just dumped the send metadata stream from the incremental snapshot now,
and it's more or less garbage at the start:

	# btrfs sub create A
	# btrfs sub create B
	# date > A/date
	# date > B/date
	# mkdir A/t B/u
	# btrfs sub snap -r A A_RO
	# btrfs sub snap -r B B_RO
	# btrfs send A_RO | btrfs receive --dump
	At subvol A_RO
	subvol          ./A_RO                          uuid=995adde4-00ac-5e49-8c6f-f01743def072 transid=7329268
	chown           ./A_RO/                         gid=0 uid=0
	chmod           ./A_RO/                         mode=755
	utimes          ./A_RO/                         atime=2020-12-31T15:51:31-0500 mtime=2020-12-31T15:51:48-0500 ctime=2020-12-31T15:51:48-0500
	mkfile          ./A_RO/o257-7329268-0
	rename          ./A_RO/o257-7329268-0           dest=./A_RO/date
	utimes          ./A_RO/                         atime=2020-12-31T15:51:31-0500 mtime=2020-12-31T15:51:48-0500 ctime=2020-12-31T15:51:48-0500
	write           ./A_RO/date                     offset=0 len=29
	chown           ./A_RO/date                     gid=0 uid=0
	chmod           ./A_RO/date                     mode=644
	utimes          ./A_RO/date                     atime=2020-12-31T15:51:38-0500 mtime=2020-12-31T15:51:38-0500 ctime=2020-12-31T15:51:38-0500
	mkdir           ./A_RO/o258-7329268-0
	rename          ./A_RO/o258-7329268-0           dest=./A_RO/t
	utimes          ./A_RO/                         atime=2020-12-31T15:51:31-0500 mtime=2020-12-31T15:51:48-0500 ctime=2020-12-31T15:51:48-0500
	chown           ./A_RO/t                        gid=0 uid=0
	chmod           ./A_RO/t                        mode=755
	utimes          ./A_RO/t                        atime=2020-12-31T15:51:48-0500 mtime=2020-12-31T15:51:48-0500 ctime=2020-12-31T15:51:48-0500
	# btrfs send B_RO -p A_RO | btrfs receive --dump
	At subvol B_RO
	snapshot        ./B_RO                          uuid=4aa7db26-b219-694e-9b3c-f8f737a46bdb transid=7329268 parent_uuid=995adde4-00ac-5e49-8c6f-f01743def072 parent_transid=7329268
	utimes          ./B_RO/                         atime=2020-12-31T15:51:33-0500 mtime=2020-12-31T15:51:52-0500 ctime=2020-12-31T15:51:52-0500
	link            ./B_RO/date                     dest=date
	unlink          ./B_RO/date
	utimes          ./B_RO/                         atime=2020-12-31T15:51:33-0500 mtime=2020-12-31T15:51:52-0500 ctime=2020-12-31T15:51:52-0500
	write           ./B_RO/date                     offset=0 len=29
	utimes          ./B_RO/date                     atime=2020-12-31T15:51:41-0500 mtime=2020-12-31T15:51:41-0500 ctime=2020-12-31T15:51:41-0500
	rename          ./B_RO/t                        dest=./B_RO/u
	utimes          ./B_RO/                         atime=2020-12-31T15:51:33-0500 mtime=2020-12-31T15:51:52-0500 ctime=2020-12-31T15:51:52-0500
	utimes          ./B_RO/u                        atime=2020-12-31T15:51:52-0500 mtime=2020-12-31T15:51:52-0500 ctime=2020-12-31T15:51:52-0500
	# btrfs send A_RO | btrfs receive -v /tmp/test
	At subvol A_RO
	At subvol A_RO
	receiving subvol A_RO uuid=995adde4-00ac-5e49-8c6f-f01743def072, stransid=7329268
	write date - offset=0 length=29
	BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=995adde4-00ac-5e49-8c6f-f01743def072, stransid=7329268
	# btrfs send B_RO -p A_RO | btrfs receive -v /tmp/test
	At subvol B_RO
	At snapshot B_RO
	receiving snapshot B_RO uuid=4aa7db26-b219-694e-9b3c-f8f737a46bdb, ctransid=7329268 parent_uuid=995adde4-00ac-5e49-8c6f-f01743def072, parent_ctransid=7329268
	ERROR: link date -> date failed: File exists

The btrfs_compare_trees function can handle arbitrary tree differences,
but something happens in one of the support functions and we get a
bogus link command.  The rest of the stream is OK though:  we fill
in the contents of B_RO/date, rename A_RO/t to B_RO/u, and update all
the timestamps.

Oh well, I didn't say send didn't have any bugs.  ;)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2020-12-31 21:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-30 16:56 hierarchical, tree-like structure of snapshots john terragon
2020-12-30 17:03 ` john terragon
2020-12-30 17:24 ` sys
2020-12-30 17:39   ` john terragon
2020-12-31  7:05     ` Andrei Borzenkov
2020-12-31 10:00       ` Forza
2020-12-31 16:08       ` john terragon
2020-12-31 17:28         ` Zygo Blaxell
2020-12-31 18:19           ` john terragon
2020-12-31 19:42             ` Andrei Borzenkov
2020-12-31 20:48               ` john terragon
2020-12-31 21:36                 ` Zygo Blaxell [this message]
2021-01-01  4:54                   ` john terragon
2021-01-01 11:42                   ` Andrei Borzenkov
2021-01-01 20:40                     ` Andrei Borzenkov
2021-01-01 23:11                       ` Zygo Blaxell
2021-01-02  9:25                         ` Andrei Borzenkov

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=20201231213650.GT31381@hungrycats.org \
    --to=ce3g8jdj@umail.furryterror.org \
    --cc=arvidjaar@gmail.com \
    --cc=jterragon@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=system@lechevalier.se \
    /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 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.