From patchwork Fri Sep 18 15:18:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junichi Nomura X-Patchwork-Id: 48547 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8IFQB08007078 for ; Fri, 18 Sep 2009 15:26:11 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 7EEF1619EFD; Fri, 18 Sep 2009 11:26:10 -0400 (EDT) Received: from int-mx03.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n8IFQ8DG024892 for ; Fri, 18 Sep 2009 11:26:08 -0400 Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.11]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8IFQ7WJ030582; Fri, 18 Sep 2009 11:26:07 -0400 Received: from tyo202.gate.nec.co.jp (TYO202.gate.nec.co.jp [202.32.8.206]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8IFPwmC007210; Fri, 18 Sep 2009 11:25:59 -0400 Received: from mailgate3.nec.co.jp ([10.7.69.195]) by tyo202.gate.nec.co.jp (8.13.8/8.13.4) with ESMTP id n8IFPpUc022387; Sat, 19 Sep 2009 00:25:51 +0900 (JST) Received: (from root@localhost) by mailgate3.nec.co.jp (8.11.7/3.7W-MAILGATE-NEC) id n8IFPoY12882; Sat, 19 Sep 2009 00:25:50 +0900 (JST) Received: from mail02.kamome.nec.co.jp (mail02.kamome.nec.co.jp [10.25.43.5]) by mailsv.nec.co.jp (8.13.8/8.13.4) with ESMTP id n8IFPoJi011977; Sat, 19 Sep 2009 00:25:50 +0900 (JST) Received: from shintaro.jp.nec.com ([10.26.220.11] [10.26.220.11]) by mail02.kamome.nec.co.jp with ESMTP id BT-MMP-2067556; Sat, 19 Sep 2009 00:18:39 +0900 Received: from [10.66.61.195] ([10.66.61.195] [10.66.61.195]) by mail.jp.nec.com with ESMTP; Sat, 19 Sep 2009 00:18:36 +0900 Message-ID: <4AB3A4CC.4010708@ce.jp.nec.com> Date: Sat, 19 Sep 2009 00:18:36 +0900 From: "Jun'ichi Nomura" User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: Jens Axboe , Alasdair G Kergon , Mike Snitzer , "Martin K. Petersen" X-RedHat-Spam-Score: 0 () X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.11 X-loop: dm-devel@redhat.com Cc: device-mapper development , linux-kernel@vger.kernel.org Subject: [dm-devel] [PATCH 1/2] dm: Set safe default max_sectors for targets with no underlying device X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com 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 Signed-off-by: Jun'ichi Nomura Cc: David Strand Cc: Mike Snitzer Cc: Alasdair G Kergon Cc: Martin K. Petersen Cc: Jens Axboe --- drivers/md/dm-table.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel 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",