public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] dm: Set safe default max_sectors for targets with no underlying device
@ 2009-09-18 15:18 Jun'ichi Nomura
  2009-09-18 15:52 ` Mike Snitzer
  0 siblings, 1 reply; 2+ messages in thread
From: Jun'ichi Nomura @ 2009-09-18 15:18 UTC (permalink / raw)
  To: Jens Axboe, Alasdair G Kergon, Mike Snitzer, Martin K. Petersen
  Cc: David Strand, device-mapper development, linux-kernel

This is a preparation for the next patch, which changes
blk_set_default_limits() to set 0 for max_sectors/max_hw_sectors.
With the next patch, for dm targets like 'zero', where there's no
underlying device, those values remain 0 and the dm device becomes
unusable.

So check the max_sectors and set to SAFE_MAX_SECTORS if 0.

Check this thread for further background:
https://www.redhat.com/archives/dm-devel/2009-September/msg00176.html


Signed-off-by: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>
Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com>
Cc: David Strand <dpstrand@gmail.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
---
 drivers/md/dm-table.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

Index: linux-2.6.31.work/drivers/md/dm-table.c
===================================================================
--- linux-2.6.31.work.orig/drivers/md/dm-table.c
+++ linux-2.6.31.work/drivers/md/dm-table.c
@@ -707,6 +707,17 @@ static int validate_hardware_logical_blo
 		    device_logical_block_size_sects - next_target_start : 0;
 	}

+	/*
+	 * blk_set_default_limits() sets max_sectors/max_hw_sectors to 0.
+	 * When all targets have no underlying device, they are
+	 * left unchanged from the default values and cause problems.
+	 * Use SAFE_MAX_SECTORS for such cases.
+	 */
+	if (limits->max_hw_sectors == 0)
+		limits->max_hw_sectors = SAFE_MAX_SECTORS;
+	if (limits->max_sectors == 0)
+		limits->max_sectors = SAFE_MAX_SECTORS;
+
 	if (remaining) {
 		DMWARN("%s: table line %u (start sect %llu len %llu) "
 		       "not aligned to h/w logical block size %u",

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

end of thread, other threads:[~2009-09-18 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-18 15:18 [PATCH 1/2] dm: Set safe default max_sectors for targets with no underlying device Jun'ichi Nomura
2009-09-18 15:52 ` Mike Snitzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox