Commit 842d6b01 authored by Daichi Mukai's avatar Daichi Mukai Committed by Ilya Dryomov
Browse files

libceph: print fsid and epoch with osd id



Print fsid and epoch in libceph log messages to distinct from which
each message come.

[ idryomov: don't bother with gid for now, print epoch instead ]

Signed-off-by: default avatarSatoru Takeuchi <satoru.takeuchi@gmail.com>
Signed-off-by: default avatarDaichi Mukai <daichi-mukai@cybozu.co.jp>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent fc54cb8d
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -11,6 +11,22 @@
#include <linux/crush/hash.h>
#include <linux/crush/mapper.h>

static __printf(2, 3)
void osdmap_info(const struct ceph_osdmap *map, const char *fmt, ...)
{
	struct va_format vaf;
	va_list args;

	va_start(args, fmt);
	vaf.fmt = fmt;
	vaf.va = &args;

	printk(KERN_INFO "%s (%pU e%u): %pV", KBUILD_MODNAME, &map->fsid,
	       map->epoch, &vaf);

	va_end(args);
}

char *ceph_osdmap_state_str(char *str, int len, u32 state)
{
	if (!len)
@@ -1566,7 +1582,7 @@ static int decode_new_primary_affinity(void **p, void *end,
		if (ret)
			return ret;

		pr_info("osd%d primary-affinity 0x%x\n", osd, aff);
		osdmap_info(map, "osd%d primary-affinity 0x%x\n", osd, aff);
	}

	return 0;
@@ -1864,7 +1880,7 @@ static int decode_new_up_state_weight(void **p, void *end, u8 struct_v,
		osd = ceph_decode_32(p);
		w = ceph_decode_32(p);
		BUG_ON(osd >= map->max_osd);
		pr_info("osd%d weight 0x%x %s\n", osd, w,
		osdmap_info(map, "osd%d weight 0x%x %s\n", osd, w,
			    w == CEPH_OSD_IN ? "(in)" :
			    (w == CEPH_OSD_OUT ? "(out)" : ""));
		map->osd_weight[osd] = w;
@@ -1898,10 +1914,10 @@ static int decode_new_up_state_weight(void **p, void *end, u8 struct_v,
		BUG_ON(osd >= map->max_osd);
		if ((map->osd_state[osd] & CEPH_OSD_UP) &&
		    (xorstate & CEPH_OSD_UP))
			pr_info("osd%d down\n", osd);
			osdmap_info(map, "osd%d down\n", osd);
		if ((map->osd_state[osd] & CEPH_OSD_EXISTS) &&
		    (xorstate & CEPH_OSD_EXISTS)) {
			pr_info("osd%d does not exist\n", osd);
			osdmap_info(map, "osd%d does not exist\n", osd);
			ret = set_primary_affinity(map, osd,
						   CEPH_OSD_DEFAULT_PRIMARY_AFFINITY);
			if (ret)
@@ -1931,7 +1947,7 @@ static int decode_new_up_state_weight(void **p, void *end, u8 struct_v,

		dout("%s osd%d addr %s\n", __func__, osd, ceph_pr_addr(&addr));

		pr_info("osd%d up\n", osd);
		osdmap_info(map, "osd%d up\n", osd);
		map->osd_state[osd] |= CEPH_OSD_EXISTS | CEPH_OSD_UP;
		map->osd_addr[osd] = addr;
	}