Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp108273lqp; Tue, 21 May 2024 21:06:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV8HzXY3acEJASspEhu1fUz4KUkwAJ0HSBAamRWhn3kz6/gHIXgfkHWbeVvgEYiqHOzbasaLwaVdO7tjB1jKftxDG+y4W7qGK4ToQMpOw== X-Google-Smtp-Source: AGHT+IHN/THzgOi8zLh6XOwxhnt155cYRK7HhEtAlOSYE+Vu8YydDEt3N1eCo9HUcsQRwCfJ4FPC X-Received: by 2002:a05:6214:3903:b0:6ab:6c2e:e425 with SMTP id 6a1803df08f44-6ab7f356954mr7935366d6.24.1716350773046; Tue, 21 May 2024 21:06:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716350773; cv=pass; d=google.com; s=arc-20160816; b=aPb5TIt7nHCWdhaagfw/YCgBIU24L6MapPoaDCB0frGTnt5x91Aqonhm/Jt14eqZwu 6Rp0GfDrvIh8TSazCj1SnA3ih2ZSM4n6v4068BI0n6dlJ8obc8tgZnAibUkKUGXV6myo 38cgWTZbInOoHF5P3O45mEKVcC0wfjHUpIDIhco+GCtmIGYS/932LrCLKwhyLIZyWW8w AeYhMyDwMgm/BvI7WgH5AWt1sYWlasRjvhK93hcUDKJlhDrND8Ts9jr8ue8wvXgcCB8j EmF752K2ZnwHdVIZHJ9KYANLh9IOy/Q8ffTm1wdhVNptZ6mOhE5UalliAGnnSTRiK8Jm N+lw== ARC-Message-Signature: i=2; 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=QXEQsL6JDy90cphnIBnXVOMMj+cEnq9Q+lhTYzr0zJY=; fh=dfpuzL54LAMf7GQmHoqmub+qZCPWKUPNTVFHnj8Vxqk=; b=ODyYKgOZbG6nZxHKd//FZdMXyftvRHK5PM6rifub7szPqowVwCmUiwVQLVob31AsZJ +e0PZDs/H/kPPijEumrnAtI8OTn7BjgsCRgTvg/DFkVL4epKUnVfl+h76eThMpZ4g+ae YgUCfLmRELjrFz0y+t2Bw+wxp8IcunfJ0u39AxKYStAGhPFwgbPPlg1tiimnzq8AN7rl jmRbbSBdwqKZBQ9Z+KzbGMuJhcgehRrxF2QMjoSKVAliz3DrFxEWOsG6oEezDfMS4Vkv MMX+2f60XAdjDMAlZPvciPNzkXKeTWty4twTKUKXLn6cQITsCYDFfqyIGAYySBoDS0xb u0Yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-185749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185749-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df549f4c0si310573811cf.5.2024.05.21.21.06.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 21:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-185749-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185749-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 C4EB11C216F7 for ; Wed, 22 May 2024 04:06:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEF56770EF; Wed, 22 May 2024 04:06:02 +0000 (UTC) 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 4F9A3537E9; Wed, 22 May 2024 04:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716350762; cv=none; b=Rzryq4IZj4wXY3Q7S0DODCbpQPz93ydX8tP8qC8ZVsS6yYuc1lMZhHjf5UP7rWkcasvVZ+jEfBbaBWtXNaOsOeejf1H4zsZip0KBR3Vsu/0anRNtJ5FKK6/4rRaiUxPFkd9By0moeMh9emO61BLYXMx/wSgjreQ27bKmH8jJIW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716350762; c=relaxed/simple; bh=6XI1XN34NW4rt/zFdE8AebS1urwUF5nF67y/z3rb7U8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WX+ngq8I5RRRWVZJvQTdogDgHFAoM2mJouw5P7Eacvt3WyeoYYrckwJGBPUceZE19QMxIbUJJhiF7eYlwf1C1aOEix3YUNS3ZAOwl5x26LgQwftHdbXtQ3yOeoRXqNss/E0D8HgxpS5hvZHi5b4j2AYSVWJ5Gr8irhh3gFW5hQ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Vkd5650dFz4f3m76; Wed, 22 May 2024 12:05:46 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 2DA7D1A0199; Wed, 22 May 2024 12:05:57 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHZQ4ib01ms1VYNQ--.24441S5; Wed, 22 May 2024 12:05:56 +0800 (CST) From: libaokun@huaweicloud.com To: netfs@lists.linux.dev, dhowells@redhat.com, jlayton@kernel.org Cc: hsiangkao@linux.alibaba.com, jefflexu@linux.alibaba.com, zhujia.zj@bytedance.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, libaokun@huaweicloud.com, yangerkun@huawei.com, houtao1@huawei.com, yukuai3@huawei.com, wozizhi@huawei.com, Baokun Li Subject: [PATCH RESEND 1/5] netfs, fscache: export fscache_put_volume() and add fscache_try_get_volume() Date: Wed, 22 May 2024 19:59:07 +0800 Message-Id: <20240522115911.2403021-2-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240522115911.2403021-1-libaokun@huaweicloud.com> References: <20240522115911.2403021-1-libaokun@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: 8bit X-CM-TRANSID:cCh0CgBHZQ4ib01ms1VYNQ--.24441S5 X-Coremail-Antispam: 1UD129KBjvJXoWxGw17ur1rJw1kWw1rCr1rWFg_yoW5Cr1Dp3 srCrn7KF48Xw1xGw45Xw47Zrn3Z3yDKan7G3y8Gw15Cw4xJr15XF12yw15AF13A34UJrWI yF1Utryjgw1UZr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQmb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zV CS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04v7M4kE6xkIj40Ew7xC0wCF04k20xvY 0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I 0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAI cVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcV CF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIE c7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjTRPfQMDUUUU X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/ From: Baokun Li Export fscache_put_volume() and add fscache_try_get_volume() helper function to allow cachefiles to get/put fscache_volume via linux/fscache-cache.h. Signed-off-by: Baokun Li --- fs/netfs/fscache_volume.c | 14 ++++++++++++++ fs/netfs/internal.h | 2 -- include/linux/fscache-cache.h | 6 ++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/fs/netfs/fscache_volume.c b/fs/netfs/fscache_volume.c index cdf991bdd9de..cb75c07b5281 100644 --- a/fs/netfs/fscache_volume.c +++ b/fs/netfs/fscache_volume.c @@ -27,6 +27,19 @@ struct fscache_volume *fscache_get_volume(struct fscache_volume *volume, return volume; } +struct fscache_volume *fscache_try_get_volume(struct fscache_volume *volume, + enum fscache_volume_trace where) +{ + int ref; + + if (!__refcount_inc_not_zero(&volume->ref, &ref)) + return NULL; + + trace_fscache_volume(volume->debug_id, ref + 1, where); + return volume; +} +EXPORT_SYMBOL(fscache_try_get_volume); + static void fscache_see_volume(struct fscache_volume *volume, enum fscache_volume_trace where) { @@ -420,6 +433,7 @@ void fscache_put_volume(struct fscache_volume *volume, fscache_free_volume(volume); } } +EXPORT_SYMBOL(fscache_put_volume); /* * Relinquish a volume representation cookie. diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h index 95e281a8af78..2a071b8010fa 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -353,8 +353,6 @@ extern const struct seq_operations fscache_volumes_seq_ops; struct fscache_volume *fscache_get_volume(struct fscache_volume *volume, enum fscache_volume_trace where); -void fscache_put_volume(struct fscache_volume *volume, - enum fscache_volume_trace where); bool fscache_begin_volume_access(struct fscache_volume *volume, struct fscache_cookie *cookie, enum fscache_access_trace why); diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h index bdf7f3eddf0a..4c91a019972b 100644 --- a/include/linux/fscache-cache.h +++ b/include/linux/fscache-cache.h @@ -19,6 +19,7 @@ enum fscache_cache_trace; enum fscache_cookie_trace; enum fscache_access_trace; +enum fscache_volume_trace; enum fscache_cache_state { FSCACHE_CACHE_IS_NOT_PRESENT, /* No cache is present for this name */ @@ -97,6 +98,11 @@ extern void fscache_withdraw_cookie(struct fscache_cookie *cookie); extern void fscache_io_error(struct fscache_cache *cache); +extern struct fscache_volume * +fscache_try_get_volume(struct fscache_volume *volume, + enum fscache_volume_trace where); +extern void fscache_put_volume(struct fscache_volume *volume, + enum fscache_volume_trace where); extern void fscache_end_volume_access(struct fscache_volume *volume, struct fscache_cookie *cookie, enum fscache_access_trace why); -- 2.39.2