Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp366762rwb; Thu, 1 Dec 2022 03:17:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf4f6B6/nSFyI3ckGBRcns6bCrqX594tVMh5gLDd8Iv7G/R8ugD8afbS83sI9R3RQLUoxROo X-Received: by 2002:a17:90a:5787:b0:218:8398:5846 with SMTP id g7-20020a17090a578700b0021883985846mr66776819pji.241.1669893435312; Thu, 01 Dec 2022 03:17:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669893435; cv=none; d=google.com; s=arc-20160816; b=l7nb0nR+WFI9b7Hbpif8rffUjqJuJgcsinlPF0RnIRwZaKUmaewYag4uLDg0GO4gOT DBRPwufr2wL05dI9YhD+f2c/NoSDNHeSw0PSLBQ8kix2XC/bKsl4mbadrKLwfeEczdJM /ERD5MsaATbXaa149vzBPZgU3dGYWV8GXHYkuJ/cwN2mczff7/btTW9XxhAk52ta6K7D Iu+cp7CEUdRTS3Rr9zNx4uHckBEqyfaZvlqoO2ixIY2LcNpbxS9PKI1aq3aPG/YfYAND KjwK19bTVrQSjA/YNjNHXHj2+cfeJXlWunOhtcD95x9MgP6hJncoaf5Yb8MaJ6diKt91 XvOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XaU/omMH3+8RvsiY397Oi1fc3o66/RFALVdNOkAe6vA=; b=U3YGGpFhzTx0fEJBDpQXk5Z1o3bTnGcclh8P4zlWVuedpXXFmzYcPAnUMd75s/ow4j MTV3Z1LoVjapR8Hnj03XX0bJNGXQru/gRWcXMRluV4yLP5jUwnUqO2LJJm53dSFx35uG 6rATjp32CQtUt0qYLDKrrukMfyN6+stg+zUVkz/AD7SVjkAM3AwwwrnVez3ZvSA9m1iF MUaQ5jDdSzmP+WGiH0oGc6RnDW0Wy852TvrF7V7eEmQV9LM6yT5sle1uaQQgwypxcQS8 LNgGO57JNuK1ws+T+x90ZKhrUzSIshmIsHT2xMzlhclEw+mcz7Oe6BzgyxBY//wJJjRC 9L4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linbit-com.20210112.gappssmtp.com header.s=20210112 header.b="Bi/QWJSk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a17090aa60800b00213120e0c85si6872809pjq.156.2022.12.01.03.17.05; Thu, 01 Dec 2022 03:17:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linbit-com.20210112.gappssmtp.com header.s=20210112 header.b="Bi/QWJSk"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230054AbiLALF6 (ORCPT + 82 others); Thu, 1 Dec 2022 06:05:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbiLALEp (ORCPT ); Thu, 1 Dec 2022 06:04:45 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF44AA85ED for ; Thu, 1 Dec 2022 03:04:38 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id ud5so3336090ejc.4 for ; Thu, 01 Dec 2022 03:04:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linbit-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XaU/omMH3+8RvsiY397Oi1fc3o66/RFALVdNOkAe6vA=; b=Bi/QWJSkFQWGeJYobcxt+XbSF/QNjoWybX4BquCD/eV20lCerj08wCTBtZeaLTJyE4 FI3XHUV0g9541YwfooD6lulPNOsbZiKLyJytDVikhTDjiYieO75v+4bhtlxjdWv/DrBs LsZGLol2mDQKkajQ6gmIpbeLuLWPxyn9gE4CJDYE52yImFfsufVqlswtVL7YxmcZIz1I ooTBu6CI0rJfaEIIXkpASSZZW/sIAhq/9SODz/74uiNMzshfsY1R5owkrI0IiRPtEfqN yJiF1PHxNWwIDCWXdGBkXuN47QMxsljfAoRzh2ueK0Z/Th9B+C5peywoMwI+qyB65vNm WYGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XaU/omMH3+8RvsiY397Oi1fc3o66/RFALVdNOkAe6vA=; b=UbXEmQdPdPz0PciYG4ElpIoOEIIC14ZI7K3H+8sLW/t6RXPyG8jtA8aiSG8fXrK2iK k47AS2XacYs3I2RCsTThJlgeMiZYB5uhtS/HVY1EaNPQZJ7ZNeIpqtNhqn53YZSjxJY/ Wh6KdzlakR5NYVnvSW2g4oEIKHrHSNfqlMS7VGCDk7Los3BpwBVovlyOLBqjffc5gHB4 ahqnbizvvzGLe2t1apNDvbTJdU9ZYdRMRpyTSXpThmnYbtdzgycfd0mb9GkaUYAy4bs1 /aOAw12+sUdkUqf/S/4n7k28FbMB2p2gxBVPv2Txxl7l8LICTKFvPfYqkqzYK3RegHzO /hBw== X-Gm-Message-State: ANoB5pkQdwfdFcENFJzvJvIpAyzUeXqjZ3d5Z+b1ZvfnbjHlrn6cAHwZ IL09QbmVobP7MaLZ00tSVIYDBA== X-Received: by 2002:a17:907:206c:b0:7be:492d:2344 with SMTP id qp12-20020a170907206c00b007be492d2344mr19710596ejb.585.1669892677429; Thu, 01 Dec 2022 03:04:37 -0800 (PST) Received: from localhost.localdomain (h082218028181.host.wavenet.at. [82.218.28.181]) by smtp.gmail.com with ESMTPSA id f26-20020a056402161a00b00463a83ce063sm1576424edv.96.2022.12.01.03.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 03:04:36 -0800 (PST) From: =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= To: Jens Axboe Cc: drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org, Lars Ellenberg , Philipp Reisner , linux-block@vger.kernel.org, =?UTF-8?q?Christoph=20B=C3=B6hmwalder?= Subject: [PATCH 2/5] drbd: split polymorph printk to its own file Date: Thu, 1 Dec 2022 12:03:47 +0100 Message-Id: <20221201110349.1282687-3-christoph.boehmwalder@linbit.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201110349.1282687-1-christoph.boehmwalder@linbit.com> References: <20221201110349.1282687-1-christoph.boehmwalder@linbit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Christoph Böhmwalder --- drivers/block/drbd/drbd_int.h | 68 +------------------- drivers/block/drbd/drbd_polymorph_printk.h | 72 ++++++++++++++++++++++ 2 files changed, 73 insertions(+), 67 deletions(-) create mode 100644 drivers/block/drbd/drbd_polymorph_printk.h diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index ea92df778c66..1734a7f8a096 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -37,6 +37,7 @@ #include "drbd_strings.h" #include "drbd_state.h" #include "drbd_protocol.h" +#include "drbd_polymorph_printk.h" #ifdef __CHECKER__ # define __protected_by(x) __attribute__((require_context(x,1,999,"rdwr"))) @@ -75,73 +76,6 @@ extern int drbd_proc_details; struct drbd_device; struct drbd_connection; -#define __drbd_printk_device(level, device, fmt, args...) \ - dev_printk(level, disk_to_dev((device)->vdisk), fmt, ## args) -#define __drbd_printk_peer_device(level, peer_device, fmt, args...) \ - dev_printk(level, disk_to_dev((peer_device)->device->vdisk), fmt, ## args) -#define __drbd_printk_resource(level, resource, fmt, args...) \ - printk(level "drbd %s: " fmt, (resource)->name, ## args) -#define __drbd_printk_connection(level, connection, fmt, args...) \ - printk(level "drbd %s: " fmt, (connection)->resource->name, ## args) - -void drbd_printk_with_wrong_object_type(void); - -#define __drbd_printk_if_same_type(obj, type, func, level, fmt, args...) \ - (__builtin_types_compatible_p(typeof(obj), type) || \ - __builtin_types_compatible_p(typeof(obj), const type)), \ - func(level, (const type)(obj), fmt, ## args) - -#define drbd_printk(level, obj, fmt, args...) \ - __builtin_choose_expr( \ - __drbd_printk_if_same_type(obj, struct drbd_device *, \ - __drbd_printk_device, level, fmt, ## args), \ - __builtin_choose_expr( \ - __drbd_printk_if_same_type(obj, struct drbd_resource *, \ - __drbd_printk_resource, level, fmt, ## args), \ - __builtin_choose_expr( \ - __drbd_printk_if_same_type(obj, struct drbd_connection *, \ - __drbd_printk_connection, level, fmt, ## args), \ - __builtin_choose_expr( \ - __drbd_printk_if_same_type(obj, struct drbd_peer_device *, \ - __drbd_printk_peer_device, level, fmt, ## args), \ - drbd_printk_with_wrong_object_type())))) - -#define drbd_dbg(obj, fmt, args...) \ - drbd_printk(KERN_DEBUG, obj, fmt, ## args) -#define drbd_alert(obj, fmt, args...) \ - drbd_printk(KERN_ALERT, obj, fmt, ## args) -#define drbd_err(obj, fmt, args...) \ - drbd_printk(KERN_ERR, obj, fmt, ## args) -#define drbd_warn(obj, fmt, args...) \ - drbd_printk(KERN_WARNING, obj, fmt, ## args) -#define drbd_info(obj, fmt, args...) \ - drbd_printk(KERN_INFO, obj, fmt, ## args) -#define drbd_emerg(obj, fmt, args...) \ - drbd_printk(KERN_EMERG, obj, fmt, ## args) - -#define dynamic_drbd_dbg(device, fmt, args...) \ - dynamic_dev_dbg(disk_to_dev(device->vdisk), fmt, ## args) - -#define D_ASSERT(x, exp) \ - do { \ - if (!(exp)) \ - drbd_err(x, "ASSERTION %s FAILED in %s\n", \ - #exp, __func__); \ - } while (0) - -/** - * expect - Make an assertion - * - * Unlike the assert macro, this macro returns a boolean result. - */ -#define expect(exp) ({ \ - bool _bool = (exp); \ - if (!_bool) \ - drbd_err(device, "ASSERTION %s FAILED in %s\n", \ - #exp, __func__); \ - _bool; \ - }) - /* Defines to control fault insertion */ enum { DRBD_FAULT_MD_WR = 0, /* meta data write */ diff --git a/drivers/block/drbd/drbd_polymorph_printk.h b/drivers/block/drbd/drbd_polymorph_printk.h new file mode 100644 index 000000000000..13cc1b311e16 --- /dev/null +++ b/drivers/block/drbd/drbd_polymorph_printk.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef DRBD_POLYMORPH_PRINTK_H +#define DRBD_POLYMORPH_PRINTK_H + +#define __drbd_printk_device(level, device, fmt, args...) \ + dev_printk(level, disk_to_dev((device)->vdisk), fmt, ## args) +#define __drbd_printk_peer_device(level, peer_device, fmt, args...) \ + dev_printk(level, disk_to_dev((peer_device)->device->vdisk), fmt, ## args) +#define __drbd_printk_resource(level, resource, fmt, args...) \ + printk(level "drbd %s: " fmt, (resource)->name, ## args) +#define __drbd_printk_connection(level, connection, fmt, args...) \ + printk(level "drbd %s: " fmt, (connection)->resource->name, ## args) + +void drbd_printk_with_wrong_object_type(void); + +#define __drbd_printk_if_same_type(obj, type, func, level, fmt, args...) \ + (__builtin_types_compatible_p(typeof(obj), type) || \ + __builtin_types_compatible_p(typeof(obj), const type)), \ + func(level, (const type)(obj), fmt, ## args) + +#define drbd_printk(level, obj, fmt, args...) \ + __builtin_choose_expr( \ + __drbd_printk_if_same_type(obj, struct drbd_device *, \ + __drbd_printk_device, level, fmt, ## args), \ + __builtin_choose_expr( \ + __drbd_printk_if_same_type(obj, struct drbd_resource *, \ + __drbd_printk_resource, level, fmt, ## args), \ + __builtin_choose_expr( \ + __drbd_printk_if_same_type(obj, struct drbd_connection *, \ + __drbd_printk_connection, level, fmt, ## args), \ + __builtin_choose_expr( \ + __drbd_printk_if_same_type(obj, struct drbd_peer_device *, \ + __drbd_printk_peer_device, level, fmt, ## args), \ + drbd_printk_with_wrong_object_type())))) + +#define drbd_dbg(obj, fmt, args...) \ + drbd_printk(KERN_DEBUG, obj, fmt, ## args) +#define drbd_alert(obj, fmt, args...) \ + drbd_printk(KERN_ALERT, obj, fmt, ## args) +#define drbd_err(obj, fmt, args...) \ + drbd_printk(KERN_ERR, obj, fmt, ## args) +#define drbd_warn(obj, fmt, args...) \ + drbd_printk(KERN_WARNING, obj, fmt, ## args) +#define drbd_info(obj, fmt, args...) \ + drbd_printk(KERN_INFO, obj, fmt, ## args) +#define drbd_emerg(obj, fmt, args...) \ + drbd_printk(KERN_EMERG, obj, fmt, ## args) + +#define dynamic_drbd_dbg(device, fmt, args...) \ + dynamic_dev_dbg(disk_to_dev(device->vdisk), fmt, ## args) + +#define D_ASSERT(x, exp) \ + do { \ + if (!(exp)) \ + drbd_err(x, "ASSERTION %s FAILED in %s\n", \ + #exp, __func__); \ + } while (0) + +/** + * expect - Make an assertion + * + * Unlike the assert macro, this macro returns a boolean result. + */ +#define expect(exp) ({ \ + bool _bool = (exp); \ + if (!_bool) \ + drbd_err(device, "ASSERTION %s FAILED in %s\n", \ + #exp, __func__); \ + _bool; \ + }) + +#endif -- 2.38.1