Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1860370pxb; Sat, 2 Apr 2022 06:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4V7IP837ZFwQfL2YQ1F5nfB/dlzROotC9hS/iTtrbd/K/8QuRdgYPNXHEMzAJ9qrqPo2F X-Received: by 2002:a17:903:41d1:b0:154:76c2:f7bc with SMTP id u17-20020a17090341d100b0015476c2f7bcmr14706506ple.109.1648905325539; Sat, 02 Apr 2022 06:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648905325; cv=none; d=google.com; s=arc-20160816; b=fEbpsPYX8CAANjE5nvN7hlrOyIyz1lKNUxpTtALVBjPmGsmDgTqtAZAKZTLllb4/8U +MLf0aKI6DEhphi8jKQUwt6/UmNVKf/ma5Z8wgpgxBPsGbth3u67n4FFLg+PVtcFI8Rj /1kl42CcLsCzNcx/R8sLeTwYfCSKWVNQlmoVejwFGKJSZwCQpproH535QhGG5FiaogT3 4Q8A9EmxY3Sw4F9MB6oztALQJjq9fL+0+xWlUtBr9Pr073ZsA7cYWPhPJfKMOI51U98W ln84AKnkZ6ZN5MjAqAAgDfUeVVc84HOlXG74MZt574cemRQrXUlxXMm6PKaSzWqb55+P yQcQ== 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=sYqGNoeKyNfXy/k1csUcqU5ZARls3XYh8BgaVvO+Lk4=; b=jS3nV/wyDXFjLuOKStsLJxSgdZ7/Z9LXzA2MWuCyRLHqyXKR2D966rYdhBElTBUGdI avy71AUztUXUKGBXEg1H61FsaJMEO01eTdgvDRF/3a/mypWs8NViVru0YAZLgYJM1gsf XJTbkItWAwq6KILmzxU2ydzHEoRV9rOCmvq4fN94Kdi2AayIJ2T7FLIFvf096kWXMGN6 JedQrVYkslP3y+143IurYPUqCW0f/bX5I70dT/aA9HfUhxXaICLpJwXgzSObn+WeG4WO aDfguHo3G76hiUY4rWvVOZzPgwuwdoCebdm+1N4WDrWbtsdg317o9W/dtnGP/f8QhSsg vnZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FL8tzJyI; 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 u15-20020a170902a60f00b00153b2d16642si4560474plq.586.2022.04.02.06.15.01; Sat, 02 Apr 2022 06:15:25 -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=FL8tzJyI; 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 S1345171AbiDAQL3 (ORCPT + 99 others); Fri, 1 Apr 2022 12:11:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349668AbiDAQI5 (ORCPT ); Fri, 1 Apr 2022 12:08:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 16BDD1A2A36 for ; Fri, 1 Apr 2022 08:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648827165; 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: in-reply-to:in-reply-to:references:references; bh=sYqGNoeKyNfXy/k1csUcqU5ZARls3XYh8BgaVvO+Lk4=; b=FL8tzJyIBt9QdbFqoRS9kYtGpxbBt6Nj3Nqc4//F+2l16On3QUiUF1OgM32BaeeWmlybrj 3GREP3NK9A2ayxv5hsbDFz0REnsPPWDtc4bYfNGJLJMa5diDThpje5KMLLULc38dEDImRB KLPcBo68f7XWGbvWRi9SIN6dN21ucuk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-371-1tWw3ybWMZGZM0SwzAzn9g-1; Fri, 01 Apr 2022 11:32:43 -0400 X-MC-Unique: 1tWw3ybWMZGZM0SwzAzn9g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 109192A2AD70; Fri, 1 Apr 2022 15:32:43 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-139.gru2.redhat.com [10.97.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4ADC9D45; Fri, 1 Apr 2022 15:32:39 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org Cc: steved@redhat.com, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, kolga@netapp.com, Thiago Becker Subject: [PATCH v4 4/7] nfsrahead: add logging Date: Fri, 1 Apr 2022 12:32:05 -0300 Message-Id: <20220401153208.3120851-5-tbecker@redhat.com> In-Reply-To: <20220401153208.3120851-1-tbecker@redhat.com> References: <20220401153208.3120851-1-tbecker@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1946283 Signed-off-by: Thiago Becker --- tools/nfsrahead/Makefile.am | 1 + tools/nfsrahead/main.c | 40 ++++++++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/tools/nfsrahead/Makefile.am b/tools/nfsrahead/Makefile.am index 0daddc4b..60a1102a 100644 --- a/tools/nfsrahead/Makefile.am +++ b/tools/nfsrahead/Makefile.am @@ -1,6 +1,7 @@ libexec_PROGRAMS = nfsrahead nfsrahead_SOURCES = main.c nfsrahead_LDFLAGS= -lmount +nfsrahead_LDADD = ../../support/nfs/libnfsconf.la udev_rulesdir = /usr/lib/udev/rules.d/ udev_rules_DATA = 99-nfs.rules diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c index 8fe6d648..b630b92f 100644 --- a/tools/nfsrahead/main.c +++ b/tools/nfsrahead/main.c @@ -2,14 +2,19 @@ #include #include #include +#include #include #include +#include "xlog.h" + #ifndef MOUNTINFO_PATH #define MOUNTINFO_PATH "/proc/self/mountinfo" #endif +#define CONF_NAME "nfsrahead" + /* Device information from the system */ struct device_info { char *device_number; @@ -108,25 +113,50 @@ static int get_device_info(const char *device_number, struct device_info *device return ret; } +#define L_DEFAULT (L_WARNING | L_ERROR | L_FATAL) + int main(int argc, char **argv) { int ret = 0; struct device_info device; - unsigned int readahead = 128; - - if (argc != 2) { - return -EINVAL; + unsigned int readahead = 128, verbose = 0, log_stderr = 0; + char opt; + + while((opt = getopt(argc, argv, "dF")) != -1) { + switch (opt) { + case 'd': + verbose = 1; + break; + case 'F': + log_stderr = 1; + break; + } } - if ((ret = get_device_info(argv[1], &device)) != 0) { + xlog_stderr(log_stderr); + xlog_syslog(~log_stderr); + xlog_config(L_DEFAULT | (L_NOTICE & verbose), 1); + xlog_open(CONF_NAME); + + // xlog_err causes the system to exit + if ((argc - optind) != 1) + xlog_err("expected the device number of a BDI; is udev ok?"); + + if ((ret = get_device_info(argv[optind], &device)) != 0) { + xlog(L_ERROR, "unable to find device %s\n", argv[optind]); goto out; } if (strncmp("nfs", device.fstype, 3) != 0) { + xlog(L_NOTICE, + "not setting readahead for non supported fstype %s on device %s\n", + device.fstype, argv[optind]); ret = -EINVAL; goto out; } + xlog(L_WARNING, "setting %s readahead to %d\n", device.mountpoint, readahead); + printf("%d\n", readahead); out: -- 2.35.1