[Linux-cachefs] [PATCH 1/2] CacheFiles: Slightly simplify 'cachefiles_has_space()'

Christophe JAILLET christophe.jaillet at wanadoo.fr
Sat Nov 20 18:22:32 UTC 2021


The "CACHEFILES_CULLING" bit is tested twice. Once with 'test_bit()' and
once with 'test_and_clear_bit()'.
Remove the first test.

While at it, bring back a ')' at the end of a line to be more compliant
with Linux coding style.

Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
---
If testing the bit first was a kind of optimization, a few words shoul
explained it.
---
 fs/cachefiles/daemon.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index 752c1e43416f..be8f2ec453b6 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -725,11 +725,9 @@ int cachefiles_has_space(struct cachefiles_cache *cache,
 	    stats.f_bavail < cache->bcull)
 		goto begin_cull;
 
-	if (test_bit(CACHEFILES_CULLING, &cache->flags) &&
-	    stats.f_ffree >= cache->frun &&
+	if (stats.f_ffree >= cache->frun &&
 	    stats.f_bavail >= cache->brun &&
-	    test_and_clear_bit(CACHEFILES_CULLING, &cache->flags)
-	    ) {
+	    test_and_clear_bit(CACHEFILES_CULLING, &cache->flags)) {
 		_debug("cease culling");
 		cachefiles_state_changed(cache);
 	}
-- 
2.30.2




More information about the Linux-cachefs mailing list