Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2467618pxb; Mon, 18 Jan 2021 20:11:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNWX2pZwCdxQsBm3Jeho+LV9zG8TDKPo2L0f6qU8U3PBWiDRl9/VmHRDI1nFJp716YofIc X-Received: by 2002:aa7:d64b:: with SMTP id v11mr1821509edr.16.1611029497254; Mon, 18 Jan 2021 20:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611029497; cv=none; d=google.com; s=arc-20160816; b=k9MeZBZqslxlgjGwtbeKytskhBZ7UmdLTZl2ouJimUhJXTSPjtoSM3iGRCq/FqEjkg XXZDGUvfpfjNxltgcxIR56Q2V8V/0/pr7U6VNAw6WKxgkQqGdb3xMvMcMtJDB4lZBCJB I6GKdomzZg0g5m95lq0OMiP6AIuVapqgtzyYQ06fSB3tSoOXjD4LV/FlvrdqPOiNCO0D elHy89FMy7NlQ8VM6EtX/1Wo5yxoI4R8XHt1qgHEfeKqtRLbhmhZGEqDgydtnRutSnEP Zom+Vg5DqxiCjiaRVcK3C6FPuWlfaxiAIW+c+9mxIvYKbuoR0bn1BiX2cDp9XYhXlFuR qOfA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V53p3fe1u8ZalPhnL0/Jqx5b1ttA+rwGzoMzj9p1gWg=; b=iyKjhd8J6dqqtfKnhSZ8y9OtTR3p2Ei765ETSzrmalM+d3iHVdmXir/1Sfge87o8k+ n+MMJEO/K3E6VB83LLiOZUcmc232bjsQqQomIogLk35ovfpE0mS+Cgu8J7z95PRbJM7U +ZwL6dMzlLqykye5hfdXy1dA8Tyhiu6jndrg7eBWjR5VMqCOKYpJwBV6V4VWT1AmkXr8 urKoWMVCArmGC4bn/9Dg0tsZx1l02O642UoVW8z0ELx4InFv3zKji66TbmGeNXnWChyf Jqp1v2KGNxrO48cBK3guat5rAcO3WHL7mO/fyPymLTwlq5N/2coKlJqv88iqztaMAAc+ Tajw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jG90e7iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a10si5034569edf.71.2021.01.18.20.11.14; Mon, 18 Jan 2021 20:11:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jG90e7iw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391406AbhARMdc (ORCPT + 99 others); Mon, 18 Jan 2021 07:33:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:39666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390742AbhARLps (ORCPT ); Mon, 18 Jan 2021 06:45:48 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39AC222D5B; Mon, 18 Jan 2021 11:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610970309; bh=/MUsu1DWYlQO9bYa2zWmidsizrbsz7Epreia6rBVOqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jG90e7iwETQT03m24EmpLq32VEeZSe8Semow59/7mQcTxIv7ADv5ErsA+THWJoArN LYcpTxij9XdTrvMnThkgxg2FKFEmEIAqzQcyG8V1b0qw95osOa97aa1QqiHB2Tl28S 4pSGtn/P/ivW8zQ1OMu2cUSGU7MAWBrMjDI8PHxw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Scott Mayhew , Benjamin Coddington , Trond Myklebust Subject: [PATCH 5.10 125/152] NFS: Adjust fs_context error logging Date: Mon, 18 Jan 2021 12:35:00 +0100 Message-Id: <20210118113358.717569317@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210118113352.764293297@linuxfoundation.org> References: <20210118113352.764293297@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Scott Mayhew commit c98e9daa59a611ff4e163689815f40380c912415 upstream. Several existing dprink()/dfprintk() calls were converted to use the new mount API logging macros by commit ce8866f0913f ("NFS: Attach supplementary error information to fs_context"). If the fs_context was not created using fsopen() then it will not have had a log buffer allocated for it, and the new mount API logging macros will wind up calling printk(). This can result in syslog messages being logged where previously there were none... most notably "NFS4: Couldn't follow remote path", which can happen if the client is auto-negotiating a protocol version with an NFS server that doesn't support the higher v4.x versions. Convert the nfs_errorf(), nfs_invalf(), and nfs_warnf() macros to check for the existence of the fs_context's log buffer and call dprintk() if it doesn't exist. Add nfs_ferrorf(), nfs_finvalf(), and nfs_warnf(), which do the same thing but take an NFS debug flag as an argument and call dfprintk(). Finally, modify the "NFS4: Couldn't follow remote path" message to use nfs_ferrorf(). Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207385 Signed-off-by: Scott Mayhew Reviewed-by: Benjamin Coddington Fixes: ce8866f0913f ("NFS: Attach supplementary error information to fs_context.") Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/internal.h | 26 +++++++++++++++++++++++--- fs/nfs/nfs4super.c | 4 ++-- 2 files changed, 25 insertions(+), 5 deletions(-) --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -142,9 +142,29 @@ struct nfs_fs_context { } clone_data; }; -#define nfs_errorf(fc, fmt, ...) errorf(fc, fmt, ## __VA_ARGS__) -#define nfs_invalf(fc, fmt, ...) invalf(fc, fmt, ## __VA_ARGS__) -#define nfs_warnf(fc, fmt, ...) warnf(fc, fmt, ## __VA_ARGS__) +#define nfs_errorf(fc, fmt, ...) ((fc)->log.log ? \ + errorf(fc, fmt, ## __VA_ARGS__) : \ + ({ dprintk(fmt "\n", ## __VA_ARGS__); })) + +#define nfs_ferrorf(fc, fac, fmt, ...) ((fc)->log.log ? \ + errorf(fc, fmt, ## __VA_ARGS__) : \ + ({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); })) + +#define nfs_invalf(fc, fmt, ...) ((fc)->log.log ? \ + invalf(fc, fmt, ## __VA_ARGS__) : \ + ({ dprintk(fmt "\n", ## __VA_ARGS__); -EINVAL; })) + +#define nfs_finvalf(fc, fac, fmt, ...) ((fc)->log.log ? \ + invalf(fc, fmt, ## __VA_ARGS__) : \ + ({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); -EINVAL; })) + +#define nfs_warnf(fc, fmt, ...) ((fc)->log.log ? \ + warnf(fc, fmt, ## __VA_ARGS__) : \ + ({ dprintk(fmt "\n", ## __VA_ARGS__); })) + +#define nfs_fwarnf(fc, fac, fmt, ...) ((fc)->log.log ? \ + warnf(fc, fmt, ## __VA_ARGS__) : \ + ({ dfprintk(fac, fmt "\n", ## __VA_ARGS__); })) static inline struct nfs_fs_context *nfs_fc2context(const struct fs_context *fc) { --- a/fs/nfs/nfs4super.c +++ b/fs/nfs/nfs4super.c @@ -227,7 +227,7 @@ int nfs4_try_get_tree(struct fs_context fc, ctx->nfs_server.hostname, ctx->nfs_server.export_path); if (err) { - nfs_errorf(fc, "NFS4: Couldn't follow remote path"); + nfs_ferrorf(fc, MOUNT, "NFS4: Couldn't follow remote path"); dfprintk(MOUNT, "<-- nfs4_try_get_tree() = %d [error]\n", err); } else { dfprintk(MOUNT, "<-- nfs4_try_get_tree() = 0\n"); @@ -250,7 +250,7 @@ int nfs4_get_referral_tree(struct fs_con fc, ctx->nfs_server.hostname, ctx->nfs_server.export_path); if (err) { - nfs_errorf(fc, "NFS4: Couldn't follow remote path"); + nfs_ferrorf(fc, MOUNT, "NFS4: Couldn't follow remote path"); dfprintk(MOUNT, "<-- nfs4_get_referral_tree() = %d [error]\n", err); } else { dfprintk(MOUNT, "<-- nfs4_get_referral_tree() = 0\n");