Pull ceph fixes from Ilya Dryomov: "Two small but important fixes: RADOS semantic change in upcoming v12.2.1 release and a rare NULL dereference in create_session_open_msg()" * tag 'ceph-for-4.14-rc2' of git://github.com/ceph/ceph-client: ceph: avoid panic in create_session_open_msg() if utsname() returns NULL libceph: don't allow bidirectional swap of pg-upmap-items
Unified · Split
| @@ -7,7 +7,6 @@ · 6 unmodified lines | |||
| 7 | #include <linux/sched.h> | 7 | #include <linux/sched.h> |
| 8 | #include <linux/debugfs.h> | 8 | #include <linux/debugfs.h> |
| 9 | #include <linux/seq_file.h> | 9 | #include <linux/seq_file.h> |
| 10 | #include <linux/utsname.h> | ||
| 11 | #include <linux/ratelimit.h> | 10 | #include <linux/ratelimit.h> |
| 12 | 11 | ||
| 13 | #include "super.h" | 12 | #include "super.h" |
| @@ -884,8 +883,8 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6 · 870 unmodified lines | |||
| 884 | void *p; | 883 | void *p; |
| 885 | 884 | ||
| 886 | const char* metadata[][2] = { | 885 | const char* metadata[][2] = { |
| 887 | {"hostname", utsname()->nodename}, | 886 | {"hostname", mdsc->nodename}, |
| 888 | {"kernel_version", utsname()->release}, | 887 | {"kernel_version", init_utsname()->release}, |
| 889 | {"entity_id", opt->name ? : ""}, | 888 | {"entity_id", opt->name ? : ""}, |
| 890 | {"root", fsopt->server_path ? : "/"}, | 889 | {"root", fsopt->server_path ? : "/"}, |
| 891 | {NULL, NULL} | 890 | {NULL, NULL} |
| @@ -3539,6 +3538,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc) · 2647 unmodified lines | |||
| 3539 | init_rwsem(&mdsc->pool_perm_rwsem); | 3538 | init_rwsem(&mdsc->pool_perm_rwsem); |
| 3540 | mdsc->pool_perm_tree = RB_ROOT; | 3539 | mdsc->pool_perm_tree = RB_ROOT; |
| 3541 | 3540 | ||
| 3541 | strncpy(mdsc->nodename, utsname()->nodename, | ||
| 3542 | sizeof(mdsc->nodename) - 1); | ||
| 3542 | return 0; | 3543 | return 0; |
| 3543 | } | 3544 | } |
| 3544 | 3545 | ||
| @@ -8,6 +8,7 @@ · 7 unmodified lines | |||
| 8 | #include <linux/rbtree.h> | 8 | #include <linux/rbtree.h> |
| 9 | #include <linux/spinlock.h> | 9 | #include <linux/spinlock.h> |
| 10 | #include <linux/refcount.h> | 10 | #include <linux/refcount.h> |
| 11 | #include <linux/utsname.h> | ||
| 11 | 12 | ||
| 12 | #include <linux/ceph/types.h> | 13 | #include <linux/ceph/types.h> |
| 13 | #include <linux/ceph/messenger.h> | 14 | #include <linux/ceph/messenger.h> |
| @@ -368,6 +369,8 @@ struct ceph_mds_client { · 354 unmodified lines | |||
| 368 | 369 | ||
| 369 | struct rw_semaphore pool_perm_rwsem; | 370 | struct rw_semaphore pool_perm_rwsem; |
| 370 | struct rb_root pool_perm_tree; | 371 | struct rb_root pool_perm_tree; |
| 372 | |||
| 373 | char nodename[__NEW_UTS_LEN + 1]; | ||
| 371 | }; | 374 | }; |
| 372 | 375 | ||
| 373 | extern const char *ceph_mds_op_name(int op); | 376 | extern const char *ceph_mds_op_name(int op); |
| @@ -2445,19 +2445,34 @@ static void apply_upmap(struct ceph_osdmap *osdmap, · 2444 unmodified lines | |||
| 2445 | 2445 | ||
| 2446 | pg = lookup_pg_mapping(&osdmap->pg_upmap_items, pgid); | 2446 | pg = lookup_pg_mapping(&osdmap->pg_upmap_items, pgid); |
| 2447 | if (pg) { | 2447 | if (pg) { |
| 2448 | for (i = 0; i < raw->size; i++) { | 2448 | /* |
| 2449 | for (j = 0; j < pg->pg_upmap_items.len; j++) { | 2449 | * Note: this approach does not allow a bidirectional swap, |
| 2450 | int from = pg->pg_upmap_items.from_to[j][0]; | 2450 | * e.g., [[1,2],[2,1]] applied to [0,1,2] -> [0,2,1]. |
| 2451 | int to = pg->pg_upmap_items.from_to[j][1]; | 2451 | */ |
| 2452 | 2452 | for (i = 0; i < pg->pg_upmap_items.len; i++) { | |
| 2453 | if (from == raw->osds[i]) { | 2453 | int from = pg->pg_upmap_items.from_to[i][0]; |
| 2454 | if (!(to != CRUSH_ITEM_NONE && | 2454 | int to = pg->pg_upmap_items.from_to[i][1]; |
| 2455 | to < osdmap->max_osd && | 2455 | int pos = -1; |
| 2456 | osdmap->osd_weight[to] == 0)) | 2456 | bool exists = false; |
| 2457 | raw->osds[i] = to; | 2457 | |
| 2458 | /* make sure replacement doesn't already appear */ | ||
| 2459 | for (j = 0; j < raw->size; j++) { | ||
| 2460 | int osd = raw->osds[j]; | ||
| 2461 | |||
| 2462 | if (osd == to) { | ||
| 2463 | exists = true; | ||
| 2458 | break; | 2464 | break; |
| 2459 | } | 2465 | } |
| 2466 | /* ignore mapping if target is marked out */ | ||
| 2467 | if (osd == from && pos < 0 && | ||
| 2468 | !(to != CRUSH_ITEM_NONE && | ||
| 2469 | to < osdmap->max_osd && | ||
| 2470 | osdmap->osd_weight[to] == 0)) { | ||
| 2471 | pos = j; | ||
| 2472 | } | ||
| 2460 | } | 2473 | } |
| 2474 | if (!exists && pos >= 0) | ||
| 2475 | raw->osds[pos] = to; | ||
| 2461 | } | 2476 | } |
| 2462 | } | 2477 | } |
| 2463 | } | 2478 | } |