Re: [PATCH 1/2] btrfs: enumerate the type of exclusive operation in progress

David Sterba
2020-09-02T15:41:46Z

On Tue, Aug 25, 2020 at 10:02:32AM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>
> Instead of using a flag bit for exclusive operation, use an atomic_t
> variable to store if the exclusive operation is being performed.
> Introduce an API to start and finish an exclusive operation.

I think we don't need it to be atomic_t, the change must be atomic but
for that cmpxchg should be sufficient.

> +enum btrfs_exclusive_operation_t {
> + BTRFS_EXCLOP_NONE = 0,
> + BTRFS_EXCLOP_BALANCE,
> + BTRFS_EXCLOP_DEV_ADD,
> + BTRFS_EXCLOP_DEV_REPLACE,
> + BTRFS_EXCLOP_DEV_REMOVE,
> + BTRFS_EXCLOP_SWAP_ACTIVATE,
> + BTRFS_EXCLOP_RESIZE,

Yeah this is much better than the single bit.