Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp15002rdb; Thu, 21 Dec 2023 01:05:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQm9zp+fwkO4B7OO1vafn6LJXQ/aNzDdvfpQAbhTnfUnV+HoADCakUsFsE0y4R3DiviAEK X-Received: by 2002:a25:db88:0:b0:dbd:ae7d:ce7c with SMTP id g130-20020a25db88000000b00dbdae7dce7cmr927178ybf.67.1703149556822; Thu, 21 Dec 2023 01:05:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703149556; cv=none; d=google.com; s=arc-20160816; b=LwRlLUWc6klbeWfx62hUVpB6Siw7SOVJKiBOVq+I+K2UOi3MWaJPjdz3i7djM+Ws+D mCohRoFxjK9V58KUr49AqCquC1jkz2QZv6h4/0yZGRZYNIw7kY/xdWmv/aNVPcgSLZwr R8ncIf812TuxhDO5BSG0EIj9CATrtC+d0KyFsezgVPtHp2GizkL1M9TQ+JHRuLF2Rm6i AqizY52EZPaDythapigKSX6094OIB3UNxYfqzam7qMyAD4OCnQD1z+vqk/w8++pts34C mXMy/UwJ76XCfZVvbjesx6IDooaAGrhgPCEWJBaY6TBoJ+QNG/XQtv079lDlvpAy1yvs XdQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=jgu3KMjXFsgMJ0qiJPYReVuVFLGz/OPlcCuNB2zzsLc=; fh=ra0zcfFNH7JWn2tyKhchpyMoSpFA+1HuRrgbaLqrjLs=; b=KfO2idSkpB1YFqpvoE32Jpyu9k9wEBY1ut556XH/V59SCxP8jPTPNNODRiwcnm02yg 4jwAlf7Vgkp4caCs+BUDrLc5bdsTo20YZZS8yiuJ0mMJEv5ed9SzfWGm0KMO6gVK/7wt w+Wv7Pn7lvTwa7L+1huh9e+uregl7HvhLpKmuzkffrwoga1ey/i6ahyBA6LhsaDXwX/K TWFhPYGN9wUh6xB/gCpgkd6myQRtUyxL8Qbbo9AhQbpeQqwWnB9D7uZGDBomasgjMhxQ CYYavdpiZ6O9wi2ULaIQWNk0Dry2NA/H7IAgMyFJagKW616Rzyn5Q5nLERitXv2MxQjU JiWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-524-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t22-20020a05622a149600b004258446cd7asi1721782qtx.117.2023.12.21.01.05.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 01:05:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-ext4+bounces-524-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B05FD1C23910 for ; Thu, 21 Dec 2023 09:05:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8CC35224C2; Thu, 21 Dec 2023 09:00:31 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org 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-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/ 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 = buf->inode; - erofs_off_t offset = (erofs_off_t)blkaddr << inode->i_blkbits; + u8 blkszbits = buf->inode ? buf->inode->i_blkbits : buf->blkszbits; + erofs_off_t offset = (erofs_off_t)blkaddr << blkszbits; pgoff_t index = offset >> PAGE_SHIFT; struct page *page = buf->page; struct folio *folio; @@ -43,7 +43,9 @@ void *erofs_bread(struct erofs_buf *buf, erofs_blk_t blkaddr, erofs_put_metabuf(buf); nofs_flag = memalloc_nofs_save(); - folio = read_cache_folio(inode->i_mapping, index, NULL, NULL); + folio = 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 blkaddr, 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 = EROFS_SB(sb)->s_fscache->inode; - else - buf->inode = sb->s_bdev->bd_inode; + buf->bdev = NULL; + } else { + buf->inode = NULL; + buf->bdev = sb->s_bdev; + buf->blkszbits = EROFS_SB(sb)->blkszbits; + } } 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 { 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 = NULL }) -- 2.39.2