Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2310797imn; Mon, 1 Aug 2022 20:20:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR69f6vZ3uihKiaKzYG5v+5NKknbBTu+YV42q4kdhsghn3GYsce5owNYc7N9y/OMaHoJEltW X-Received: by 2002:a17:902:6b0c:b0:16e:de0e:9d0e with SMTP id o12-20020a1709026b0c00b0016ede0e9d0emr11002380plk.30.1659410440119; Mon, 01 Aug 2022 20:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659410440; cv=none; d=google.com; s=arc-20160816; b=KOjYki5KG34lVDy1GnAy98kIFEs/buT+EKp4BpxxfrzrkdQ9q5Jyfs8d0WJYQXVe5f O/GNH1tzsjhIzlVsLNfFrDyiIf1iLmXkgl4em+1ZctAy+ReRT+aC8MBTlMt1gFYNfvPL rjJ29nrHluQxvl20EVCUudtJa0n+bKR4xG5nxwu5olfN5HWop4VaOcZb+VHvObWPvq1q UrUFTK35if2xUbI/ILLnVO0ynMlQ5lqd+EqipRSH6uYxMc6w68iKQLevjWp9BgdAUjlU LYOC/ys56E4Xv0BxQBuEk7Rs4RWq0NY3o3GPxjok/cPLreCRObyIudASX1SmEtsanOxm WNOA== 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=v5aXB5Gdm87TUmwXmAA6oG2iyTYphQNH/CdyaPDNWHE=; b=H7RImw8HIZX+weN8vudf8WEhaXXX5FvlPwNZ5bMKJd+V8au4XuvYe9o//slX2j1wDC A5PVP9rxBkGONrom9OnFhAEEGlt9Ak3k38SnRqRAJDWrV3RwXscYFM181WVp4OOBgGcI dOK94lK3yjutg7XfoCAbwVn904urltF/lhtJXS3ru7k4u60gmqb2zOrvupsFvkriYDyV gnUPZDXvBoIevNrv9v469QMBBl/nALK0KEIFNes33avo16Nrw4q9a8rsWcyt8azijIQj dkc53O7Q5/HO43X01ozk4pbwXFGVjecCOqkiu7et+oxqeI9Y3sxkZkgRzCcM5uFLJ33x 34LA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020a056a001a0f00b0052546400216si15234429pfv.306.2022.08.01.20.20.26; Mon, 01 Aug 2022 20:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235680AbiHBDES (ORCPT + 99 others); Mon, 1 Aug 2022 23:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235400AbiHBDDw (ORCPT ); Mon, 1 Aug 2022 23:03:52 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC3A1EC4D for ; Mon, 1 Aug 2022 20:03:47 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VL9W-MZ_1659409424; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VL9W-MZ_1659409424) by smtp.aliyun-inc.com; Tue, 02 Aug 2022 11:03:45 +0800 From: Jingbo Xu To: dhowells@redhat.com, linux-cachefs@redhat.com Cc: linux-kernel@vger.kernel.org, xiang@kernel.org Subject: [PATCH RFC 3/9] cachefiles: allocate per-subdir content map files Date: Tue, 2 Aug 2022 11:03:36 +0800 Message-Id: <20220802030342.46302-4-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220802030342.46302-1-jefflexu@linux.alibaba.com> References: <20220802030342.46302-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 Allocate one content map file for each sub-directory under one volume, so that the cacehfilesd only needs to remove the whole sub-directory (including the content map file and backing files in the sub-directory) as usual when it's going to cull the whole sub-directory or volume. The content map file will be shared among all backing files under this same sub-directory. Signed-off-by: Jingbo Xu --- fs/cachefiles/internal.h | 1 + fs/cachefiles/namei.c | 2 +- fs/cachefiles/volume.c | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 4c3ee6935811..06bde4e0e4f5 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -42,6 +42,7 @@ struct cachefiles_volume { struct fscache_volume *vcookie; /* The netfs's representation */ struct dentry *dentry; /* The volume dentry */ struct dentry *fanout[256]; /* Fanout subdirs */ + struct file *content_map[256]; /* Content map files */ }; /* diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c index 2948eea18ca2..d2d5feea64e8 100644 --- a/fs/cachefiles/namei.c +++ b/fs/cachefiles/namei.c @@ -292,7 +292,7 @@ int cachefiles_look_up_map(struct cachefiles_cache *cache, path.mnt = cache->mnt; path.dentry = dentry; - file = open_with_fake_path(&path, O_RDWR | O_LARGEFILE, + file = open_with_fake_path(&path, O_RDWR | O_LARGEFILE | O_DSYNC, d_backing_inode(dentry), cache->cache_cred); if (IS_ERR(file)) cachefiles_put_directory(dentry); diff --git a/fs/cachefiles/volume.c b/fs/cachefiles/volume.c index 89df0ba8ba5e..4decc91a8886 100644 --- a/fs/cachefiles/volume.c +++ b/fs/cachefiles/volume.c @@ -20,6 +20,7 @@ void cachefiles_acquire_volume(struct fscache_volume *vcookie) struct cachefiles_cache *cache = vcookie->cache->cache_priv; const struct cred *saved_cred; struct dentry *vdentry, *fan; + struct file *map; size_t len; char *name; bool is_new = false; @@ -73,6 +74,11 @@ void cachefiles_acquire_volume(struct fscache_volume *vcookie) if (IS_ERR(fan)) goto error_fan; volume->fanout[i] = fan; + + ret = cachefiles_look_up_map(cache, fan, &map); + if (ret) + goto error_fan; + volume->content_map[i] = map; } cachefiles_end_secure(cache, saved_cred); @@ -91,8 +97,10 @@ void cachefiles_acquire_volume(struct fscache_volume *vcookie) return; error_fan: - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { cachefiles_put_directory(volume->fanout[i]); + cachefiles_put_map(volume->content_map[i]); + } error_dir: cachefiles_put_directory(volume->dentry); error_name: @@ -113,8 +121,10 @@ static void __cachefiles_free_volume(struct cachefiles_volume *volume) volume->vcookie->cache_priv = NULL; - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { cachefiles_put_directory(volume->fanout[i]); + cachefiles_put_map(volume->content_map[i]); + } cachefiles_put_directory(volume->dentry); kfree(volume); } -- 2.27.0