ceph: only set message data pointers if non-empty
authorAlex Elder <elder@inktank.com>
Tue, 5 Mar 2013 04:29:57 +0000 (22:29 -0600)
committerSage Weil <sage@inktank.com>
Thu, 2 May 2013 04:16:41 +0000 (21:16 -0700)
Change it so we only assign outgoing data information for messages
if there is outgoing data to send.

This then allows us to add a few more (currently commented-out)
assertions.

This is related to:
    http://tracker.ceph.com/issues/4284

Signed-off-by: Alex Elder <elder@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
fs/ceph/mds_client.c
net/ceph/messenger.c
net/ceph/osd_client.c

index 3b2aa8702ae0fa4adefb962dd9a07c15ddc18327..600d770d70f7a6725bf72d94e952d52aa210c02b 100644 (file)
@@ -1721,7 +1721,11 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
        msg->front.iov_len = p - msg->front.iov_base;
        msg->hdr.front_len = cpu_to_le32(msg->front.iov_len);
 
-       ceph_msg_data_set_pages(msg, req->r_pages, req->r_data_len, 0);
+       if (req->r_data_len) {
+               /* outbound data set only by ceph_sync_setxattr() */
+               BUG_ON(!req->r_pages);
+               ceph_msg_data_set_pages(msg, req->r_pages, req->r_data_len, 0);
+       }
 
        msg->hdr.data_len = cpu_to_le32(req->r_data_len);
        msg->hdr.data_off = cpu_to_le16(0);
@@ -2603,10 +2607,13 @@ static void send_mds_reconnect(struct ceph_mds_client *mdsc,
                        goto fail;
        }
 
-       ceph_msg_data_set_pagelist(reply, pagelist);
        if (recon_state.flock)
                reply->hdr.version = cpu_to_le16(2);
-       reply->hdr.data_len = cpu_to_le32(pagelist->length);
+       if (pagelist->length) {
+               /* set up outbound data if we have any */
+               reply->hdr.data_len = cpu_to_le32(pagelist->length);
+               ceph_msg_data_set_pagelist(reply, pagelist);
+       }
        ceph_con_send(&session->s_con, reply);
 
        mutex_unlock(&session->s_mutex);
index d1183536d5a8bacd3269f5f1addee529bdb088d7..1965d785cf836b03f31cadeaafbe92bfb09d1140 100644 (file)
@@ -2692,6 +2692,8 @@ EXPORT_SYMBOL(ceph_con_keepalive);
 void ceph_msg_data_set_pages(struct ceph_msg *msg, struct page **pages,
                size_t length, size_t alignment)
 {
+       /* BUG_ON(!pages); */
+       /* BUG_ON(!length); */
        /* BUG_ON(msg->pages); */
        /* BUG_ON(msg->page_count); */
 
@@ -2705,6 +2707,7 @@ void ceph_msg_data_set_pagelist(struct ceph_msg *msg,
                                struct ceph_pagelist *pagelist)
 {
        /* BUG_ON(!pagelist); */
+       /* BUG_ON(!pagelist->length); */
        /* BUG_ON(msg->pagelist); */
 
        msg->pagelist = pagelist;
@@ -2723,6 +2726,7 @@ EXPORT_SYMBOL(ceph_msg_data_set_bio);
 void ceph_msg_data_set_trail(struct ceph_msg *msg, struct ceph_pagelist *trail)
 {
        /* BUG_ON(!trail); */
+       /* BUG_ON(!trail->length); */
        /* BUG_ON(msg->trail); */
 
        msg->trail = trail;
index 387e3123d1ed5acf7c0503db507e01ad4c655c56..4402e917b9b15909658c170aa9ab101d5aef98f1 100644 (file)
@@ -1759,8 +1759,10 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc,
        osd_data = &req->r_data_out;
        if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) {
                BUG_ON(osd_data->length > (u64) SIZE_MAX);
-               ceph_msg_data_set_pages(req->r_request, osd_data->pages,
-                       osd_data->length, osd_data->alignment);
+               if (osd_data->length)
+                       ceph_msg_data_set_pages(req->r_request,
+                               osd_data->pages, osd_data->length,
+                               osd_data->alignment);
 #ifdef CONFIG_BLOCK
        } else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) {
                ceph_msg_data_set_bio(req->r_request, osd_data->bio);
@@ -1768,7 +1770,8 @@ int ceph_osdc_start_request(struct ceph_osd_client *osdc,
        } else {
                BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE);
        }
-       ceph_msg_data_set_trail(req->r_request, &req->r_trail);
+       if (req->r_trail.length)
+               ceph_msg_data_set_trail(req->r_request, &req->r_trail);
 
        register_request(osdc, req);