Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1169849

[PATCH] null_blk: fix wrong capacity when bs is not 512 bytes

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Matias Bjørling <m@bjorling.me>
Newsgroups linux.kernel
Subject [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes
Date Mon, 22 Jun 2015 13:30:02 +0200
Message-ID <pE85k-2e7-15@gated-at.bofh.it> (permalink)
X-Original-To axboe@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=dS1IzMYbVTN1VJTXkqdUrW0kxFsAX9I9H8sI2mmjIWc=; b=mXuoSXUdD5QnbBXIKr+KUWuY5DFypq3gru4ZcVyoS1M4S90vxvjVk1eWdH44SBYVVx fJMzUTs2zZlmeYGMoC4RYPe9HhsSVnaMSreobwLLZBGwuiA+Lc2IjjgBeXMBOPYzgAd9 JL0O0ph6ZGqkh5/zHf5jZUPemTqZvM6cEomBM=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-type:content-transfer-encoding; bh=dS1IzMYbVTN1VJTXkqdUrW0kxFsAX9I9H8sI2mmjIWc=; b=kuyJ6bcvHf4byZ+8IR3/9NqkRRIj0QMAaZ60ALWEd07pg5MGECDxP0NVeSqY3yLzc3 Tmu6Tm3+SjfJnVRxG8JqwRgXI95KSK3RlYgp0a7Inl1NOZ0iE710njc0v/AfsDDP1K7c QwsKzlJtPSa8e7BikAUtUGaKm9QbCwAPbsdjTL6FrsySnMCmv3mk4Tfk7oefeZSKD3su hu2Xi9dvMmr/adWmBeeN8s/l+n/IEkpBTkdCt88zO9idpx+YUp36okLy27wBiCWyxmIo i6kBU7uJSTGufE69vy6EhHDk5KarRe27alkPN4SO2ArjYQRRvtjNdZ622mDiun+WRJR9 geEQ==
X-Gm-Message-State ALoCoQlx7I7DstMQSe1Dgcpv8fjN8Pq1BkwkzD4LwZle6SITHIHr3WO+lMxFOSd79eVw/+Cp3/mu
X-Received by 10.112.119.198 with SMTP id kw6mr29038299lbb.97.1434972540237; Mon, 22 Jun 2015 04:29:00 -0700 (PDT)
X-Mailer git-send-email 2.1.4
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 30
Organization linux.* mail to news gateway
X-Original-Cc Matias Bjørling <m@bjorling.me>
X-Original-Date Mon, 22 Jun 2015 13:28:37 +0200
X-Original-Message-ID <1434972517-20711-1-git-send-email-m@bjorling.me>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref aioe.org linux.kernel:1169849

Show key headers only | View raw


set_capacity() sets device's capacity using 512 bytes sectors.
null_blk calculates the number of sectors by size / bs, which
set_capacity is called with. This led to null_blk exposing the
wrong number of sectors when bs is not 512 bytes.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 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 6f9b753..bf8f764 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -588,8 +588,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
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] null_blk: fix wrong capacity when bs is not 512 bytes Matias Bjørling <m@bjorling.me> - 2015-06-22 13:30 +0200

csiph-web