All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pnfs/blocklayout: pnfs_block_dev_map uses bytes, not sectors
@ 2018-01-25 14:36 Benjamin Coddington
  2018-01-25 14:36 ` [PATCH 2/2 v2] pnfs/blocklayout: Ensure disk address in block device map Benjamin Coddington
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Coddington @ 2018-01-25 14:36 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: Christoph Hellwig, linux-nfs

Fixup the field types to match their use.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/blocklayout/blocklayout.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h
index efc007f00742..716bc75e9ed2 100644
--- a/fs/nfs/blocklayout/blocklayout.h
+++ b/fs/nfs/blocklayout/blocklayout.h
@@ -92,10 +92,9 @@ struct pnfs_block_volume {
 };
 
 struct pnfs_block_dev_map {
-	sector_t			start;
-	sector_t			len;
-
-	sector_t			disk_offset;
+	u64			start;
+	u64			len;
+	u64			disk_offset;
 	struct block_device		*bdev;
 };
 
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2 v2] pnfs/blocklayout: Ensure disk address in block device map
  2018-01-25 14:36 [PATCH 1/2] pnfs/blocklayout: pnfs_block_dev_map uses bytes, not sectors Benjamin Coddington
@ 2018-01-25 14:36 ` Benjamin Coddington
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Coddington @ 2018-01-25 14:36 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: Christoph Hellwig, linux-nfs

It's possible that the device map is smaller than the offset into the device
for the I/O we're adding.  Add a check for it and bail out, otherwise we
risk botching the bio calculations that follow.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
 fs/nfs/blocklayout/blocklayout.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 334570888649..9919d9e98fa6 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -137,6 +137,11 @@ bl_alloc_init_bio(int npg, struct block_device *bdev, sector_t disk_sector,
 	return bio;
 }
 
+static bool offset_in_map(u64 offset, struct pnfs_block_dev_map *map)
+{
+	return offset >= map->start && offset < map->start + map->len;
+}
+
 static struct bio *
 do_add_page_to_bio(struct bio *bio, int npg, int rw, sector_t isect,
 		struct page *page, struct pnfs_block_dev_map *map,
@@ -156,8 +161,8 @@ do_add_page_to_bio(struct bio *bio, int npg, int rw, sector_t isect,
 
 	/* translate to physical disk offset */
 	disk_addr = (u64)isect << SECTOR_SHIFT;
-	if (disk_addr < map->start || disk_addr >= map->start + map->len) {
-		if (!dev->map(dev, disk_addr, map))
+	if (!offset_in_map(disk_addr, map)) {
+		if (!dev->map(dev, disk_addr, map) || !offset_in_map(disk_addr, map))
 			return ERR_PTR(-EIO);
 		bio = bl_submit_bio(bio);
 	}
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-25 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25 14:36 [PATCH 1/2] pnfs/blocklayout: pnfs_block_dev_map uses bytes, not sectors Benjamin Coddington
2018-01-25 14:36 ` [PATCH 2/2 v2] pnfs/blocklayout: Ensure disk address in block device map Benjamin Coddington

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.