lkml.org 
[lkml]   [2021]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 51/67] fscache: Make fscache_write_to_cache() conditional on cookie
From
Date
Make fscache_write_to_cache() conditional on cookie not being NULL, rather
than merely conditional on CONFIG_FSCACHE=[ym]. The problem with the
latter is if a filesystem, say afs, has CONFIG_AFS_FSCACHE=n but calls into
this function - linkage will fail if CONFIG_FSCACHE is less than
CONFIG_AFS. Analogous problems can affect other filesystems, e.g. 9p.

Making fscache_write_to_cache() conditional on the cookie achieves two
things:

(1) If cookie optimises down to constant NULL, term_func is called
directly and may be inlined and the slow path is never called.

(2) __fscache_write_to_cache() isn't called if cookie is dynamically NULL
- and so, in such a case, term_func is called immediately.

Signed-off-by: David Howells <dhowells@redhat.com>
---

include/linux/fscache.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index 847c076d05a6..ba192567d099 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -593,7 +593,7 @@ static inline void fscache_write_to_cache(struct fscache_cookie *cookie,
netfs_io_terminated_t term_func,
void *term_func_priv)
{
- if (fscache_available()) {
+ if (fscache_cookie_valid(cookie)) {
__fscache_write_to_cache(cookie, mapping, start, len, i_size,
term_func, term_func_priv);
} else {

\
 
 \ /
  Last update: 2021-10-18 17:05    [W:0.504 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site