Although I'm glad that a bug has been uncovered, maybe it's best if I
stick with good old rsync for backups.
It would be kind of ironic if the first data loss that I experienced
in many years of btrfs use would be caused by an ancillary backup
tool.

On Thu, Dec 31, 2020 at 10:36 PM Zygo Blaxell
<[email protected]> wrote:
>
> On Thu, Dec 31, 2020 at 09:48:54PM +0100, john terragon wrote:
> > On Thu, Dec 31, 2020 at 8:42 PM Andrei Borzenkov <[email protected]> 
> > 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.  ;)

Reply via email to