dax: fallback to non-dax IO in the presence of badblocks

If a file system is mounted with dax, all IO, including read(2) and
write(2) go through dax. Since dax is unable to clear media errors
(badblocks), this leaves us with no way to clear these errors for a dax
filesystem.

Fix this by adding a check for badblocks at the bdev level, and when
checking if we want to do dax IO from filesystems, only make that
optimization if there are no badblocks. In the presence of badblocks,
fall back to the regular (O_DIRECT or page cache) IO that goes through
the block driver, which is able to handle badblock clearing as needed.

Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Jan Kara <jack@suse.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
6 files changed