From patchwork Fri Nov 20 15:43:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 11921157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49076C63798 for ; Fri, 20 Nov 2020 15:45:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA9892240B for ; Fri, 20 Nov 2020 15:45:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="TOE/PoNx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729906AbgKTPpB (ORCPT ); Fri, 20 Nov 2020 10:45:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:40878 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728579AbgKTPpB (ORCPT ); Fri, 20 Nov 2020 10:45:01 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1605887100; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=upMRMOErGqCihysCuI40ryGBNqj5MBoRUT7UoXwQC4Y=; b=TOE/PoNxnjEsjtFl87X6KpTrkbM3lTsTxpsXooXrPsLCSZcSNK/Rcd8EN2wG6taUB5bAg/ pqKmVg9wONErtrirVp+KZdA6TT23LTkoC3KZwvT8XJWHSjDc5XVOrZ3byXLms8p4MJkbzy 22+iSwQRm18uUWBkOnxXiklZROIfRqU= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8C8B9ACBA; Fri, 20 Nov 2020 15:45:00 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id CF554DA6E1; Fri, 20 Nov 2020 16:43:13 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH] btrfs: remove stub device info from messages when we have no fs_info Date: Fri, 20 Nov 2020 16:43:12 +0100 Message-Id: <20201120154312.23976-1-dsterba@suse.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Without a NULL fs_info the helpers will print something like BTRFS error (device ): ... This can happen in contexts where fs_info is not available at all or it's potentially unsafe due to object lifetime. The stub does not bring much information and with the prefix makes the message unnecessarily longer. Remove it for the NULL fs_info case. BTRFS error: ... Callers can add the device information to the message itself if needed. Signed-off-by: David Sterba Reviewed-by: Anand Jain --- fs/btrfs/super.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 6693cfc14dfd..348f8899f4f4 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -240,9 +240,13 @@ void __cold btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, . vaf.fmt = fmt; vaf.va = &args; - if (__ratelimit(ratelimit)) - printk("%sBTRFS %s (device %s): %pV\n", lvl, type, - fs_info ? fs_info->sb->s_id : "", &vaf); + if (__ratelimit(ratelimit)) { + if (fs_info) + printk("%sBTRFS %s (device %s): %pV\n", lvl, type, + fs_info->sb->s_id, &vaf); + else + printk("%sBTRFS %s: %pV\n", lvl, type, &vaf); + } va_end(args); }