From patchwork Tue Sep 20 14:04:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 9341743 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 671D460B16 for ; Tue, 20 Sep 2016 14:05:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58525286BD for ; Tue, 20 Sep 2016 14:05:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CCAD294E8; Tue, 20 Sep 2016 14:05: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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C0BD296F9 for ; Tue, 20 Sep 2016 14:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753960AbcITOFI (ORCPT ); Tue, 20 Sep 2016 10:05:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:45362 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752187AbcITOFH (ORCPT ); Tue, 20 Sep 2016 10:05:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6C927AC4B for ; Tue, 20 Sep 2016 14:05:05 +0000 (UTC) Received: by starscream.home.jeffm.io (Postfix, from userid 1000) id F313C824CE; Tue, 20 Sep 2016 10:05:03 -0400 (EDT) From: jeffm@suse.com To: linux-btrfs@vger.kernel.org Cc: David Sterba , Jeff Mahoney Subject: [PATCH 1/5] btrfs: add dynamic debug support Date: Tue, 20 Sep 2016 10:04:59 -0400 Message-Id: <1474380303-25995-2-git-send-email-jeffm@suse.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1474380303-25995-1-git-send-email-jeffm@suse.com> References: <1474380303-25995-1-git-send-email-jeffm@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jeff Mahoney We can re-use the dynamic debugging descriptor to make use of the dynamic debugging mechanism but still use our own printk interface. Defining the DEBUG macro works as it did before. When it's defined, all of the messages default to print. We can also enable all debug messages at boot or module-load time using the 'dyndbg' and 'btrfs.dyndbg' options. Signed-off-by: Jeff Mahoney diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 33fe035..9267436 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "extent_io.h" #include "extent_map.h" #include "async-thread.h" @@ -3315,7 +3316,35 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...) btrfs_printk_ratelimited(fs_info, KERN_NOTICE fmt, ##args) #define btrfs_info_rl(fs_info, fmt, args...) \ btrfs_printk_ratelimited(fs_info, KERN_INFO fmt, ##args) -#ifdef DEBUG + +#if defined(CONFIG_DYNAMIC_DEBUG) +#define btrfs_debug(fs_info, fmt, args...) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \ + btrfs_printk(fs_info, KERN_DEBUG fmt, ##args); \ +} while (0) +#define btrfs_debug_in_rcu(fs_info, fmt, args...) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \ + btrfs_printk_in_rcu(fs_info, KERN_DEBUG fmt, ##args); \ +} while (0) +#define btrfs_debug_rl_in_rcu(fs_info, fmt, args...) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \ + btrfs_printk_rl_in_rcu(fs_info, KERN_DEBUG fmt, \ + ##args);\ +} while (0) +#define btrfs_debug_rl(fs_info, fmt, args...) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \ + btrfs_printk_ratelimited(fs_info, KERN_DEBUG fmt, \ + ##args); \ +} while (0) +#elif defined(DEBUG) #define btrfs_debug(fs_info, fmt, args...) \ btrfs_printk(fs_info, KERN_DEBUG fmt, ##args) #define btrfs_debug_in_rcu(fs_info, fmt, args...) \