History

Merge tag 'ceph-for-4.14-rc2' of git://github.com/ceph/ceph-client

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

Linus Torvalds committed 9 years ago

Commit b03fcfa2 parents e2577d2 717e6f23 files · +32 −13Browse files

Unified · Split

3 files
  1. fs/ceph/mds_client.c +4 −3
  2. fs/ceph/mds_client.h +3 −0
  3. net/ceph/osdmap.c +25 −10
fs/ceph/mds_client.c+4−3
@@ -7,7 +7,6 @@ · 6 unmodified lines
77 #include <linux/sched.h>
88 #include <linux/debugfs.h>
99 #include <linux/seq_file.h>
10−#include <linux/utsname.h>
1110 #include <linux/ratelimit.h>
1211
1312 #include "super.h"
@@ -884,8 +883,8 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6 · 870 unmodified lines
884883 void *p;
885884
886885 const char* metadata[][2] = {
887− {"hostname", utsname()->nodename},
888− {"kernel_version", utsname()->release},
886+ {"hostname", mdsc->nodename},
887+ {"kernel_version", init_utsname()->release},
889888 {"entity_id", opt->name ? : ""},
890889 {"root", fsopt->server_path ? : "/"},
891890 {NULL, NULL}
@@ -3539,6 +3538,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc) · 2647 unmodified lines
35393538 init_rwsem(&mdsc->pool_perm_rwsem);
35403539 mdsc->pool_perm_tree = RB_ROOT;
35413540
3541+ strncpy(mdsc->nodename, utsname()->nodename,
3542+ sizeof(mdsc->nodename) - 1);
35423543 return 0;
35433544 }
35443545
fs/ceph/mds_client.h+3−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <linux/rbtree.h>
99 #include <linux/spinlock.h>
1010 #include <linux/refcount.h>
11+#include <linux/utsname.h>
1112
1213 #include <linux/ceph/types.h>
1314 #include <linux/ceph/messenger.h>
@@ -368,6 +369,8 @@ struct ceph_mds_client { · 354 unmodified lines
368369
369370 struct rw_semaphore pool_perm_rwsem;
370371 struct rb_root pool_perm_tree;
372+
373+ char nodename[__NEW_UTS_LEN + 1];
371374 };
372375
373376 extern const char *ceph_mds_op_name(int op);
net/ceph/osdmap.c+25−10
@@ -2445,19 +2445,34 @@ static void apply_upmap(struct ceph_osdmap *osdmap, · 2444 unmodified lines
24452445
24462446 pg = lookup_pg_mapping(&osdmap->pg_upmap_items, pgid);
24472447 if (pg) {
2448− for (i = 0; i < raw->size; i++) {
2449− for (j = 0; j < pg->pg_upmap_items.len; j++) {
2450− int from = pg->pg_upmap_items.from_to[j][0];
2451− int to = pg->pg_upmap_items.from_to[j][1];
2452−
2453− if (from == raw->osds[i]) {
2454− if (!(to != CRUSH_ITEM_NONE &&
2455− to < osdmap->max_osd &&
2456− osdmap->osd_weight[to] == 0))
2457− raw->osds[i] = to;
2448+ /*
2449+ * Note: this approach does not allow a bidirectional swap,
2450+ * e.g., [[1,2],[2,1]] applied to [0,1,2] -> [0,2,1].
2451+ */
2452+ for (i = 0; i < pg->pg_upmap_items.len; i++) {
2453+ int from = pg->pg_upmap_items.from_to[i][0];
2454+ int to = pg->pg_upmap_items.from_to[i][1];
2455+ int pos = -1;
2456+ bool exists = false;
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;
24582464 break;
24592465 }
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+ }
24602473 }
2474+ if (!exists && pos >= 0)
2475+ raw->osds[pos] = to;
24612476 }
24622477 }
24632478 }

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