aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-03-01 19:00:16 -0500
committerSage Weil <sage@inktank.com>2013-05-02 00:16:35 -0400
commit9516e45b25d9967c35d2e798496ec5e590aaa24f (patch)
treed5020891abe591d1821129ce15db8d0e797c1a21
parent35c7bfbcd4fabded090e5ab316a1cbf053a0a980 (diff)
libceph: simplify new message initialization
Rather than explicitly initializing many fields to 0, NULL, or false in a newly-allocated message, just use kzalloc() for allocating new messages. This will become a much more convenient way of doing things anyway for upcoming patches that abstract the data field. Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r--net/ceph/messenger.c38
1 files changed, 4 insertions, 34 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 2734d0337f95..ce1669f75ca5 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2699,49 +2699,19 @@ struct ceph_msg *ceph_msg_new(int type, int front_len, gfp_t flags,
2699{ 2699{
2700 struct ceph_msg *m; 2700 struct ceph_msg *m;
2701 2701
2702 m = kmalloc(sizeof(*m), flags); 2702 m = kzalloc(sizeof(*m), flags);
2703 if (m == NULL) 2703 if (m == NULL)
2704 goto out; 2704 goto out;
2705 kref_init(&m->kref);
2706
2707 m->con = NULL;
2708 INIT_LIST_HEAD(&m->list_head);
2709 2705
2710 m->hdr.tid = 0;
2711 m->hdr.type = cpu_to_le16(type); 2706 m->hdr.type = cpu_to_le16(type);
2712 m->hdr.priority = cpu_to_le16(CEPH_MSG_PRIO_DEFAULT); 2707 m->hdr.priority = cpu_to_le16(CEPH_MSG_PRIO_DEFAULT);
2713 m->hdr.version = 0;
2714 m->hdr.front_len = cpu_to_le32(front_len); 2708 m->hdr.front_len = cpu_to_le32(front_len);
2715 m->hdr.middle_len = 0;
2716 m->hdr.data_len = 0;
2717 m->hdr.data_off = 0;
2718 m->hdr.reserved = 0;
2719 m->footer.front_crc = 0;
2720 m->footer.middle_crc = 0;
2721 m->footer.data_crc = 0;
2722 m->footer.flags = 0;
2723 m->front_max = front_len;
2724 m->front_is_vmalloc = false;
2725 m->more_to_follow = false;
2726 m->ack_stamp = 0;
2727 m->pool = NULL;
2728 2709
2729 /* middle */ 2710 INIT_LIST_HEAD(&m->list_head);
2730 m->middle = NULL; 2711 kref_init(&m->kref);
2731
2732 /* data */
2733 m->page_count = 0;
2734 m->page_alignment = 0;
2735 m->pages = NULL;
2736 m->pagelist = NULL;
2737#ifdef CONFIG_BLOCK
2738 m->bio = NULL;
2739 m->bio_iter = NULL;
2740 m->bio_seg = 0;
2741#endif /* CONFIG_BLOCK */
2742 m->trail = NULL;
2743 2712
2744 /* front */ 2713 /* front */
2714 m->front_max = front_len;
2745 if (front_len) { 2715 if (front_len) {
2746 if (front_len > PAGE_CACHE_SIZE) { 2716 if (front_len > PAGE_CACHE_SIZE) {
2747 m->front.iov_base = __vmalloc(front_len, flags, 2717 m->front.iov_base = __vmalloc(front_len, flags,