diff options
| author | Sage Weil <sage@inktank.com> | 2012-08-19 15:29:16 -0400 |
|---|---|---|
| committer | Sage Weil <sage@inktank.com> | 2012-08-20 13:03:15 -0400 |
| commit | d1c338a509cea5378df59629ad47382810c38623 (patch) | |
| tree | da12e11b8ae0df8ae424d1cef0d98eac095e2268 | |
| parent | 6dab7ede9390d4d937cb89feca932e4fd575d2da (diff) | |
libceph: delay debugfs initialization until we learn global_id
The debugfs directory includes the cluster fsid and our unique global_id.
We need to delay the initialization of the debug entry until we have
learned both the fsid and our global_id from the monitor or else the
second client can't create its debugfs entry and will fail (and multiple
client instances aren't properly reflected in debugfs).
Reported by: Yan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
| -rw-r--r-- | fs/ceph/debugfs.c | 1 | ||||
| -rw-r--r-- | net/ceph/ceph_common.c | 1 | ||||
| -rw-r--r-- | net/ceph/debugfs.c | 4 | ||||
| -rw-r--r-- | net/ceph/mon_client.c | 51 |
4 files changed, 51 insertions, 6 deletions
diff --git a/fs/ceph/debugfs.c b/fs/ceph/debugfs.c index fb962efdacee..6d59006bfa27 100644 --- a/fs/ceph/debugfs.c +++ b/fs/ceph/debugfs.c | |||
| @@ -201,6 +201,7 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) | |||
| 201 | int err = -ENOMEM; | 201 | int err = -ENOMEM; |
| 202 | 202 | ||
| 203 | dout("ceph_fs_debugfs_init\n"); | 203 | dout("ceph_fs_debugfs_init\n"); |
| 204 | BUG_ON(!fsc->client->debugfs_dir); | ||
| 204 | fsc->debugfs_congestion_kb = | 205 | fsc->debugfs_congestion_kb = |
| 205 | debugfs_create_file("writeback_congestion_kb", | 206 | debugfs_create_file("writeback_congestion_kb", |
| 206 | 0600, | 207 | 0600, |
diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 69e38db28e5f..a8020293f342 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c | |||
| @@ -84,7 +84,6 @@ int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid) | |||
| 84 | return -1; | 84 | return -1; |
| 85 | } | 85 | } |
| 86 | } else { | 86 | } else { |
| 87 | pr_info("client%lld fsid %pU\n", ceph_client_id(client), fsid); | ||
| 88 | memcpy(&client->fsid, fsid, sizeof(*fsid)); | 87 | memcpy(&client->fsid, fsid, sizeof(*fsid)); |
| 89 | } | 88 | } |
| 90 | return 0; | 89 | return 0; |
diff --git a/net/ceph/debugfs.c b/net/ceph/debugfs.c index 54b531a01121..38b5dc1823d4 100644 --- a/net/ceph/debugfs.c +++ b/net/ceph/debugfs.c | |||
| @@ -189,6 +189,9 @@ int ceph_debugfs_client_init(struct ceph_client *client) | |||
| 189 | snprintf(name, sizeof(name), "%pU.client%lld", &client->fsid, | 189 | snprintf(name, sizeof(name), "%pU.client%lld", &client->fsid, |
| 190 | client->monc.auth->global_id); | 190 | client->monc.auth->global_id); |
| 191 | 191 | ||
| 192 | dout("ceph_debugfs_client_init %p %s\n", client, name); | ||
| 193 | |||
| 194 | BUG_ON(client->debugfs_dir); | ||
| 192 | client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir); | 195 | client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir); |
| 193 | if (!client->debugfs_dir) | 196 | if (!client->debugfs_dir) |
| 194 | goto out; | 197 | goto out; |
| @@ -234,6 +237,7 @@ out: | |||
| 234 | 237 | ||
| 235 | void ceph_debugfs_client_cleanup(struct ceph_client *client) | 238 | void ceph_debugfs_client_cleanup(struct ceph_client *client) |
| 236 | { | 239 | { |
| 240 | dout("ceph_debugfs_client_cleanup %p\n", client); | ||
| 237 | debugfs_remove(client->debugfs_osdmap); | 241 | debugfs_remove(client->debugfs_osdmap); |
| 238 | debugfs_remove(client->debugfs_monmap); | 242 | debugfs_remove(client->debugfs_monmap); |
| 239 | debugfs_remove(client->osdc.debugfs_file); | 243 | debugfs_remove(client->osdc.debugfs_file); |
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c index 105d533b55f3..900ea0f043fc 100644 --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c | |||
| @@ -311,6 +311,17 @@ int ceph_monc_open_session(struct ceph_mon_client *monc) | |||
| 311 | EXPORT_SYMBOL(ceph_monc_open_session); | 311 | EXPORT_SYMBOL(ceph_monc_open_session); |
| 312 | 312 | ||
| 313 | /* | 313 | /* |
| 314 | * We require the fsid and global_id in order to initialize our | ||
| 315 | * debugfs dir. | ||
| 316 | */ | ||
| 317 | static bool have_debugfs_info(struct ceph_mon_client *monc) | ||
| 318 | { | ||
| 319 | dout("have_debugfs_info fsid %d globalid %lld\n", | ||
| 320 | (int)monc->client->have_fsid, monc->auth->global_id); | ||
| 321 | return monc->client->have_fsid && monc->auth->global_id > 0; | ||
| 322 | } | ||
| 323 | |||
| 324 | /* | ||
| 314 | * The monitor responds with mount ack indicate mount success. The | 325 | * The monitor responds with mount ack indicate mount success. The |
| 315 | * included client ticket allows the client to talk to MDSs and OSDs. | 326 | * included client ticket allows the client to talk to MDSs and OSDs. |
| 316 | */ | 327 | */ |
| @@ -320,9 +331,12 @@ static void ceph_monc_handle_map(struct ceph_mon_client *monc, | |||
| 320 | struct ceph_client *client = monc->client; | 331 | struct ceph_client *client = monc->client; |
| 321 | struct ceph_monmap *monmap = NULL, *old = monc->monmap; | 332 | struct ceph_monmap *monmap = NULL, *old = monc->monmap; |
| 322 | void *p, *end; | 333 | void *p, *end; |
| 334 | int had_debugfs_info, init_debugfs = 0; | ||
| 323 | 335 | ||
| 324 | mutex_lock(&monc->mutex); | 336 | mutex_lock(&monc->mutex); |
| 325 | 337 | ||
| 338 | had_debugfs_info = have_debugfs_info(monc); | ||
| 339 | |||
| 326 | dout("handle_monmap\n"); | 340 | dout("handle_monmap\n"); |
| 327 | p = msg->front.iov_base; | 341 | p = msg->front.iov_base; |
| 328 | end = p + msg->front.iov_len; | 342 | end = p + msg->front.iov_len; |
| @@ -344,12 +358,22 @@ static void ceph_monc_handle_map(struct ceph_mon_client *monc, | |||
| 344 | 358 | ||
| 345 | if (!client->have_fsid) { | 359 | if (!client->have_fsid) { |
| 346 | client->have_fsid = true; | 360 | client->have_fsid = true; |
| 361 | if (!had_debugfs_info && have_debugfs_info(monc)) { | ||
| 362 | pr_info("client%lld fsid %pU\n", | ||
| 363 | ceph_client_id(monc->client), | ||
| 364 | &monc->client->fsid); | ||
| 365 | init_debugfs = 1; | ||
| 366 | } | ||
| 347 | mutex_unlock(&monc->mutex); | 367 | mutex_unlock(&monc->mutex); |
| 348 | /* | 368 | |
| 349 | * do debugfs initialization without mutex to avoid | 369 | if (init_debugfs) { |
| 350 | * creating a locking dependency | 370 | /* |
| 351 | */ | 371 | * do debugfs initialization without mutex to avoid |
| 352 | ceph_debugfs_client_init(client); | 372 | * creating a locking dependency |
| 373 | */ | ||
| 374 | ceph_debugfs_client_init(monc->client); | ||
| 375 | } | ||
| 376 | |||
| 353 | goto out_unlocked; | 377 | goto out_unlocked; |
| 354 | } | 378 | } |
| 355 | out: | 379 | out: |
| @@ -865,8 +889,10 @@ static void handle_auth_reply(struct ceph_mon_client *monc, | |||
| 865 | { | 889 | { |
| 866 | int ret; | 890 | int ret; |
| 867 | int was_auth = 0; | 891 | int was_auth = 0; |
| 892 | int had_debugfs_info, init_debugfs = 0; | ||
| 868 | 893 | ||
| 869 | mutex_lock(&monc->mutex); | 894 | mutex_lock(&monc->mutex); |
| 895 | had_debugfs_info = have_debugfs_info(monc); | ||
| 870 | if (monc->auth->ops) | 896 | if (monc->auth->ops) |
| 871 | was_auth = monc->auth->ops->is_authenticated(monc->auth); | 897 | was_auth = monc->auth->ops->is_authenticated(monc->auth); |
| 872 | monc->pending_auth = 0; | 898 | monc->pending_auth = 0; |
| @@ -889,7 +915,22 @@ static void handle_auth_reply(struct ceph_mon_client *monc, | |||
| 889 | __send_subscribe(monc); | 915 | __send_subscribe(monc); |
| 890 | __resend_generic_request(monc); | 916 | __resend_generic_request(monc); |
| 891 | } | 917 | } |
| 918 | |||
| 919 | if (!had_debugfs_info && have_debugfs_info(monc)) { | ||
| 920 | pr_info("client%lld fsid %pU\n", | ||
| 921 | ceph_client_id(monc->client), | ||
| 922 | &monc->client->fsid); | ||
| 923 | init_debugfs = 1; | ||
| 924 | } | ||
| 892 | mutex_unlock(&monc->mutex); | 925 | mutex_unlock(&monc->mutex); |
| 926 | |||
| 927 | if (init_debugfs) { | ||
| 928 | /* | ||
| 929 | * do debugfs initialization without mutex to avoid | ||
| 930 | * creating a locking dependency | ||
| 931 | */ | ||
| 932 | ceph_debugfs_client_init(monc->client); | ||
| 933 | } | ||
| 893 | } | 934 | } |
| 894 | 935 | ||
| 895 | static int __validate_auth(struct ceph_mon_client *monc) | 936 | static int __validate_auth(struct ceph_mon_client *monc) |
