Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp174958lqd; Tue, 23 Apr 2024 20:38:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWM89gw8IC2ySDviLY3O1Q2hm19nvERfhkZfuAwAO3br/rqXRiRJY1Ug454v7+K4aywtcTwloLM+N+fI0DKXS4kEHVQ6DOh0ixoXdXfSQ== X-Google-Smtp-Source: AGHT+IHh+xFB53zLG1qauMs2xStpwUm0nZT7nIp3eN12KXlEYs1MjF7s7liHbiTruPs9zWOBdbny X-Received: by 2002:a05:6a20:9710:b0:1aa:58c9:6992 with SMTP id hr16-20020a056a20971000b001aa58c96992mr1177353pzc.42.1713929890011; Tue, 23 Apr 2024 20:38:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713929889; cv=pass; d=google.com; s=arc-20160816; b=kMYbpyI20TKM3U4cMgvoeWCbbRWWSMOc3X/0qoPswGn3hUeStLDM7OSC9dK8CoyLz4 fZaZ1Lm/b+9/fvcBPIUzaKrzXJFvRLmrb/rc5V+0XFHl/R0Uiu9AzZ9UnWOdvLY2LkBg 17ejjIRLTFl6rRQ7BjjScLZqcUwChAS8/LbvocfNNAd709vhY4mXstxF1Sfe3aQSHGcF Lh/QA0F9YN1VAkjSmhIA1letK9SU5wqr9VQxBhJPz4g7bZwocDdJuNJEKEWYE3tavSwB uWNEPjYAoSmrCbQcDN/axcnVyUzdp50MdU9iJCgHbDKYjEyiD4Q8ZGoSby7ntz1TjdJk liKQ== 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=/oYh0v68wgtBflKST+Jb57DwT23wl1xgA4+mqYG/ix0=; fh=3CsaseL1DGH+EMXcTH0kn5GO4vnHCl+kF9eyofb3vLk=; b=CSUZcYzDu5ZdzL81LB5cAMAXyjSk1gaAITChgmOV6JpVjEZEtj5ykt0P3q5LJoAJ0K i4essAWaCAEW3h1TM+9McyRE5kh2eKR+3UGh8zHXcJP4KOKwQNy1vYHNVTvM+dzoTgLo u7+zt7Q2Q+AzxOkGuNb4py9MGLKfcDnpuhkAWzxXdVUdvROLuhDv9xcPOAKo0OBwqnXj 41y9Tmx6aVeVi+zhgCuLlLSivyvWs37tqnVcHQ0BNLypzMgPYp46z+9njL78W3qNvFjA yXvIWXBPuDkszdWwvVhVjg7jiarkfZH62FZ/4N/fats9T+4OEDtOuw3qZMMB4Z9DdRBi fZjA==; 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-156217-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156217-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gq22-20020a17090b105600b002ab4951a8e5si10477483pjb.27.2024.04.23.20.38.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 20:38:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156217-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-156217-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156217-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D7777281964 for ; Wed, 24 Apr 2024 03:37:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35AEF1428F1; Wed, 24 Apr 2024 03:36:54 +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 81A8F125D5; Wed, 24 Apr 2024 03:36:51 +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=1713929813; cv=none; b=iS++DluZEoN+F21Y9C68SmfE4PPxadUAMBQzh0oZy8skiVqrdndqoU+8wwlOQQg8LuJg389tOc1YPJ8Jol0C69W2NYMEBTADG7Qe5udochLxKd/Ikt9fZgEZzuErhnldwBY1S1K3//79hZcKbVcQbGNOIg7Wt7kj8UX4XxSfpY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713929813; c=relaxed/simple; bh=VekTjXJWG/vwl9TNzF0hki9AG327/LyNuPoQoWMw9fE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O3I6Xo6E355l+VBM42ktqSxO+pO42DZ0HwnKuMiRibm0KMu5NtmiAoSrkKfyuy1Ykov/N3pMYk9aif+XE/k8Ev38mAAiCH9cOoi5UKUTIq72lN25YnL3Xp/syf3dU6zc7LdJwnzb0nD3W6GSGByxugOrliutHLuyC9UhaKhT5p0= 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 4VPPmW4dyXz4f3kpj; Wed, 24 Apr 2024 11:36:43 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 7C5831A0C7E; Wed, 24 Apr 2024 11:36:48 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHZQ5Nfihmarc3Kw--.25590S5; Wed, 24 Apr 2024 11:36:48 +0800 (CST) From: libaokun@huaweicloud.com To: netfs@lists.linux.dev Cc: dhowells@redhat.com, jlayton@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH 1/5] netfs, fscache: export fscache_put_volume() and add fscache_try_get_volume() Date: Wed, 24 Apr 2024 11:27:28 +0800 Message-Id: <20240424032732.2711487-2-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240424032732.2711487-1-libaokun@huaweicloud.com> References: <20240424032732.2711487-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:cCh0CgBHZQ5Nfihmarc3Kw--.25590S5 X-Coremail-Antispam: 1UD129KBjvJXoWxGw17ur1rJw1kWw1rCr1rWFg_yoW5Cr1Dp3 srCrn7KF48Xw1xGw45Xw47Zrn3Z3yDKan7G348Gw15Cw4xtr15XF12yw15AF13A34UJrWI yF1Utryjgw1UZr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUmE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWUWVWUuwAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwAKzVCY07xG64k0F24lc7CjxVAKzI0EY4vE52x082I5MxAIw28IcxkI7VAKI48JMxC2 0s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI 0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE 14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20x vaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8 JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7sRi9a97UUUUU== 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 ec7045d24400..edf9b2a180ca 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -326,8 +326,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