From patchwork Sun Mar 17 12:22:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 10856291 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB90A1390 for ; Sun, 17 Mar 2019 12:23:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC49629506 for ; Sun, 17 Mar 2019 12:23:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD9E12950E; Sun, 17 Mar 2019 12:23:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C18F29506 for ; Sun, 17 Mar 2019 12:23:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D4A630832D4; Sun, 17 Mar 2019 12:23:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E17841001DFE; Sun, 17 Mar 2019 12:23:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4A735181A138; Sun, 17 Mar 2019 12:23:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2HCN74j021939 for ; Sun, 17 Mar 2019 08:23:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id AFB8E1001DFE; Sun, 17 Mar 2019 12:23:07 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA42C1001DE1 for ; Sun, 17 Mar 2019 12:23:05 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB4E8118EBA for ; Sun, 17 Mar 2019 12:23:04 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id i8so14046719wrm.0 for ; Sun, 17 Mar 2019 05:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arrikto-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RkrYZLLM/svtOayGyKhgfyVlvewbzak9YejfanGGyf0=; b=oePQeXqNxnitLQbzw0Aawm6Vo99ZCdQ/8op5I3x4fwVrpgXZ2vFVP1djMmyk2alitV qofim9f9tS2F5P9wAsXdjq+0bUb5WU2Mtn3VkDbUiZ3Tp2kuwwAS8xls8CuTc8VT6goj GSE5DV7ux8Cw8qGjcj/10/O4xvKA30+v+l8U73QmHl/Xw8IzQdOTNMUMCHj9+TEzrl/C 1g8NYZs+UmDN67YSBNnvQCQ7HgNDo9zxvmDEmB6all/KIRy9CmsudSgg/y/NXsvOs2hX fDAbajPOiKh09vXGErNa2yAD4ozRKjdEFY8IEAhA+IMwqTZh2eicDXmJBEkdQexIkkW/ 2l9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RkrYZLLM/svtOayGyKhgfyVlvewbzak9YejfanGGyf0=; b=TSNKBVEy/YfbbmHliTOYtzjNAbNdDw/3wXf1I28tuoi9SSTWw9qhOSFZjSSt77CDoI InRXH+R5NV9rYQmCSF2C/Wz/98Iy3KmYTD16NWHGqmcR+dkeoDCnDFt+AaSShO30FHVU 1dpH+ungwSheFlEJie8CZyrGHGGP6wD20Lt05eSM3No5GHByPC/jGtUZf2lZ0svUDMio 6nU90i0HrX0CS5rweBWXKVXHAp3pK/kHaaR6EAluZcNqR83yfhmXSMC2gWzi2UkprlAs TErrll5S/1OQW/fbca1gdaPA0w7q6P16zp7YTFapaylkZyROS4lcbwH7JFK/1TYHWV49 l1yg== X-Gm-Message-State: APjAAAUgU0pd0+Yw8V607uDljbFV5NF/wx/3d2tJisxGzzWM/wbyib2X VqIALIw9bYAaPkleDO2el22kYUbjajE= X-Google-Smtp-Source: APXvYqykp3hijQu1uj0lzMf4Uoky4HuSBXbY8DXMXl/9GDVA7jpoICzZrCSLrarmtQJ+oUDwgJVQrw== X-Received: by 2002:adf:a10b:: with SMTP id o11mr8265755wro.91.1552825383526; Sun, 17 Mar 2019 05:23:03 -0700 (PDT) Received: from snf-864.vm.snf.arr ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id z10sm5453292wrs.11.2019.03.17.05.23.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 05:23:02 -0700 (PDT) From: Nikos Tsironis To: snitzer@redhat.com, agk@redhat.com, dm-devel@redhat.com Date: Sun, 17 Mar 2019 14:22:54 +0200 Message-Id: <20190317122258.21760-3-ntsironis@arrikto.com> In-Reply-To: <20190317122258.21760-1-ntsironis@arrikto.com> References: <20190317122258.21760-1-ntsironis@arrikto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 17 Mar 2019 12:23:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 17 Mar 2019 12:23:05 +0000 (UTC) for IP:'209.85.221.65' DOMAIN:'mail-wr1-f65.google.com' HELO:'mail-wr1-f65.google.com' FROM:'ntsironis@arrikto.com' RCPT:'' X-RedHat-Spam-Score: -0.012 (DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.221.65 mail-wr1-f65.google.com 209.85.221.65 mail-wr1-f65.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: hch@infradead.org, paulmck@linux.ibm.com, mpatocka@redhat.com, linux-kernel@vger.kernel.org, iliastsi@arrikto.com Subject: [dm-devel] [PATCH v3 2/6] list_bl: Add hlist_bl_add_before/behind helpers X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sun, 17 Mar 2019 12:23:14 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Add hlist_bl_add_before/behind helpers to add an element before/after an existing element in a bl_list. Signed-off-by: Nikos Tsironis Signed-off-by: Ilias Tsitsimpis Reviewed-by: Paul E. McKenney --- include/linux/list_bl.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h index 3fc2cc57ba1b..ae1b541446c9 100644 --- a/include/linux/list_bl.h +++ b/include/linux/list_bl.h @@ -86,6 +86,32 @@ static inline void hlist_bl_add_head(struct hlist_bl_node *n, hlist_bl_set_first(h, n); } +static inline void hlist_bl_add_before(struct hlist_bl_node *n, + struct hlist_bl_node *next) +{ + struct hlist_bl_node **pprev = next->pprev; + + n->pprev = pprev; + n->next = next; + next->pprev = &n->next; + + /* pprev may be `first`, so be careful not to lose the lock bit */ + WRITE_ONCE(*pprev, + (struct hlist_bl_node *) + ((uintptr_t)n | ((uintptr_t)*pprev & LIST_BL_LOCKMASK))); +} + +static inline void hlist_bl_add_behind(struct hlist_bl_node *n, + struct hlist_bl_node *prev) +{ + n->next = prev->next; + n->pprev = &prev->next; + prev->next = n; + + if (n->next) + n->next->pprev = &n->next; +} + static inline void __hlist_bl_del(struct hlist_bl_node *n) { struct hlist_bl_node *next = n->next;