From patchwork Mon Jun 17 01:28:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 10997723 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DDFB914C0 for ; Mon, 17 Jun 2019 01:28:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE56F28807 for ; Mon, 17 Jun 2019 01:28:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2AC82880D; Mon, 17 Jun 2019 01:28:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7030F28807 for ; Mon, 17 Jun 2019 01:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727536AbfFQB24 (ORCPT ); Sun, 16 Jun 2019 21:28:56 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:7477 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727515AbfFQB24 (ORCPT ); Sun, 16 Jun 2019 21:28:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1560734936; x=1592270936; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Po0y7wi7jBwNRRxhDvOMwQBHOw0QeZhHy5S/KsHyCxI=; b=mEOK4UB2YBaizUvcS7Mgx5BIGPCH+4LAXKyfKeL54aefhMl7q+mJX7Rz NHi9l/Q7YjJHKjcchqZPg8ExIbJ3XtICvKN5uE7qSXIlzpQErkq1xcOZo q+dnsMm3NMsj4ZLsp33gbxMWGWUW+9GgLZG7ru/AniAHMgA566a6geboc EHnQoADTSEN8Q0lCKVX2Ut0d8jXvQPkfmWWLrFiWD4L8+HAO2fWxrd260 VLSbQ18Jpw95mSQPqUhMUI8mmsifB4qOdp+aupQTe/56F0sYtYKasAHc1 ZYEO9YBDuPfaGfIj7MKtW9wcrXmxUhnCC4b8PtkIFV78y2L9LShb/eQul w==; X-IronPort-AV: E=Sophos;i="5.63,383,1557158400"; d="scan'208";a="112362951" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 17 Jun 2019 09:28:55 +0800 IronPort-SDR: E/Ud+an33LhPCR7Yzf3N/3jEkjaZFxxpYEH+KzHtgDeS1JAnepxlHWKq4ftn0eSZFo9zCIr7Lp tPkyI+6xXJoggT1tEbqmKhAvL+iyjmFrSXmUkceGrR4KsFgR8y/iYeswXHviTx4xAl0t9y303J /MaPaXeE/r25U4fBRcfxDHeVFsUe8AiGlv94AbBmgs1BGnGyusSNqFgoydUmGRbkrf4QvaOpVW bxIYjUs41zQRsXnYAawR9mcWw/yqKy4aJ6XKeW2c0ZBlRQS3F83RqJMdPs6uWbAyu0c3Ytyp3+ crt5/QaGGM68jvqqK/HqS4LY Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 16 Jun 2019 18:28:33 -0700 IronPort-SDR: wpns3c4kKsnbhvcIRUAjqJE/TCZH+cA8O1jQ7RcEkN05WL4rNnDu7rMopee44SQ5O1H1L2+GOS OqRwdB8hxq5Qyn6TyFUWVupa6coyBVcNxRrl/zn8tiPH/D8q0vjND/Go7pte1rs5njH9H/6lms TY66eCzLUPXXhI1Tlu8yvcEHUPx+HwupofYw7KvQpRewyd2yKBkXuy68ySB7yirt9KhTi3GySa 8jmgyn81krAdGXQmqyX4eWNC5ye84nFNM3ucQVmW44+QnUgKJ32bcYDGsLgHMX5cxYmaR6+Z1j /EY= Received: from cmercuryqemu.hgst.com ([10.202.65.32]) by uls-op-cesaip01.wdc.com with ESMTP; 16 Jun 2019 18:28:56 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Cc: colyli@suse.de, linux-bcache@vger.kernel.org, linux-btrace@vger.kernel.org, kent.overstreet@gmail.com, jaegeuk@kernel.org, damien.lemoal@wdc.com, Chaitanya Kulkarni Subject: [PATCH V2 5/7] bcache: update cached_dev_init() with helper Date: Sun, 16 Jun 2019 18:28:30 -0700 Message-Id: <20190617012832.4311-6-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190617012832.4311-1-chaitanya.kulkarni@wdc.com> References: <20190617012832.4311-1-chaitanya.kulkarni@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the bcache when initializing the device we don't actually use any sort of locking when reading the number of sectors from the part. This patch updates the cached_dev_init() with newly introduced helper function to read the nr_sects from block device's hd_parts with the help of part_nr_sects_read(). Signed-off-by: Chaitanya Kulkarni Acked-by: Coly Li --- drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 1b63ac876169..6a29ba89dae1 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -1263,7 +1263,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size) q->limits.raid_partial_stripes_expensive; ret = bcache_device_init(&dc->disk, block_size, - dc->bdev->bd_part->nr_sects - dc->sb.data_offset); + bdev_nr_sects(dc->bdev) - dc->sb.data_offset); if (ret) return ret;