From patchwork Fri Dec 18 15:33:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7886801 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 093379F1AF for ; Fri, 18 Dec 2015 15:41:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 46234204A9 for ; Fri, 18 Dec 2015 15:40:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B38F2047D for ; Fri, 18 Dec 2015 15:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932879AbbLRPkG (ORCPT ); Fri, 18 Dec 2015 10:40:06 -0500 Received: from m50-135.163.com ([123.125.50.135]:52213 "EHLO m50-135.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754039AbbLRPeF (ORCPT ); Fri, 18 Dec 2015 10:34:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=0BQ+2AC09YX4jb9eca Evdh1YttFqGuui01DVPv52T4E=; b=I/mJFc7jUFF/725lAQYeAdPK2AsqQH9spa 6fuzfL6rKQurT98LET+nv7rAXnTG2suJJjk63aIm1h9yis51ApoFrJ+AIUf+mMXz He+nFamq6SRdtiAsEb0NkqHJnUG2IB2vMoek+tFYlmL0zOw9FdYNrcKqkouK6bgT 8NG28yowI= Received: from localhost (unknown [116.77.150.30]) by smtp5 (Coremail) with SMTP id D9GowAAnDuRiJ3RWv0OjAw--.24426S3; Fri, 18 Dec 2015 23:33:55 +0800 (CST) From: Geliang Tang To: Ilya Dryomov , "Yan, Zheng" , Sage Weil , "David S. Miller" Cc: Geliang Tang , ceph-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/14] libceph: use list_for_each_entry_safe Date: Fri, 18 Dec 2015 23:33:30 +0800 Message-Id: <40510e6829654a5a4726650c63bf00d88c037593.1450451516.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-CM-TRANSID: D9GowAAnDuRiJ3RWv0OjAw--.24426S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw48Kry8tF4kAryrJF15CFg_yoW8JFWkpF Z8C3y3GFWkJw1fuF48XF9rWFyFvF13Gry2qryjk3WrKF15Gw48tF17GFyrXFyYyrWxuan0 gw48KF1UZrs2krJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UOmRUUUUUU= X-Originating-IP: [116.77.150.30] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiMAPUmVWBTMa8CwAAsX Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code. Signed-off-by: Geliang Tang --- net/ceph/messenger.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 9981039..c664b7f 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -3361,9 +3361,8 @@ static void ceph_msg_free(struct ceph_msg *m) static void ceph_msg_release(struct kref *kref) { struct ceph_msg *m = container_of(kref, struct ceph_msg, kref); - LIST_HEAD(data); - struct list_head *links; - struct list_head *next; + LIST_HEAD(head); + struct ceph_msg_data *data, *next; dout("%s %p\n", __func__, m); WARN_ON(!list_empty(&m->list_head)); @@ -3376,12 +3375,9 @@ static void ceph_msg_release(struct kref *kref) m->middle = NULL; } - list_splice_init(&m->data, &data); - list_for_each_safe(links, next, &data) { - struct ceph_msg_data *data; - - data = list_entry(links, struct ceph_msg_data, links); - list_del_init(links); + list_splice_init(&m->data, &head); + list_for_each_entry_safe(data, next, &head, links) { + list_del_init(&data->links); ceph_msg_data_destroy(data); } m->data_length = 0;