+ /*
+ * Check for stale information in the status file, ie. if it's
+ * canceled=0, finished=0 but no scrub is running.
+ */
+ if (!is_scrub_running_in_kernel(fdmnt, di_args, fi_args.num_devices))
+ force = 1;
+
+ /*
+ * check whether any involved device is already busy running a
+ * scrub. This would cause damaged status messages and the state
+ * "aborted" without the explanation that a scrub was already
+ * running. Therefore check it first, prevent it and give some
+ * feedback to the user if scrub is already running.
+ * Note that if scrub is started with a block device as the
+ * parameter, only that particular block device is checked. It
+ * is a normal mode of operation to start scrub on multiple
+ * single devices, there is no reason to prevent this.
+ */
+ if (!force && is_scrub_running_on_fs(&fi_args, di_args, past_scrubs)) {
+ error_on(!do_quiet,
+ "Scrub is already running.\n"
+ "To cancel use 'btrfs scrub cancel %s'.\n"
+ "To see the status use 'btrfs scrub status [-d] %s'",
+ path, path);
+ err = 1;
+ goto out;
+ }
+