Btrfs: fix protection between send and root deletion
authorWang Shilong <wangsl.fnst@cn.fujitsu.com>
Tue, 7 Jan 2014 09:25:19 +0000 (17:25 +0800)
committerChris Mason <clm@fb.com>
Tue, 28 Jan 2014 21:20:21 +0000 (13:20 -0800)
commit18f687d538449373c37cbe52b03f5f3d42b7c7ed
treeda340e3522b0e22516af99a7f3cb44d96cfdd6cf
parent896c14f97f700aec6565154f2451605d7c5ce3ed
Btrfs: fix protection between send and root deletion

We should gurantee that parent and clone roots can not be destroyed
during send, for this we have two ideas.

1.by holding @subvol_sem, this might be a nightmare, because it will
block all subvolumes deletion for a long time.

2.Miao pointed out we can reuse @send_in_progress, that mean we will
skip snapshot deletion if root sending is in progress.

Here we adopt the second approach since it won't block other subvolumes
deletion for a long time.

Besides in btrfs_clean_one_deleted_snapshot(), we only check first root
, if this root is involved in send, we return directly rather than
continue to check.There are several reasons about it:

1.this case happen seldomly.
2.after sending,cleaner thread can continue to drop that root.
3.make code simple

Cc: David Sterba <dsterba@suse.cz>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/send.c
fs/btrfs/transaction.c