Skip to content

Commit 85b08b3

Browse files
LiBaokun96brauner
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 163eae0 commit 85b08b3

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

fs/netfs/fscache_volume.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ struct fscache_volume *fscache_get_volume(struct fscache_volume *volume,
2727
return volume;
2828
}
2929

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+
3043
static void fscache_see_volume(struct fscache_volume *volume,
3144
enum fscache_volume_trace where)
3245
{
@@ -420,6 +433,7 @@ void fscache_put_volume(struct fscache_volume *volume,
420433
fscache_free_volume(volume);
421434
}
422435
}
436+
EXPORT_SYMBOL(fscache_put_volume);
423437

424438
/*
425439
* Relinquish a volume representation cookie.

fs/netfs/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,6 @@ extern const struct seq_operations fscache_volumes_seq_ops;
352352

353353
struct fscache_volume *fscache_get_volume(struct fscache_volume *volume,
354354
enum fscache_volume_trace where);
355-
void fscache_put_volume(struct fscache_volume *volume,
356-
enum fscache_volume_trace where);
357355
bool fscache_begin_volume_access(struct fscache_volume *volume,
358356
struct fscache_cookie *cookie,
359357
enum fscache_access_trace why);

include/linux/fscache-cache.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
enum fscache_cache_trace;
2020
enum fscache_cookie_trace;
2121
enum fscache_access_trace;
22+
enum fscache_volume_trace;
2223

2324
enum fscache_cache_state {
2425
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);
9798

9899
extern void fscache_io_error(struct fscache_cache *cache);
99100

101+
extern struct fscache_volume *
102+
fscache_try_get_volume(struct fscache_volume *volume,
103+
enum fscache_volume_trace where);
104+
extern void fscache_put_volume(struct fscache_volume *volume,
105+
enum fscache_volume_trace where);
100106
extern void fscache_end_volume_access(struct fscache_volume *volume,
101107
struct fscache_cookie *cookie,
102108
enum fscache_access_trace why);

0 commit comments

Comments
 (0)