btrfs: enumerate the type of exclusive operation in progress
authorGoldwyn Rodrigues <rgoldwyn@suse.com>
Tue, 25 Aug 2020 15:02:32 +0000 (10:02 -0500)
committerDavid Sterba <dsterba@suse.com>
Wed, 7 Oct 2020 10:12:20 +0000 (12:12 +0200)
commitc3e1f96c37d0f863ac6ddcafac6921fd46f1aa37
tree31eac90a96b5e8924f5eca20c8fa442185782dd7
parentca10845a56856fff4de3804c85e6424d0f6d0cde
btrfs: enumerate the type of exclusive operation in progress

Instead of using a flag bit for exclusive operation, use a variable to
store which exclusive operation is being performed.  Introduce an API
to start and finish an exclusive operation.

This would enable another way for tools to check which operation is
running on why starting an exclusive operation failed. The followup
patch adds a sysfs_notify() to alert userspace when the state changes, so
userspace can perform select() on it to get notified of the change.

This would enable us to enqueue a command which will wait for current
exclusive operation to complete before issuing the next exclusive
operation. This has been done synchronously as opposed to a background
process, or else error collection (if any) will become difficult.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update comments ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/dev-replace.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/volumes.c