Commit 2e5522ad authored by Ilya Dryomov's avatar Ilya Dryomov Committed by Greg Kroah-Hartman

libceph: wait for latest osdmap in ceph_monc_blacklist_add()

commit bb229bbb3bf63d23128e851a1f3b85c083178fa1 upstream.

Because map updates are distributed lazily, an OSD may not know about
the new blacklist for quite some time after "osd blacklist add" command
is completed.  This makes it possible for a blacklisted but still alive
client to overwrite a post-blacklist update, resulting in data

Waiting for latest osdmap in ceph_monc_blacklist_add() and thus using
the post-blacklist epoch for all post-blacklist requests ensures that
all such requests "wait" for the blacklist to come into force on their
respective OSDs.

Fixes: 6305a3b4 ("libceph: support for blacklisting clients")
Signed-off-by: default avatarIlya Dryomov <>
Reviewed-by: default avatarJason Dillaman <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 1e7b9a31
......@@ -291,6 +291,8 @@ extern void ceph_destroy_client(struct ceph_client *client);
extern int __ceph_open_session(struct ceph_client *client,
unsigned long started);
extern int ceph_open_session(struct ceph_client *client);
int ceph_wait_for_latest_osdmap(struct ceph_client *client,
unsigned long timeout);
/* pagevec.c */
extern void ceph_release_page_vector(struct page **pages, int num_pages);
......@@ -720,7 +720,6 @@ int __ceph_open_session(struct ceph_client *client, unsigned long started)
int ceph_open_session(struct ceph_client *client)
int ret;
......@@ -736,6 +735,23 @@ int ceph_open_session(struct ceph_client *client)
int ceph_wait_for_latest_osdmap(struct ceph_client *client,
unsigned long timeout)
u64 newest_epoch;
int ret;
ret = ceph_monc_get_version(&client->monc, "osdmap", &newest_epoch);
if (ret)
return ret;
if (client->osdc.osdmap->epoch >= newest_epoch)
return 0;
return ceph_monc_wait_osdmap(&client->monc, newest_epoch, timeout);
static int __init init_ceph_lib(void)
......@@ -922,6 +922,15 @@ int ceph_monc_blacklist_add(struct ceph_mon_client *monc,
ret = wait_generic_request(req);
if (!ret)
* Make sure we have the osdmap that includes the blacklist
* entry. This is needed to ensure that the OSDs pick up the
* new blacklist before processing any future requests from
* this client.
ret = ceph_wait_for_latest_osdmap(monc->client, 0);
return ret;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment