Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfs, fscache: export fscache_put_volume() and add fscache_try_get_volume()

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 <libaokun1@huawei.com>
Link: https://lore.kernel.org/r/20240628062930.2467993-2-libaokun@huaweicloud.com
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Baokun Li and committed by
Christian Brauner
85b08b31 163eae0f

+20 -2
+14
fs/netfs/fscache_volume.c
··· 27 27 return volume; 28 28 } 29 29 30 + struct fscache_volume *fscache_try_get_volume(struct fscache_volume *volume, 31 + enum fscache_volume_trace where) 32 + { 33 + int ref; 34 + 35 + if (!__refcount_inc_not_zero(&volume->ref, &ref)) 36 + return NULL; 37 + 38 + trace_fscache_volume(volume->debug_id, ref + 1, where); 39 + return volume; 40 + } 41 + EXPORT_SYMBOL(fscache_try_get_volume); 42 + 30 43 static void fscache_see_volume(struct fscache_volume *volume, 31 44 enum fscache_volume_trace where) 32 45 { ··· 433 420 fscache_free_volume(volume); 434 421 } 435 422 } 423 + EXPORT_SYMBOL(fscache_put_volume); 436 424 437 425 /* 438 426 * Relinquish a volume representation cookie.
-2
fs/netfs/internal.h
··· 352 352 353 353 struct fscache_volume *fscache_get_volume(struct fscache_volume *volume, 354 354 enum fscache_volume_trace where); 355 - void fscache_put_volume(struct fscache_volume *volume, 356 - enum fscache_volume_trace where); 357 355 bool fscache_begin_volume_access(struct fscache_volume *volume, 358 356 struct fscache_cookie *cookie, 359 357 enum fscache_access_trace why);
+6
include/linux/fscache-cache.h
··· 19 19 enum fscache_cache_trace; 20 20 enum fscache_cookie_trace; 21 21 enum fscache_access_trace; 22 + enum fscache_volume_trace; 22 23 23 24 enum fscache_cache_state { 24 25 FSCACHE_CACHE_IS_NOT_PRESENT, /* No cache is present for this name */ ··· 98 97 99 98 extern void fscache_io_error(struct fscache_cache *cache); 100 99 100 + extern struct fscache_volume * 101 + fscache_try_get_volume(struct fscache_volume *volume, 102 + enum fscache_volume_trace where); 103 + extern void fscache_put_volume(struct fscache_volume *volume, 104 + enum fscache_volume_trace where); 101 105 extern void fscache_end_volume_access(struct fscache_volume *volume, 102 106 struct fscache_cookie *cookie, 103 107 enum fscache_access_trace why);