From patchwork Wed Aug 30 14:51:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9929847 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 851DE60383 for ; Wed, 30 Aug 2017 14:51:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 765CF283FF for ; Wed, 30 Aug 2017 14:51:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B2AA286A9; Wed, 30 Aug 2017 14:51:35 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 0C7E528691 for ; Wed, 30 Aug 2017 14:51:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751813AbdH3Ovd (ORCPT ); Wed, 30 Aug 2017 10:51:33 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35051 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751763AbdH3Ovb (ORCPT ); Wed, 30 Aug 2017 10:51:31 -0400 Received: by mail-wr0-f194.google.com with SMTP id a47so4317739wra.2; Wed, 30 Aug 2017 07:51:30 -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=ie9SKNbMDawlzrtyo/nWsqefrBZymMVVT/WnNpqPPKg=; b=ODnUAXSuzDdXEs8fyjCeUVvvYEaOW2kZthINNQnvjvf0amX6L70I3p7GMQCO9uEWQ3 fJfB7lU7FJ8kpjnJso13woK/DWwN030LT4ZYZIkDObkIq4CuOiIdMWCpm7iRJTLrcIqd jY9a1v2lMwrZrczQ9/ygk5Oue2wBW6ec6niFgRM+9r+4C4RxNoD+ZzswmaribPqAtR+f cHOvhyLAZpXivQa6xLcnnTxLuHcDxhH3GWH/g5j2hQouOWrLLvVk7grXQOwM9m8O6uW1 c16LM9v1ZNPn0kpNQLrhzqG8dHs6eW6zn/LarOx5rdl5AB45s2gJbuYtOS87q7a4mlgA E22w== 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=ie9SKNbMDawlzrtyo/nWsqefrBZymMVVT/WnNpqPPKg=; b=R4GVp43ajw3DJ+D74jHsZyLq1kdhHtJvWutjBfhdhK1LhsjYXhVRqQY3Iyj0Fz2v+Y R5N6vxdVqzkYDZNcW62NIA28POTtZBND87+34r69PQv2HevAeV9qFC0jr34NK+RBm6VO gyPq3ryqGHa5cOo/2+BUUu9oVpyuDkH9tGQOdNOu8hguKWlZmO5P+PAxRrxLbO1ZhNak 0anJvOfpwN61PcKrXX7LVBnA35zoYO4nwne0SHhO9QIbwTMxeBoE2OUPlc+FgVIO/nhU n4/UmSY9e0XzTLwXVwKrkAjGMQuQBWrjQQ4qbWKZHqLYvvjxs5u+thmQ2P9FFd6jWrIT FMtA== X-Gm-Message-State: AHYfb5j7LqgZ9VI1IDxcjmw33ZEKK9lEjFw1CBZSC7B0NYQlcp6fBLC9 7ROR17oE3eIjyw== X-Received: by 10.223.129.41 with SMTP id 38mr1428794wrm.324.1504104689794; Wed, 30 Aug 2017 07:51:29 -0700 (PDT) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id f42sm2606306wrf.27.2017.08.30.07.51.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Aug 2017 07:51:29 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Josef Bacik , "Darrick J . Wong" , Christoph Hellwig , fstests@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v2 07/14] fsx: add optional logid prefix to log messages Date: Wed, 30 Aug 2017 17:51:39 +0300 Message-Id: <1504104706-11965-8-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504104706-11965-1-git-send-email-amir73il@gmail.com> References: <1504104706-11965-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 d206a3a..a6420f6 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); fputs(buffer, stdout); if (fsxlogf) fputs(buffer, fsxlogf); @@ -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)