From patchwork Mon Jul 8 18:47:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chaitanya Kulkarni X-Patchwork-Id: 11035643 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 A96FB14E5 for ; Mon, 8 Jul 2019 18:48:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9487F285E2 for ; Mon, 8 Jul 2019 18:48:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 839F528658; Mon, 8 Jul 2019 18:48:59 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1EBB2285B3 for ; Mon, 8 Jul 2019 18:48:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hkYfa-00053i-Sp; Mon, 08 Jul 2019 18:47:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hkYfZ-00053d-A8 for xen-devel@lists.xenproject.org; Mon, 08 Jul 2019 18:47:21 +0000 X-Inumbo-ID: cf15188e-a1b0-11e9-919b-cf468974c32c Received: from esa2.hgst.iphmx.com (unknown [68.232.143.124]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id cf15188e-a1b0-11e9-919b-cf468974c32c; Mon, 08 Jul 2019 18:47:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1562611652; x=1594147652; h=from:to:cc:subject:date:message-id; bh=uTqlKG2ILdegr5sU0HeNGcEucdW/yuMkATM/4UkxKXI=; b=ODuIhuvk1IOPXS/upsxUSRbmTLc6jFjP9YfKc1oq6web14dhzogKBT7H kRQL8iMZSaWYJyYbag8irWBHyR11jMRLC37a07USYtuT9HC0cVKbGKurf IKN44Id7HlZ61ffxpmNKwXRNqMbMCzfCnFC3oN2V9RqJEgcQbbFYbWAHa ifcQO0K8GZPmILHxKj4SJly8Nj6buZt2N3r0jle+Qg1Gy+D3VlZnQVkke CUzErJz11v8we/Qwtd2wNYlud+rUUpltvZZ971AJd2+2ZcO6GDnaxK/zn wTcS6iSd6Qo+vXz+7HcKgTEQkCoMEXjibf6f9BuopDO7h82+VXcGGQA3P g==; IronPort-SDR: dPbcEmD2s4dakDc7MTh8Qds7PQ0KQVsfKWh8eifa5GEZJYIWeGJ5PPD+7QRi54unx7kxuJ7fBt QcTk0x7XgA9cMjyGWXL+dMmKNWRKHet6rCkUD0Cb4jpRSqgEYW0mtfwKIaZAWEUYUSTOnofrKX CbHtyEj8ghdUJVWlYDIksRdnq0MqH4MwqfTf4AdlfAv19tNGM1lFVZ/sU/GTU4LxJ6vBWoBDrj LudkY19RNyessmOMVgBcD2c9unm2KqnIB999j84twfhwUAE+HVUig9f+HE0vpUCrgRjaIJxd8p QUI= X-IronPort-AV: E=Sophos;i="5.63,466,1557158400"; d="scan'208";a="212364690" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 09 Jul 2019 02:47:31 +0800 IronPort-SDR: 0uGl0jWUnel16ZGq6gKKxRRTxjDPOUGi/jLhg2HY8lfYuNNw+SDeqd+lqRN1sr1497net8a0rx JtjZjrqRUThghsEAK1E6Ae/l0+89a1gZ9GTKNGzL6BMSzUCS1KT8JhXQOY/jWhcRcvsu4uBT9y eDCLWoU+PmKh+IEMrTajfn5WZ+Oq/ukMsy1KItGSkwzsbsCeWub2/Z0i0asdOSOH8g6L8jNC2M HxKbUPZnbaogw0WEdnFfco5pCQqpI2VRuMUfYCjxHXgDz5QrDiaIuEauweJuezR8SmYd8iSiRu I9K7JmVYww5q1t0kJa4m7NnG Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 08 Jul 2019 11:46:05 -0700 IronPort-SDR: eW86af4OthOZtKlcukw8hg5FI8z3Pyrc2gRdLV4x4bpMNy4sygCYPSfYDcM2B4QXsj4ILsUxuF TQU3d19L1c5FTnZDXmSuL2XtMIjgw4+ea8vwSw8DmEbRevzLHYwgY1GdfVVK3SuKBCqem7cbn4 XSceRHtmXS96JKNQcd4ThjYOnlatcCPqKA495dVcxKVT6l/6xIuUjOo10IT/VyGg6hXSPR4ROm 3eC68pRisrEJDHQJIq9cvRlSgSS4pR/SeWPXZj+HOmUCZYEiKJ64+r/aVfvhqfvINTloVQsnsJ 61U= Received: from cvenusqemu.hgst.com ([10.202.66.73]) by uls-op-cesaip02.wdc.com with ESMTP; 08 Jul 2019 11:47:16 -0700 From: Chaitanya Kulkarni To: linux-block@vger.kernel.org Date: Mon, 8 Jul 2019 11:47:02 -0700 Message-Id: <20190708184711.2984-1-chaitanya.kulkarni@wdc.com> X-Mailer: git-send-email 2.17.0 Subject: [Xen-devel] [PATCH V4 0/9] block: use right accessor to read nr_sects X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: damien.lemoal@wdc.com, linux-btrace@vger.kernel.org, bvanassche@acm.org, linux-scsi@vger.kernel.org, konrad.wilk@oracle.com, Chaitanya Kulkarni , yuchao0@huawei.com, colyli@suse.de, linux-bcache@vger.kernel.org, jaegeuk@kernel.org, xen-devel@lists.xenproject.org, kent.overstreet@gmail.com, roger.pau@citrix.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi, In the blk-zoned, bcache, f2fs, target-pscsi, xen and blktrace implementation block device->hd_part->number of sectors field is accessed directly without any appropriate locking or accessor function. There is an existing accessor function present in the in include/linux/genhd.h which should be used to read the bdev->hd_part->nr_sects. From ${KERN_DIR}/include/linux/genhd.h:- 714 /* 715 * Any access of part->nr_sects which is not protected by partition 716 * bd_mutex or gendisk bdev bd_mutex, should be done using this 717 * accessor function. 718 * 719 * Code written along the lines of i_size_read() and i_size_write(). 720 * CONFIG_PREEMPT case optimizes the case of UP kernel with preemption 721 * on. 722 */ 723 static inline sector_t part_nr_sects_read(struct hd_struct *part) 724 { This patch series introduces a helper function on the top of the part_nr_sects_read() and removes the all direct accesses to the bdev->hd_part->nr_sects. This series is based on :- 1. Repo :- git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git. 2. Branch :- for-next. Please consider this for 5.3. Changes from V3:- 1. Get rid of the comment in the 1st patch for helper. (Bart) Chaitanya Kulkarni (9): block: add a helper function to read nr_setcs blk-zoned: update blkdev_nr_zones() with helper blk-zoned: update blkdev_report_zone() with helper blk-zoned: update blkdev_reset_zones() with helper bcache: update cached_dev_init() with helper f2fs: use helper in init_blkz_info() blktrace: use helper in blk_trace_setup_lba() target/pscsi: use helper in pscsi_get_blocks() xen/blkback: use helper in vbd_sz() block/blk-zoned.c | 12 ++++++------ drivers/block/xen-blkback/common.h | 2 +- drivers/md/bcache/super.c | 2 +- drivers/target/target_core_pscsi.c | 2 +- fs/f2fs/super.c | 2 +- include/linux/blkdev.h | 5 +++++ kernel/trace/blktrace.c | 2 +- 7 files changed, 16 insertions(+), 11 deletions(-)