I have 2 partitions and sometimes I synchronize subvolumes between them. Last time synchronization happened within 15minutes window after 2017-04-04 14:30:06 (my local time) and was successful without any issues. Now I'm trying to sync subvolumes once again and getting errors: root@nazar-pc:~# /bin/btrfs send -p "/media/Backup/web/2017-04-04_06:20:52" "/media/Backup/web/2017-04-04_14:30:06" | /bin/btrfs receive "/media/Backup_backup/web" At subvol /media/Backup/web/2017-04-04_14:30:06 At snapshot 2017-04-04_14:30:06 ERROR: empty stream is not considered valid root@nazar-pc:~# /bin/btrfs subvolume delete "/media/Backup_backup/web/2017-04-04_14:30:06" Delete subvolume (no-commit): '/media/Backup_backup/web/2017-04-04_14:30:06' root@nazar-pc:~# /bin/btrfs send "/media/Backup/web/2017-04-04_14:30:06" | /bin/btrfs receive "/media/Backup_backup/web" At subvol /media/Backup/web/2017-04-04_14:30:06 At subvol 2017-04-04_14:30:06 ERROR: empty stream is not considered valid I've compared two snapshots (one that existed after previous synchronization and new manually copied) with `diff -qr '/media/Backup_backup/web/2017-04-04_09:15:17' '/media/Backup_backup/web/2017-04-04_14:30:06'` and it appears to be sent fine, so looks like false-positive error. I'm keeping filesystems as is so that I can do more tests as requested. btrfs-progs at the moment of previous sync was Ubuntu's package with version 4.9.1-1, current version is Ubuntu's package with version 4.9.1-1ubuntu1. Changelog between these 2 versions is following: * Fix btrfs send/receive: - 0001-btrfs-progs-fix-btrfs-send-receive-with-e-flag.patch - 0002-tests-use-receive-e-to-terminate-on-end-marker.patch
Comparing above patch https://patchwork.kernel.org/patch/9643035/ with latest btrfs-progs https://github.com/kdave/btrfs-progs/blob/master/cmds-receive.c#L1205 Seems like above patch not yet accepted into btrfs-progs? I can see below code is missing on btrfs-progs master branch. > + if (ret < 0 && ret == -ENODATA) { > + /* Empty stream is invalid */ > error("empty stream is not considered valid"); > ret = -EINVAL; > goto out; > + } else if (ret < 0) { > + goto out; Can you try with latest btrfs-progs from https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git and see whether you have still this issue?
I've just compiled master branch (commit bd0ab27afbf14370f9f0da1f5f5ecbb0adc654c1) and it works fine: root@nazar-pc:~# /media/Data/btrfs-progs-master/btrfs send -p "/media/Backup/web/2017-04-04_06:20:52" "/media/Backup/web/2017-04-04_14:30:06" | /media/Data/btrfs-progs-master/btrfs receive "/media/Backup_backup/web" At subvol /media/Backup/web/2017-04-04_14:30:06 At snapshot 2017-04-04_14:30:06 root@nazar-pc:~# /media/Data/btrfs-progs-master/btrfs --version btrfs-progs v4.10.2 Apparently it wasn't merged yet. However it is already in Ubuntu's repositories, so if that patch was indeed needed, it should be corrected. Additional info: My setup consists of primary SSD where I do regular snapshots, these snapshots are immediately sent to online HDD and then from time to time to the offline HDD. This bug describes sending snapshots from the online HDD to the offline HDD, however, sending snapshots from SSD to the online HDD works fine. There might be some more tricks happening, I'm still keeping affected partition to test possible fix in future. Here is an exact patch applied to latest version of Ubuntu's package: https://launchpadlibrarian.net/314579804/btrfs-progs_4.9.1-1_4.9.1-1ubuntu1.diff.gz
(In reply to Nazar Mokrynskyi from comment #2) > I've just compiled master branch (commit > bd0ab27afbf14370f9f0da1f5f5ecbb0adc654c1) and it works fine: > root@nazar-pc:~# /media/Data/btrfs-progs-master/btrfs send -p > "/media/Backup/web/2017-04-04_06:20:52" > "/media/Backup/web/2017-04-04_14:30:06" | > /media/Data/btrfs-progs-master/btrfs receive "/media/Backup_backup/web" > At subvol /media/Backup/web/2017-04-04_14:30:06 > At snapshot 2017-04-04_14:30:06 > root@nazar-pc:~# /media/Data/btrfs-progs-master/btrfs --version > btrfs-progs v4.10.2 > > Apparently it wasn't merged yet. However it is already in Ubuntu's > repositories, so if that patch was indeed needed, it should be corrected. I shared this bug with patch dev, hopefully he will look into it.
I'm sorry for confusion, the same error indeed happens in all cases. Regular backups are happening in cron task so I haven't seen the output, but snapshots look fine.
thanks for the details.Yes, received your email on mailing list too.
I've sent a patch to the btrfs mailing list that tries to address this problem. My tests show that this should work. Please test, if possible. Patch: https://mail-archive.com/linux-btrfs@vger.kernel.org/msg63609.html
I've applied latest patch on top of previous patch on top of mentioned upstream 4.10.2 (commit bd0ab27afbf14370f9f0da1f5f5ecbb0adc654c1) and the issue is gone now, thanks!
Created attachment 256157 [details] btrfs-progs: send: fail on first -ENODATA only
I think this bug can be marked as 'fixed'. Nazar, can change the state? (I don't see options for that)
Sure
Thank you all, patch merged and scheduled for 4.11 release.