[PATCH] Allow disabling drop_caches logging immediately

From: Stephen Kitt
Date: Fri Oct 25 2019 - 12:05:29 EST


Currently, echoing 4 to drop_caches disables logging for subsequent
operations, not the current operation, even if the write is combined
(echo 7 ...). This patch takes bit 2 into account before logging, so
that logging can be disabled concurrently with other operations.

This doesn't change the behaviour for existing scenarios encountered
in the wild.

Signed-off-by: Stephen Kitt <steve@xxxxxxx>
---
fs/drop_caches.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d31b6c72b476..2562d6285ce4 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -65,12 +65,12 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write,
drop_slab();
count_vm_event(DROP_SLAB);
}
+ stfu |= sysctl_drop_caches & 4;
if (!stfu) {
pr_info("%s (%d): drop_caches: %d\n",
current->comm, task_pid_nr(current),
sysctl_drop_caches);
}
- stfu |= sysctl_drop_caches & 4;
}
return 0;
}
--
2.20.1