Commit d1c338a509cea5378df59629ad47382810c38623
1 parent
6dab7ede93
Exists in
master
and in
20 other branches
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>
Showing 4 changed files with 51 additions and 6 deletions Side-by-side Diff
fs/ceph/debugfs.c
net/ceph/ceph_common.c
net/ceph/debugfs.c
... | ... | @@ -189,6 +189,9 @@ |
189 | 189 | snprintf(name, sizeof(name), "%pU.client%lld", &client->fsid, |
190 | 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 | 195 | client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir); |
193 | 196 | if (!client->debugfs_dir) |
194 | 197 | goto out; |
... | ... | @@ -234,6 +237,7 @@ |
234 | 237 | |
235 | 238 | void ceph_debugfs_client_cleanup(struct ceph_client *client) |
236 | 239 | { |
240 | + dout("ceph_debugfs_client_cleanup %p\n", client); | |
237 | 241 | debugfs_remove(client->debugfs_osdmap); |
238 | 242 | debugfs_remove(client->debugfs_monmap); |
239 | 243 | debugfs_remove(client->osdc.debugfs_file); |
net/ceph/mon_client.c
... | ... | @@ -311,6 +311,17 @@ |
311 | 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 | 325 | * The monitor responds with mount ack indicate mount success. The |
315 | 326 | * included client ticket allows the client to talk to MDSs and OSDs. |
316 | 327 | */ |
317 | 328 | |
... | ... | @@ -320,9 +331,12 @@ |
320 | 331 | struct ceph_client *client = monc->client; |
321 | 332 | struct ceph_monmap *monmap = NULL, *old = monc->monmap; |
322 | 333 | void *p, *end; |
334 | + int had_debugfs_info, init_debugfs = 0; | |
323 | 335 | |
324 | 336 | mutex_lock(&monc->mutex); |
325 | 337 | |
338 | + had_debugfs_info = have_debugfs_info(monc); | |
339 | + | |
326 | 340 | dout("handle_monmap\n"); |
327 | 341 | p = msg->front.iov_base; |
328 | 342 | end = p + msg->front.iov_len; |
329 | 343 | |
... | ... | @@ -344,12 +358,22 @@ |
344 | 358 | |
345 | 359 | if (!client->have_fsid) { |
346 | 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 | 367 | mutex_unlock(&monc->mutex); |
348 | - /* | |
349 | - * do debugfs initialization without mutex to avoid | |
350 | - * creating a locking dependency | |
351 | - */ | |
352 | - ceph_debugfs_client_init(client); | |
368 | + | |
369 | + if (init_debugfs) { | |
370 | + /* | |
371 | + * do debugfs initialization without mutex to avoid | |
372 | + * creating a locking dependency | |
373 | + */ | |
374 | + ceph_debugfs_client_init(monc->client); | |
375 | + } | |
376 | + | |
353 | 377 | goto out_unlocked; |
354 | 378 | } |
355 | 379 | out: |
356 | 380 | |
... | ... | @@ -865,8 +889,10 @@ |
865 | 889 | { |
866 | 890 | int ret; |
867 | 891 | int was_auth = 0; |
892 | + int had_debugfs_info, init_debugfs = 0; | |
868 | 893 | |
869 | 894 | mutex_lock(&monc->mutex); |
895 | + had_debugfs_info = have_debugfs_info(monc); | |
870 | 896 | if (monc->auth->ops) |
871 | 897 | was_auth = monc->auth->ops->is_authenticated(monc->auth); |
872 | 898 | monc->pending_auth = 0; |
873 | 899 | |
... | ... | @@ -889,7 +915,22 @@ |
889 | 915 | __send_subscribe(monc); |
890 | 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 | 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 | 936 | static int __validate_auth(struct ceph_mon_client *monc) |