Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvs: remove dropcache #6622

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions src/modules/kvs/kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,6 @@ static int event_subscribe (struct kvs_ctx *ctx, const char *ns)
*/

if (!(ctx->events_init)) {

/* These belong to all namespaces, subscribe once the first
* time we init a namespace */

if (flux_event_subscribe (ctx->h, "kvs.dropcache") < 0) {
flux_log_error (ctx->h, "flux_event_subscribe");
goto cleanup;
}

/* On rank 0, we need to listen for all of these namespace
* events, all of the time. So subscribe to them just once on
* rank 0. */
Expand Down Expand Up @@ -1171,62 +1162,6 @@ static void transaction_check_cb (flux_reactor_t *r,
* rpc/event callbacks
*/

static void dropcache_request_cb (flux_t *h, flux_msg_handler_t *mh,
const flux_msg_t *msg, void *arg)
{
struct kvs_ctx *ctx = arg;
int size, expcount = 0;

/* irrelevant if root not initialized, drop cache entries */

if (flux_request_decode (msg, NULL, NULL) < 0)
goto error;
size = cache_count_entries (ctx->cache);
if ((expcount = cache_expire_entries (ctx->cache, 0)) < 0) {
flux_log_error (ctx->h, "%s: cache_expire_entries", __FUNCTION__);
goto error;
}
else {
flux_log (h,
LOG_ALERT,
"dropped %d of %d cache entries",
expcount,
size);
}
if (flux_respond (h, msg, NULL) < 0)
flux_log_error (h, "%s: flux_respond", __FUNCTION__);
return;
error:
if (flux_respond_error (h, msg, errno, NULL) < 0)
flux_log_error (h, "%s: flux_respond_error", __FUNCTION__);
}

static void dropcache_event_cb (flux_t *h,
flux_msg_handler_t *mh,
const flux_msg_t *msg,
void *arg)
{
struct kvs_ctx *ctx = arg;
int size, expcount = 0;

/* irrelevant if root not initialized, drop cache entries */

if (flux_event_decode (msg, NULL, NULL) < 0) {
flux_log_error (ctx->h, "%s: flux_event_decode", __FUNCTION__);
return;
}
size = cache_count_entries (ctx->cache);
if ((expcount = cache_expire_entries (ctx->cache, 0)) < 0)
flux_log_error (ctx->h, "%s: cache_expire_entries", __FUNCTION__);
else {
flux_log (h,
LOG_ALERT,
"dropped %d of %d cache entries",
expcount,
size);
}
}

static int heartbeat_root_cb (struct kvsroot *root, void *arg)
{
struct kvs_ctx *ctx = arg;
Expand Down Expand Up @@ -2600,18 +2535,6 @@ static const struct flux_msg_handler_spec htab[] = {
getroot_request_cb,
FLUX_ROLE_USER
},
{
FLUX_MSGTYPE_REQUEST,
"kvs.dropcache",
dropcache_request_cb,
0
},
{
FLUX_MSGTYPE_EVENT,
"kvs.dropcache",
dropcache_event_cb,
0
},
{
FLUX_MSGTYPE_REQUEST,
"kvs.disconnect",
Expand Down
32 changes: 30 additions & 2 deletions t/issues/t1760-kvs-use-after-free.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
#!/bin/sh -e
# dropcache, do a put that misses a references, unlink a dir, the reference
# should not be missing.
#
# N.B. the reason this test is split across two flux starts is we need the
# internal KVS cache to be empty

TEST=issue1760
${FLUX_BUILD_DIR}/t/kvs/issue1760 a
cat <<-EOF >t1760setup.sh
#!/bin/sh -e

flux kvs mkdir foo

EOF

cat <<-EOF >t1760test.sh
#!/bin/sh -e

${FLUX_BUILD_DIR}/t/kvs/issue1760 foo

EOF

chmod +x t1760setup.sh
chmod +x t1760test.sh

STATEDIR=issue1760-statedir
mkdir issue1760-statedir

flux start -s 1 \
--setattr=statedir=${STATEDIR} \
./t1760setup.sh

flux start -s 1 \
--setattr=statedir=${STATEDIR} \
./t1760test.sh
26 changes: 7 additions & 19 deletions t/kvs/issue1760.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
* SPDX-License-Identifier: LGPL-3.0
\************************************************************/

/* issue1760.c - make kvs module sad */
/* issue1760.c - make kvs module sad
*
* - it is assumed the directory passed in under argv[1] has already
* been created. The command line `flux kvs` command does not allow
* a put & unlink to be done under a single transaction, thus the need
* for this utility test.
*/

/* Failure mode 1:
./issue1760 a
Expand Down Expand Up @@ -52,24 +58,6 @@ int main (int argc, char *argv[])
if (!(h = flux_open (NULL, 0)))
log_err_exit ("flux_open");

/* Mkdir <dir>
*/
if (!(txn = flux_kvs_txn_create ()))
log_err_exit ("flux_kvs_txn_create");
if (flux_kvs_txn_mkdir (txn, 0, dir) < 0)
log_err_exit ("flux_kvs_txn_mkdir");
if (!(f = flux_kvs_commit (h, NULL, 0, txn)))
log_err_exit ("flux_kvs_commit");
if (flux_future_get (f, NULL) < 0)
log_err_exit ("flux_future_get");
flux_future_destroy (f);
flux_kvs_txn_destroy (txn);

/* Expire internal kvs cache
*/
if (flux_kvs_dropcache (h) < 0)
log_err_exit ("flux_kvs_dropcache");

/* Commit the following:
* put <dir>.a
* unlink <dir>
Expand Down
11 changes: 0 additions & 11 deletions t/t1000-kvs.t
Original file line number Diff line number Diff line change
Expand Up @@ -1164,17 +1164,6 @@ test_expect_success 'kvs: --sequence on write ops works' '
test $VER -eq $SEQ
'

#
# dropcache tests
#

test_expect_success 'kvs: dropcache works' '
flux kvs dropcache
'
test_expect_success 'kvs: dropcache --all works' '
flux kvs dropcache --all
'

#
# version/wait tests
#
Expand Down
6 changes: 0 additions & 6 deletions t/t1005-kvs-security.t
Original file line number Diff line number Diff line change
Expand Up @@ -379,12 +379,6 @@ test_expect_success 'kvs: guest cannot make a symlink in the test ns on rank 1'
# Basic tests, user can't perform non-namespace operations
#

test_expect_success 'kvs: dropcache fails (user)' '
set_userid 9999 &&
! flux kvs dropcache &&
unset_userid
'

test_expect_success 'kvs: stats works (user)' '
set_userid 9999 &&
flux module stats kvs >/dev/null &&
Expand Down
Loading