Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4456480rdb; Mon, 11 Dec 2023 22:49:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlVCMXx/ok+FFA1ywtUCGQCCh+XBxpjfdx1KlY4SB11M+GkoNeTVZPXPV5wIyK6epzkhI6 X-Received: by 2002:a05:6870:390d:b0:1fb:75a:de61 with SMTP id b13-20020a056870390d00b001fb075ade61mr6549989oap.79.1702363797674; Mon, 11 Dec 2023 22:49:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702363797; cv=none; d=google.com; s=arc-20160816; b=JotfO1y34kQeGglm/ZQlxqsk5KmOiqNFmyIHXM0l7gi1Co26g+Lgx9gq2patTkmozO U634TsyMW6q0JYKCwSbZEdu7sQ99MK+7e0lzG8mpugO8rDypVvpbkO1QVGOQry9FFA1l rxBB6DiVOZ52bP7zUPi8CRfVgzaEB5oQXEkLA8pXSzxPzK0gtBum8A6Gnrrv9KJbj/fc yJ7rsEtnXlLm6v4B0KQYr0XvwvH9vJu5PRxpRlS3M2cMgc+2N1MK7K9gRlSEmOsABLla ED514O3vB0p7pgAk9mmutbaqTLoYqoekzh9KiYbxATqAcqDsxy0M524R7u9zhXokm6h2 aOXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=vGu3uyKFADbLsmuZP9hTZyy/RE2lDwlk6656UAm5uE8=; fh=Z+qSK29IQDEA3ymGY7EBUs2+aJSHk6AcTHLF9lnpbQE=; b=mQs0gOCOaxPzrUmkOuQCy0jLnKtnAQPxFgxNi40nhzrIqoCduWND2wRRnYwwKq4yxt dpvIb1J5KLDb68bdeAhIBQMXlDdv88iyWB7loz34UYk98w5WDPzjXl8TyubVVBkrMPrV BrsUv7SDG9TJ2rh/Xwk+v9rLyiAfRr/q3FmI/0WCDlFNo735H9SWJwgv04KaafnixSvo f1QIG0x8PWD838nH5N2DnWvS07hgtNzGd4EQoNL3x6IdRi4hW+Qi5SCOuIfKdFh9i4uB Ef/6go/F0un3lqlcsJYzXTQccRCwerhoQDAkxCiJrSG0aIeOOUFCliBrOLfDdJj5OTcd S6pQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o13-20020a65614d000000b005bdf5961646si7107396pgv.268.2023.12.11.22.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 22:49:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 4D6F3806AFF9; Mon, 11 Dec 2023 22:49:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbjLLGtm (ORCPT + 99 others); Tue, 12 Dec 2023 01:49:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjLLGtl (ORCPT ); Tue, 12 Dec 2023 01:49:41 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6DCCB; Mon, 11 Dec 2023 22:49:46 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Sq8P22Bmcz4f3jHd; Tue, 12 Dec 2023 14:49:42 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 747D91A0BD2; Tue, 12 Dec 2023 14:49:43 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP1 (Coremail) with SMTP id cCh0CgCnqxGDAnhl4n6yDQ--.9546S3; Tue, 12 Dec 2023 14:49:42 +0800 (CST) Subject: Re: [PATCH RFC v2 for-6.8/block 11/18] erofs: use bdev api To: Gao Xiang , Yu Kuai , 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, agruenba@redhat.com, jack@suse.com, konishi.ryusuke@gmail.com, willy@infradead.org, akpm@linux-foundation.org, p.raghav@samsung.com, hare@suse.de 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, gfs2@lists.linux.dev, linux-nilfs@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, "yukuai (C)" References: <20231211140552.973290-1-yukuai1@huaweicloud.com> <20231211140722.974745-1-yukuai1@huaweicloud.com> <1812c1bf-08b5-46a5-a633-12470e2c8f18@linux.alibaba.com> From: Yu Kuai Message-ID: <7465ebce-1290-e258-13cf-146fa4fd6302@huaweicloud.com> Date: Tue, 12 Dec 2023 14:49:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1812c1bf-08b5-46a5-a633-12470e2c8f18@linux.alibaba.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgCnqxGDAnhl4n6yDQ--.9546S3 X-Coremail-Antispam: 1UD129KBjvJXoWxJw45Jr1kGFWxtFWfXFyUtrb_yoW5Kw4fpF ykAFy8GrWrJrn5ur1xXr1UZFy5t397Ja18Cw4xX3WFvw4UJr10gFy0qr1qgF1UKr4kGr40 qr1Ivr97ur1UJrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9a14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_Wrv_Gr1UMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF 4lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw20EY4v20xvaj40_WFyU JVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJr UvcSsGvfC2KfnxnUUI43ZEXa7VUbJ73DUUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 11 Dec 2023 22:49:55 -0800 (PST) Hi, 在 2023/12/12 14:35, Gao Xiang 写道: > > > On 2023/12/11 22:07, Yu Kuai wrote: >> From: Yu Kuai >> >> Avoid to access bd_inode directly, prepare to remove bd_inode from >> block_devcie. >> >> 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..8cf3618190ab 100644 >> --- a/fs/erofs/data.c >> +++ b/fs/erofs/data.c >> @@ -32,8 +32,7 @@ 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; >> +    erofs_off_t offset = (erofs_off_t)blkaddr << buf->blkszbits; > I'd suggest that use `buf->blkszbits` only for bdev_read_folio() since > erofs_init_metabuf() is not always called before erofs_bread() is used. > > For example, buf->inode can be one of directory inodes other than > initialized by erofs_init_metabuf(). Thanks for the notice, and you're right, I'll update code in v3: u8 blkszbits = buf->inode ? inode->i_blkbits : buf->blkszbits; erofs_off_t offset = (erofs_off_t)blkaddr << blkszbits; Kuai > > Thanks, > Gao Xiang > > >>       pgoff_t index = offset >> PAGE_SHIFT; >>       struct page *page = buf->page; >>       struct folio *folio; >> @@ -43,7 +42,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 +68,15 @@ 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; >> +        buf->blkszbits = buf->inode->i_blkbits; >> +    } 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 }) > . >