From patchwork Mon Aug 31 12:17:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 7099611 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DA55F9F36E for ; Mon, 31 Aug 2015 12:17:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 09ACF20705 for ; Mon, 31 Aug 2015 12:17:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2EB11206FD for ; Mon, 31 Aug 2015 12:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752967AbbHaMRk (ORCPT ); Mon, 31 Aug 2015 08:17:40 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:35981 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752923AbbHaMRi (ORCPT ); Mon, 31 Aug 2015 08:17:38 -0400 Received: by wicfv10 with SMTP id fv10so61473642wic.1 for ; Mon, 31 Aug 2015 05:17:37 -0700 (PDT) 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=yLyARj5BbVaKlfiWBOenZVxC3ERAmMLMnhM7km8OuO5XjZjB5iuhCXIv/5V7UCMkV/ D3alQp/Qghuiv6553P8ea8sIjyyU1i6IBtj9QvajaAhtgbrCrwwyX3Ya1aBTce/HGK+m eALK7+Xw5cZ4QsbPlK/uJF758qW5JiFxclL9I= 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=iNeNVTjTfFVAsP1mywannS5Jt2/zk7A+mse9deXKHEzTMsps01H1SAi+KBQi7hONcx PFFjry+Zg/U+XewPnAEt/qidZb9aPlw6N5lVPsk+GvVNcux3W6dG+Xnsbos0s2oHacEt YHrNmC/zghdVmLy6EpF3jbqVINe69dYojMj9WReOK/f5lkFvWpkxNh/J2FvDkFn0nLgw OxeA7rHQvcfoabrUX5kF1ju68kYkRcP9RCPmbO3XECR3AxI3xGXoxgfgc5UqdHLqLMtm aNyeqmUb5fE6o5hUg8JpNhUSr4W92sanPLEDyGiPsuuY5iWfMLGDdzohYSLAVqMHRXh1 Kzgg== X-Gm-Message-State: ALoCoQlZ+HKx633ZsoKyBqeqNuQfgGLQec1tvaLgTy8zj05esZ6xE7PEqZqfdq4pM3XYbViV1mGh X-Received: by 10.194.87.4 with SMTP id t4mr29540425wjz.84.1441023457736; Mon, 31 Aug 2015 05:17:37 -0700 (PDT) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id fa8sm17800622wib.14.2015.08.31.05.17.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 05:17:36 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH] null_blk: fix wrong capacity when bs is not 512 bytes Date: Mon, 31 Aug 2015 14:17:31 +0200 Message-Id: <1441023451-17049-1-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Ross Zwisler --- 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;