We log warning if root::orphan_cleanup_state is not set to ORPHAN_CLEANUP_DONE in btrfs_ioctl_send(). However if the filesystem is mounted as readonly we skip the orphan items cleanup during the lookup and root::orphan_cleanup_state remains at the init state 0 instead of ORPHAN_CLEANUP_DONE (2). WARNING: CPU: 0 PID: 2616 at /Volumes/ws/btrfs-devel/fs/btrfs/send.c:7090 btrfs_ioctl_send+0xb2f/0x18c0 [btrfs] :: RIP: 0010:btrfs_ioctl_send+0xb2f/0x18c0 [btrfs] :: Call Trace: :: _btrfs_ioctl_send+0x7b/0x110 [btrfs] btrfs_ioctl+0x150a/0x2b00 [btrfs] :: do_vfs_ioctl+0xa9/0x620 ? __fget+0xac/0xe0 ksys_ioctl+0x60/0x90 __x64_sys_ioctl+0x16/0x20 do_syscall_64+0x49/0x130 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Reproducer: mkfs.btrfs -fq /dev/sdb && mount /dev/sdb /btrfs btrfs subvolume create /btrfs/sv1 btrfs subvolume snapshot -r /btrfs/sv1 /btrfs/ss1 umount /btrfs && mount -o ro /dev/sdb /btrfs btrfs send /btrfs/ss1 -f /tmp/f Fix this by removing the warn_on completely because: 1) Having orphan items means we could have files to delete (link count of 0) and dealing with such cases could make send fail for several reasons. If this happens, it's not longer a problem since the following commit: 46b2f4590aab71d31088a265c86026b1e96c9de4 Btrfs: fix send failure when root has deleted files still open 2) Orphan items used to indicate previously unfinished truncations, in which case it would lead to send creating corrupt files at the destination (i_size incorrect and the file filled with zeroes between real i_size and stale i_size). We no longer need to create orphans for truncations since commit: f7e9e8fc792fe2f823ff7d64d23f4363b3f2203a Btrfs: stop creating orphan items for truncate Reported-by: Christoph Anton Mitterer <calestyo@xxxxxxxxxxxx> Suggested-by: Filipe Manana <fdmanana@xxxxxxxxx> Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx> --- v2: Remove WARN_ON() completely. fs/btrfs/send.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index ae2db5eb1549..091e5bc8c7ea 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -7084,12 +7084,6 @@ long btrfs_ioctl_send(struct file *mnt_file, struct btrfs_ioctl_send_args *arg) spin_unlock(&send_root->root_item_lock); /* - * This is done when we lookup the root, it should already be complete - * by the time we get here. - */ - WARN_ON(send_root->orphan_cleanup_state != ORPHAN_CLEANUP_DONE); - - /* * Userspace tools do the checks and warn the user if it's * not RO. */ -- 1.8.3.1
