Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751265AbbFEMy6 (ORCPT ); Fri, 5 Jun 2015 08:54:58 -0400 Received: from mail-lb0-f176.google.com ([209.85.217.176]:33098 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754403AbbFEMyx (ORCPT ); Fri, 5 Jun 2015 08:54:53 -0400 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: hch@infradead.org, axboe@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: javier@lightnvm.io, Stephen.Bates@pmcs.com, keith.busch@intel.com, =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH v4 3/8] null_blk: wrong capacity when bs is not 512 bytes Date: Fri, 5 Jun 2015 14:54:25 +0200 Message-Id: <1433508870-28251-4-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433508870-28251-1-git-send-email-m@bjorling.me> References: <1433508870-28251-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1091 Lines: 32 set_capacity() sets device capacity by the number of 512 bytes sectors. null_blk calculates the number of sectors by size / bs and calls set_capacity. This leads to the wrong number of sectors when bs is not 512 bytes. Signed-off-by: Matias Bjørling --- drivers/block/null_blk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 65cd61a..79972ab 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -576,8 +576,7 @@ static int null_add_dev(void) blk_queue_physical_block_size(nullb->q, bs); size = gb * 1024 * 1024 * 1024ULL; - sector_div(size, bs); - set_capacity(disk, size); + set_capacity(disk, size >> 9); disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO; disk->major = null_major; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/