mirror of
https://github.com/ceph/ceph
synced 2025-02-02 08:22:36 +00:00
dc48f25847
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2100 29311d96-e01e-0410-9327-a35deaab8ce9
27 lines
571 B
C
27 lines
571 B
C
#include <linux/slab.h>
|
|
#include "monmap.h"
|
|
#include "messenger.h"
|
|
|
|
int ceph_monmap_decode(struct ceph_monmap *m, void **p, void *end)
|
|
{
|
|
int err;
|
|
|
|
if ((err = ceph_decode_64(p, end, &m->epoch)) < 0)
|
|
return err;
|
|
if ((err = ceph_decode_32(p, end, &m->num_mon)) < 0)
|
|
return err;
|
|
|
|
m->mon_inst = kmalloc(m->num_mon*sizeof(*m->mon_inst), GFP_KERNEL);
|
|
if (m->mon_inst == NULL)
|
|
return -ENOMEM;
|
|
if ((err = ceph_decode_copy(p, end, m->mon_inst, m->num_mon*sizeof(m->mon_inst[0]))) < 0)
|
|
goto bad;
|
|
|
|
return 0;
|
|
|
|
bad:
|
|
kfree(m->mon_inst);
|
|
m->mon_inst = 0;
|
|
return err;
|
|
}
|