mbox series

[v3,0/2] btrfs: Enumerate and export exclusive operations

Message ID 20200825150233.30294-1-rgoldwyn@suse.de (mailing list archive)
Headers show
Series btrfs: Enumerate and export exclusive operations | expand

Message

Goldwyn Rodrigues Aug. 25, 2020, 3:02 p.m. UTC
This patch series enumerates the exlcusive operation currently being
perfomed by the current filesystem and exports it in the sys filesytem
at /sys/fs/btrfs/<fsid>/exclusive_operation.

This would enable our tools to specify precisely which operation is
running on why starting an exclusive operation failed. The series also
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 a nightmare.

For backward compatibility, the tools continue working as before if the
sys file is not present.

Changes since v1:
 - Corrected call for btrfs_start_exop() in btrfs_ioctl_dev_replace()
 - Use fsid_str[] instead of fsid[] to save on uuid_parse()

Changes since v2:
 - Dropped patch to add additional balance information
 - modified (simplified) progs patches accordingly

Comments

David Sterba Sept. 2, 2020, 8:11 p.m. UTC | #1
On Tue, Aug 25, 2020 at 10:02:31AM -0500, Goldwyn Rodrigues wrote:
> This patch series enumerates the exlcusive operation currently being
> perfomed by the current filesystem and exports it in the sys filesytem
> at /sys/fs/btrfs/<fsid>/exclusive_operation.
> 
> This would enable our tools to specify precisely which operation is
> running on why starting an exclusive operation failed. The series also
> 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 a nightmare.
> 
> For backward compatibility, the tools continue working as before if the
> sys file is not present.
> 
> Changes since v1:
>  - Corrected call for btrfs_start_exop() in btrfs_ioctl_dev_replace()
>  - Use fsid_str[] instead of fsid[] to save on uuid_parse()
> 
> Changes since v2:
>  - Dropped patch to add additional balance information
>  - modified (simplified) progs patches accordingly

I've switched exclusive_operation to long and used cmpxchg, plus some
fixup to comments still mentioning the old EXCL_OP bit, some other minor
style fixups.  The patches will be in for-next for a day or two and then
moved to misc-next.