* [PATCH 1/2] CacheFiles: Slightly simplify 'cachefiles_has_space()'
@ 2021-11-20 18:22 Christophe JAILLET
2021-11-20 18:22 ` [PATCH 2/2] CacheFiles: Slightly optimize 'cachefiles_has_space()' Christophe JAILLET
0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2021-11-20 18:22 UTC (permalink / raw)
To: dhowells; +Cc: linux-cachefs, linux-kernel, kernel-janitors, Christophe JAILLET
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@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] CacheFiles: Slightly optimize 'cachefiles_has_space()'
2021-11-20 18:22 [PATCH 1/2] CacheFiles: Slightly simplify 'cachefiles_has_space()' Christophe JAILLET
@ 2021-11-20 18:22 ` Christophe JAILLET
0 siblings, 0 replies; 2+ messages in thread
From: Christophe JAILLET @ 2021-11-20 18:22 UTC (permalink / raw)
To: dhowells; +Cc: linux-cachefs, linux-kernel, kernel-janitors, Christophe JAILLET
There is no need to clear the 'struct kstatfs' buffer when calling
'vfs_statfs()', it is already be done in 'statfs_by_dentry()'. So a few
cycles can be saved here.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
fs/cachefiles/daemon.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
index be8f2ec453b6..45bfc5643615 100644
--- a/fs/cachefiles/daemon.c
+++ b/fs/cachefiles/daemon.c
@@ -688,8 +688,6 @@ int cachefiles_has_space(struct cachefiles_cache *cache,
// fnr, bnr);
/* find out how many pages of blockdev are available */
- memset(&stats, 0, sizeof(stats));
-
ret = vfs_statfs(&path, &stats);
if (ret < 0) {
if (ret == -EIO)
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-20 18:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-20 18:22 [PATCH 1/2] CacheFiles: Slightly simplify 'cachefiles_has_space()' Christophe JAILLET
2021-11-20 18:22 ` [PATCH 2/2] CacheFiles: Slightly optimize 'cachefiles_has_space()' Christophe JAILLET
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.