Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb257664 authored by Sage Weil's avatar Sage Weil
Browse files

ceph: simplify ceph_msg_new



We only need to pass in front_len.  Callers can attach any other payload
pieces (middle, data) as they see fit.

Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent a79832f2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -938,7 +938,7 @@ static int send_cap_msg(struct ceph_mds_session *session,
	     seq, issue_seq, mseq, follows, size, max_size,
	     xattr_version, xattrs_buf ? (int)xattrs_buf->vec.iov_len : 0);

	msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc), 0, 0, NULL);
	msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPS, sizeof(*fc));
	if (!msg)
		return -ENOMEM;

+5 −6
Original line number Diff line number Diff line
@@ -665,7 +665,7 @@ static struct ceph_msg *create_session_msg(u32 op, u64 seq)
	struct ceph_msg *msg;
	struct ceph_mds_session_head *h;

	msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h), 0, 0, NULL);
	msg = ceph_msg_new(CEPH_MSG_CLIENT_SESSION, sizeof(*h));
	if (!msg) {
		pr_err("create_session_msg ENOMEM creating msg\n");
		return NULL;
@@ -1051,8 +1051,7 @@ static int add_cap_releases(struct ceph_mds_client *mdsc,

	while (session->s_num_cap_releases < session->s_nr_caps + extra) {
		spin_unlock(&session->s_cap_lock);
		msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE,
				   0, 0, NULL);
		msg = ceph_msg_new(CEPH_MSG_CLIENT_CAPRELEASE, PAGE_CACHE_SIZE);
		if (!msg)
			goto out_unlocked;
		dout("add_cap_releases %p msg %p now %d\n", session, msg,
@@ -1418,7 +1417,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
	if (req->r_old_dentry_drop)
		len += req->r_old_dentry->d_name.len;

	msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len, 0, 0, NULL);
	msg = ceph_msg_new(CEPH_MSG_CLIENT_REQUEST, len);
	if (!msg) {
		msg = ERR_PTR(-ENOMEM);
		goto out_free2;
@@ -2154,7 +2153,7 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc, int mds)
	ceph_pagelist_init(pagelist);

	err = -ENOMEM;
	reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0, 0, 0, NULL);
	reply = ceph_msg_new(CEPH_MSG_CLIENT_RECONNECT, 0);
	if (!reply)
		goto fail_nomsg;

@@ -2462,7 +2461,7 @@ void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
	dnamelen = dentry->d_name.len;
	len += dnamelen;

	msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, 0, 0, NULL);
	msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len);
	if (!msg)
		return;
	lease = msg->front.iov_base;
+9 −11
Original line number Diff line number Diff line
@@ -2081,8 +2081,7 @@ void ceph_con_keepalive(struct ceph_connection *con)
 * construct a new message with given type, size
 * the new msg has a ref count of 1.
 */
struct ceph_msg *ceph_msg_new(int type, int front_len,
			      int page_len, int page_off, struct page **pages)
struct ceph_msg *ceph_msg_new(int type, int front_len)
{
	struct ceph_msg *m;

@@ -2098,8 +2097,8 @@ struct ceph_msg *ceph_msg_new(int type, int front_len,
	m->hdr.version = 0;
	m->hdr.front_len = cpu_to_le32(front_len);
	m->hdr.middle_len = 0;
	m->hdr.data_len = cpu_to_le32(page_len);
	m->hdr.data_off = cpu_to_le16(page_off);
	m->hdr.data_len = 0;
	m->hdr.data_off = 0;
	m->hdr.reserved = 0;
	m->footer.front_crc = 0;
	m->footer.middle_crc = 0;
@@ -2133,18 +2132,17 @@ struct ceph_msg *ceph_msg_new(int type, int front_len,
	m->middle = NULL;

	/* data */
	m->nr_pages = calc_pages_for(page_off, page_len);
	m->pages = pages;
	m->nr_pages = 0;
	m->pages = NULL;
	m->pagelist = NULL;

	dout("ceph_msg_new %p page %d~%d -> %d\n", m, page_off, page_len,
	     m->nr_pages);
	dout("ceph_msg_new %p front %d\n", m, front_len);
	return m;

out2:
	ceph_msg_put(m);
out:
	pr_err("msg_new can't create type %d len %d\n", type, front_len);
	pr_err("msg_new can't create type %d front %d\n", type, front_len);
	return NULL;
}

@@ -2193,7 +2191,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
	}
	if (!msg) {
		*skip = 0;
		msg = ceph_msg_new(type, front_len, 0, 0, NULL);
		msg = ceph_msg_new(type, front_len);
		if (!msg) {
			pr_err("unable to allocate msg type %d len %d\n",
			       type, front_len);
@@ -2202,7 +2200,7 @@ static struct ceph_msg *ceph_alloc_msg(struct ceph_connection *con,
	}
	memcpy(&msg->hdr, &con->in_hdr, sizeof(con->in_hdr));

	if (middle_len) {
	if (middle_len && !msg->middle) {
		ret = ceph_alloc_middle(con, msg);
		if (ret < 0) {
			ceph_msg_put(msg);
+1 −3
Original line number Diff line number Diff line
@@ -234,9 +234,7 @@ extern void ceph_con_keepalive(struct ceph_connection *con);
extern struct ceph_connection *ceph_con_get(struct ceph_connection *con);
extern void ceph_con_put(struct ceph_connection *con);

extern struct ceph_msg *ceph_msg_new(int type, int front_len,
				     int page_len, int page_off,
				     struct page **pages);
extern struct ceph_msg *ceph_msg_new(int type, int front_len);
extern void ceph_msg_kfree(struct ceph_msg *m);


+7 −9
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ static void __send_subscribe(struct ceph_mon_client *monc)
		struct ceph_mon_subscribe_item *i;
		void *p, *end;

		msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96, 0, 0, NULL);
		msg = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE, 96);
		if (!msg)
			return;

@@ -491,10 +491,10 @@ int ceph_monc_do_statfs(struct ceph_mon_client *monc, struct ceph_statfs *buf)
	init_completion(&req->completion);

	err = -ENOMEM;
	req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h), 0, 0, NULL);
	req->request = ceph_msg_new(CEPH_MSG_STATFS, sizeof(*h));
	if (!req->request)
		goto out;
	req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024, 0, 0, NULL);
	req->reply = ceph_msg_new(CEPH_MSG_STATFS_REPLY, 1024);
	if (!req->reply)
		goto out;

@@ -633,17 +633,15 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
	/* msg pools */
	err = -ENOMEM;
	monc->m_subscribe_ack = ceph_msg_new(CEPH_MSG_MON_SUBSCRIBE_ACK,
				     sizeof(struct ceph_mon_subscribe_ack),
				     0, 0, NULL);
				     sizeof(struct ceph_mon_subscribe_ack));
	if (!monc->m_subscribe_ack)
		goto out_monmap;

	monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096, 0, 0,
					  NULL);
	monc->m_auth_reply = ceph_msg_new(CEPH_MSG_AUTH_REPLY, 4096);
	if (!monc->m_auth_reply)
		goto out_subscribe_ack;

	monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096, 0, 0, NULL);
	monc->m_auth = ceph_msg_new(CEPH_MSG_AUTH, 4096);
	monc->pending_auth = 0;
	if (!monc->m_auth)
		goto out_auth_reply;
@@ -818,7 +816,7 @@ static struct ceph_msg *mon_alloc_msg(struct ceph_connection *con,
	case CEPH_MSG_MON_MAP:
	case CEPH_MSG_MDS_MAP:
	case CEPH_MSG_OSD_MAP:
		m = ceph_msg_new(type, front_len, 0, 0, NULL);
		m = ceph_msg_new(type, front_len);
		break;
	}

Loading