History

libceph: wait for latest osdmap in ceph_monc_blacklist_add()

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 corruption. 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.

Ilya Dryomov committed 7 years ago

Commit bb229bb1 parent 16d80c53 files · +28 −1Browse files

Unified · Split

3 files
  1. include/linux/ceph/libceph.h +2 −0
  2. net/ceph/ceph_common.c +17 −1
  3. net/ceph/mon_client.c +9 −0
include/linux/ceph/libceph.h+2−0
@@ -294,6 +294,8 @@ extern void ceph_destroy_client(struct ceph_client *client); · 293 unmodified lines
294extern int __ceph_open_session(struct ceph_client *client,294extern int __ceph_open_session(struct ceph_client *client,
295 unsigned long started);295 unsigned long started);
296extern int ceph_open_session(struct ceph_client *client);296extern int ceph_open_session(struct ceph_client *client);
297int ceph_wait_for_latest_osdmap(struct ceph_client *client,
298 unsigned long timeout);
297 299
298/* pagevec.c */300/* pagevec.c */
299extern void ceph_release_page_vector(struct page **pages, int num_pages);301extern void ceph_release_page_vector(struct page **pages, int num_pages);
net/ceph/ceph_common.c+17−1
@@ -738,7 +738,6 @@ int __ceph_open_session(struct ceph_client *client, unsigned long started) · 737 unmodified lines
738}738}
739EXPORT_SYMBOL(__ceph_open_session);739EXPORT_SYMBOL(__ceph_open_session);
740 740
741
742int ceph_open_session(struct ceph_client *client)741int ceph_open_session(struct ceph_client *client)
743{742{
744 int ret;743 int ret;
@@ -754,6 +753,23 @@ int ceph_open_session(struct ceph_client *client) · 9 unmodified lines
754}753}
755EXPORT_SYMBOL(ceph_open_session);754EXPORT_SYMBOL(ceph_open_session);
756 755
756int ceph_wait_for_latest_osdmap(struct ceph_client *client,
757 unsigned long timeout)
758{
759 u64 newest_epoch;
760 int ret;
761
762 ret = ceph_monc_get_version(&client->monc, "osdmap", &newest_epoch);
763 if (ret)
764 return ret;
765
766 if (client->osdc.osdmap->epoch >= newest_epoch)
767 return 0;
768
769 ceph_osdc_maybe_request_map(&client->osdc);
770 return ceph_monc_wait_osdmap(&client->monc, newest_epoch, timeout);
771}
772EXPORT_SYMBOL(ceph_wait_for_latest_osdmap);
757 773
758static int __init init_ceph_lib(void)774static int __init init_ceph_lib(void)
759{775{
net/ceph/mon_client.c+9−0
@@ -922,6 +922,15 @@ int ceph_monc_blacklist_add(struct ceph_mon_client *monc, · 921 unmodified lines
922 mutex_unlock(&monc->mutex);922 mutex_unlock(&monc->mutex);
923 923
924 ret = wait_generic_request(req);924 ret = wait_generic_request(req);
925 if (!ret)
926 /*
927 * Make sure we have the osdmap that includes the blacklist
928 * entry. This is needed to ensure that the OSDs pick up the
929 * new blacklist before processing any future requests from
930 * this client.
931 */
932 ret = ceph_wait_for_latest_osdmap(monc->client, 0);
933
925out:934out:
926 put_generic_request(req);935 put_generic_request(req);
927 return ret;936 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t