]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
nfit, address-range-scrub: fix scrub in-progress reporting
authorDan Williams <dan.j.williams@intel.com>
Mon, 2 Apr 2018 23:40:04 +0000 (16:40 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 6 Jun 2018 15:49:05 +0000 (11:49 -0400)
BugLink: http://bugs.launchpad.net/bugs/1773233
commit 78727137fdf49edf9f731bde79d7189067b4047a upstream.

There is a small window whereby ARS scan requests can schedule work that
userspace will miss when polling scrub_show. Hold the init_mutex lock
over calls to report the status to close this potential escape. Also,
make sure that requests to cancel the ARS workqueue are treated as an
idle event.

Cc: <stable@vger.kernel.org>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Fixes: 37b137ff8c83 ("nfit, libnvdimm: allow an ARS scrub...")
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/acpi/nfit/core.c

index 9f8f39d4939605acdd4c0a760da9abe985c995ff..9151d6903b855a7d4deadf3fce0be56a16c5e824 100644 (file)
@@ -1250,8 +1250,11 @@ static ssize_t scrub_show(struct device *dev,
        if (nd_desc) {
                struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);
 
+               mutex_lock(&acpi_desc->init_mutex);
                rc = sprintf(buf, "%d%s", acpi_desc->scrub_count,
-                               (work_busy(&acpi_desc->work)) ? "+\n" : "\n");
+                               work_busy(&acpi_desc->work)
+                               && !acpi_desc->cancel ? "+\n" : "\n");
+               mutex_unlock(&acpi_desc->init_mutex);
        }
        device_unlock(dev);
        return rc;