summaryrefslogtreecommitdiffstats
path: root/fs/xfs/scrub/scrub.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2017-10-17 21:37:36 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2017-10-26 15:38:23 -0700
commitdcb660f9222fd9f607e7e05f4755b39b809ca19f (patch)
tree7f18fd46d04dae3fb1aa27192e2e7e1d4ab0110c /fs/xfs/scrub/scrub.c
parenta56371865e7870d953d3837aaa1d12230bba021d (diff)
downloadlinux-dcb660f9222fd9f607e7e05f4755b39b809ca19f.tar.gz
linux-dcb660f9222fd9f607e7e05f4755b39b809ca19f.tar.bz2
linux-dcb660f9222fd9f607e7e05f4755b39b809ca19f.zip
xfs: probe the scrub ioctl
Create a probe scrubber with id 0. This will be used by xfs_scrub to probe the kernel's abilities to scrub (and repair) the metadata. We do this by validating the ioctl inputs from userspace, preparing the filesystem for a scrub (or a repair) operation, and immediately returning to userspace. Userspace can use the returned errno and structure state to decide (in broad terms) if scrub/repair are supported by the running kernel. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/scrub/scrub.c')
-rw-r--r--fs/xfs/scrub/scrub.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/fs/xfs/scrub/scrub.c b/fs/xfs/scrub/scrub.c
index 1fc8d3b43902..71183a8678aa 100644
--- a/fs/xfs/scrub/scrub.c
+++ b/fs/xfs/scrub/scrub.c
@@ -42,6 +42,7 @@
#include "xfs_rmap_btree.h"
#include "scrub/xfs_scrub.h"
#include "scrub/scrub.h"
+#include "scrub/common.h"
#include "scrub/trace.h"
/*
@@ -108,6 +109,30 @@
* will be set.
*/
+/*
+ * Scrub probe -- userspace uses this to probe if we're willing to scrub
+ * or repair a given mountpoint. This will be used by xfs_scrub to
+ * probe the kernel's abilities to scrub (and repair) the metadata. We
+ * do this by validating the ioctl inputs from userspace, preparing the
+ * filesystem for a scrub (or a repair) operation, and immediately
+ * returning to userspace. Userspace can use the returned errno and
+ * structure state to decide (in broad terms) if scrub/repair are
+ * supported by the running kernel.
+ */
+int
+xfs_scrub_probe(
+ struct xfs_scrub_context *sc)
+{
+ int error = 0;
+
+ if (sc->sm->sm_ino || sc->sm->sm_agno)
+ return -EINVAL;
+ if (xfs_scrub_should_terminate(sc, &error))
+ return error;
+
+ return 0;
+}
+
/* Scrub setup and teardown */
/* Free all the resources and finish the transactions. */
@@ -126,6 +151,10 @@ xfs_scrub_teardown(
/* Scrubbing dispatch. */
static const struct xfs_scrub_meta_ops meta_scrub_ops[] = {
+ { /* ioctl presence test */
+ .setup = xfs_scrub_setup_fs,
+ .scrub = xfs_scrub_probe,
+ },
};
/* This isn't a stable feature, warn once per day. */