From: Mike Snitzer <snitzer@redhat.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: device-mapper development <dm-devel@redhat.com>,
"Alasdair G. Kergon" <agk@redhat.com>,
Jens Axboe <jens.axboe@oracle.com>
Subject: [PATCH] block: bdev_stack_limits wrapper and DM topology fixes
Date: Fri, 8 Jan 2010 19:01:45 -0500 [thread overview]
Message-ID: <20100109000145.GB21439@redhat.com> (raw)
In-Reply-To: <20100106132508.GA3589@redhat.com>
Martin,
On Wed, Jan 06 2010 at 8:25am -0500,
Mike Snitzer <snitzer@redhat.com> wrote:
> On Wed, Jan 06 2010 at 3:39am -0500,
> Martin K. Petersen <martin.petersen@oracle.com> wrote:
>
> > You'll notice that bdev_stack_limits takes a sector offset as argument.
> > I have a patch that I intend to push at a later date that will convert
> > the remaining stacking functions to take soft sector offsets instead of
> > bytes. I deal with the appropriate conversion in the alignment
> > calculation. That way we avoid the blk_off_t goo entirely and it makes
> > the difference between absolute offsets and alignment offsets crystal
> > clear.
>
> Looks good. But you're missing the EXPORT_SYMBOL(bdev_stack_limits)
In that you're carrying the dm_set_device_limits() change as part of
this patch:
http://oss.oracle.com/git/?p=mkp/linux-2.6.git;a=commit;h=f3bc9c611895
Any chance you'd shepherd this revised patch to Jens? It includes
various DM topology cleanups that we've discussed as well as the
EXPORT_SYMBOL(bdev_stack_limits).
The dm_set_device_limits DMWARN() cleanup is the line after your
sector change so it'd require coordination. I'm purposely displaying
the 'start' in bytes because all other topology limit values in that
DMWARN are in bytes. [and yes it's > 80-char, linus is OK with that now
if it "makes sense"]
The 2nd and 3rd hunks of the dm-table.c changes respectively offer
another topology DMWARN cleanup and the removal of the alignment_offset
and misaligned resets that we discussed extensively.
If you'd rather not take those 2 hunks I can queue them with Alasdair
but I figured we could just add them to this patch.
Let me know, thanks.
From: Martin K. Petersen <martin.petersen@oracle.com>
block: bdev_stack_limits wrapper and DM topology fixes
DM does not want to know about partition offsets. Add a partition-aware
wrapper that DM can use when stacking block devices.
Also remove the clearing of alignment_offset and misaligned in
dm_table_set_restrictions(). Adjust some misleading topology DMWARN
messages too.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: Alasdair G. Kergon <agk@redhat.com>
---
block/blk-settings.c | 22 ++++++++++++++++++++++
drivers/md/dm-table.c | 20 +++++---------------
include/linux/blkdev.h | 2 ++
3 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/block/blk-settings.c b/block/blk-settings.c
index d52d4ad..0d8de4e 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -631,6 +631,28 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
EXPORT_SYMBOL(blk_stack_limits);
/**
+ * bdev_stack_limits - adjust queue limits for stacked drivers
+ * @t: the stacking driver limits (top device)
+ * @bdev: the component block_device (bottom)
+ * @start: first data sector within component device
+ *
+ * Description:
+ * Merges queue limits for a top device and a block_device. Returns
+ * 0 if alignment didn't change. Returns -1 if adding the bottom
+ * device caused misalignment.
+ */
+int bdev_stack_limits(struct queue_limits *t, struct block_device *bdev,
+ sector_t start)
+{
+ struct request_queue *bq = bdev_get_queue(bdev);
+
+ start += get_start_sect(bdev);
+
+ return blk_stack_limits(t, &bq->limits, start << 9);
+}
+EXPORT_SYMBOL(bdev_stack_limits);
+
+/**
* disk_stack_limits - adjust queue limits for stacked drivers
* @disk: MD/DM gendisk (top)
* @bdev: the underlying block device (bottom)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index be62547..4b22feb 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -503,16 +503,15 @@ int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev,
return 0;
}
- if (blk_stack_limits(limits, &q->limits, start << 9) < 0)
- DMWARN("%s: target device %s is misaligned: "
+ if (bdev_stack_limits(limits, bdev, start) < 0)
+ DMWARN("%s: adding target device %s caused an alignment inconsistency: "
"physical_block_size=%u, logical_block_size=%u, "
"alignment_offset=%u, start=%llu",
dm_device_name(ti->table->md), bdevname(bdev, b),
q->limits.physical_block_size,
q->limits.logical_block_size,
q->limits.alignment_offset,
- (unsigned long long) start << 9);
-
+ (unsigned long long) start << SECTOR_SHIFT);
/*
* Check if merge fn is supported.
@@ -1026,9 +1025,9 @@ combine_limits:
* for the table.
*/
if (blk_stack_limits(limits, &ti_limits, 0) < 0)
- DMWARN("%s: target device "
+ DMWARN("%s: adding target device "
"(start sect %llu len %llu) "
- "is misaligned",
+ "caused an alignment inconsistency",
dm_device_name(table->md),
(unsigned long long) ti->begin,
(unsigned long long) ti->len);
@@ -1080,15 +1079,6 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
struct queue_limits *limits)
{
/*
- * Each target device in the table has a data area that should normally
- * be aligned such that the DM device's alignment_offset is 0.
- * FIXME: Propagate alignment_offsets up the stack and warn of
- * sub-optimal or inconsistent settings.
- */
- limits->alignment_offset = 0;
- limits->misaligned = 0;
-
- /*
* Copy table's limits to the DM device's request_queue
*/
q->limits = *limits;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 9b98173..70b7ede 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -938,6 +938,8 @@ extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
extern void blk_set_default_limits(struct queue_limits *lim);
extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
sector_t offset);
+extern int bdev_stack_limits(struct queue_limits *t, struct block_device *bdev,
+ sector_t offset);
extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
sector_t offset);
extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
next prev parent reply other threads:[~2010-01-09 0:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-23 18:07 [PATCH v2] dm: Fix alignment stacking on partitioned devices Mike Snitzer
2009-12-23 19:21 ` Mike Snitzer
2010-01-05 18:04 ` Alasdair G Kergon
2010-01-05 18:27 ` Alasdair G Kergon
2010-01-06 2:23 ` Martin K. Petersen
2010-01-06 2:57 ` Mike Snitzer
2010-01-06 3:03 ` Mike Snitzer
2010-01-06 3:24 ` Martin K. Petersen
2010-01-06 4:10 ` Mike Snitzer
2010-01-06 4:16 ` Martin K. Petersen
2010-01-06 5:16 ` Mike Snitzer
2010-01-06 8:39 ` Martin K. Petersen
2010-01-06 13:25 ` Mike Snitzer
2010-01-07 17:15 ` Martin K. Petersen
2010-01-07 18:55 ` Mike Snitzer
2010-01-08 18:41 ` Martin K. Petersen
2010-01-08 20:28 ` Mike Snitzer
2010-01-09 0:01 ` Mike Snitzer [this message]
2010-01-06 13:55 ` Alasdair G Kergon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100109000145.GB21439@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=jens.axboe@oracle.com \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.