Skip to content

Commit

Permalink
dax: guarantee page aligned results from bdev_direct_access()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Williams authored and Linus Torvalds committed Jan 16, 2016
1 parent 0e749e5 commit fe683ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 2 additions & 0 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion fs/dax.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fe683ad

Please sign in to comment.