public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Goldwyn Rodrigues <rgoldwyn@suse.de>, linux-btrfs@vger.kernel.org
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
Subject: Re: [PATCH 2/3] btrfs: export currently executing exclusive operation via sysfs
Date: Wed, 5 Aug 2020 12:04:30 +0300	[thread overview]
Message-ID: <032ce33e-7249-d08f-1ffe-4ac5a4e20efe@suse.com> (raw)
In-Reply-To: <20200803202913.15913-3-rgoldwyn@suse.de>



On 3.08.20 г. 23:29 ч., Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> /sys/fs/<fsid>/exclusive_operation contains the currently executing
> exclusive operation. Add a sysfs_notify() when operation end, so
> userspace can be notified of exclusive operation is finished.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/ioctl.c |  2 ++
>  fs/btrfs/sysfs.c | 25 +++++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 3352b4ffa5c6..664c02a5baf9 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -373,6 +373,8 @@ bool btrfs_exclop_start(struct btrfs_fs_info *fs_info, int type)
>  void btrfs_exclop_finish(struct btrfs_fs_info *fs_info)
>  {
>  	atomic_set(&fs_info->exclusive_operation, BTRFS_EXCLOP_NONE);
> +	sysfs_notify(&fs_info->fs_devices->fsid_kobj, NULL,
> +			"exclusive_operation");
>  }
>  
>  /*
> diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
> index a39bff64ff24..71950c121588 100644
> --- a/fs/btrfs/sysfs.c
> +++ b/fs/btrfs/sysfs.c
> @@ -808,6 +808,30 @@ static ssize_t btrfs_checksum_show(struct kobject *kobj,
>  
>  BTRFS_ATTR(, checksum, btrfs_checksum_show);
>  
> +static ssize_t btrfs_exclusive_operation_show(struct kobject *kobj,
> +		struct kobj_attribute *a, char *buf)
> +{
> +	struct btrfs_fs_info *fs_info = to_fs_info(kobj);
> +	switch (atomic_read(&fs_info->exclusive_operation)) {
> +		case  BTRFS_EXCLOP_NONE:
> +			return scnprintf(buf, PAGE_SIZE, "none\n");
> +		case BTRFS_EXCLOP_BALANCE:
> +			return scnprintf(buf, PAGE_SIZE, "balance\n");
> +		case BTRFS_EXCLOP_DEV_ADD:
> +			return scnprintf(buf, PAGE_SIZE, "device add\n");
> +		case BTRFS_EXCLOP_DEV_REPLACE:
> +			return scnprintf(buf, PAGE_SIZE, "device replace\n");
> +		case BTRFS_EXCLOP_DEV_REMOVE:
> +			return scnprintf(buf, PAGE_SIZE, "device remove\n");
> +		case BTRFS_EXCLOP_SWAP_ACTIVATE:
> +			return scnprintf(buf, PAGE_SIZE, "swap activate\n");
> +		case BTRFS_EXCLOP_RESIZE:
> +			return scnprintf(buf, PAGE_SIZE, "resize\n");
> +	}
> +	return 0;
> +}
> +BTRFS_ATTR(, exclusive_operation, btrfs_exclusive_operation_show);
> +
>  static const struct attribute *btrfs_attrs[] = {
>  	BTRFS_ATTR_PTR(, label),
>  	BTRFS_ATTR_PTR(, nodesize),
> @@ -816,6 +840,7 @@ static const struct attribute *btrfs_attrs[] = {
>  	BTRFS_ATTR_PTR(, quota_override),
>  	BTRFS_ATTR_PTR(, metadata_uuid),
>  	BTRFS_ATTR_PTR(, checksum),
> +	BTRFS_ATTR_PTR(, exclusive_operation),
>  	NULL,
>  };
>  
> 

  reply	other threads:[~2020-08-05  9:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 20:29 [PATCH v2 0/3] btrfs: Enumerate and export exclusive operations Goldwyn Rodrigues
2020-08-03 20:29 ` [PATCH 1/3] btrfs: enumerate the type of exclusive operation in progress Goldwyn Rodrigues
2020-08-05  8:35   ` Nikolay Borisov
2020-08-03 20:29 ` [PATCH 2/3] btrfs: export currently executing exclusive operation via sysfs Goldwyn Rodrigues
2020-08-05  9:04   ` Nikolay Borisov [this message]
2020-08-03 20:29 ` [PATCH 3/3] btrfs: add more information for balance Goldwyn Rodrigues
2020-08-05 12:17   ` Nikolay Borisov
2020-08-05 16:29     ` Goldwyn Rodrigues
2020-08-03 20:30 ` [PATCH 1/4] btrfs-progs: get_fsid_fd() for getting fsid using fd Goldwyn Rodrigues
2020-08-03 20:30   ` [PATCH 2/4] btrfs-progs: add sysfs file reading functions Goldwyn Rodrigues
2020-08-03 20:30   ` [PATCH 3/4] btrfs-progs: Check for exclusive operation before issuing ioctl Goldwyn Rodrigues
2020-08-03 20:30   ` [PATCH 4/4] btrfs-progs: Enqueue command if it can't be performed immediately Goldwyn Rodrigues
  -- strict thread matches above, loose matches on Subject: below --
2020-07-27 22:04 [PATCH 0/3] btrfs: Enumerate and export exclusive operations Goldwyn Rodrigues
2020-07-27 22:04 ` [PATCH 2/3] btrfs: export currently executing exclusive operation via sysfs Goldwyn Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=032ce33e-7249-d08f-1ffe-4ac5a4e20efe@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=rgoldwyn@suse.com \
    --cc=rgoldwyn@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox