From 2b5bbab55c44f93361e667a5ad6f759dd4fdce49 Mon Sep 17 00:00:00 2001 From: John Spray Date: Fri, 5 Sep 2014 13:16:16 +0100 Subject: [PATCH] client: failure injection for cap release Used for simulating a buggy client that trips the error detection in #9282 (warn clients which aren't revoking caps) Signed-off-by: John Spray --- src/client/Client.cc | 20 +++++++++++++++++--- src/common/config_opts.h | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index ae4df67651201..201c989851749 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2472,8 +2472,17 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, << " dropping " << ccap_string(dropping) << dendl; - cap->issued &= retain; - cap->implemented &= cap->issued | used; + if (cct->_conf->client_inject_release_failure && revoking) { + // Simulated bug: + // - tell the server we think issued is whatever they issued plus whatever we implemented + // - leave what we have implemented in place + ldout(cct, 20) << __func__ << " injecting failure to release caps" << dendl; + cap->issued = cap->issued | cap->implemented; + } else { + // Normal behaviour + cap->issued &= retain; + cap->implemented &= cap->issued | used; + } uint64_t flush_tid = 0; snapid_t follows = 0; @@ -4183,7 +4192,12 @@ void Client::flush_cap_releases() p != mds_sessions.end(); ++p) { if (p->second->release && mdsmap->is_clientreplay_or_active_or_stopping(p->first)) { - p->second->con->send_message(p->second->release); + if (cct->_conf->client_inject_release_failure) { + ldout(cct, 20) << __func__ << " injecting failure to send cap release message" << dendl; + p->second->release->put(); + } else { + p->second->con->send_message(p->second->release); + } p->second->release = 0; } } diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 2cd6a04289fb8..8abdb33cea9ca 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -280,6 +280,7 @@ OPTION(client_oc_max_objects, OPT_INT, 1000) // max objects in cache OPTION(client_debug_force_sync_read, OPT_BOOL, false) // always read synchronously (go to osds) OPTION(client_debug_inject_tick_delay, OPT_INT, 0) // delay the client tick for a number of seconds OPTION(client_max_inline_size, OPT_U64, 4096) +OPTION(client_inject_release_failure, OPT_BOOL, false) // synthetic client bug for testing // note: the max amount of "in flight" dirty data is roughly (max - target) OPTION(fuse_use_invalidate_cb, OPT_BOOL, false) // use fuse 2.8+ invalidate callback to keep page cache consistent OPTION(fuse_allow_other, OPT_BOOL, true) -- 2.39.5