From: Yu Kuai yukuai3@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT
--------------------------------
A new filed 'new_location' is added in fscache_cookie_def() to determine the behaviour, two new helpers is also added to judge if 'new_location' is set for volume or data cookie.
Signed-off-by: Yu Kuai yukuai3@huawei.com Signed-off-by: Baokun Li libaokun1@huawei.com --- include/linux/fscache.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/include/linux/fscache.h b/include/linux/fscache.h index 6931c144a2fd..40ede2ff29dc 100644 --- a/include/linux/fscache.h +++ b/include/linux/fscache.h @@ -70,6 +70,12 @@ struct fscache_cookie_def { #define FSCACHE_COOKIE_TYPE_INDEX 0 #define FSCACHE_COOKIE_TYPE_DATAFILE 1
+ /* + * Used for index cookie. If set, the location of cachefile will be the + * same as mainline kernel v5.18+. + */ + bool new_location; + /* select the cache into which to insert an entry in this index * - optional * - should return a cache identifier or NULL to cause the cache to be @@ -876,4 +882,18 @@ void fscache_enable_cookie(struct fscache_cookie *cookie, can_enable, data); }
+static inline bool volume_new_location(struct fscache_cookie *cookie) +{ + return cookie->def && cookie->type == FSCACHE_COOKIE_TYPE_INDEX && + cookie->def->new_location; +} + +static inline bool data_new_location(struct fscache_cookie *cookie) +{ + if (cookie->type != FSCACHE_COOKIE_TYPE_DATAFILE) + return false; + + return cookie->parent && volume_new_location(cookie->parent); +} + #endif /* _LINUX_FSCACHE_H */