dax: guarantee page aligned results from bdev_direct_access()
authorDan Williams <dan.j.williams@intel.com>
Sat, 16 Jan 2016 00:55:56 +0000 (16:55 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jan 2016 01:56:32 +0000 (17:56 -0800)
If a ->direct_access() implementation ever returns a map count less than
PAGE_SIZE, catch the error in bdev_direct_access().  This simplifies
error checking in upper layers.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reported-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/block_dev.c
fs/dax.c

index 81c0705558beb4cce129d673fb97c6a53e02c955..ddc6cdd1860b476e08c59dfa1f7dfbff331486f4 100644 (file)
@@ -494,6 +494,8 @@ long bdev_direct_access(struct block_device *bdev, sector_t sector,
        avail = ops->direct_access(bdev, sector, addr, pfn);
        if (!avail)
                return -ERANGE;
+       if (avail > 0 && avail & ~PAGE_MASK)
+               return -ENXIO;
        return min(avail, size);
 }
 EXPORT_SYMBOL_GPL(bdev_direct_access);
index 11721c0fc12765b80e25de26904565fd0be3505a..1080fb50fa4d46d9ffcdd569f5c1c801521c6f78 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -52,7 +52,6 @@ int dax_clear_blocks(struct inode *inode, sector_t block, long size)
                sz = min_t(long, count, SZ_128K);
                clear_pmem(addr, sz);
                size -= sz;
-               BUG_ON(sz & 511);
                sector += sz / 512;
                cond_resched();
        } while (size);