All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: Jens Axboe <jens.axboe@oracle.com>,
	Alasdair G Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: device-mapper development <dm-devel@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] dm: Set safe default max_sectors for targets with no underlying device
Date: Sat, 19 Sep 2009 00:18:36 +0900	[thread overview]
Message-ID: <4AB3A4CC.4010708@ce.jp.nec.com> (raw)

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",

WARNING: multiple messages have this Message-ID (diff)
From: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
To: Jens Axboe <jens.axboe@oracle.com>,
	Alasdair G Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@redhat.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: David Strand <dpstrand@gmail.com>,
	device-mapper development <dm-devel@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] dm: Set safe default max_sectors for targets with no underlying device
Date: Sat, 19 Sep 2009 00:18:36 +0900	[thread overview]
Message-ID: <4AB3A4CC.4010708@ce.jp.nec.com> (raw)

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",

             reply	other threads:[~2009-09-18 15:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-18 15:18 Jun'ichi Nomura [this message]
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
2009-09-18 15:52   ` Mike Snitzer

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=4AB3A4CC.4010708@ce.jp.nec.com \
    --to=j-nomura@ce.jp.nec.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=jens.axboe@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=snitzer@redhat.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.