From patchwork Sat Mar 9 15:15:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2241741 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C3883DF2F2 for ; Sat, 9 Mar 2013 15:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932288Ab3CIPPW (ORCPT ); Sat, 9 Mar 2013 10:15:22 -0500 Received: from mail-ie0-f176.google.com ([209.85.223.176]:64927 "EHLO mail-ie0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758645Ab3CIPPV (ORCPT ); Sat, 9 Mar 2013 10:15:21 -0500 Received: by mail-ie0-f176.google.com with SMTP id k13so3175873iea.35 for ; Sat, 09 Mar 2013 07:15:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=vM4zoyDe8HFhVGMFvMOZkyU0HNgOiGj/kmFTz4c2bwM=; b=UX/TunIfLB3W2Pgxvm0G2XOYiIVZ7T1RmjSC7c6XqIWoSzBlaJLSKK3ZhKo3JINxaA TzFZQvAz00vaKRpkKdXRU/pjpZn/haepqA+Sq41EQfId431JK+1i/a6l2EL71rno8woR sLAwf95Itmzrd0ZM8Ehk866cMYx+MuE6AtbqZGDGTjd1wgqN6ot1fBkhSW2941gQeSSo Yjx5mcATlVCXC+IyiVLjDZ1w7kttFR7o41I2a5T/rbzkEAqD4m7of15uTh7ECp0ugnss tx1FD/PgcuxkSyxwhDC7zNH4SNhgodUQBbKXDPfaebI7ksy9UJaF8fONVuKY7O3AKilg PFQw== X-Received: by 10.50.214.67 with SMTP id ny3mr2566130igc.13.1362842120577; Sat, 09 Mar 2013 07:15:20 -0800 (PST) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPS id ur12sm4546614igb.8.2013.03.09.07.15.18 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 09 Mar 2013 07:15:19 -0800 (PST) Message-ID: <513B5206.4080704@inktank.com> Date: Sat, 09 Mar 2013 09:15:18 -0600 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130221 Thunderbird/17.0.3 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH 7/8] libceph: simplify new message initialization References: <513B5116.2020305@inktank.com> In-Reply-To: <513B5116.2020305@inktank.com> X-Gm-Message-State: ALoCoQnIi+ejA0oiAeOODjFUKb+Slyj/SGmWY/HmBacsmCIQiPXXo5jEtB/W5nzMo9ayHy6uJ7k8 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 --- net/ceph/messenger.c | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) m->front.iov_base = __vmalloc(front_len, flags, diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 2734d03..ce1669f 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, { struct ceph_msg *m; - m = kmalloc(sizeof(*m), flags); + m = kzalloc(sizeof(*m), flags); if (m == NULL) goto out; - kref_init(&m->kref); - - m->con = NULL; - INIT_LIST_HEAD(&m->list_head); - m->hdr.tid = 0; m->hdr.type = cpu_to_le16(type); m->hdr.priority = cpu_to_le16(CEPH_MSG_PRIO_DEFAULT); - m->hdr.version = 0; m->hdr.front_len = cpu_to_le32(front_len); - m->hdr.middle_len = 0; - m->hdr.data_len = 0; - m->hdr.data_off = 0; - m->hdr.reserved = 0; - m->footer.front_crc = 0; - m->footer.middle_crc = 0; - m->footer.data_crc = 0; - m->footer.flags = 0; - m->front_max = front_len; - m->front_is_vmalloc = false; - m->more_to_follow = false; - m->ack_stamp = 0; - m->pool = NULL; - /* middle */ - m->middle = NULL; - - /* data */ - m->page_count = 0; - m->page_alignment = 0; - m->pages = NULL; - m->pagelist = NULL; -#ifdef CONFIG_BLOCK - m->bio = NULL; - m->bio_iter = NULL; - m->bio_seg = 0; -#endif /* CONFIG_BLOCK */ - m->trail = NULL; + INIT_LIST_HEAD(&m->list_head); + kref_init(&m->kref); /* front */ + m->front_max = front_len; if (front_len) { if (front_len > PAGE_CACHE_SIZE) {