From patchwork Tue Sep 5 19:11:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9939511 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 7A09260350 for ; Tue, 5 Sep 2017 19:11:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B48A289EB for ; Tue, 5 Sep 2017 19:11:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 60366289F2; Tue, 5 Sep 2017 19:11:00 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 013B1289FF for ; Tue, 5 Sep 2017 19:11:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752256AbdIETK5 (ORCPT ); Tue, 5 Sep 2017 15:10:57 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33282 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751959AbdIETKy (ORCPT ); Tue, 5 Sep 2017 15:10:54 -0400 Received: by mail-wr0-f195.google.com with SMTP id b9so2146785wra.0; Tue, 05 Sep 2017 12:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DND/v6tGQXOkJq5fWXfXN3C0GSIOZ7p9i6ExL/l175o=; b=EoDuSvg4jaVSz/iWvqp43lu14QiamxAYUouLYeBDGxx4Mx6/0w87Oego3zb4AuCZBW gGzg3xApnMEB1ZfGfZA/VTpbj5DDrtfmrUbvkbDKn+0kDkS6SCi/KQYiS/YSEAip89y3 ugpGLentw5xwR6NjW7EAYhH8NsKHeAgquvEYM1NE44Qy7Tsy9b99UefvdCq/Re432Zy2 UwuH7yfSL2tAJZC6SJYYw2/Ae7ndNargRLR6SLe2Ry3TeIKKVax1Hqu/lMeZj+txGt5E 0yZOlN1YzWvqq/yY188xB8v6D7soLXWDIMNh/F6brXUPpnI7zV7n0jWIuCgRsohYcjE1 sXDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DND/v6tGQXOkJq5fWXfXN3C0GSIOZ7p9i6ExL/l175o=; b=p7o0SALFI0lBj65Nbjxid3cWo9+7CbcZp1S9q9EkACmmPFbIbVg957lIg9b/E+2PDK mIZ4Fe0Hn4GA7lvetouanmGm9Myp4CoqnldghjRFDb9qJwD7UKWxNVij2yQljtOMoOkR 7v+ssWEPIB8y8c9G+lsENTAmqHuvlFubtvoYtFyrjePm5d9x4nbYIuX01L4Ip3YA0BmO NnhbDmxo8c3dNu7xMHYg9AXRmb8/L70atj/HOWAnY4YoqmyxeIzlx1AvMp0HkDcf/N8G mI04rFrBF4TAzDWBfamcCTyYCOOZdrmjMcnbwU/DNOKk2sekw8UMjnpDoB038TrboV+D YqzQ== X-Gm-Message-State: AHPjjUhtcSeeWSNrh2aM5CXL5y0YIgOySGvxk8chbOkMtvfjtSWxPXa4 QKoyc9MvNoO54g== X-Google-Smtp-Source: ADKCNb5Y/Yw7sn1F5iT3ae/wMjtwLDtE5UvJV9bGiq/R3ZUERgd1H4xSABK9lC5Sb8Q0B5M5/9vrcA== X-Received: by 10.223.172.66 with SMTP id v60mr39042wrc.143.1504638652884; Tue, 05 Sep 2017 12:10:52 -0700 (PDT) Received: from localhost.localdomain (bzq-79-182-137-119.red.bezeqint.net. [79.182.137.119]) by smtp.gmail.com with ESMTPSA id 30sm1829015wry.34.2017.09.05.12.10.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 12:10:52 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Josef Bacik , fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 02/13] fsx: add optional logid prefix to log messages Date: Tue, 5 Sep 2017 22:11:09 +0300 Message-Id: <1504638680-25682-3-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504638680-25682-1-git-send-email-amir73il@gmail.com> References: <1504638680-25682-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When writing the intermixed output of several fsx processes to a single log file, it is usefull to prefix logs with a log id. Use fsx -j to define the log messages prefix. Signed-off-by: Amir Goldstein --- ltp/fsx.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index ac466ee..16684cc 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -132,6 +132,7 @@ unsigned long simulatedopcount = 0; /* -b flag */ int closeprob = 0; /* -c flag */ int debug = 0; /* -d flag */ unsigned long debugstart = 0; /* -D flag */ +int logid = 0; /* -j flag */ int flush = 0; /* -f flag */ int do_fsync = 0; /* -y flag */ unsigned long maxfilelen = 256 * 1024; /* -l flag */ @@ -195,13 +196,16 @@ static void *round_ptr_up(void *ptr, unsigned long align, unsigned long offset) } void -vwarnc(int code, const char *fmt, va_list ap) { - fprintf(stderr, "fsx: "); - if (fmt != NULL) { - vfprintf(stderr, fmt, ap); - fprintf(stderr, ": "); - } - fprintf(stderr, "%s\n", strerror(code)); +vwarnc(int code, const char *fmt, va_list ap) +{ + if (logid) + fprintf(stderr, "%d: ", logid); + fprintf(stderr, "fsx: "); + if (fmt != NULL) { + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": "); + } + fprintf(stderr, "%s\n", strerror(code)); } void @@ -223,6 +227,8 @@ prt(const char *fmt, ...) va_start(args, fmt); vsnprintf(buffer, BUF_SIZE, fmt, args); va_end(args); + if (logid) + fprintf(stdout, "%d: ", logid); fprintf(stdout, "%s", buffer); if (fsxlogf) fprintf(fsxlogf, "%s", buffer); @@ -1624,12 +1630,13 @@ void usage(void) { fprintf(stdout, "usage: %s", - "fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-i logdev] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ + "fsx [-dnqxAFLOWZ] [-b opnum] [-c Prob] [-i logdev] [-j logid] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ -b opnum: beginning operation number (default 1)\n\ -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ -f flush and invalidate cache after I/O\n\ -i logdev: do integrity testing, logdev is the dm log writes device\n\ + -j logid: prefix logs with this id\n\ -l flen: the upper bound on file size (default 262144)\n\ -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\ -n: no verifications of file size\n\ @@ -1862,7 +1869,7 @@ main(int argc, char **argv) setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ while ((ch = getopt_long(argc, argv, - "b:c:dfi:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ", + "b:c:dfi:j:l:m:no:p:qr:s:t:w:xyAD:FKHzCILN:OP:RS:WZ", longopts, NULL)) != EOF) switch (ch) { case 'b': @@ -1897,6 +1904,9 @@ main(int argc, char **argv) exit(101); } break; + case 'j': + logid = getnum(optarg, &endp); + break; case 'l': maxfilelen = getnum(optarg, &endp); if (maxfilelen <= 0)