From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149191583273.2362313718901; Thu, 21 Dec 2023 00:59:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658601.1027842 (Exim 4.92) (envelope-from ) id 1rGEto-0001ek-6E; Thu, 21 Dec 2023 08:59:24 +0000 Received: by outflank-mailman (output) from mailman id 658601.1027842; Thu, 21 Dec 2023 08:59:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtn-0001eA-W5; Thu, 21 Dec 2023 08:59:23 +0000 Received: by outflank-mailman (input) for mailman id 658601; Thu, 21 Dec 2023 08:59:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtn-0001b5-8P for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:23 +0000 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3771e1d0-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 09:59:17 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SwkrF1Yndz4f3lVp for ; Thu, 21 Dec 2023 16:59:09 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 72F301A0AF4 for ; Thu, 21 Dec 2023 16:59:14 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S5; Thu, 21 Dec 2023 16:59:13 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3771e1d0-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 01/17] block: add some bdev apis Date: Thu, 21 Dec 2023 16:56:56 +0800 Message-Id: <20231221085712.1766333-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S5 X-Coremail-Antispam: 1UD129KBjvJXoW3ArWxKrWfCFW8Kw1DKFyrtFb_yoWfGFWfpF WUGFy5JrWDG34IgFs2yw47ZrySgw1IyF1fJa43Jryak3yDtr9agF95KF1UArWxtrZ7Ja12 qFy2vFW8ur1j9FJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1UMIIYrx kI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v2 6r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfUOR6z UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149191855100010 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Those apis will be used for other modules, so that bd_inode won't be accessed directly from other modules. Signed-off-by: Yu Kuai --- block/bdev.c | 148 +++++++++++++++++++++++++++++++++++++++++ block/blk.h | 2 - include/linux/blkdev.h | 17 +++++ 3 files changed, 165 insertions(+), 2 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 750aec178b6a..6204621c6db6 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -89,6 +89,25 @@ void invalidate_bdev(struct block_device *bdev) } EXPORT_SYMBOL(invalidate_bdev); =20 +/** + * invalidate_bdev_pages - Invalidate clean unused buffers and pagecache. + * @bdev: the block device which holds the cache to invalidate + * @start: the offset 'from' which to invalidate + * @end: the offset 'to' which to invalidate (inclusive) + * + * This function removes pages that are clean, unmapped and unlocked, + * as well as shadow entries. It will not block on IO activity. + * + * If you want to remove all the pages of one block device, regardless of + * their use and writeback state, use truncate_bdev_range(). + */ +void invalidate_bdev_range(struct block_device *bdev, pgoff_t start, + pgoff_t end) +{ + invalidate_mapping_pages(bdev->bd_inode->i_mapping, start, end); +} +EXPORT_SYMBOL_GPL(invalidate_bdev_range); + /* * Drop all buffers & page cache for given bdev range. This function bails * with error if bdev has other exclusive owner (such as filesystem). @@ -121,6 +140,7 @@ int truncate_bdev_range(struct block_device *bdev, blk_= mode_t mode, lstart >> PAGE_SHIFT, lend >> PAGE_SHIFT); } +EXPORT_SYMBOL_GPL(truncate_bdev_range); =20 static void set_init_blocksize(struct block_device *bdev) { @@ -1102,3 +1122,131 @@ void bdev_statx_dioalign(struct inode *inode, struc= t kstat *stat) =20 blkdev_put_no_open(bdev); } + +/** + * bdev_read_folio - Read into block device page cache. + * @bdev: the block device which holds the cache to read. + * @pos: the offset that allocated folio will contain. + * + * Read one page into the block device page cache. If it succeeds, the fol= io + * returned will contain @pos; + * + * Return: Uptodate folio on success, ERR_PTR() on failure. + */ +struct folio *bdev_read_folio(struct block_device *bdev, loff_t pos) +{ + return mapping_read_folio_gfp(bdev->bd_inode->i_mapping, + pos >> PAGE_SHIFT, GFP_KERNEL); +} +EXPORT_SYMBOL_GPL(bdev_read_folio); + +/** + * bdev_get_folio - Find and get a reference to a folio. + * @bdev: the block device which holds the address_space to search. + * @pos: the offset the returned folio will contain. + * @fgp_flags: %FGP flags modify how the folio is returned. + * @gfp: Memory allocation flags to use if %FGP_CREAT is specified. + * + * Looks up the page cache entry at @bdev->bd_inode->i_mapping from @pos. = If + * this function returns a folio, it is returned with an increased refcoun= t. + * + * Return: The found folio or an ERR_PTR() otherwise. + */ +struct folio *bdev_get_folio(struct block_device *bdev, loff_t pos, + fgf_t fgp_flags, gfp_t gfp) +{ + return __filemap_get_folio(bdev->bd_inode->i_mapping, pos >> PAGE_SHIFT, + fgp_flags, gfp); +} +EXPORT_SYMBOL_GPL(bdev_get_folio); + +/** + * bdev_wb_err_check - Has block device writeback error occurred? + * @bdev: the block device to check. + * @since: Previously-sampled @bdev->bd_inode->i_mapping->wb_err. + * + * Grab @bdev->bd_inode->i_mapping->wb_err, and see if it has changed @sin= ce + * the given value was sampled. + * + * Return: The latest error or 0 if it hasn't changed. + */ +int bdev_wb_err_check(struct block_device *bdev, errseq_t since) +{ + return errseq_check(&bdev->bd_inode->i_mapping->wb_err, since); +} +EXPORT_SYMBOL_GPL(bdev_wb_err_check); + +/** + * bdev_wb_err_check_and_advance() - Check block device writeback error and + * advance to current value. + * @bdev: the block device to check; + * @since: Pointer to previously-sampled @bdev->bd_inode->i_mapping->wb_er= r to + * check against and advance. + * + * Grab @bdev->bd_inode->i_mapping->wb_err, and see whether it matches the + * value that @since points to. If it does, then just return 0; If it does= n't, + * then the value has changed. Set the "seen" flag, and try to swap it into + * place as the new eseq value. Then, set that value as the new @since val= ue, + * and return whatever the error portion is set to. + * + * Return: Negative errno if one has been stored, or 0 if no new error has + * occurred. + */ +int bdev_wb_err_check_and_advance(struct block_device *bdev, errseq_t *sin= ce) +{ + return errseq_check_and_advance(&bdev->bd_inode->i_mapping->wb_err, + since); +} +EXPORT_SYMBOL_GPL(bdev_wb_err_check_and_advance); + +/** + * bdev_balance_dirty_pages_ratelimited - balance dirty memory state. + * @bdev: the block device which was dirtied. + * + * Check the system's dirty state and will initiate writeback if needed. + */ +void bdev_balance_dirty_pages_ratelimited(struct block_device *bdev) +{ + return balance_dirty_pages_ratelimited(bdev->bd_inode->i_mapping); +} +EXPORT_SYMBOL_GPL(bdev_balance_dirty_pages_ratelimited); + +/** + * bdev_async_readahead - readahead for marked block device pages + * @bdev: the block device to read. + * @ra: file_ra_state which holds the readahead state. + * @file: Used by the filesystem for authentication. + * @index: Index of first page to be read. + * @req_count: Total number of pages being read by the caller. + * + * Read multiple pages into the block device page cache. The readahead log= ic may + * decide to piggyback more pages onto the read request if access patterns + * suggest it will improve performance. + */ +void bdev_sync_readahead(struct block_device *bdev, struct file_ra_state *= ra, + struct file *file, pgoff_t index, + unsigned long req_count) +{ + struct file_ra_state tmp_ra =3D {}; + + if (!ra) { + ra =3D &tmp_ra; + file_ra_state_init(ra, bdev->bd_inode->i_mapping); + } + page_cache_sync_readahead(bdev->bd_inode->i_mapping, ra, file, index, + req_count); +} +EXPORT_SYMBOL_GPL(bdev_sync_readahead); + +/** + * bdev_attach_wb - associate an block device with its wb + * @bdev: block device of interest + * + * If @bdev->bd_inode doesn't have its wb, associate it with the wb matchi= ng the + * %current. + */ +void bdev_attach_wb(struct block_device *bdev) +{ + inode_attach_wb(bdev->bd_inode, NULL); +} +EXPORT_SYMBOL_GPL(bdev_attach_wb); diff --git a/block/blk.h b/block/blk.h index 1ef920f72e0f..ce5fcd927eaa 100644 --- a/block/blk.h +++ b/block/blk.h @@ -465,8 +465,6 @@ extern struct device_attribute dev_attr_events_poll_mse= cs; extern struct attribute_group blk_trace_attr_group; =20 blk_mode_t file_to_blk_mode(struct file *file); -int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode, - loff_t lstart, loff_t lend); long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg); long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long ar= g); =20 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index bc236e77d85e..ccac7d32bb86 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -24,6 +24,7 @@ #include #include #include +#include =20 struct module; struct request_queue; @@ -1475,6 +1476,22 @@ struct block_device *blkdev_get_no_open(dev_t dev); void blkdev_put_no_open(struct block_device *bdev); =20 struct block_device *I_BDEV(struct inode *inode); +void invalidate_bdev_range(struct block_device *bdev, pgoff_t start, + pgoff_t end); +int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode, + loff_t lstart, loff_t lend); +struct folio *bdev_read_folio(struct block_device *bdev, loff_t pos); +struct folio *bdev_get_folio(struct block_device *bdev, loff_t pos, + fgf_t fgp_flags, gfp_t gfp); +int bdev_wb_err_check(struct block_device *bdev, errseq_t since); +int bdev_wb_err_check_and_advance(struct block_device *bdev, errseq_t *sin= ce); +void bdev_balance_dirty_pages_ratelimited(struct block_device *bdev); +void bdev_sync_readahead(struct block_device *bdev, struct file_ra_state *= ra, + struct file *file, pgoff_t index, + unsigned long req_count); +void bdev_attach_wb(struct block_device *bdev); +void bdev_associated_mapping(struct block_device *bdev, + struct address_space *mapping); =20 #ifdef CONFIG_BLOCK void invalidate_bdev(struct block_device *bdev); --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17031491849301021.8907096290883; Thu, 21 Dec 2023 00:59:44 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658602.1027856 (Exim 4.92) (envelope-from ) id 1rGEtq-00026a-Fy; Thu, 21 Dec 2023 08:59:26 +0000 Received: by outflank-mailman (output) from mailman id 658602.1027856; Thu, 21 Dec 2023 08:59:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtq-00026T-C3; Thu, 21 Dec 2023 08:59:26 +0000 Received: by outflank-mailman (input) for mailman id 658602; Thu, 21 Dec 2023 08:59:25 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtp-0001sl-Bw for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:25 +0000 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 39392637-9fdf-11ee-98eb-6d05b1d4d9a1; Thu, 21 Dec 2023 09:59:21 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SwkrL4Z7fz4f3k5m for ; Thu, 21 Dec 2023 16:59:14 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 0BD431A0AF8 for ; Thu, 21 Dec 2023 16:59:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S6; Thu, 21 Dec 2023 16:59:15 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 39392637-9fdf-11ee-98eb-6d05b1d4d9a1 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 02/17] xen/blkback: use bdev api in xen_update_blkif_status() Date: Thu, 21 Dec 2023 16:56:57 +0800 Message-Id: <20231221085712.1766333-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S6 X-Coremail-Antispam: 1UD129KBjvdXoW7XFW7tFW3Wr4xCFyrtrWfAFb_yoWfWFb_ZF 18urWxXrn7Crs0kayUuFs3Z3yv93WrurWF9ay2qFySqw1UXFWSq39FvFn5Gr47ZayUGws0 yF17uFW7tr4xXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbDAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY02 0Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWrXVW8Jr1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr 1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUHbyAU UUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149185983100001 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Avoid to access bd_inode directly, prepare to remove bd_inode from block_devcie. Signed-off-by: Yu Kuai --- drivers/block/xen-blkback/xenbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback= /xenbus.c index e34219ea2b05..e645afa4af57 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -104,8 +104,7 @@ static void xen_update_blkif_status(struct xen_blkif *b= lkif) xenbus_dev_error(blkif->be->dev, err, "block flush"); return; } - invalidate_inode_pages2( - blkif->vbd.bdev_handle->bdev->bd_inode->i_mapping); + invalidate_bdev(blkif->vbd.bdev_handle->bdev); =20 for (i =3D 0; i < blkif->nr_rings; i++) { ring =3D &blkif->rings[i]; --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 170314918893313.660618364189759; Thu, 21 Dec 2023 00:59:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658603.1027866 (Exim 4.92) (envelope-from ) id 1rGEtr-0002Mq-Oj; Thu, 21 Dec 2023 08:59:27 +0000 Received: by outflank-mailman (output) from mailman id 658603.1027866; Thu, 21 Dec 2023 08:59:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtr-0002Mf-LB; Thu, 21 Dec 2023 08:59:27 +0000 Received: by outflank-mailman (input) for mailman id 658603; Thu, 21 Dec 2023 08:59:25 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtp-0001sl-J2 for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:25 +0000 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 39e6c372-9fdf-11ee-98eb-6d05b1d4d9a1; Thu, 21 Dec 2023 09:59:21 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SwkrN2JvDz4f3kK8 for ; Thu, 21 Dec 2023 16:59:16 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id B145D1A0357 for ; Thu, 21 Dec 2023 16:59:17 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S7; Thu, 21 Dec 2023 16:59:17 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 39e6c372-9fdf-11ee-98eb-6d05b1d4d9a1 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 03/17] bcache: use bdev api in read_super() Date: Thu, 21 Dec 2023 16:56:58 +0800 Message-Id: <20231221085712.1766333-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S7 X-Coremail-Antispam: 1UD129KBjvJXoW7Ww17Zw4kZr48Xr13XF18Xwb_yoW8Jw4xpF Z7uF9xZr48Gw17u3y8Zr4DZFyrK3srKFWUKa4xCw43ua43Jw1Y9rW5J34UG34rZr18WFs2 vF4rJr4xu3WUGFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1UMIIYrx kI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v2 6r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfUojjg UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149189828100005 Content-Type: text/plain; charset="utf-8" From: Yu Kuai On the one hand covert to use folio while reading bdev inode, on the other hand prevent to access bd_inode directly. Signed-off-by: Yu Kuai --- drivers/md/bcache/super.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index bfe1685dbae5..23892b32c582 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -168,14 +168,13 @@ static const char *read_super(struct cache_sb *sb, st= ruct block_device *bdev, { const char *err; struct cache_sb_disk *s; - struct page *page; + struct folio *folio; unsigned int i; =20 - page =3D read_cache_page_gfp(bdev->bd_inode->i_mapping, - SB_OFFSET >> PAGE_SHIFT, GFP_KERNEL); - if (IS_ERR(page)) + folio =3D bdev_read_folio(bdev, SB_OFFSET); + if (IS_ERR(folio)) return "IO error"; - s =3D page_address(page) + offset_in_page(SB_OFFSET); + s =3D folio_address(folio) + offset_in_folio(folio, SB_OFFSET); =20 sb->offset =3D le64_to_cpu(s->offset); sb->version =3D le64_to_cpu(s->version); @@ -272,7 +271,7 @@ static const char *read_super(struct cache_sb *sb, stru= ct block_device *bdev, *res =3D s; return NULL; err: - put_page(page); + folio_put(folio); return err; } =20 --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17031491885701023.0909111981192; Thu, 21 Dec 2023 00:59:48 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658604.1027870 (Exim 4.92) (envelope-from ) id 1rGEts-0002QA-3P; Thu, 21 Dec 2023 08:59:28 +0000 Received: by outflank-mailman (output) from mailman id 658604.1027870; Thu, 21 Dec 2023 08:59:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtr-0002PN-Ub; Thu, 21 Dec 2023 08:59:27 +0000 Received: by outflank-mailman (input) for mailman id 658604; Thu, 21 Dec 2023 08:59:25 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtp-0001b5-Ln for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:25 +0000 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3a4e7dc5-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 09:59:22 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SwkrL08TPz4f3lWC for ; Thu, 21 Dec 2023 16:59:14 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 42F191A049B for ; Thu, 21 Dec 2023 16:59:19 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S8; Thu, 21 Dec 2023 16:59:18 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3a4e7dc5-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 04/17] mtd: block2mtd: use bdev apis Date: Thu, 21 Dec 2023 16:56:59 +0800 Message-Id: <20231221085712.1766333-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S8 X-Coremail-Antispam: 1UD129KBjvJXoW3Jw1DtryDWw17CF45XFyrZwb_yoW7Aw18pa y3Ca95Aw4UKrn8urs7Xwn8Zr12g3sFqa1Uuay7C3yakFyfXryIkas7ta45tFyrKry8AFWk XF4DAr4rXF40grJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPa14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1UMI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjfU OBTYUUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149189852100006 Content-Type: text/plain; charset="utf-8" From: Yu Kuai On the one hand covert to use folio while reading bdev inode, on the other hand prevent to access bd_inode directly. Signed-off-by: Yu Kuai --- drivers/mtd/devices/block2mtd.c | 81 +++++++++++++++------------------ 1 file changed, 36 insertions(+), 45 deletions(-) diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mt= d.c index aa44a23ec045..cf201bf73184 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -46,40 +46,34 @@ struct block2mtd_dev { /* Static info about the MTD, used in cleanup_module */ static LIST_HEAD(blkmtd_device_list); =20 - -static struct page *page_read(struct address_space *mapping, pgoff_t index) -{ - return read_mapping_page(mapping, index, NULL); -} - /* erase a specified part of the device */ static int _block2mtd_erase(struct block2mtd_dev *dev, loff_t to, size_t l= en) { - struct address_space *mapping =3D - dev->bdev_handle->bdev->bd_inode->i_mapping; - struct page *page; + struct block_device *bdev =3D dev->bdev_handle->bdev; + struct folio *folio; pgoff_t index =3D to >> PAGE_SHIFT; // page index int pages =3D len >> PAGE_SHIFT; u_long *p; u_long *max; =20 while (pages) { - page =3D page_read(mapping, index); - if (IS_ERR(page)) - return PTR_ERR(page); + folio =3D bdev_read_folio(bdev, index << PAGE_SHIFT); + if (IS_ERR(folio)) + return PTR_ERR(folio); =20 - max =3D page_address(page) + PAGE_SIZE; - for (p=3Dpage_address(page); ppriv; - struct address_space *mapping =3D - dev->bdev_handle->bdev->bd_inode->i_mapping; - struct page *page; + struct folio *folio; pgoff_t index =3D from >> PAGE_SHIFT; int offset =3D from & (PAGE_SIZE-1); int cpylen; @@ -120,12 +112,13 @@ static int block2mtd_read(struct mtd_info *mtd, loff_= t from, size_t len, cpylen =3D len; // this page len =3D len - cpylen; =20 - page =3D page_read(mapping, index); - if (IS_ERR(page)) - return PTR_ERR(page); + folio =3D bdev_read_folio(dev->bdev_handle->bdev, + index << PAGE_SHIFT); + if (IS_ERR(folio)) + return PTR_ERR(folio); =20 - memcpy(buf, page_address(page) + offset, cpylen); - put_page(page); + memcpy(buf, folio_address(folio) + offset, cpylen); + folio_put(folio); =20 if (retlen) *retlen +=3D cpylen; @@ -141,9 +134,8 @@ static int block2mtd_read(struct mtd_info *mtd, loff_t = from, size_t len, static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf, loff_t to, size_t len, size_t *retlen) { - struct page *page; - struct address_space *mapping =3D - dev->bdev_handle->bdev->bd_inode->i_mapping; + struct block_device *bdev =3D dev->bdev_handle->bdev; + struct folio *folio; pgoff_t index =3D to >> PAGE_SHIFT; // page index int offset =3D to & ~PAGE_MASK; // page offset int cpylen; @@ -155,18 +147,18 @@ static int _block2mtd_write(struct block2mtd_dev *dev= , const u_char *buf, cpylen =3D len; // this page len =3D len - cpylen; =20 - page =3D page_read(mapping, index); - if (IS_ERR(page)) - return PTR_ERR(page); + folio =3D bdev_read_folio(bdev, index << PAGE_SHIFT); + if (IS_ERR(folio)) + return PTR_ERR(folio); =20 - if (memcmp(page_address(page)+offset, buf, cpylen)) { - lock_page(page); - memcpy(page_address(page) + offset, buf, cpylen); - set_page_dirty(page); - unlock_page(page); - balance_dirty_pages_ratelimited(mapping); + if (memcmp(folio_address(folio) + offset, buf, cpylen)) { + folio_lock(folio); + memcpy(folio_address(folio) + offset, buf, cpylen); + folio_mark_dirty(folio); + folio_unlock(folio); + bdev_balance_dirty_pages_ratelimited(bdev); } - put_page(page); + folio_put(folio); =20 if (retlen) *retlen +=3D cpylen; @@ -211,8 +203,7 @@ static void block2mtd_free_device(struct block2mtd_dev = *dev) kfree(dev->mtd.name); =20 if (dev->bdev_handle) { - invalidate_mapping_pages( - dev->bdev_handle->bdev->bd_inode->i_mapping, 0, -1); + invalidate_bdev(dev->bdev_handle->bdev); bdev_release(dev->bdev_handle); } =20 @@ -295,7 +286,7 @@ static struct block2mtd_dev *add_device(char *devname, = int erase_size, goto err_free_block2mtd; } =20 - if ((long)bdev->bd_inode->i_size % erase_size) { + if (bdev_nr_bytes(bdev) % erase_size) { pr_err("erasesize must be a divisor of device size\n"); goto err_free_block2mtd; } @@ -313,7 +304,7 @@ static struct block2mtd_dev *add_device(char *devname, = int erase_size, =20 dev->mtd.name =3D name; =20 - dev->mtd.size =3D bdev->bd_inode->i_size & PAGE_MASK; + dev->mtd.size =3D bdev_nr_bytes(bdev) & PAGE_MASK; dev->mtd.erasesize =3D erase_size; dev->mtd.writesize =3D 1; dev->mtd.writebufsize =3D PAGE_SIZE; --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149198852138.74132545922134; Thu, 21 Dec 2023 00:59:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658608.1027916 (Exim 4.92) (envelope-from ) id 1rGEty-0003rQ-TW; Thu, 21 Dec 2023 08:59:34 +0000 Received: by outflank-mailman (output) from mailman id 658608.1027916; Thu, 21 Dec 2023 08:59:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEty-0003qy-O8; Thu, 21 Dec 2023 08:59:34 +0000 Received: by outflank-mailman (input) for mailman id 658608; Thu, 21 Dec 2023 08:59:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtx-0001b5-2A for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:33 +0000 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3be3eaca-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 09:59:29 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4SwkrQ0NP3z4f3l2K for ; Thu, 21 Dec 2023 16:59:18 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id D22CE1A0B3C for ; Thu, 21 Dec 2023 16:59:20 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S9; Thu, 21 Dec 2023 16:59:20 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3be3eaca-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 05/17] s390/dasd: use bdev api in dasd_format() Date: Thu, 21 Dec 2023 16:57:00 +0800 Message-Id: <20231221085712.1766333-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S9 X-Coremail-Antispam: 1UD129KBjvdXoW7XFWrKF1rWw4UAw4kXFWkWFg_yoWfWrg_Zr 1fGryxtr1xCr9Ikr1YvF15Zr9Y9F1kWr4Svry3KryfXFnrXFsaq3ykuFW3JrZ7JayUG3s3 GF9rXw10yr15WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqkFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2 IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28E F7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr 1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWrXVW8Jr1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149199833100003 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Avoid to access bd_inode directly, prepare to remove bd_inode from block_devcie. Signed-off-by: Yu Kuai --- drivers/s390/block/dasd_ioctl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioct= l.c index 61b9675e2a67..bbfb958237e6 100644 --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -221,8 +221,9 @@ dasd_format(struct dasd_block *block, struct format_dat= a_t *fdata) * enabling the device later. */ if (fdata->start_unit =3D=3D 0) { - block->gdp->part0->bd_inode->i_blkbits =3D - blksize_bits(fdata->blksize); + rc =3D set_blocksize(block->gdp->part0, fdata->blksize); + if (rc) + return rc; } =20 rc =3D base->discipline->format_device(base, fdata, 1); --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149191315604.0916477458327; Thu, 21 Dec 2023 00:59:51 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658605.1027886 (Exim 4.92) (envelope-from ) id 1rGEtu-0002x6-QH; Thu, 21 Dec 2023 08:59:30 +0000 Received: by outflank-mailman (output) from mailman id 658605.1027886; Thu, 21 Dec 2023 08:59:30 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtu-0002wr-Lc; Thu, 21 Dec 2023 08:59:30 +0000 Received: by outflank-mailman (input) for mailman id 658605; Thu, 21 Dec 2023 08:59:28 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEts-0001b5-N1 for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:28 +0000 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3c309ac2-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 09:59:25 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SwkrT0K4wz4f3kKN for ; Thu, 21 Dec 2023 16:59:21 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 6C9E61A073D for ; Thu, 21 Dec 2023 16:59:22 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S10; Thu, 21 Dec 2023 16:59:21 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3c309ac2-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 06/17] scsicam: use bdev api in scsi_bios_ptable() Date: Thu, 21 Dec 2023 16:57:01 +0800 Message-Id: <20231221085712.1766333-7-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S10 X-Coremail-Antispam: 1UD129KBjvdXoW7XFWrKrykKr43Jr15KryrCrg_yoW3urb_CF WS9ryxWr18KFs7Kwn8tF47Zryvvan8XF1I9FWSqa4Svr1UXrn5Kw4vvr17Zr47Gr4kJ3Z3 CF17XrWakrsrujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqkFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2 IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28E F7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr 1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWrXVW8Jr1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149191825100009 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Avoid to access bd_inode directly, prepare to remove bd_inode from block_devcie. Signed-off-by: Yu Kuai --- drivers/scsi/scsicam.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/scsi/scsicam.c b/drivers/scsi/scsicam.c index e2c7d8ef205f..9617d70c0ed1 100644 --- a/drivers/scsi/scsicam.c +++ b/drivers/scsi/scsicam.c @@ -32,11 +32,9 @@ */ unsigned char *scsi_bios_ptable(struct block_device *dev) { - struct address_space *mapping =3D bdev_whole(dev)->bd_inode->i_mapping; unsigned char *res =3D NULL; - struct folio *folio; + struct folio *folio =3D bdev_read_folio(bdev_whole(dev), 0); =20 - folio =3D read_mapping_folio(mapping, 0, NULL); if (IS_ERR(folio)) return NULL; =20 --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20EBF4CDE5; Thu, 21 Dec 2023 08:59:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SwkrR05mDz4f3lfZ; Thu, 21 Dec 2023 16:59:19 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 3465C1A093C; Thu, 21 Dec 2023 16:59:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S11; Thu, 21 Dec 2023 16:59:23 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 07/17] bcachefs: remove dead function bdev_sectors() Date: Thu, 21 Dec 2023 16:57:02 +0800 Message-Id: <20231221085712.1766333-8-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S11 X-Coremail-Antispam: 1UD129KBjvdXoWrZFyrKrWkuF1fAw4fZrWUurg_yoW3Wrc_KF nY9F17Ww4SqF9Y93W2qr1vvr4Y93yDXrW2gFs0v3W7G3WDArZ5ZFZ5KrW5Zrsru397uFy7 X3yxJrW29ryFkjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqkFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2 IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28E F7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr 1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWrXVW8Jr1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai bdev_sectors() is not used hence remove it. Signed-off-by: Yu Kuai Acked-by: Kent Overstreet --- fs/bcachefs/util.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index 2984b57b2958..22a0acc1704f 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -516,11 +516,6 @@ static inline unsigned fract_exp_two(unsigned x, unsig= ned fract_bits) void bch2_bio_map(struct bio *bio, void *base, size_t); int bch2_bio_alloc_pages(struct bio *, size_t, gfp_t); =20 -static inline sector_t bdev_sectors(struct block_device *bdev) -{ - return bdev->bd_inode->i_size >> 9; -} - #define closure_bio_submit(bio, cl) \ do { \ closure_get(cl); \ --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149193498910.3188542136481; Thu, 21 Dec 2023 00:59:53 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658607.1027906 (Exim 4.92) (envelope-from ) id 1rGEtx-0003YF-EW; Thu, 21 Dec 2023 08:59:33 +0000 Received: by outflank-mailman (output) from mailman id 658607.1027906; Thu, 21 Dec 2023 08:59:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtx-0003Xs-AS; Thu, 21 Dec 2023 08:59:33 +0000 Received: by outflank-mailman (input) for mailman id 658607; Thu, 21 Dec 2023 08:59:31 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtv-0001b5-QO for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:31 +0000 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3e1007a5-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 09:59:28 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4SwkrV5MJtz4f3jXY for ; Thu, 21 Dec 2023 16:59:22 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 8660E1A0B2C for ; Thu, 21 Dec 2023 16:59:25 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S12; Thu, 21 Dec 2023 16:59:25 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3e1007a5-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 08/17] bio: export bio_add_folio_nofail() Date: Thu, 21 Dec 2023 16:57:03 +0800 Message-Id: <20231221085712.1766333-9-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S12 X-Coremail-Antispam: 1UD129KBjvdXoW7Xw4rur1rtr17JFyUCF18AFb_yoW3Wrg_AF n293W8Wan7G3WSk3Wvyay8AFZYvw1rurWY9FZ3JF9xZF1DJFnak340yr40vrn5CFykKw43 u3yDXryayw47JjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbqxFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2 IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28E F7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJr0_Gc Wl84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI 8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwAC jcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka0x kIwI1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AK xVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26rWY6r4UJwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AK xVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUbmZ X7UUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149193824100014 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Currently btrfs is using __bio_add_page() in write_dev_supers(). In order to convert to use folio for bdev in btrfs, export bio_add_folio_nofail() so that it can replace __bio_add_page(). Signed-off-by: Yu Kuai --- block/bio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/bio.c b/block/bio.c index b9642a41f286..c7459839ca40 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1122,6 +1122,7 @@ void bio_add_folio_nofail(struct bio *bio, struct fol= io *folio, size_t len, WARN_ON_ONCE(off > UINT_MAX); __bio_add_page(bio, &folio->page, len, off); } +EXPORT_SYMBOL_GPL(bio_add_folio_nofail); =20 /** * bio_add_folio - Attempt to add part of a folio to a bio. --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149193242960.8809827718496; Thu, 21 Dec 2023 00:59:53 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658609.1027922 (Exim 4.92) (envelope-from ) id 1rGEtz-0003xl-Jk; Thu, 21 Dec 2023 08:59:35 +0000 Received: by outflank-mailman (output) from mailman id 658609.1027922; Thu, 21 Dec 2023 08:59:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtz-0003wl-4R; Thu, 21 Dec 2023 08:59:35 +0000 Received: by outflank-mailman (input) for mailman id 658609; Thu, 21 Dec 2023 08:59:33 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtx-0001b5-R2 for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:33 +0000 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3efc421c-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 09:59:30 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4SwkrX2HVsz4f3jsb for ; Thu, 21 Dec 2023 16:59:24 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 1E4731A0199 for ; Thu, 21 Dec 2023 16:59:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S13; Thu, 21 Dec 2023 16:59:26 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3efc421c-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 09/17] btrfs: use bdev apis Date: Thu, 21 Dec 2023 16:57:04 +0800 Message-Id: <20231221085712.1766333-10-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S13 X-Coremail-Antispam: 1UD129KBjvJXoW3WFWUur17WF47JrWfZry7Wrg_yoWfJFyDpr W7Cas5trWUJrn8Ww1kXw4kAw1Sq3sFvay8CFy3Gw4Ska45t345KF1vy34Fqa4Fkry8JFyk XF4UtFWxuF1xCF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6r xdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWrXVW8Jr1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr 0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149193856100015 Content-Type: text/plain; charset="utf-8" From: Yu Kuai On the one hand covert to use folio while reading bdev inode, on the other hand prevent to access bd_inode directly. Signed-off-by: Yu Kuai --- fs/btrfs/disk-io.c | 71 +++++++++++++++++++++------------------------- fs/btrfs/volumes.c | 17 ++++++----- fs/btrfs/zoned.c | 15 +++++----- 3 files changed, 48 insertions(+), 55 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 401ea09ae4b8..a1cfdee99a81 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3620,28 +3620,24 @@ ALLOW_ERROR_INJECTION(open_ctree, ERRNO); static void btrfs_end_super_write(struct bio *bio) { struct btrfs_device *device =3D bio->bi_private; - struct bio_vec *bvec; - struct bvec_iter_all iter_all; - struct page *page; - - bio_for_each_segment_all(bvec, bio, iter_all) { - page =3D bvec->bv_page; + struct folio_iter fi; =20 + bio_for_each_folio_all(fi, bio) { if (bio->bi_status) { btrfs_warn_rl_in_rcu(device->fs_info, "lost page write due to IO error on %s (%d)", btrfs_dev_name(device), blk_status_to_errno(bio->bi_status)); - ClearPageUptodate(page); - SetPageError(page); + folio_clear_uptodate(fi.folio); + folio_set_error(fi.folio); btrfs_dev_stat_inc_and_print(device, BTRFS_DEV_STAT_WRITE_ERRS); } else { - SetPageUptodate(page); + folio_mark_uptodate(fi.folio); } =20 - put_page(page); - unlock_page(page); + folio_put(fi.folio); + folio_unlock(fi.folio); } =20 bio_put(bio); @@ -3651,9 +3647,9 @@ struct btrfs_super_block *btrfs_read_dev_one_super(st= ruct block_device *bdev, int copy_num, bool drop_cache) { struct btrfs_super_block *super; - struct page *page; + struct folio *folio; u64 bytenr, bytenr_orig; - struct address_space *mapping =3D bdev->bd_inode->i_mapping; + unsigned int nofs_flag; int ret; =20 bytenr_orig =3D btrfs_sb_offset(copy_num); @@ -3674,16 +3670,17 @@ struct btrfs_super_block *btrfs_read_dev_one_super(= struct block_device *bdev, * Drop the page of the primary superblock, so later read will * always read from the device. */ - invalidate_inode_pages2_range(mapping, - bytenr >> PAGE_SHIFT, + invalidate_bdev_range(bdev, bytenr >> PAGE_SHIFT, (bytenr + BTRFS_SUPER_INFO_SIZE) >> PAGE_SHIFT); } =20 - page =3D read_cache_page_gfp(mapping, bytenr >> PAGE_SHIFT, GFP_NOFS); - if (IS_ERR(page)) - return ERR_CAST(page); + nofs_flag =3D memalloc_nofs_save(); + folio =3D bdev_read_folio(bdev, bytenr); + memalloc_nofs_restore(nofs_flag); + if (IS_ERR(folio)) + return ERR_CAST(folio); =20 - super =3D page_address(page); + super =3D folio_address(folio); if (btrfs_super_magic(super) !=3D BTRFS_MAGIC) { btrfs_release_disk_super(super); return ERR_PTR(-ENODATA); @@ -3740,7 +3737,6 @@ static int write_dev_supers(struct btrfs_device *devi= ce, struct btrfs_super_block *sb, int max_mirrors) { struct btrfs_fs_info *fs_info =3D device->fs_info; - struct address_space *mapping =3D device->bdev->bd_inode->i_mapping; SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); int i; int errors =3D 0; @@ -3753,7 +3749,7 @@ static int write_dev_supers(struct btrfs_device *devi= ce, shash->tfm =3D fs_info->csum_shash; =20 for (i =3D 0; i < max_mirrors; i++) { - struct page *page; + struct folio *folio; struct bio *bio; struct btrfs_super_block *disk_super; =20 @@ -3778,9 +3774,10 @@ static int write_dev_supers(struct btrfs_device *dev= ice, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE, sb->csum); =20 - page =3D find_or_create_page(mapping, bytenr >> PAGE_SHIFT, - GFP_NOFS); - if (!page) { + folio =3D bdev_get_folio(device->bdev, bytenr, + FGP_LOCK|FGP_ACCESSED|FGP_CREAT, + GFP_NOFS); + if (IS_ERR(folio)) { btrfs_err(device->fs_info, "couldn't get super block page for bytenr %llu", bytenr); @@ -3789,9 +3786,9 @@ static int write_dev_supers(struct btrfs_device *devi= ce, } =20 /* Bump the refcount for wait_dev_supers() */ - get_page(page); + folio_get(folio); =20 - disk_super =3D page_address(page); + disk_super =3D folio_address(folio); memcpy(disk_super, sb, BTRFS_SUPER_INFO_SIZE); =20 /* @@ -3805,8 +3802,8 @@ static int write_dev_supers(struct btrfs_device *devi= ce, bio->bi_iter.bi_sector =3D bytenr >> SECTOR_SHIFT; bio->bi_private =3D device; bio->bi_end_io =3D btrfs_end_super_write; - __bio_add_page(bio, page, BTRFS_SUPER_INFO_SIZE, - offset_in_page(bytenr)); + bio_add_folio_nofail(bio, folio, BTRFS_SUPER_INFO_SIZE, + offset_in_folio(folio, bytenr)); =20 /* * We FUA only the first super block. The others we allow to @@ -3842,7 +3839,7 @@ static int wait_dev_supers(struct btrfs_device *devic= e, int max_mirrors) max_mirrors =3D BTRFS_SUPER_MIRROR_MAX; =20 for (i =3D 0; i < max_mirrors; i++) { - struct page *page; + struct folio *folio; =20 ret =3D btrfs_sb_log_location(device, i, READ, &bytenr); if (ret =3D=3D -ENOENT) { @@ -3857,27 +3854,23 @@ static int wait_dev_supers(struct btrfs_device *dev= ice, int max_mirrors) device->commit_total_bytes) break; =20 - page =3D find_get_page(device->bdev->bd_inode->i_mapping, - bytenr >> PAGE_SHIFT); - if (!page) { + folio =3D bdev_get_folio(device->bdev, bytenr, 0, 0); + if (!IS_ERR(folio)) { errors++; if (i =3D=3D 0) primary_failed =3D true; continue; } /* Page is submitted locked and unlocked once the IO completes */ - wait_on_page_locked(page); - if (PageError(page)) { + folio_wait_locked(folio); + if (folio_test_error(folio)) { errors++; if (i =3D=3D 0) primary_failed =3D true; } =20 - /* Drop our reference */ - put_page(page); - - /* Drop the reference from the writing run */ - put_page(page); + /* Drop our reference and the reference from the writing run */ + folio_put_refs(folio, 2); } =20 /* log error, force error return */ diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index c6f16625af51..b3538777683c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1230,16 +1230,16 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_= devices, =20 void btrfs_release_disk_super(struct btrfs_super_block *super) { - struct page *page =3D virt_to_page(super); + struct folio *folio =3D virt_to_folio(super); =20 - put_page(page); + folio_put(folio); } =20 static struct btrfs_super_block *btrfs_read_disk_super(struct block_device= *bdev, u64 bytenr, u64 bytenr_orig) { struct btrfs_super_block *disk_super; - struct page *page; + struct folio *folio; void *p; pgoff_t index; =20 @@ -1257,15 +1257,14 @@ static struct btrfs_super_block *btrfs_read_disk_su= per(struct block_device *bdev return ERR_PTR(-EINVAL); =20 /* pull in the page with our super */ - page =3D read_cache_page_gfp(bdev->bd_inode->i_mapping, index, GFP_KERNEL= ); + folio =3D bdev_read_folio(bdev, index); + if (IS_ERR(folio)) + return ERR_CAST(folio); =20 - if (IS_ERR(page)) - return ERR_CAST(page); - - p =3D page_address(page); + p =3D folio_address(folio); =20 /* align our pointer to the offset of the super block */ - disk_super =3D p + offset_in_page(bytenr); + disk_super =3D p + offset_in_folio(folio, bytenr); =20 if (btrfs_super_bytenr(disk_super) !=3D bytenr_orig || btrfs_super_magic(disk_super) !=3D BTRFS_MAGIC) { diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 23c1e6b19a65..eb1a9a8b5959 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -120,8 +120,6 @@ static int sb_write_pointer(struct block_device *bdev, = struct blk_zone *zones, return -ENOENT; } else if (full[0] && full[1]) { /* Compare two super blocks */ - struct address_space *mapping =3D bdev->bd_inode->i_mapping; - struct page *page[BTRFS_NR_SB_LOG_ZONES]; struct btrfs_super_block *super[BTRFS_NR_SB_LOG_ZONES]; int i; =20 @@ -129,15 +127,18 @@ static int sb_write_pointer(struct block_device *bdev= , struct blk_zone *zones, u64 zone_end =3D (zones[i].start + zones[i].capacity) << SECTOR_SHIFT; u64 bytenr =3D ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) - BTRFS_SUPER_INFO_SIZE; + struct folio *folio; + unsigned int nofs_flag; =20 - page[i] =3D read_cache_page_gfp(mapping, - bytenr >> PAGE_SHIFT, GFP_NOFS); - if (IS_ERR(page[i])) { + nofs_flag =3D memalloc_nofs_save(); + folio =3D bdev_read_folio(bdev, bytenr); + memalloc_nofs_restore(nofs_flag); + if (IS_ERR(folio)) { if (i =3D=3D 1) btrfs_release_disk_super(super[0]); - return PTR_ERR(page[i]); + return PTR_ERR(folio); } - super[i] =3D page_address(page[i]); + super[i] =3D folio_address(folio); } =20 if (btrfs_super_generation(super[0]) > --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149197389844.756326732296; Thu, 21 Dec 2023 00:59:57 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658610.1027934 (Exim 4.92) (envelope-from ) id 1rGEu1-0004P9-Ae; Thu, 21 Dec 2023 08:59:37 +0000 Received: by outflank-mailman (output) from mailman id 658610.1027934; Thu, 21 Dec 2023 08:59:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEu0-0004Mx-Uk; Thu, 21 Dec 2023 08:59:36 +0000 Received: by outflank-mailman (input) for mailman id 658610; Thu, 21 Dec 2023 08:59:35 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEtz-0001sl-8M for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 08:59:35 +0000 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4074d98e-9fdf-11ee-98eb-6d05b1d4d9a1; Thu, 21 Dec 2023 09:59:33 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4SwkrY67Xjz4f3kFr for ; Thu, 21 Dec 2023 16:59:25 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id A20FA1A085F for ; Thu, 21 Dec 2023 16:59:28 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDnNw5d_oNlEQPvEA--.24929S14; Thu, 21 Dec 2023 16:59:28 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4074d98e-9fdf-11ee-98eb-6d05b1d4d9a1 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 10/17] cramfs: use bdev apis in cramfs_blkdev_read() Date: Thu, 21 Dec 2023 16:57:05 +0800 Message-Id: <20231221085712.1766333-11-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDnNw5d_oNlEQPvEA--.24929S14 X-Coremail-Antispam: 1UD129KBjvJXoW7Ww17ur1fXryfAFyrJF4fKrg_yoW8tF4UpF 1akanIkr4q9ryI9ayfXr1DZF15Ga4kXF4DCFWxu3y3Z3W5Jrna9r10kry0qFW8GrZFqryv 9r4jkryfur15Ka7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6r xdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWrXVW8Jr1lIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr1j6rxdMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JV WxJwCI42IY6I8E87Iv6xkF7I0E14v26F4UJVW0obIYCTnIWIevJa73UjIFyTuYvjfUOBTY UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149197858100001 Content-Type: text/plain; charset="utf-8" From: Yu Kuai On the one hand covert to use folio while reading bdev inode, on the other hand prevent to access bd_inode directly. Also do some cleanup that there is no need for two for loop, and remove local array pages. Signed-off-by: Yu Kuai --- fs/cramfs/inode.c | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 60dbfa0f8805..fad95d683d97 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -183,9 +183,6 @@ static int next_buffer; static void *cramfs_blkdev_read(struct super_block *sb, unsigned int offse= t, unsigned int len) { - struct address_space *mapping =3D sb->s_bdev->bd_inode->i_mapping; - struct file_ra_state ra =3D {}; - struct page *pages[BLKS_PER_BUF]; unsigned i, blocknr, buffer; unsigned long devsize; char *data; @@ -214,37 +211,30 @@ static void *cramfs_blkdev_read(struct super_block *s= b, unsigned int offset, devsize =3D bdev_nr_bytes(sb->s_bdev) >> PAGE_SHIFT; =20 /* Ok, read in BLKS_PER_BUF pages completely first. */ - file_ra_state_init(&ra, mapping); - page_cache_sync_readahead(mapping, &ra, NULL, blocknr, BLKS_PER_BUF); - - for (i =3D 0; i < BLKS_PER_BUF; i++) { - struct page *page =3D NULL; - - if (blocknr + i < devsize) { - page =3D read_mapping_page(mapping, blocknr + i, NULL); - /* synchronous error? */ - if (IS_ERR(page)) - page =3D NULL; - } - pages[i] =3D page; - } + bdev_sync_readahead(sb->s_bdev, NULL, NULL, blocknr, BLKS_PER_BUF); =20 buffer =3D next_buffer; next_buffer =3D NEXT_BUFFER(buffer); buffer_blocknr[buffer] =3D blocknr; buffer_dev[buffer] =3D sb; - data =3D read_buffers[buffer]; + for (i =3D 0; i < BLKS_PER_BUF; i++) { - struct page *page =3D pages[i]; + struct folio *folio =3D NULL; + + if (blocknr + i < devsize) + folio =3D bdev_read_folio(sb->s_bdev, + (blocknr + i) << PAGE_SHIFT); =20 - if (page) { - memcpy_from_page(data, page, 0, PAGE_SIZE); - put_page(page); - } else + if (IS_ERR_OR_NULL(folio)) { memset(data, 0, PAGE_SIZE); + } else { + memcpy_from_folio(data, folio, 0, PAGE_SIZE); + folio_put(folio); + } data +=3D PAGE_SIZE; } + return read_buffers[buffer] + offset; } =20 --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A744C208AE; Thu, 21 Dec 2023 09:00:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Swksc71JYz4f3lVY; Thu, 21 Dec 2023 17:00:20 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 2D0F41A01CA; Thu, 21 Dec 2023 17:00:26 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHlQun_oNlCxfvEA--.34192S4; Thu, 21 Dec 2023 17:00:25 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 11/17] erofs: use bdev api Date: Thu, 21 Dec 2023 16:58:26 +0800 Message-Id: <20231221085826.1768395-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgBHlQun_oNlCxfvEA--.34192S4 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFWUAF1xtr4rGr45Ww17Jrb_yoW8KF1kpr W3Cr1rGrWrXrs09wn2gr1UZF13ta97Gw48CayxJw1Fv3yUtryagFyvywnrGr48Kr4kKrs2 qF1Ivry8uw1UJrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1U MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I 0E14v26F4UJVW0owCI42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAFwI0_ Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_GcJvcSsGvfC2KfnxnUUI43ZEXa7VU1 VOJ5UUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai Avoid to access bd_inode directly, prepare to remove bd_inode from block_device. Signed-off-by: Yu Kuai --- fs/erofs/data.c | 18 ++++++++++++------ fs/erofs/internal.h | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index c98aeda8abb2..bbe2fe199bf3 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -32,8 +32,8 @@ void erofs_put_metabuf(struct erofs_buf *buf) void *erofs_bread(struct erofs_buf *buf, erofs_blk_t blkaddr, enum erofs_kmap_type type) { - struct inode *inode =3D buf->inode; - erofs_off_t offset =3D (erofs_off_t)blkaddr << inode->i_blkbits; + u8 blkszbits =3D buf->inode ? buf->inode->i_blkbits : buf->blkszbits; + erofs_off_t offset =3D (erofs_off_t)blkaddr << blkszbits; pgoff_t index =3D offset >> PAGE_SHIFT; struct page *page =3D buf->page; struct folio *folio; @@ -43,7 +43,9 @@ void *erofs_bread(struct erofs_buf *buf, erofs_blk_t blka= ddr, erofs_put_metabuf(buf); =20 nofs_flag =3D memalloc_nofs_save(); - folio =3D read_cache_folio(inode->i_mapping, index, NULL, NULL); + folio =3D buf->inode ? + read_mapping_folio(buf->inode->i_mapping, index, NULL) : + bdev_read_folio(buf->bdev, offset); memalloc_nofs_restore(nofs_flag); if (IS_ERR(folio)) return folio; @@ -67,10 +69,14 @@ void *erofs_bread(struct erofs_buf *buf, erofs_blk_t bl= kaddr, =20 void erofs_init_metabuf(struct erofs_buf *buf, struct super_block *sb) { - if (erofs_is_fscache_mode(sb)) + if (erofs_is_fscache_mode(sb)) { buf->inode =3D EROFS_SB(sb)->s_fscache->inode; - else - buf->inode =3D sb->s_bdev->bd_inode; + buf->bdev =3D NULL; + } else { + buf->inode =3D NULL; + buf->bdev =3D sb->s_bdev; + buf->blkszbits =3D EROFS_SB(sb)->blkszbits; + } } =20 void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb, diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index b0409badb017..c9206351b485 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -224,8 +224,10 @@ enum erofs_kmap_type { =20 struct erofs_buf { struct inode *inode; + struct block_device *bdev; struct page *page; void *base; + u8 blkszbits; enum erofs_kmap_type kmap_type; }; #define __EROFS_BUF_INITIALIZER ((struct erofs_buf){ .page =3D NULL }) --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E2E23B19D; Thu, 21 Dec 2023 09:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Swkss3m8Wz4f3lVt; Thu, 21 Dec 2023 17:00:33 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id B494B1A0BD7; Thu, 21 Dec 2023 17:00:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDX2Q+0_oNldxrvEA--.33944S4; Thu, 21 Dec 2023 17:00:38 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 12/17] nilfs2: use bdev api in nilfs_attach_log_writer() Date: Thu, 21 Dec 2023 16:58:39 +0800 Message-Id: <20231221085839.1768763-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgDX2Q+0_oNldxrvEA--.33944S4 X-Coremail-Antispam: 1UD129KBjvdXoWrKw1xCF4xArWfGFy7ArW3Awb_yoW3Gwc_Xr n5JrykWrWYqFZ3uw4DurZ0yryrA3W8Ka18Jry0kFyrGF4IyFZ5Cr1qvr45tayUursrXwn3 W3ZrWrZ8tr1UXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbxxFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j 6rxdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xII jxv20xvE14v26r1Y6r17McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr 1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxa n2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrV AFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWrXVW8Jr1l IxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxV AFwI0_Cr1j6rxdMIIF0xvE42xK8VAvwI8IcIk0rVW8JVW3JwCI42IY6I8E87Iv67AKxVW8 JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26F4UJVW0obIYCTnIWIevJa73UjIFyTuYvjfUoL 0eDUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai Avoid to access bd_inode directly, prepare to remove bd_inode from block_device. Signed-off-by: Yu Kuai Acked-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 55e31cc903d1..a1130e384937 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -2823,7 +2823,7 @@ int nilfs_attach_log_writer(struct super_block *sb, s= truct nilfs_root *root) if (!nilfs->ns_writer) return -ENOMEM; =20 - inode_attach_wb(nilfs->ns_bdev->bd_inode, NULL); + bdev_attach_wb(nilfs->ns_bdev); =20 err =3D nilfs_segctor_start_thread(nilfs->ns_writer); if (unlikely(err)) --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149268995391.11938953256526; Thu, 21 Dec 2023 01:01:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658643.1027966 (Exim 4.92) (envelope-from ) id 1rGEvG-000146-8M; Thu, 21 Dec 2023 09:00:54 +0000 Received: by outflank-mailman (output) from mailman id 658643.1027966; Thu, 21 Dec 2023 09:00:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEvG-00013z-54; Thu, 21 Dec 2023 09:00:54 +0000 Received: by outflank-mailman (input) for mailman id 658643; Thu, 21 Dec 2023 09:00:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEvE-0000CD-Nz for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 09:00:52 +0000 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 6df13c95-9fdf-11ee-98eb-6d05b1d4d9a1; Thu, 21 Dec 2023 10:00:50 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Swkt21gxVz4f3jsG for ; Thu, 21 Dec 2023 17:00:42 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 098E01A0A06 for ; Thu, 21 Dec 2023 17:00:45 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXpQu6_oNlNxzvEA--.33831S4; Thu, 21 Dec 2023 17:00:44 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6df13c95-9fdf-11ee-98eb-6d05b1d4d9a1 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 13/17] jbd2: use bdev apis Date: Thu, 21 Dec 2023 16:58:46 +0800 Message-Id: <20231221085846.1768977-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgBXpQu6_oNlNxzvEA--.33831S4 X-Coremail-Antispam: 1UD129KBjvJXoW7AryDWFWftF1xCw18GF4Uurg_yoW8ZFyrpr yUGas8CrZFvrW8XF1kGF4kJrWjga40vayUCFnF93Z2yw4Svr1avw18Kr13GFyYvFWFga1U Xr1jyay8Kw4YgFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1U MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I 0E14v26F4UJVW0owCI42IY6xAIw20EY4v20xvaj40_JFI_Gr1lIxAIcVC2z280aVAFwI0_ Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_GcJvcSsGvfC2KfnxnUUI43ZEXa7VUb Mq2tUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149270596100001 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Avoid to access bd_inode directly, prepare to remove bd_inode from block_device. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara --- fs/jbd2/journal.c | 3 +-- fs/jbd2/recovery.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index ed53188472f9..f1b5ffeaf02a 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2003,8 +2003,7 @@ static int __jbd2_journal_erase(journal_t *journal, u= nsigned int flags) byte_count =3D (block_stop - block_start + 1) * journal->j_blocksize; =20 - truncate_inode_pages_range(journal->j_dev->bd_inode->i_mapping, - byte_start, byte_stop); + truncate_bdev_range(journal->j_dev, 0, byte_start, byte_stop); =20 if (flags & JBD2_JOURNAL_FLUSH_DISCARD) { err =3D blkdev_issue_discard(journal->j_dev, diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index 01f744cb97a4..6b6a2c4585fa 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -290,7 +290,6 @@ int jbd2_journal_recover(journal_t *journal) =20 struct recovery_info info; errseq_t wb_err; - struct address_space *mapping; =20 memset(&info, 0, sizeof(info)); sb =3D journal->j_superblock; @@ -309,8 +308,7 @@ int jbd2_journal_recover(journal_t *journal) } =20 wb_err =3D 0; - mapping =3D journal->j_fs_dev->bd_inode->i_mapping; - errseq_check_and_advance(&mapping->wb_err, &wb_err); + bdev_wb_err_check_and_advance(journal->j_fs_dev, &wb_err); err =3D do_one_pass(journal, &info, PASS_SCAN); if (!err) err =3D do_one_pass(journal, &info, PASS_REVOKE); @@ -334,7 +332,7 @@ int jbd2_journal_recover(journal_t *journal) err2 =3D sync_blockdev(journal->j_fs_dev); if (!err) err =3D err2; - err2 =3D errseq_check_and_advance(&mapping->wb_err, &wb_err); + err2 =3D bdev_wb_err_check_and_advance(journal->j_fs_dev, &wb_err); if (!err) err =3D err2; /* Make sure all replayed data is on permanent storage */ --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149274985529.7483542955109; Thu, 21 Dec 2023 01:01:14 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658644.1027976 (Exim 4.92) (envelope-from ) id 1rGEvM-0001XJ-Gc; Thu, 21 Dec 2023 09:01:00 +0000 Received: by outflank-mailman (output) from mailman id 658644.1027976; Thu, 21 Dec 2023 09:01:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEvM-0001XC-Cn; Thu, 21 Dec 2023 09:01:00 +0000 Received: by outflank-mailman (input) for mailman id 658644; Thu, 21 Dec 2023 09:00:58 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEvK-0000Xx-GD for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 09:00:58 +0000 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 71b129bd-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 10:00:55 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Swkt92zB1z4f3jrr for ; Thu, 21 Dec 2023 17:00:49 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 3822F1A0486 for ; Thu, 21 Dec 2023 17:00:52 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCn9QvB_oNlLR7vEA--.33384S4; Thu, 21 Dec 2023 17:00:51 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 71b129bd-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 14/17] buffer: add a new helper to read sb block Date: Thu, 21 Dec 2023 16:58:53 +0800 Message-Id: <20231221085853.1770062-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgCn9QvB_oNlLR7vEA--.33384S4 X-Coremail-Antispam: 1UD129KBjvJXoW3AFyUCF4kKryrJrW3trWrXwb_yoW7Ww13pr 98Kay3trWDKFyaqF1xtwn8Jr13t3Z2v3W8CayfJ3s3ArWUGrn3XF9rGr129FWFyr9rXry5 XFW5CrWfCr1UWFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1U MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I 0E14v26F4UJVW0owCI42IY6xAIw20EY4v20xvaj40_JFI_Gr1lIxAIcVC2z280aVAFwI0_ Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_GcJvcSsGvfC2KfnxnUUI43ZEXa7VUb ZNVDUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149276500100001 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Unlike __bread_gfp(), ext4 has special handing while reading sb block: 1) __GFP_NOFAIL is not set, and memory allocation can fail; 2) If buffer write failed before, set buffer uptodate and don't read block from disk; 3) REQ_META is set for all IO, and REQ_PRIO is set for reading xattr; 4) If failed, return error ptr instead of NULL; This patch add a new helper __bread_gfp2() that will match above 2 and 3( 1 will be used, and 4 will still be encapsulated by ext4), and prepare to prevent calling mapping_gfp_constraint() directly on bd_inode->i_mapping in ext4. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara --- fs/buffer.c | 68 ++++++++++++++++++++++++++----------- include/linux/buffer_head.h | 18 +++++++++- 2 files changed, 65 insertions(+), 21 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 967f34b70aa8..188bd36c9fea 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -1255,16 +1255,19 @@ void __bforget(struct buffer_head *bh) } EXPORT_SYMBOL(__bforget); =20 -static struct buffer_head *__bread_slow(struct buffer_head *bh) +static struct buffer_head *__bread_slow(struct buffer_head *bh, + blk_opf_t op_flags, + bool check_write_error) { lock_buffer(bh); - if (buffer_uptodate(bh)) { + if (buffer_uptodate(bh) || + (check_write_error && buffer_uptodate_or_error(bh))) { unlock_buffer(bh); return bh; } else { get_bh(bh); bh->b_end_io =3D end_buffer_read_sync; - submit_bh(REQ_OP_READ, bh); + submit_bh(REQ_OP_READ | op_flags, bh); wait_on_buffer(bh); if (buffer_uptodate(bh)) return bh; @@ -1445,6 +1448,31 @@ void __breadahead(struct block_device *bdev, sector_= t block, unsigned size) } EXPORT_SYMBOL(__breadahead); =20 +static struct buffer_head * +bread_gfp(struct block_device *bdev, sector_t block, unsigned int size, + blk_opf_t op_flags, gfp_t gfp, bool check_write_error) +{ + struct buffer_head *bh; + + gfp |=3D mapping_gfp_constraint(bdev->bd_inode->i_mapping, ~__GFP_FS); + + /* + * Prefer looping in the allocator rather than here, at least that + * code knows what it's doing. + */ + gfp |=3D __GFP_NOFAIL; + + bh =3D bdev_getblk(bdev, block, size, gfp); + if (unlikely(!bh)) + return NULL; + + if (buffer_uptodate(bh) || + (check_write_error && buffer_uptodate_or_error(bh))) + return bh; + + return __bread_slow(bh, op_flags, check_write_error); +} + /** * __bread_gfp() - reads a specified block and returns the bh * @bdev: the block_device to read from @@ -1458,27 +1486,27 @@ EXPORT_SYMBOL(__breadahead); * It returns NULL if the block was unreadable. */ struct buffer_head * -__bread_gfp(struct block_device *bdev, sector_t block, - unsigned size, gfp_t gfp) +__bread_gfp(struct block_device *bdev, sector_t block, unsigned int size, + gfp_t gfp) { - struct buffer_head *bh; - - gfp |=3D mapping_gfp_constraint(bdev->bd_inode->i_mapping, ~__GFP_FS); - - /* - * Prefer looping in the allocator rather than here, at least that - * code knows what it's doing. - */ - gfp |=3D __GFP_NOFAIL; - - bh =3D bdev_getblk(bdev, block, size, gfp); - - if (likely(bh) && !buffer_uptodate(bh)) - bh =3D __bread_slow(bh); - return bh; + return bread_gfp(bdev, block, size, 0, gfp, false); } EXPORT_SYMBOL(__bread_gfp); =20 +/* + * This works like __bread_gfp() except: + * 1) If buffer write failed before, set buffer uptodate and don't read + * block from disk; + * 2) Caller can pass in additional op_flags like REQ_META; + */ +struct buffer_head * +__bread_gfp2(struct block_device *bdev, sector_t block, unsigned int size, + blk_opf_t op_flags, gfp_t gfp) +{ + return bread_gfp(bdev, block, size, op_flags, gfp, true); +} +EXPORT_SYMBOL(__bread_gfp2); + static void __invalidate_bh_lrus(struct bh_lru *b) { int i; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 5f23ee599889..751b2744b4ae 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -171,6 +171,18 @@ static __always_inline int buffer_uptodate(const struc= t buffer_head *bh) return test_bit_acquire(BH_Uptodate, &bh->b_state); } =20 +static __always_inline int buffer_uptodate_or_error(struct buffer_head *bh) +{ + /* + * If the buffer has the write error flag, data was failed to write + * out in the block. In this case, set buffer uptodate to prevent + * reading old data. + */ + if (buffer_write_io_error(bh)) + set_buffer_uptodate(bh); + return buffer_uptodate(bh); +} + static inline unsigned long bh_offset(const struct buffer_head *bh) { return (unsigned long)(bh)->b_data & (page_size(bh->b_page) - 1); @@ -231,7 +243,11 @@ void __brelse(struct buffer_head *); void __bforget(struct buffer_head *); void __breadahead(struct block_device *, sector_t block, unsigned int size= ); struct buffer_head *__bread_gfp(struct block_device *, - sector_t block, unsigned size, gfp_t gfp); + sector_t block, unsigned int size, gfp_t gfp); +struct buffer_head *__bread_gfp2(struct block_device *bdev, sector_t block, + unsigned int size, blk_opf_t op_flags, + gfp_t gfp); + struct buffer_head *alloc_buffer_head(gfp_t gfp_flags); void free_buffer_head(struct buffer_head * bh); void unlock_buffer(struct buffer_head *bh); --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149284425713.5136676354706; Thu, 21 Dec 2023 01:01:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658647.1027986 (Exim 4.92) (envelope-from ) id 1rGEvR-0001zH-VK; Thu, 21 Dec 2023 09:01:05 +0000 Received: by outflank-mailman (output) from mailman id 658647.1027986; Thu, 21 Dec 2023 09:01:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEvR-0001z9-SV; Thu, 21 Dec 2023 09:01:05 +0000 Received: by outflank-mailman (input) for mailman id 658647; Thu, 21 Dec 2023 09:01:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEvR-0000Xx-Dj for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 09:01:05 +0000 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 756eb98d-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 10:01:01 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4SwktF1kylz4f3lDS for ; Thu, 21 Dec 2023 17:00:53 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 782201A09C5 for ; Thu, 21 Dec 2023 17:00:58 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgA3OhDH_oNl4h_vEA--.34329S4; Thu, 21 Dec 2023 17:00:57 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 756eb98d-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 15/17] ext4: use new helper to read sb block Date: Thu, 21 Dec 2023 16:58:59 +0800 Message-Id: <20231221085859.1772154-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgA3OhDH_oNl4h_vEA--.34329S4 X-Coremail-Antispam: 1UD129KBjvJXoWxtr4kKw17tFyDGFW3Zry5Jwb_yoW7Cr17pa sIka9FkryvqFn09a1xKr13tw1Yy3Z2ga1UGayfC34furyqqrn3Xa48tF1I9FWrArZxXry5 XF1jkryrCr18CFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1U MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I 0E14v26F4UJVW0owCI42IY6xAIw20EY4v20xvaj40_JFI_Gr1lIxAIcVC2z280aVAFwI0_ Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_GcJvcSsGvfC2KfnxnUUI43ZEXa7VUb ZNVDUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149286650100001 Content-Type: text/plain; charset="utf-8" From: Yu Kuai Remove __ext4_sb_bread_gfp() and ext4_buffer_uptodate() that is defined by ext4, and convert to use common helper __bread_gfp2() and buffer_uptodate_or_error(). Signed-off-by: Yu Kuai Reviewed-by: Jan Kara --- fs/ext4/ext4.h | 13 ------------- fs/ext4/inode.c | 8 ++++---- fs/ext4/super.c | 45 ++++++++++----------------------------------- fs/ext4/symlink.c | 2 +- 4 files changed, 15 insertions(+), 53 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index a5d784872303..8377f6c5264f 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3824,19 +3824,6 @@ extern const struct iomap_ops ext4_iomap_ops; extern const struct iomap_ops ext4_iomap_overwrite_ops; extern const struct iomap_ops ext4_iomap_report_ops; =20 -static inline int ext4_buffer_uptodate(struct buffer_head *bh) -{ - /* - * If the buffer has the write error flag, we have failed - * to write out data in the block. In this case, we don't - * have to read the block because we may read the old data - * successfully. - */ - if (buffer_write_io_error(bh)) - set_buffer_uptodate(bh); - return buffer_uptodate(bh); -} - #endif /* __KERNEL__ */ =20 #define EFSBADCRC EBADMSG /* Bad CRC detected */ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 61277f7f8722..efb0af6f02f7 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -887,7 +887,7 @@ struct buffer_head *ext4_bread(handle_t *handle, struct= inode *inode, bh =3D ext4_getblk(handle, inode, block, map_flags); if (IS_ERR(bh)) return bh; - if (!bh || ext4_buffer_uptodate(bh)) + if (!bh || buffer_uptodate_or_error(bh)) return bh; =20 ret =3D ext4_read_bh_lock(bh, REQ_META | REQ_PRIO, true); @@ -915,7 +915,7 @@ int ext4_bread_batch(struct inode *inode, ext4_lblk_t b= lock, int bh_count, =20 for (i =3D 0; i < bh_count; i++) /* Note that NULL bhs[i] is valid because of holes. */ - if (bhs[i] && !ext4_buffer_uptodate(bhs[i])) + if (bhs[i] && !buffer_uptodate_or_error(bhs[i])) ext4_read_bh_lock(bhs[i], REQ_META | REQ_PRIO, false); =20 if (!wait) @@ -4392,11 +4392,11 @@ static int __ext4_get_inode_loc(struct super_block = *sb, unsigned long ino, bh =3D sb_getblk(sb, block); if (unlikely(!bh)) return -ENOMEM; - if (ext4_buffer_uptodate(bh)) + if (buffer_uptodate_or_error(bh)) goto has_buffer; =20 lock_buffer(bh); - if (ext4_buffer_uptodate(bh)) { + if (buffer_uptodate_or_error(bh)) { /* Someone brought it uptodate while we waited */ unlock_buffer(bh); goto has_buffer; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c5fcf377ab1f..3f07eaa33332 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -180,7 +180,7 @@ void ext4_read_bh_nowait(struct buffer_head *bh, blk_op= f_t op_flags, { BUG_ON(!buffer_locked(bh)); =20 - if (ext4_buffer_uptodate(bh)) { + if (buffer_uptodate_or_error(bh)) { unlock_buffer(bh); return; } @@ -191,7 +191,7 @@ int ext4_read_bh(struct buffer_head *bh, blk_opf_t op_f= lags, bh_end_io_t *end_io { BUG_ON(!buffer_locked(bh)); =20 - if (ext4_buffer_uptodate(bh)) { + if (buffer_uptodate_or_error(bh)) { unlock_buffer(bh); return 0; } @@ -214,49 +214,24 @@ int ext4_read_bh_lock(struct buffer_head *bh, blk_opf= _t op_flags, bool wait) return ext4_read_bh(bh, op_flags, NULL); } =20 -/* - * This works like __bread_gfp() except it uses ERR_PTR for error - * returns. Currently with sb_bread it's impossible to distinguish - * between ENOMEM and EIO situations (since both result in a NULL - * return. - */ -static struct buffer_head *__ext4_sb_bread_gfp(struct super_block *sb, - sector_t block, - blk_opf_t op_flags, gfp_t gfp) -{ - struct buffer_head *bh; - int ret; - - bh =3D sb_getblk_gfp(sb, block, gfp); - if (bh =3D=3D NULL) - return ERR_PTR(-ENOMEM); - if (ext4_buffer_uptodate(bh)) - return bh; - - ret =3D ext4_read_bh_lock(bh, REQ_META | op_flags, true); - if (ret) { - put_bh(bh); - return ERR_PTR(ret); - } - return bh; -} - struct buffer_head *ext4_sb_bread(struct super_block *sb, sector_t block, blk_opf_t op_flags) { - gfp_t gfp =3D mapping_gfp_constraint(sb->s_bdev->bd_inode->i_mapping, - ~__GFP_FS) | __GFP_MOVABLE; + struct buffer_head *bh =3D __bread_gfp2(sb->s_bdev, block, + sb->s_blocksize, + REQ_META | op_flags, + __GFP_MOVABLE); =20 - return __ext4_sb_bread_gfp(sb, block, op_flags, gfp); + return bh ? bh : ERR_PTR(-EIO); } =20 struct buffer_head *ext4_sb_bread_unmovable(struct super_block *sb, sector_t block) { - gfp_t gfp =3D mapping_gfp_constraint(sb->s_bdev->bd_inode->i_mapping, - ~__GFP_FS); + struct buffer_head *bh =3D __bread_gfp2(sb->s_bdev, block, + sb->s_blocksize, REQ_META, 0); =20 - return __ext4_sb_bread_gfp(sb, block, 0, gfp); + return bh ? bh : ERR_PTR(-EIO); } =20 void ext4_sb_breadahead_unmovable(struct super_block *sb, sector_t block) diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c index 75bf1f88843c..49e918221aac 100644 --- a/fs/ext4/symlink.c +++ b/fs/ext4/symlink.c @@ -94,7 +94,7 @@ static const char *ext4_get_link(struct dentry *dentry, s= truct inode *inode, bh =3D ext4_getblk(NULL, inode, 0, EXT4_GET_BLOCKS_CACHED_NOWAIT); if (IS_ERR(bh)) return ERR_CAST(bh); - if (!bh || !ext4_buffer_uptodate(bh)) + if (!bh || !buffer_uptodate_or_error(bh)) return ERR_PTR(-ECHILD); } else { bh =3D ext4_bread(NULL, inode, 0, 0); --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1703149286460652.053038892392; Thu, 21 Dec 2023 01:01:26 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.658652.1027995 (Exim 4.92) (envelope-from ) id 1rGEva-0002XZ-89; Thu, 21 Dec 2023 09:01:14 +0000 Received: by outflank-mailman (output) from mailman id 658652.1027995; Thu, 21 Dec 2023 09:01:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEva-0002XQ-5E; Thu, 21 Dec 2023 09:01:14 +0000 Received: by outflank-mailman (input) for mailman id 658652; Thu, 21 Dec 2023 09:01:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rGEvY-0000Xx-SO for xen-devel@lists.xenproject.org; Thu, 21 Dec 2023 09:01:12 +0000 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7a56793f-9fdf-11ee-9b0f-b553b5be7939; Thu, 21 Dec 2023 10:01:09 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4SwktR6hMRz4f3kFY for ; Thu, 21 Dec 2023 17:01:03 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id B70801A0B8F for ; Thu, 21 Dec 2023 17:01:06 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgC3BQzQ_oNlHiLvEA--.34070S4; Thu, 21 Dec 2023 17:01:06 +0800 (CST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7a56793f-9fdf-11ee-9b0f-b553b5be7939 From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 16/17] ext4: remove block_device_ejected() Date: Thu, 21 Dec 2023 16:59:07 +0800 Message-Id: <20231221085907.1772856-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgC3BQzQ_oNlHiLvEA--.34070S4 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr4UGw1xJF1fWr48KFy3urg_yoW8tF1Up3 yfuw1fJrW8Zr1I9ayxJr4xW3y0qa92ya40gFyI9r1Fgr1xJ340qF4ktr1Iya4YvrZ3uw1F qF1UCrWxCr18CrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1U MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I 0E14v26F4UJVW0owCI42IY6xAIw20EY4v20xvaj40_JFI_Gr1lIxAIcVC2z280aVAFwI0_ Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_GcJvcSsGvfC2KfnxnUUI43ZEXa7VUb ZNVDUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-ZM-MESSAGEID: 1703149288750100003 Content-Type: text/plain; charset="utf-8" From: Yu Kuai block_device_ejected() is added by commit bdfe0cbd746a ("Revert "ext4: remove block_device_ejected"") in 2015. At that time 'bdi->wb' is destroyed synchronized from del_gendisk(), hence if ext4 is still mounted, and then mark_buffer_dirty() will reference destroyed 'wb'. However, such problem doesn't exist anymore: - commit d03f6cdc1fc4 ("block: Dynamically allocate and refcount backing_dev_info") switch bdi to use refcounting; - commit 13eec2363ef0 ("fs: Get proper reference for s_bdi"), will grab additional reference of bdi while mounting, so that 'bdi->wb' will not be destroyed until generic_shutdown_super(). Hence remove this dead function block_device_ejected(). Signed-off-by: Yu Kuai Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/ext4/super.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 3f07eaa33332..a7935edbd7b1 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -467,22 +467,6 @@ static void ext4_maybe_update_superblock(struct super_= block *sb) schedule_work(&EXT4_SB(sb)->s_sb_upd_work); } =20 -/* - * The del_gendisk() function uninitializes the disk-specific data - * structures, including the bdi structure, without telling anyone - * else. Once this happens, any attempt to call mark_buffer_dirty() - * (for example, by ext4_commit_super), will cause a kernel OOPS. - * This is a kludge to prevent these oops until we can put in a proper - * hook in del_gendisk() to inform the VFS and file system layers. - */ -static int block_device_ejected(struct super_block *sb) -{ - struct inode *bd_inode =3D sb->s_bdev->bd_inode; - struct backing_dev_info *bdi =3D inode_to_bdi(bd_inode); - - return bdi->dev =3D=3D NULL; -} - static void ext4_journal_commit_callback(journal_t *journal, transaction_t= *txn) { struct super_block *sb =3D journal->j_private; @@ -6162,8 +6146,6 @@ static int ext4_commit_super(struct super_block *sb) =20 if (!sbh) return -EINVAL; - if (block_device_ejected(sb)) - return -ENODEV; =20 ext4_update_super(sb); =20 --=20 2.39.2 From nobody Sun May 12 08:59:04 2024 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ECA652F8F; Thu, 21 Dec 2023 09:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4SwktZ3FrTz4f3kG7; Thu, 21 Dec 2023 17:01:10 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 34EB21A0920; Thu, 21 Dec 2023 17:01:13 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgCXmhDW_oNlyCPvEA--.34448S4; Thu, 21 Dec 2023 17:01:12 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, roger.pau@citrix.com, colyli@suse.de, kent.overstreet@gmail.com, joern@lazybastard.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sth@linux.ibm.com, hoeppner@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, jejb@linux.ibm.com, martin.petersen@oracle.com, clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, viro@zeniv.linux.org.uk, brauner@kernel.org, nico@fluxnic.net, xiang@kernel.org, chao@kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, hare@suse.de, p.raghav@samsung.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-bcache@vger.kernel.org, linux-mtd@lists.infradead.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-nilfs@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v3 for-6.8/block 17/17] ext4: use bdev apis Date: Thu, 21 Dec 2023 16:59:14 +0800 Message-Id: <20231221085914.1772988-1-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231221085712.1766333-1-yukuai1@huaweicloud.com> References: <20231221085712.1766333-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: cCh0CgCXmhDW_oNlyCPvEA--.34448S4 X-Coremail-Antispam: 1UD129KBjvJXoWxAF47JryfCw48Xw1Duw48JFb_yoW5Xw4Upa 43GFyDGr4DZry09anrGFsrZa40kw18Ga43GryfZ3W2qrWaq34SkF95KF1xZF4UXay8Xw18 XFyjkryxAr45CrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUv014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F4U JVW0owA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628v n2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F4 0E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Wrv_Gr1U MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I 0E14v26F4UJVW0owCI42IY6xAIw20EY4v20xvaj40_JFI_Gr1lIxAIcVC2z280aVAFwI0_ Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_GcJvcSsGvfC2KfnxnUUI43ZEXa7VUb YLvtUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ Content-Type: text/plain; charset="utf-8" From: Yu Kuai Avoid to access bd_inode directly, prepare to remove bd_inode from block_device. Signed-off-by: Yu Kuai Reviewed-by: Jan Kara --- fs/ext4/dir.c | 6 ++---- fs/ext4/ext4_jbd2.c | 6 +++--- fs/ext4/super.c | 3 +-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 3985f8c33f95..64e35eb6a324 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c @@ -191,10 +191,8 @@ static int ext4_readdir(struct file *file, struct dir_= context *ctx) pgoff_t index =3D map.m_pblk >> (PAGE_SHIFT - inode->i_blkbits); if (!ra_has_index(&file->f_ra, index)) - page_cache_sync_readahead( - sb->s_bdev->bd_inode->i_mapping, - &file->f_ra, file, - index, 1); + bdev_sync_readahead(sb->s_bdev, &file->f_ra, + file, index, 1); file->f_ra.prev_pos =3D (loff_t)index << PAGE_SHIFT; bh =3D ext4_bread(NULL, inode, map.m_lblk, 0); if (IS_ERR(bh)) { diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c index d1a2e6624401..c1bf3a00fad9 100644 --- a/fs/ext4/ext4_jbd2.c +++ b/fs/ext4/ext4_jbd2.c @@ -206,7 +206,6 @@ static void ext4_journal_abort_handle(const char *calle= r, unsigned int line, =20 static void ext4_check_bdev_write_error(struct super_block *sb) { - struct address_space *mapping =3D sb->s_bdev->bd_inode->i_mapping; struct ext4_sb_info *sbi =3D EXT4_SB(sb); int err; =20 @@ -216,9 +215,10 @@ static void ext4_check_bdev_write_error(struct super_b= lock *sb) * we could read old data from disk and write it out again, which * may lead to on-disk filesystem inconsistency. */ - if (errseq_check(&mapping->wb_err, READ_ONCE(sbi->s_bdev_wb_err))) { + if (bdev_wb_err_check(sb->s_bdev, READ_ONCE(sbi->s_bdev_wb_err))) { spin_lock(&sbi->s_bdev_wb_lock); - err =3D errseq_check_and_advance(&mapping->wb_err, &sbi->s_bdev_wb_err); + err =3D bdev_wb_err_check_and_advance(sb->s_bdev, + &sbi->s_bdev_wb_err); spin_unlock(&sbi->s_bdev_wb_lock); if (err) ext4_error_err(sb, -err, diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a7935edbd7b1..25c3d2ac8559 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5544,8 +5544,7 @@ static int __ext4_fill_super(struct fs_context *fc, s= truct super_block *sb) * used to detect the metadata async write error. */ spin_lock_init(&sbi->s_bdev_wb_lock); - errseq_check_and_advance(&sb->s_bdev->bd_inode->i_mapping->wb_err, - &sbi->s_bdev_wb_err); + bdev_wb_err_check_and_advance(sb->s_bdev, &sbi->s_bdev_wb_err); EXT4_SB(sb)->s_mount_state |=3D EXT4_ORPHAN_FS; ext4_orphan_cleanup(sb, es); EXT4_SB(sb)->s_mount_state &=3D ~EXT4_ORPHAN_FS; --=20 2.39.2