]> git.openfabrics.org - ~emulex/infiniband.git/commit
Btrfs: race free update of commit root for ro snapshots
authorFilipe Manana <fdmanana@suse.com>
Thu, 31 Jul 2014 13:41:07 +0000 (14:41 +0100)
committerChris Mason <clm@fb.com>
Thu, 21 Aug 2014 14:55:21 +0000 (07:55 -0700)
commit9c3b306e1c9e6be4be09e99a8fe2227d1005effc
tree3959abb99f9d14ae1ab26c0c2735e56504e5939b
parent87fa3bb0786f37dff0b92f2c38421dd56d8902a9
Btrfs: race free update of commit root for ro snapshots

This is a better solution for the problem addressed in the following
commit:

    Btrfs: update commit root on snapshot creation after orphan cleanup
    (3821f348889e506efbd268cc8149e0ebfa47c4e5)

The previous solution wasn't the best because of 2 reasons:

    1) It added another full transaction commit, which is more expensive
       than just swapping the commit root with the root;

    2) If a reboot happened after the first transaction commit (the one
       that creates the snapshot) and before the second transaction commit,
       then we would end up with the same problem if a send using that
       snapshot was requested before the first transaction commit after
       the reboot.

This change addresses those 2 issues. The second issue is addressed by
switching the commit root in the dentry lookup VFS callback, which is
also called by the snapshot/subvol creation ioctl and performs orphan
cleanup if needed. Like the vfs, the ioctl locks the parent inode too,
preventing race issues between a dentry lookup and snapshot creation.

Cc: Alex Lyakas <alex.btrfs@zadarastorage.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/inode.c
fs/btrfs/ioctl.c