Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1811471iob; Fri, 29 Apr 2022 13:29:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypfbvmRic8/iCwgL+bajJp3lwNL0jRJBdUPZibz60YWudo77epa7+KHKghocfhaoBqGK68 X-Received: by 2002:ac2:5dca:0:b0:471:f470:dafa with SMTP id x10-20020ac25dca000000b00471f470dafamr672680lfq.689.1651264180589; Fri, 29 Apr 2022 13:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651264180; cv=none; d=google.com; s=arc-20160816; b=cPMtSKLU9RpsXUMgaag2h1aYTFbaPrwTPip2vOVr4agPLoyqGlLaAAbHlrB9NE4if+ dKhj87v0N30Y5PlqlgqwsxEKP8U9lmggixf97z/HVnWUIPPbOaKSF1VOP7C1/T04bN4m rvF+qD1d0LpwSrw6roa+jEq1sI7DXbkgH+68YGpBDUXLaLbbfbIJEaK1dC4uzQZVf3mp qXJmbDLiv9/dOZF4VAMtbg0a3i6UqGoW3ZRVHRsijEBmVegKd1USkBBigBtDysu/yiBG ge/NIsGrEBcloLEvoSv8nnE8wio9ERAWmHb/A6l7ky6A05h5GvKjjipXINjfnYgC9tRK XQug== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=L7FTrF/yPZzmSwhUZJ73xkpPE9UAiqxcprGWHSAIFZo=; b=NxszBfReyBADT8GpPfFva8xqEin8jM6J83Pc0rq2+Uj4C8I7uyNFbG2EYf/DSdivuu 32gqU5ZT5ofb9fL+1MPFQGr5mSBIq8uBhtVZ80RkaZkDahibDAhJOliz2uO1FOuVaRaB 3ugKEysap2bMcr9nIeXB1u9vvrcL62YfZpqMby34awja+ibI1f1vXrHm6llYceDzbuK3 qXnKVftldIULpOJGewSUHM+WNGIQaPbQ+ciNrU+MMxsBxn9GgIXoPuOUCizW0abn8dCp eB7jsPEgdoDW2lvdbT0RWkBPWMLXslNc/5KY2tqDYR+bJquG5koPeilNjKYAov0WTNgV tMww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GhmVdDsm; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bi36-20020a0565120ea400b004723fb09b11si4296925lfb.120.2022.04.29.13.29.03; Fri, 29 Apr 2022 13:29:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@redhat.com header.s=mimecast20190719 header.b=GhmVdDsm; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235169AbiD2Qjg (ORCPT + 99 others); Fri, 29 Apr 2022 12:39:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234707AbiD2Qje (ORCPT ); Fri, 29 Apr 2022 12:39:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D15DD95E0 for ; Fri, 29 Apr 2022 09:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651250175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=L7FTrF/yPZzmSwhUZJ73xkpPE9UAiqxcprGWHSAIFZo=; b=GhmVdDsmLf9pPFW3G/HwOyJgCtJOiYkWFseM38wBCEhle/WC2N6QVRt6ZoFSIWQeR9Q9+x OyId2tJgciN9VcfL7naobAzT5z53y7H9/YUb9mTxVglrDnyCzuestbYaAaWzX5rmOISOgT zQCX7pnBQM4ygAgHkARami1/rycQle8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-670-sJ8I6IoOOrKK0yU45XnzQg-1; Fri, 29 Apr 2022 12:36:13 -0400 X-MC-Unique: sJ8I6IoOOrKK0yU45XnzQg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 461638015BA for ; Fri, 29 Apr 2022 16:36:13 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-126.gru2.redhat.com [10.97.116.126]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0439840CF8E5; Fri, 29 Apr 2022 16:36:10 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, Thiago Becker Subject: [PATCH] nfsrahead: fix and improve logging. Date: Fri, 29 Apr 2022 13:36:04 -0300 Message-Id: <20220429163604.1645422-1-tbecker@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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-nfs@vger.kernel.org Logging was not working properly wrt verbosity, it is changed by changing the facilities used. While at logging, add some extra logs when verbose that may be important. Signed-off-by: Thiago Becker --- tools/nfsrahead/main.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c index 83a389f7..5fae941c 100644 --- a/tools/nfsrahead/main.c +++ b/tools/nfsrahead/main.c @@ -85,8 +85,10 @@ static int get_mountinfo(const char *device_number, struct device_info *device_i mnttbl = mnt_new_table(); - if ((ret = mnt_table_parse_file(mnttbl, mountinfo_path)) < 0) + if ((ret = mnt_table_parse_file(mnttbl, mountinfo_path)) < 0) { + xlog(D_GENERAL, "Failed to parse %s\n", mountinfo_path); goto out_free_tbl; + } if ((fs = mnt_table_find_devno(mnttbl, device_info->dev, MNT_ITER_FORWARD)) == NULL) { ret = ENOENT; @@ -130,19 +132,20 @@ static int conf_get_readahead(const char *kind) { return readahead; } -#define L_DEFAULT (L_WARNING | L_ERROR | L_FATAL) int main(int argc, char **argv) { int ret = 0, retry; struct device_info device; - unsigned int readahead = 128, verbose = 0, log_stderr = 0; + unsigned int readahead = 128, log_level, log_stderr = 0; char opt; + + log_level = D_ALL & ~D_GENERAL; while((opt = getopt(argc, argv, "dF")) != -1) { switch (opt) { case 'd': - verbose = 1; + log_level = D_ALL; break; case 'F': log_stderr = 1; @@ -154,7 +157,7 @@ int main(int argc, char **argv) xlog_stderr(log_stderr); xlog_syslog(~log_stderr); - xlog_config(L_DEFAULT | (L_NOTICE & verbose), 1); + xlog_config(log_level, 1); xlog_open(CONF_NAME); // xlog_err causes the system to exit @@ -166,12 +169,12 @@ int main(int argc, char **argv) break; if (ret != 0) { - xlog(L_ERROR, "unable to find device %s\n", argv[optind]); + xlog(D_GENERAL, "unable to find device %s\n", argv[optind]); goto out; } if (strncmp("nfs", device.fstype, 3) != 0) { - xlog(L_NOTICE, + xlog(D_GENERAL, "not setting readahead for non supported fstype %s on device %s\n", device.fstype, argv[optind]); ret = -EINVAL; @@ -180,7 +183,7 @@ int main(int argc, char **argv) readahead = conf_get_readahead(device.fstype); - xlog(L_WARNING, "setting %s readahead to %d\n", device.mountpoint, readahead); + xlog(D_FAC7, "setting %s readahead to %d\n", device.mountpoint, readahead); printf("%d\n", readahead); -- 2.35.1