pmem, dax: disable dax in the presence of bad blocks
authorDan Williams <dan.j.williams@intel.com>
Wed, 6 Jan 2016 20:03:42 +0000 (12:03 -0800)
committerDan Williams <dan.j.williams@intel.com>
Sun, 10 Jan 2016 06:42:31 +0000 (22:42 -0800)
Longer term teach dax to punch "error" holes in mapping requests and
deliver SIGBUS to applications that consume a bad pmem page.  For now,
simply disable the dax performance optimization in the presence of known
errors.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
block/ioctl.c
drivers/nvdimm/pmem.c

index 7a964d842913f92df4bbe7942f494f9cb8153e16..2c84683aada56e4b52c9080b88ce99eb1d7b68c8 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/gfp.h>
 #include <linux/blkpg.h>
 #include <linux/hdreg.h>
+#include <linux/badblocks.h>
 #include <linux/backing-dev.h>
 #include <linux/fs.h>
 #include <linux/blktrace_api.h>
@@ -422,6 +423,15 @@ bool blkdev_dax_capable(struct block_device *bdev)
                        || (bdev->bd_part->nr_sects % (PAGE_SIZE / 512)))
                return false;
 
+       /*
+        * If the device has known bad blocks, force all I/O through the
+        * driver / page cache.
+        *
+        * TODO: support finer grained dax error handling
+        */
+       if (disk->bb && disk->bb->count)
+               return false;
+
        return true;
 }
 
index d00c659d13049612121543809d6ffc205ca898d2..6a1832b3983ca27c2faefaa10cee7dc9fe05de16 100644 (file)
@@ -233,6 +233,7 @@ static int pmem_attach_disk(struct device *dev,
                return -ENOMEM;
        nvdimm_namespace_add_poison(ndns, &pmem->bb, pmem->data_offset);
 
+       disk->bb = &pmem->bb;
        add_disk(disk);
        revalidate_disk(disk);