From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs: introduce BTRFS_IOC_CHECK_DEV_EXCL_OPS ioctl to check dev excl op
Date: Wed, 21 Aug 2013 21:10:42 +0800 [thread overview]
Message-ID: <1377090643-23658-1-git-send-email-anand.jain@oracle.com> (raw)
This patch provides an ioctl to check if the FS is performing
any device exclusive operations like device add remove balance
etc. Basically any operation which will set
fs_info->mutually_exclusive_operation_running to true
This will be necessary for any user cli which has to know
the state before putting long running commands to background.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/ioctl.c | 10 ++++++++++
include/uapi/linux/btrfs.h | 1 +
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 89f346c..3544a90 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4420,6 +4420,14 @@ out_unlock:
return ret;
}
+static int btrfs_ioctl_check_dev_excl_op(struct btrfs_root *root,
+ void __user *arg)
+{
+ if (atomic_read(&root->fs_info->mutually_exclusive_operation_running))
+ return BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS;
+ return 0;
+}
+
long btrfs_ioctl(struct file *file, unsigned int
cmd, unsigned long arg)
{
@@ -4532,6 +4540,8 @@ long btrfs_ioctl(struct file *file, unsigned int
return btrfs_ioctl_set_fslabel(file, argp);
case BTRFS_IOC_FILE_EXTENT_SAME:
return btrfs_ioctl_file_extent_same(file, argp);
+ case BTRFS_IOC_CHECK_DEV_EXCL_OPS:
+ return btrfs_ioctl_check_dev_excl_op(root, NULL);
}
return -ENOTTY;
diff --git a/include/uapi/linux/btrfs.h b/include/uapi/linux/btrfs.h
index 90d7bd9..a4fa6eb 100644
--- a/include/uapi/linux/btrfs.h
+++ b/include/uapi/linux/btrfs.h
@@ -606,5 +606,6 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)
struct btrfs_ioctl_dev_replace_args)
#define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
struct btrfs_ioctl_same_args)
+#define BTRFS_IOC_CHECK_DEV_EXCL_OPS _IO(BTRFS_IOCTL_MAGIC, 56)
#endif /* _UAPI_LINUX_BTRFS_H */
--
1.7.1
next reply other threads:[~2013-08-21 13:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-21 13:10 Anand Jain [this message]
2013-08-21 13:10 ` [PATCH] btrfs-progs: replace fails start but in the background Anand Jain
2013-09-02 2:55 ` [PATCH] btrfs-progs: replace fails start but in the background v2 Anand Jain
2013-09-06 9:39 ` Anand Jain
2013-09-06 9:38 ` [PATCH] btrfs-progs: replace fails start but in the background Anand Jain
2013-08-21 13:58 ` [PATCH] btrfs: introduce BTRFS_IOC_CHECK_DEV_EXCL_OPS ioctl to check dev excl op Stefan Behrens
2013-08-22 9:51 ` anand jain
2013-08-22 10:36 ` Stefan Behrens
2013-08-23 6:45 ` Anand Jain
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=1377090643-23658-1-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).