Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1840822pxb; Wed, 9 Feb 2022 05:44:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwp3Qlyi+mMApwuKzaO+lY/2BQ93Q2JJ6/1JuyhTjgMKvOn91KraIbjWdILVxb8NYbspUsJ X-Received: by 2002:a63:6888:: with SMTP id d130mr1982870pgc.124.1644414247221; Wed, 09 Feb 2022 05:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644414247; cv=none; d=google.com; s=arc-20160816; b=kLquGlm1ixbeFS2XgDq9JrCDx/O2pSRIX+BJtOHBOBpZ5MIYG6eyoFr+HPwlpOWID9 4CKw1X+ismHZ1Xa4qYgUzTqdQiK8VopMXp3yg01ULNK1rr+ncD0dYwEFmOCGiVZHZz5N f1RuH2R4W1PFNAJph7tSdDgT2OxtNaE8NV8A1Ls0JPu9HtdjbJTbq2LflLDVxkJcMTpz BZfYQ6d4KHuh0QROiRnrQTQv2FFTNzkuUNJUaKj4svCd7x6nh3SyHExSZcC06H4z6KOi 0z8assjRnWjagSX1pP4U3cvGlH9sAqV5kAon3CYUTaPjnri3zN6vXcu9RPsLp3ZlgmV/ ipOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BLKsnbaOsOZ4RzRKbmsBxH//5kR5MsnQv7GPO7z6Hkw=; b=C/YzxB1I8F2nxbS9D3d7/4KrzRvBe3ej0V6Wpi90DzYjJnspSnwiZCpE29QGNLPcty 6rAUORXqPloZB9XII5B7X4YzG54wRrNg0RD83sMmledyQYjmVc+J0biWr4KjYWnmWkJ5 dKOLPXbuj9CDZaWoMbsRLByL+Vbt/wklqjFKuonERsKSi/WcGMsgVMfGK6oUSCuC6O3y kU7UzHFHufeYtMksN+NajRWlj3ZgcYE4zMp8G79H5NjAdydykd1FRwa6s4J0LNp14pJd rCfIgj3Rej+qUqu7EQhYYMLLNGnOvk5hE9RdPZd2A4VyRF4pkXIwn4aLw7na/DnXMbHw Iuqg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w2si15009674pgm.464.2022.02.09.05.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:44:07 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3985AE05027F; Wed, 9 Feb 2022 02:25:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232873AbiBIGH4 (ORCPT + 99 others); Wed, 9 Feb 2022 01:07:56 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:53286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235949AbiBIGBy (ORCPT ); Wed, 9 Feb 2022 01:01:54 -0500 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A92C05CBA2; Tue, 8 Feb 2022 22:01:57 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R531e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0V3zaQUW_1644386491; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V3zaQUW_1644386491) by smtp.aliyun-inc.com(127.0.0.1); Wed, 09 Feb 2022 14:01:31 +0800 From: Jeffle Xu To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: torvalds@linux-foundation.org, gregkh@linuxfoundation.org, willy@infradead.org, linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org Subject: [PATCH v3 17/22] erofs: register cookie context for data blobs Date: Wed, 9 Feb 2022 14:01:03 +0800 Message-Id: <20220209060108.43051-18-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220209060108.43051-1-jefflexu@linux.alibaba.com> References: <20220209060108.43051-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to the multi device mode, erofs could be mounted from multiple blob files (one bootstrap blob file and optional multiple data blob files). In this case, each device slot contains the path of corresponding data blob file. This patch registers corresponding cookie context for each data blob file. Signed-off-by: Jeffle Xu --- fs/erofs/internal.h | 1 + fs/erofs/super.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 548f928b0ded..5d514c7b73cc 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -53,6 +53,7 @@ struct erofs_device_info { struct block_device *bdev; struct dax_device *dax_dev; u64 dax_part_off; + struct erofs_fscache_context *ctx; u32 blocks; u32 mapped_blkaddr; diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 8c5783c6f71f..f058a04a00c7 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -250,6 +250,7 @@ static int erofs_init_devices(struct super_block *sb, down_read(&sbi->devs->rwsem); idr_for_each_entry(&sbi->devs->tree, dif, id) { struct block_device *bdev; + struct erofs_fscache_context *ctx; ptr = erofs_read_metabuf(&buf, sb, erofs_blknr(pos), EROFS_KMAP); @@ -259,15 +260,24 @@ static int erofs_init_devices(struct super_block *sb, } dis = ptr + erofs_blkoff(pos); - bdev = blkdev_get_by_path(dif->path, - FMODE_READ | FMODE_EXCL, - sb->s_type); - if (IS_ERR(bdev)) { - err = PTR_ERR(bdev); - break; + if (erofs_bdev_mode(sb)) { + bdev = blkdev_get_by_path(dif->path, + FMODE_READ | FMODE_EXCL, + sb->s_type); + if (IS_ERR(bdev)) { + err = PTR_ERR(bdev); + break; + } + dif->bdev = bdev; + dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off); + } else { + ctx = erofs_fscache_get_ctx(sb, dif->path, false); + if (IS_ERR(ctx)) { + err = PTR_ERR(ctx); + break; + } + dif->ctx = ctx; } - dif->bdev = bdev; - dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off); dif->blocks = le32_to_cpu(dis->blocks); dif->mapped_blkaddr = le32_to_cpu(dis->mapped_blkaddr); sbi->total_blocks += dif->blocks; @@ -694,6 +704,7 @@ static int erofs_release_device_info(int id, void *ptr, void *data) { struct erofs_device_info *dif = ptr; + erofs_fscache_put_ctx(dif->ctx); fs_put_dax(dif->dax_dev); if (dif->bdev) blkdev_put(dif->bdev, FMODE_READ | FMODE_EXCL); -- 2.27.0