Commit b03fcfae authored by Linus Torvalds's avatar Linus Torvalds

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
parents e2577d22 717e6f28
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/utsname.h>
#include <linux/ratelimit.h> #include <linux/ratelimit.h>
#include "super.h" #include "super.h"
...@@ -884,8 +883,8 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6 ...@@ -884,8 +883,8 @@ static struct ceph_msg *create_session_open_msg(struct ceph_mds_client *mdsc, u6
void *p; void *p;
const char* metadata[][2] = { const char* metadata[][2] = {
{"hostname", utsname()->nodename}, {"hostname", mdsc->nodename},
{"kernel_version", utsname()->release}, {"kernel_version", init_utsname()->release},
{"entity_id", opt->name ? : ""}, {"entity_id", opt->name ? : ""},
{"root", fsopt->server_path ? : "/"}, {"root", fsopt->server_path ? : "/"},
{NULL, NULL} {NULL, NULL}
...@@ -3539,6 +3538,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc) ...@@ -3539,6 +3538,8 @@ int ceph_mdsc_init(struct ceph_fs_client *fsc)
init_rwsem(&mdsc->pool_perm_rwsem); init_rwsem(&mdsc->pool_perm_rwsem);
mdsc->pool_perm_tree = RB_ROOT; mdsc->pool_perm_tree = RB_ROOT;
strncpy(mdsc->nodename, utsname()->nodename,
sizeof(mdsc->nodename) - 1);
return 0; return 0;
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/utsname.h>
#include <linux/ceph/types.h> #include <linux/ceph/types.h>
#include <linux/ceph/messenger.h> #include <linux/ceph/messenger.h>
...@@ -368,6 +369,8 @@ struct ceph_mds_client { ...@@ -368,6 +369,8 @@ struct ceph_mds_client {
struct rw_semaphore pool_perm_rwsem; struct rw_semaphore pool_perm_rwsem;
struct rb_root pool_perm_tree; struct rb_root pool_perm_tree;
char nodename[__NEW_UTS_LEN + 1];
}; };
extern const char *ceph_mds_op_name(int op); extern const char *ceph_mds_op_name(int op);
......
...@@ -2445,19 +2445,34 @@ static void apply_upmap(struct ceph_osdmap *osdmap, ...@@ -2445,19 +2445,34 @@ static void apply_upmap(struct ceph_osdmap *osdmap,
pg = lookup_pg_mapping(&osdmap->pg_upmap_items, pgid); pg = lookup_pg_mapping(&osdmap->pg_upmap_items, pgid);
if (pg) { if (pg) {
for (i = 0; i < raw->size; i++) { /*
for (j = 0; j < pg->pg_upmap_items.len; j++) { * Note: this approach does not allow a bidirectional swap,
int from = pg->pg_upmap_items.from_to[j][0]; * e.g., [[1,2],[2,1]] applied to [0,1,2] -> [0,2,1].
int to = pg->pg_upmap_items.from_to[j][1]; */
for (i = 0; i < pg->pg_upmap_items.len; i++) {
if (from == raw->osds[i]) { int from = pg->pg_upmap_items.from_to[i][0];
if (!(to != CRUSH_ITEM_NONE && int to = pg->pg_upmap_items.from_to[i][1];
to < osdmap->max_osd && int pos = -1;
osdmap->osd_weight[to] == 0)) bool exists = false;
raw->osds[i] = to;
/* make sure replacement doesn't already appear */
for (j = 0; j < raw->size; j++) {
int osd = raw->osds[j];
if (osd == to) {
exists = true;
break; break;
} }
/* ignore mapping if target is marked out */
if (osd == from && pos < 0 &&
!(to != CRUSH_ITEM_NONE &&
to < osdmap->max_osd &&
osdmap->osd_weight[to] == 0)) {
pos = j;
}
} }
if (!exists && pos >= 0)
raw->osds[pos] = to;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment