From patchwork Fri Jun 12 11:24:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F1C4138C for ; Fri, 12 Jun 2020 11:35:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59B032081A for ; Fri, 12 Jun 2020 11:35:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="GeWaKB9V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726283AbgFLLfA (ORCPT ); Fri, 12 Jun 2020 07:35:00 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46340 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgFLLfA (ORCPT ); Fri, 12 Jun 2020 07:35:00 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBQZ3J176461; Fri, 12 Jun 2020 11:34:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=TxhHsVS7JiRPV5GZo9g0D9Xuktfu5EtKcDZqxWyb9ww=; b=GeWaKB9V9giXl0FKymy/bcFGb0iA4ELgQCUccZLSKbdIDSOKRybQhkwaEv+BIVjT0zcG nMtJP5MY9y7dVOy242iFTQMQO+l2rEB6afuxhIzkIXXW3ioqoy21nq8OENUaSqMTbJbN 3kogjNADz18vxDGMxeRF9bRNuzygMMnckQ6RoDqiqiw2h928TduLQEtBO5Nw6cERkC/I pIMNHf25XblI4IHBgV8T/xl4xj+8a0PFRt/T2GncZ/attmpWPXAxGQb0yjk9h47DuHdG BoER7Rj7aJQkpreYOmF/aXfBpibTcwPmvgelr/sscNkLviaVTG95GXwNRviWKXcQIxh8 kw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 31g3sncg4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:34:55 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBWWWV067336; Fri, 12 Jun 2020 11:34:55 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 31m8x3r57h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:34:54 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05CBOqN9025067; Fri, 12 Jun 2020 11:24:52 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:24:51 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 04/16] btrfs-progs: receive: use global verbose and quiet options Date: Fri, 12 Jun 2020 19:24:44 +0800 Message-Id: <20200612112444.3511-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-5-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-5-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=1 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=1 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose and --quiet options down to the btrfs receive sub-command. Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: Updae the help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() Documentation/btrfs-receive.asciidoc | 6 +- cmds/receive.c | 86 ++++++++++++++++------------ 2 files changed, 52 insertions(+), 40 deletions(-) diff --git a/Documentation/btrfs-receive.asciidoc b/Documentation/btrfs-receive.asciidoc index a271d89b9d7d..aed08ba5e705 100644 --- a/Documentation/btrfs-receive.asciidoc +++ b/Documentation/btrfs-receive.asciidoc @@ -36,10 +36,12 @@ A subvolume is made read-only after the receiving process finishes successfully `Options` -v:: -increase verbosity about performed actions, print details about each operation +increase verbosity about performed actions, print details about each operation. +This option is merged to the global verbose option. -q|--quiet:: -suppress all messages except errors +suppress all messages except errors. This option is merged to the global quiet option. + -f :: read the stream from instead of stdin, diff --git a/cmds/receive.c b/cmds/receive.c index 74b73f488a0d..95fc09b8ce9f 100644 --- a/cmds/receive.c +++ b/cmds/receive.c @@ -53,12 +53,6 @@ #include "common/help.h" #include "common/path-utils.h" -/* - * Default is 1 for historical reasons, changing may break scripts that expect - * the 'At subvol' message. - */ -static int g_verbose = 1; - struct btrfs_receive { int mnt_fd; @@ -116,7 +110,7 @@ static int finish_subvol(struct btrfs_receive *rctx) memcpy(rs_args.uuid, rctx->cur_subvol.received_uuid, BTRFS_UUID_SIZE); rs_args.stransid = rctx->cur_subvol.stransid; - if (g_verbose >= 2) { + if (bconf.verbose >= 2) { uuid_unparse((u8*)rs_args.uuid, uuid_str); fprintf(stderr, "BTRFS_IOC_SET_RECEIVED_SUBVOL uuid=%s, " "stransid=%llu\n", uuid_str, rs_args.stransid); @@ -199,13 +193,13 @@ static int process_subvol(const char *path, const u8 *uuid, u64 ctransid, goto out; } - if (g_verbose) + if (bconf.verbose > BTRFS_BCONF_QUIET) fprintf(stderr, "At subvol %s\n", path); memcpy(rctx->cur_subvol.received_uuid, uuid, BTRFS_UUID_SIZE); rctx->cur_subvol.stransid = ctransid; - if (g_verbose >= 2) { + if (bconf.verbose >= 2) { uuid_unparse((u8*)rctx->cur_subvol.received_uuid, uuid_str); fprintf(stderr, "receiving subvol %s uuid=%s, stransid=%llu\n", path, uuid_str, @@ -269,13 +263,12 @@ static int process_snapshot(const char *path, const u8 *uuid, u64 ctransid, goto out; } - if (g_verbose) - fprintf(stdout, "At snapshot %s\n", path); + pr_verbose(1, "At snapshot %s\n", path); memcpy(rctx->cur_subvol.received_uuid, uuid, BTRFS_UUID_SIZE); rctx->cur_subvol.stransid = ctransid; - if (g_verbose >= 2) { + if (bconf.verbose >= 2) { uuid_unparse((u8*)rctx->cur_subvol.received_uuid, uuid_str); fprintf(stderr, "receiving snapshot %s uuid=%s, " "ctransid=%llu ", path, uuid_str, @@ -393,7 +386,7 @@ static int process_mkfile(const char *path, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "mkfile %s\n", path); ret = creat(full_path, 0600); @@ -421,7 +414,7 @@ static int process_mkdir(const char *path, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "mkdir %s\n", path); ret = mkdir(full_path, 0700); @@ -446,7 +439,7 @@ static int process_mknod(const char *path, u64 mode, u64 dev, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "mknod %s mode=%llu, dev=%llu\n", path, mode, dev); @@ -472,7 +465,7 @@ static int process_mkfifo(const char *path, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "mkfifo %s\n", path); ret = mkfifo(full_path, 0600); @@ -497,7 +490,7 @@ static int process_mksock(const char *path, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "mksock %s\n", path); ret = mknod(full_path, 0600 | S_IFSOCK, 0); @@ -522,7 +515,7 @@ static int process_symlink(const char *path, const char *lnk, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "symlink %s -> %s\n", path, lnk); ret = symlink(lnk, full_path); @@ -554,7 +547,7 @@ static int process_rename(const char *from, const char *to, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "rename %s -> %s\n", from, to); ret = rename(full_from, full_to); @@ -586,7 +579,7 @@ static int process_link(const char *path, const char *lnk, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "link %s -> %s\n", path, lnk); ret = link(full_link_path, full_path); @@ -612,7 +605,7 @@ static int process_unlink(const char *path, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "unlink %s\n", path); ret = unlink(full_path); @@ -637,7 +630,7 @@ static int process_rmdir(const char *path, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "rmdir %s\n", path); ret = rmdir(full_path); @@ -702,7 +695,7 @@ static int process_write(const char *path, const void *data, u64 offset, if (ret < 0) goto out; - if (g_verbose >= 2) + if (bconf.verbose >= 2) fprintf(stderr, "write %s - offset=%llu length=%llu\n", path, offset, len); @@ -792,7 +785,7 @@ static int process_clone(const char *path, u64 offset, u64 len, goto out; } - if (g_verbose >= 2) + if (bconf.verbose >= 2) fprintf(stderr, "clone %s - source=%s source offset=%llu offset=%llu length=%llu\n", path, clone_path, clone_offset, offset, len); @@ -833,7 +826,7 @@ static int process_set_xattr(const char *path, const char *name, } if (strcmp("security.capability", name) == 0) { - if (g_verbose >= 4) + if (bconf.verbose >= 4) fprintf(stderr, "set_xattr: cache capabilities\n"); if (rctx->cached_capabilities_len) warning("capabilities set multiple times per file: %s", @@ -848,7 +841,7 @@ static int process_set_xattr(const char *path, const char *name, memcpy(rctx->cached_capabilities, data, len); } - if (g_verbose >= 3) { + if (bconf.verbose >= 3) { fprintf(stderr, "set_xattr %s - name=%s data_len=%d " "data=%.*s\n", path, name, len, len, (char*)data); @@ -878,7 +871,7 @@ static int process_remove_xattr(const char *path, const char *name, void *user) goto out; } - if (g_verbose >= 3) { + if (bconf.verbose >= 3) { fprintf(stderr, "remove_xattr %s - name=%s\n", path, name); } @@ -906,7 +899,7 @@ static int process_truncate(const char *path, u64 size, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "truncate %s size=%llu\n", path, size); ret = truncate(full_path, size); @@ -932,7 +925,7 @@ static int process_chmod(const char *path, u64 mode, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "chmod %s - mode=0%o\n", path, (int)mode); ret = chmod(full_path, mode); @@ -958,7 +951,7 @@ static int process_chown(const char *path, u64 uid, u64 gid, void *user) goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "chown %s - uid=%llu, gid=%llu\n", path, uid, gid); @@ -970,7 +963,7 @@ static int process_chown(const char *path, u64 uid, u64 gid, void *user) } if (rctx->cached_capabilities_len) { - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "chown: restore capabilities\n"); ret = lsetxattr(full_path, "security.capability", rctx->cached_capabilities, @@ -1004,7 +997,7 @@ static int process_utimes(const char *path, struct timespec *at, goto out; } - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "utimes %s\n", path); tv[0] = *at; @@ -1023,7 +1016,7 @@ out: static int process_update_extent(const char *path, u64 offset, u64 len, void *user) { - if (g_verbose >= 3) + if (bconf.verbose >= 3) fprintf(stderr, "update_extent %s: offset=%llu, len=%llu\n", path, (unsigned long long)offset, (unsigned long long)len); @@ -1163,7 +1156,7 @@ static int do_receive(struct btrfs_receive *rctx, const char *tomnt, while (!end) { if (rctx->cached_capabilities_len) { - if (g_verbose >= 4) + if (bconf.verbose >= 4) fprintf(stderr, "clear cached capabilities\n"); memset(rctx->cached_capabilities, 0, sizeof(rctx->cached_capabilities)); @@ -1236,8 +1229,10 @@ static const char * const cmd_receive_usage[] = { "After receiving a subvolume, it is immediately set to", "read-only.", "", - "-v increase verbosity about performed actions", - "-q|--quiet suppress all messages, except errors", + "-v increase verbosity about performed actions. This", + " option is merged to the global verbose option.", + "-q|--quiet suppress all messages, except errors. This option", + " is merged with the global quiet option.", "-f FILE read the stream from FILE instead of stdin", "-e terminate after receiving an marker in the stream.", " Without this option the receiver side terminates only in case", @@ -1252,6 +1247,9 @@ static const char * const cmd_receive_usage[] = { " this file system is mounted.", "--dump dump stream metadata, one line per operation,", " does not require the MOUNT parameter", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, + HELPINFO_INSERT_QUIET, NULL }; @@ -1274,6 +1272,18 @@ static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv) realmnt[0] = 0; fromfile[0] = 0; + /* + * Init global verbose to default, if it is unset. + * Default is 1 for historical reasons, changing may break scripts that + * expect the 'At subvol' message. + * As default is 1, which means the effective verbose for receive is 2 + * which global verbose is unaware. So adjust global verbose value here. + */ + if (bconf.verbose == BTRFS_BCONF_UNSET) + bconf.verbose = 1; + else if (bconf.verbose > BTRFS_BCONF_QUIET) + bconf.verbose++; + optind = 0; while (1) { int c; @@ -1292,10 +1302,10 @@ static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv) switch (c) { case 'v': - g_verbose++; + bconf_be_verbose(); break; case 'q': - g_verbose = 0; + bconf_be_quiet(); break; case 'f': if (arg_copy_path(fromfile, optarg, sizeof(fromfile))) { From patchwork Fri Jun 12 11:24:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601651 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 006086A2 for ; Fri, 12 Jun 2020 13:44:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCA8C20792 for ; Fri, 12 Jun 2020 13:44:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="u3uJTZDa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726272AbgFLNo5 (ORCPT ); Fri, 12 Jun 2020 09:44:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58620 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgFLNo5 (ORCPT ); Fri, 12 Jun 2020 09:44:57 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CDe0nh013606; Fri, 12 Jun 2020 13:44:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=tdHF5qjPu8ixC2L5Y4s2IV4XxBAR/Z1wO7OXpurzY9A=; b=u3uJTZDaq/BJUSZa2gI2zOu0E6R/mcuOcoUbSphoUvC7gf8G0/kkx7abr7aljeqlHR2t LT1+n7uh20VjzEq86ITuq2vClUs72eKsUHY2bLu3vCCAexHNyVLPNKDMZK2dUbtnWokQ TGO0ms039BBOeW+kF/kBYt+wTnNDySd8iDdR1b3Ub6cywQrZcahA/57NGiEVfrV8uYeh jf/MtRop4+mhTF1SCu3U28ayQXwcLunk84sHAzJCNBkq5YZjNE6QYPIwt+wsvEtszASR BaGrziISy0zl+Wft7x8DoHj6esefH9VxetmxI/U97aXHOpHCoavNLJYivuO3dQ38eoR8 BA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 31g3snd0xa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 13:44:54 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CDebdj089950; Fri, 12 Jun 2020 13:44:53 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 31masr054g-122 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 13:44:53 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05CBP4Ml025178; Fri, 12 Jun 2020 11:25:04 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:25:03 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 05/16] btrfs-progs: subvolume delete: use global verbose option Date: Fri, 12 Jun 2020 19:24:56 +0800 Message-Id: <20200612112456.3568-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-6-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-6-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 suspectscore=1 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120101 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=1 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120101 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs subvolume delete sub-command. Suggested-by: David Sterba Signed-off-by: Anand Jain --- V3: Update the help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() Documentation/btrfs-subvolume.asciidoc | 3 ++- cmds/subvolume.c | 31 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Documentation/btrfs-subvolume.asciidoc b/Documentation/btrfs-subvolume.asciidoc index d8c414fd5c60..47f0cc471297 100644 --- a/Documentation/btrfs-subvolume.asciidoc +++ b/Documentation/btrfs-subvolume.asciidoc @@ -87,7 +87,8 @@ wait for transaction commit at the end of the operation. wait for transaction commit after deleting each subvolume. + -v|--verbose:::: -verbose output of operations. +verbose output of operations. This option is merged to the global verbose +option. + -i|--subvolid :::: subvolume id to be removed instead of the that should point to the diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 6f1d90358785..b1606fbd398c 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -236,7 +236,10 @@ static const char * const cmd_subvol_delete_usage[] = { "-c|--commit-after wait for transaction commit at the end of the operation", "-C|--commit-each wait for transaction commit after deleting each subvolume", "-i|--subvolid subvolume id of the to be removed subvolume", - "-v|--verbose verbose output of operations", + "-v|--verbose verbose output of operations. This option is", + " merged to the global verbose option.", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -251,7 +254,6 @@ static int cmd_subvol_delete(const struct cmd_struct *cmd, char *dupvname = NULL; char *path = NULL; DIR *dirstream = NULL; - int verbose = 0; int commit_mode = 0; u8 fsid[BTRFS_FSID_SIZE]; u64 subvolid = 0; @@ -287,7 +289,7 @@ static int cmd_subvol_delete(const struct cmd_struct *cmd, subvolid = arg_strtou64(optarg); break; case 'v': - verbose++; + bconf_be_verbose(); break; default: usage_unknown_option(cmd, argv); @@ -301,11 +303,9 @@ static int cmd_subvol_delete(const struct cmd_struct *cmd, if (subvolid > 0 && check_argc_exact(argc - optind, 1)) return 1; - if (verbose > 0) { - printf("Transaction commit: %s\n", - !commit_mode ? "none (default)" : - commit_mode == COMMIT_AFTER ? "at the end" : "after each"); - } + pr_verbose(1, "Transaction commit: %s\n", + !commit_mode ? "none (default)" : + commit_mode == COMMIT_AFTER ? "at the end" : "after each"); cnt = optind; @@ -395,11 +395,9 @@ again: } if (add_seen_fsid(fsid, seen_fsid_hash, fd, dirstream) == 0) { - if (verbose > 0) { - uuid_unparse(fsid, uuidbuf); - printf(" new fs is found for '%s', fsid: %s\n", - path, uuidbuf); - } + uuid_unparse(fsid, uuidbuf); + pr_verbose(1, " new fs is found for '%s', fsid: %s\n", + path, uuidbuf); /* * This is the first time a subvolume on this * filesystem is deleted, keep fd in order to issue @@ -440,10 +438,11 @@ keep_fd: "unable to do final sync after deletion: %m, fsid: %s", uuidbuf); ret = 1; - } else if (verbose > 0) { + } else { uuid_unparse(seen->fsid, uuidbuf); - printf("final sync is done for fsid: %s\n", - uuidbuf); + pr_verbose(1, + "final sync is done for fsid: %s\n", + uuidbuf); } seen = seen->next; } From patchwork Fri Jun 12 11:25:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24669159A for ; Fri, 12 Jun 2020 11:35:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0888E207D8 for ; Fri, 12 Jun 2020 11:35:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="fXQSYA+e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726255AbgFLLfm (ORCPT ); Fri, 12 Jun 2020 07:35:42 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:50372 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgFLLfl (ORCPT ); Fri, 12 Jun 2020 07:35:41 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBQPn0125026; Fri, 12 Jun 2020 11:35:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=jVH6nh6bvG7HQXl6XWRMGhTz/QqQwYrOQe7mMjDkHmo=; b=fXQSYA+eaGu53fqk+CrIacvbdSreEORIzzxbbIszalTOxhysRLDIUJjrBdbkjkyiDNfg uEHeJfgaJhObhqDhcY37YFPgpeajfBUSeGqmeq/tihpRt2oN7e2q/YSzkZ5uOQaFXwCM fZWhnYC3ArhMmfKWGWUnHitSULKBQdSLjav/3yYLuslPHyNCTmhMOSBGjjZErcZvxj2g p1AupRXlQtZxW5InPKmfWdJ9lBvZpWvHSiY0A0CX5D/d84fHiS6G+tAFS+YEsHfzx90O rGzsp8geI+07A4YBNizDBi3PS+SNCB9QFU4HhmXtTC8gexZaBVLoo82u8615AXY4lE0U fg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 31g2jrmn10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:35:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBWWta067324; Fri, 12 Jun 2020 11:35:38 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 31m8x3r7u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:35:37 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05CBPVbl032758; Fri, 12 Jun 2020 11:25:32 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:25:31 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 07/16] btrfs-progs: balance start: use global verbose option Date: Fri, 12 Jun 2020 19:25:23 +0800 Message-Id: <20200612112523.3681-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-8-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-8-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=1 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 cotscore=-2147483648 priorityscore=1501 spamscore=0 suspectscore=1 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs balance start sub-command. Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: update help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() No need to init bconf.verbose in the sub command. Documentation/btrfs-balance.asciidoc | 3 ++- cmds/balance.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/btrfs-balance.asciidoc b/Documentation/btrfs-balance.asciidoc index 8afd76da2177..4d81692a60d8 100644 --- a/Documentation/btrfs-balance.asciidoc +++ b/Documentation/btrfs-balance.asciidoc @@ -99,7 +99,8 @@ act on metadata chunks, see `FILTERS` section for details about 'filters' -s[]:::: act on system chunks (requires '-f'), see `FILTERS` section for details about 'filters'. -v:::: -be verbose and print balance filter arguments +be verbose and print balance filter arguments. This option is merged to the +global verbose option. -f:::: force a reduction of metadata integrity, eg. when going from 'raid1' to 'single' --background|--bg:::: diff --git a/cmds/balance.c b/cmds/balance.c index 8b611185bd7d..73bfedba1405 100644 --- a/cmds/balance.c +++ b/cmds/balance.c @@ -494,11 +494,14 @@ static const char * const cmd_balance_start_usage[] = { "-d[filters] act on data chunks", "-m[filters] act on metadata chunks", "-s[filters] act on system chunks (only under -f)", - "-v|--verbose be verbose", + "-v|--verbose be verbose. This option is merged to the global", + " verbose option.", "-f force a reduction of metadata integrity", "--full-balance do not print warning and do not delay start", "--background|--bg", " run the balance as a background process", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -509,7 +512,6 @@ static int cmd_balance_start(const struct cmd_struct *cmd, struct btrfs_balance_args *ptrs[] = { &args.data, &args.sys, &args.meta, NULL }; int force = 0; - int verbose = 0; int background = 0; unsigned start_flags = 0; int i; @@ -564,7 +566,7 @@ static int cmd_balance_start(const struct cmd_struct *cmd, force = 1; break; case 'v': - verbose = 1; + bconf_be_verbose(); break; case GETOPT_VAL_FULL_BALANCE: start_flags |= BALANCE_START_NOWARN; @@ -640,7 +642,7 @@ static int cmd_balance_start(const struct cmd_struct *cmd, if (force) args.flags |= BTRFS_BALANCE_FORCE; - if (verbose) + if (bconf.verbose > BTRFS_BCONF_QUIET) dump_ioctl_balance_args(&args); if (background) { switch (fork()) { From patchwork Fri Jun 12 11:25:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C69221391 for ; Fri, 12 Jun 2020 11:25:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9DD020792 for ; Fri, 12 Jun 2020 11:25:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="fNJ7GrEA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726024AbgFLLZs (ORCPT ); Fri, 12 Jun 2020 07:25:48 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:41328 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbgFLLZs (ORCPT ); Fri, 12 Jun 2020 07:25:48 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBN6QF173862; Fri, 12 Jun 2020 11:25:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=t/P82KxbeBt4vTaDYq4WKVr975L12zJYHrPMVCPMOAA=; b=fNJ7GrEAufw2wBwVNXRnqCD49J/xlUpU3hoU8pwWNL9xNsN/O2NhPehmt0e+EjSHSFKF 1y872ylJkNt34QUNN1S9rMiNJ/I7igeuF9HHIzAhdyq8pb7cga6gGfIhqtvY+z/9Ub2l mUIAvbg3unuK5MM5K5XFyGVML0Wxb/m3tudGKReWtCVjH01jCLXAf5ahkoSnPz4bWvWk GfFHQsfagZ84EjPOERuh16U+27jtr1DYr1WZ02FnfiwPs2DJs3sDh7mqaBoPMT9X4ruc h3Hqfdb5mZ9b1uTiEZ0VBs+DfrDw3767V5HgSf28HwRA2LYT5E5efSeow4yDHQ77qB4t Bw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 31g3sncfhh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:25:44 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBO1gb019337; Fri, 12 Jun 2020 11:25:44 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 31m8rg85m6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:25:44 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05CBPhnV000329; Fri, 12 Jun 2020 11:25:43 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:25:42 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 08/16] btrfs-progs: balance status: use global verbose option Date: Fri, 12 Jun 2020 19:25:35 +0800 Message-Id: <20200612112535.3737-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-9-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-9-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=1 mlxlogscore=999 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=1 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120085 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs balance status sub-command. Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: update help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() No need to init bconf.verbose in the sub command. Documentation/btrfs-balance.asciidoc | 3 ++- cmds/balance.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Documentation/btrfs-balance.asciidoc b/Documentation/btrfs-balance.asciidoc index 4d81692a60d8..2dccb1cc523e 100644 --- a/Documentation/btrfs-balance.asciidoc +++ b/Documentation/btrfs-balance.asciidoc @@ -110,7 +110,8 @@ start the process that calls the kernel ioctl *status* [-v] :: Show status of running or paused balance. + -If '-v' option is given, output will be verbose. +If '-v' option is given, output will be verbose. This option is merged to the +global verbose option. FILTERS ------- diff --git a/cmds/balance.c b/cmds/balance.c index 73bfedba1405..4b4adc2ceae6 100644 --- a/cmds/balance.c +++ b/cmds/balance.c @@ -830,7 +830,10 @@ static const char * const cmd_balance_status_usage[] = { "btrfs balance status [-v] ", "Show status of running or paused balance", "", - "-v|--verbose be verbose", + "-v|--verbose be verbose. This option is merged to the global", + " verbose option.", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -847,7 +850,6 @@ static int cmd_balance_status(const struct cmd_struct *cmd, const char *path; DIR *dirstream = NULL; int fd; - int verbose = 0; int ret; optind = 0; @@ -864,7 +866,7 @@ static int cmd_balance_status(const struct cmd_struct *cmd, switch (opt) { case 'v': - verbose = 1; + bconf_be_verbose(); break; default: usage_unknown_option(cmd, argv); @@ -910,7 +912,7 @@ static int cmd_balance_status(const struct cmd_struct *cmd, (unsigned long long)args.stat.considered, 100 * (1 - (float)args.stat.completed/args.stat.expected)); - if (verbose) + if (bconf.verbose > BTRFS_BCONF_QUIET) dump_ioctl_balance_args(&args); ret = 1; From patchwork Fri Jun 12 11:25:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601551 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAD5D618 for ; Fri, 12 Jun 2020 11:28:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90DC820792 for ; Fri, 12 Jun 2020 11:28:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="FwPg0kIB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726272AbgFLL2B (ORCPT ); Fri, 12 Jun 2020 07:28:01 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59144 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgFLL2A (ORCPT ); Fri, 12 Jun 2020 07:28:00 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBR4VX113567; Fri, 12 Jun 2020 11:27:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=SqbMjTQYEg5OqrG5J46mVyPIEQm6jD/BtUDvA9xajcQ=; b=FwPg0kIB5yiGlVpvc0u+q+hN7oEvTh678us3CySbGES1UUKeppynZZjWum6Qtdrcmbn0 AldGnjJLnDaY9pm1kjyhkVa6RgGDL/7vgaMC9KyGp5rGGvWwUf4DXcdK4UqVoGGs98TK 6zO3nKWiwEP33e2EHjD+e3bN0qaLMj65TwdI+zl17Z6EGxY9XKqptJ3waNrIOU8ptR/Z 0lD0eWD/4DFMxkGUxndpGZAr5cTd0R3S7LZ+bPjiZD03qG4qPdgSd+4aWIiENRev7uzQ 0sYG2kWMwiusgqJmtDVeVhFQQmNeN+ls3dyWX9CGxmhxOEzKACqK9NJu72G9oQzo5eng jw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 31jepp6eub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:27:57 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBOhik156099; Fri, 12 Jun 2020 11:25:57 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 31m8te0114-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:25:56 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05CBPtPs000570; Fri, 12 Jun 2020 11:25:55 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:25:54 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 09/16] btrfs-progs: rescue chunk-recover: use global verbose option Date: Fri, 12 Jun 2020 19:25:45 +0800 Message-Id: <20200612112545.3793-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-10-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-10-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 suspectscore=1 bulkscore=0 malwarescore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=1 priorityscore=1501 bulkscore=0 clxscore=1015 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 cotscore=-2147483648 adultscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs rescue chunk-recover sub-command. For example: Both global and local verbose options are now supported. btrfs -v|--verbose rescue chunk-recover btrfs rescue chunk-recover -v Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: update help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() Drop verbose argument in init_recover_control() Documentation/btrfs-rescue.asciidoc | 2 +- cmds/rescue-chunk-recover.c | 9 ++++----- cmds/rescue.c | 14 ++++++++++---- cmds/rescue.h | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Documentation/btrfs-rescue.asciidoc b/Documentation/btrfs-rescue.asciidoc index f94a0ff2b45e..995515890e9e 100644 --- a/Documentation/btrfs-rescue.asciidoc +++ b/Documentation/btrfs-rescue.asciidoc @@ -24,7 +24,7 @@ Recover the chunk tree by scanning the devices -y:::: assume an answer of 'yes' to all questions. -v:::: -verbose mode. +verbose mode. This option is merged to the global verbose option. -h:::: help. diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c index a13acc015d11..1854e7984127 100644 --- a/cmds/rescue-chunk-recover.c +++ b/cmds/rescue-chunk-recover.c @@ -194,8 +194,7 @@ static struct btrfs_chunk *create_chunk_item(struct chunk_record *record) return ret; } -static void init_recover_control(struct recover_control *rc, int verbose, - int yes) +static void init_recover_control(struct recover_control *rc, int yes) { memset(rc, 0, sizeof(struct recover_control)); cache_tree_init(&rc->chunk); @@ -208,7 +207,7 @@ static void init_recover_control(struct recover_control *rc, int verbose, INIT_LIST_HEAD(&rc->rebuild_chunks); INIT_LIST_HEAD(&rc->unrepaired_chunks); - rc->verbose = verbose; + rc->verbose = bconf.verbose; rc->yes = yes; pthread_mutex_init(&rc->rc_lock, NULL); } @@ -2319,14 +2318,14 @@ static void validate_rebuild_chunks(struct recover_control *rc) /* * Return 0 when successful, < 0 on error and > 0 if aborted by user */ -int btrfs_recover_chunk_tree(const char *path, int verbose, int yes) +int btrfs_recover_chunk_tree(const char *path, int yes) { int ret = 0; struct btrfs_root *root = NULL; struct btrfs_trans_handle *trans; struct recover_control rc; - init_recover_control(&rc, verbose, yes); + init_recover_control(&rc, yes); ret = recover_prepare(&rc, path); if (ret) { diff --git a/cmds/rescue.c b/cmds/rescue.c index 087c33befeff..bb65a672bbf3 100644 --- a/cmds/rescue.c +++ b/cmds/rescue.c @@ -38,8 +38,11 @@ static const char * const cmd_rescue_chunk_recover_usage[] = { "Recover the chunk tree by scanning the devices one by one.", "", "-y Assume an answer of `yes' to all questions", - "-v Verbose mode", + "-v Verbose mode. This option is merged to the global verbose", + " option", "-h Help", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -49,7 +52,10 @@ static int cmd_rescue_chunk_recover(const struct cmd_struct *cmd, int ret = 0; char *file; int yes = 0; - int verbose = 0; + + /* If verbose is unset, set it to 0 */ + if (bconf.verbose == BTRFS_BCONF_UNSET) + bconf.verbose = BTRFS_BCONF_QUIET; optind = 0; while (1) { @@ -61,7 +67,7 @@ static int cmd_rescue_chunk_recover(const struct cmd_struct *cmd, yes = 1; break; case 'v': - verbose = 1; + bconf.verbose++; break; default: usage_unknown_option(cmd, argv); @@ -83,7 +89,7 @@ static int cmd_rescue_chunk_recover(const struct cmd_struct *cmd, return 1; } - ret = btrfs_recover_chunk_tree(file, verbose, yes); + ret = btrfs_recover_chunk_tree(file, yes); if (!ret) { fprintf(stdout, "Chunk tree recovered successfully\n"); } else if (ret > 0) { diff --git a/cmds/rescue.h b/cmds/rescue.h index de486e2e2004..e594954f78e2 100644 --- a/cmds/rescue.h +++ b/cmds/rescue.h @@ -16,6 +16,6 @@ #define __BTRFS_RESCUE_H__ int btrfs_recover_superblocks(const char *path, int verbose, int yes); -int btrfs_recover_chunk_tree(const char *path, int verbose, int yes); +int btrfs_recover_chunk_tree(const char *path, int yes); #endif From patchwork Fri Jun 12 11:25:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601547 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5B731391 for ; Fri, 12 Jun 2020 11:26:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC32C20792 for ; Fri, 12 Jun 2020 11:26:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="oxWqfhco" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726044AbgFLL0O (ORCPT ); Fri, 12 Jun 2020 07:26:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:41610 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgFLL0O (ORCPT ); Fri, 12 Jun 2020 07:26:14 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBMiXT173737; Fri, 12 Jun 2020 11:26:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=4aKXhjMIQI7o+RbqWUwTbGlo4I1Q38IzxaVbH2dSZkU=; b=oxWqfhco3PM8yRGKWUlmWm1N0VMUQKEfzrC05N0zxc52Oz9cIyWIt0qZxvxo6o+dCSyu XFBj3/B7xAMyjpqx38Z3WBBNMfXepEEHh0+Ne/hl2UakXYfTy05cDbEgoZPVqlQbuFoe x812XRMAK7jxYSaOYo13lEzYZMD6zBFNBpXsRILm+TwYnskyUvT0DiBCUkDo8a3TYb7j E98Rbv99yMrPuGRQ1XlNQxQBXwXUPXhYwRERqvdWx/JJx/uYLtaMBAgjo+c+RQFQ5o1P mD9bUeuW9e456lA9Dc/5+33O2HxL7YZnEq+SqMjQqMLHhv9L/0KM6H1oB3/KItTR/Otf 1A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 31g3sncfjn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:26:10 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBO3Eu019733; Fri, 12 Jun 2020 11:26:10 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 31m8rg867q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:26:10 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05CBQ9Yg003401; Fri, 12 Jun 2020 11:26:09 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:26:08 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 10/16] btrfs-progs: rescue super-recover: use global verbose option Date: Fri, 12 Jun 2020 19:25:59 +0800 Message-Id: <20200612112559.3849-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-11-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-11-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=1 mlxlogscore=999 spamscore=0 adultscore=0 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=1 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120085 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs rescue super-recover sub-command. For example: Both global and local verbose options are now supported. btrfs -v|--verbose rescue super-recover btrfs rescue super-recover -v Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: update help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() Drop verbose argument in btrfs_recover_superblocks() Documentation/btrfs-rescue.asciidoc | 2 +- cmds/rescue-super-recover.c | 7 +++---- cmds/rescue.c | 10 ++++++---- cmds/rescue.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Documentation/btrfs-rescue.asciidoc b/Documentation/btrfs-rescue.asciidoc index 995515890e9e..b48c55189844 100644 --- a/Documentation/btrfs-rescue.asciidoc +++ b/Documentation/btrfs-rescue.asciidoc @@ -58,7 +58,7 @@ Recover bad superblocks from good copies. -y:::: assume an answer of 'yes' to all questions. -v:::: -verbose mode. +verbose mode. This option is merged to the global verbose option. *zero-log* :: clear the filesystem log tree diff --git a/cmds/rescue-super-recover.c b/cmds/rescue-super-recover.c index 5d6bea836c8b..3a60eb40c8bb 100644 --- a/cmds/rescue-super-recover.c +++ b/cmds/rescue-super-recover.c @@ -226,8 +226,7 @@ static void recover_err_str(int ret) } } -int btrfs_recover_superblocks(const char *dname, - int verbose, int yes) +int btrfs_recover_superblocks(const char *dname, int yes) { int fd, ret; struct btrfs_recover_superblock recover; @@ -249,7 +248,7 @@ int btrfs_recover_superblocks(const char *dname, goto no_recover; } - if (verbose) + if (bconf.verbose > BTRFS_BCONF_QUIET) print_all_devices(&recover.fs_devices->devices); ret = read_fs_supers(&recover); @@ -257,7 +256,7 @@ int btrfs_recover_superblocks(const char *dname, ret = 1; goto no_recover; } - if (verbose) { + if (bconf.verbose > BTRFS_BCONF_QUIET) { printf("Before Recovering:\n"); print_all_supers(&recover); } diff --git a/cmds/rescue.c b/cmds/rescue.c index bb65a672bbf3..1d53cf446a96 100644 --- a/cmds/rescue.c +++ b/cmds/rescue.c @@ -107,7 +107,10 @@ static const char * const cmd_rescue_super_recover_usage[] = { "Recover bad superblocks from good copies", "", "-y Assume an answer of `yes' to all questions", - "-v Verbose mode", + "-v Verbose mode. This option is merged to the global verbose", + " option", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -123,7 +126,6 @@ static int cmd_rescue_super_recover(const struct cmd_struct *cmd, int argc, char **argv) { int ret; - int verbose = 0; int yes = 0; char *dname; @@ -134,7 +136,7 @@ static int cmd_rescue_super_recover(const struct cmd_struct *cmd, break; switch (c) { case 'v': - verbose = 1; + bconf_be_verbose(); break; case 'y': yes = 1; @@ -156,7 +158,7 @@ static int cmd_rescue_super_recover(const struct cmd_struct *cmd, error("the device is busy"); return 1; } - ret = btrfs_recover_superblocks(dname, verbose, yes); + ret = btrfs_recover_superblocks(dname, yes); return ret; } static DEFINE_SIMPLE_COMMAND(rescue_super_recover, "super-recover"); diff --git a/cmds/rescue.h b/cmds/rescue.h index e594954f78e2..3b99ec6b0daa 100644 --- a/cmds/rescue.h +++ b/cmds/rescue.h @@ -15,7 +15,7 @@ #ifndef __BTRFS_RESCUE_H__ #define __BTRFS_RESCUE_H__ -int btrfs_recover_superblocks(const char *path, int verbose, int yes); +int btrfs_recover_superblocks(const char *path, int yes); int btrfs_recover_chunk_tree(const char *path, int yes); #endif From patchwork Fri Jun 12 11:26:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601563 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21CE66A2 for ; Fri, 12 Jun 2020 11:39:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 01006207D8 for ; Fri, 12 Jun 2020 11:39:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="q58uYuMy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726089AbgFLLjx (ORCPT ); Fri, 12 Jun 2020 07:39:53 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:55548 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbgFLLjw (ORCPT ); Fri, 12 Jun 2020 07:39:52 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBWcQ3128832; Fri, 12 Jun 2020 11:39:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=YyHaOgSpamErUNUNNZStwrq8AG0s3P3axPSrNPPIGqc=; b=q58uYuMy/WAVDp/RzqzjLTD3l6XTmyeD5Wss6nXhf64gsXyxyH1axr0WpoCLgy/pDbdm Ku3xq+MNTAPjXqh7YfPNWQe3PY0ahrOQbTlqwZazNLqMqWpGL0ix16mCVJhy2t1SXVCT CzzowTWEMJ0zEa5ELfsC502lb3CAD1kv8e7NkHpWv1nWHJmOEYcuBtHX6IBZpX782kI2 A/k2H2wAUeSddH4lMw/dGYAxMcayBhtgqazaC0nQfd7ETzcbinAUIbjCVBgHYPWC1C6C H/1m4/uWcuiZ3Bhbcg9105C2Ii03/NlxJWtbkd1RfOamsafTDH5BSOyMdMz7C1xKqkc7 Zg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 31g2jrmnvv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:39:48 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBWbrn084803; Fri, 12 Jun 2020 11:37:48 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 31m8x40dd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:37:47 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05CBQPk1003424; Fri, 12 Jun 2020 11:26:25 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:26:25 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 11/16] btrfs-progs: restore: use global verbose option Date: Fri, 12 Jun 2020 19:26:17 +0800 Message-Id: <20200612112617.3906-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-12-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-12-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 suspectscore=3 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 impostorscore=0 cotscore=-2147483648 priorityscore=1501 spamscore=0 suspectscore=3 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 phishscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs restore sub-command. Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: update help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() Documentation/btrfs-restore.asciidoc | 3 +- cmds/restore.c | 60 +++++++++++++--------------- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/Documentation/btrfs-restore.asciidoc b/Documentation/btrfs-restore.asciidoc index 090dcc555bc2..9174c2951db3 100644 --- a/Documentation/btrfs-restore.asciidoc +++ b/Documentation/btrfs-restore.asciidoc @@ -48,7 +48,8 @@ restore owner, mode and times for files and directories restore symbolic links as well as normal files -v|--verbose:: -be verbose and print what is being restored +be verbose and print what is being restored. This option is merged to the +global verbose option -i|--ignore-errors:: ignore errors during restoration and continue diff --git a/cmds/restore.c b/cmds/restore.c index 08f5b7e73183..e587ee33beab 100644 --- a/cmds/restore.c +++ b/cmds/restore.c @@ -51,7 +51,6 @@ static char fs_name[PATH_MAX]; static char path_name[PATH_MAX]; static char symlink_target[PATH_MAX]; static int get_snaps = 0; -static int verbose = 0; static int restore_metadata = 0; static int restore_symlinks = 0; static int ignore_errors = 0; @@ -386,8 +385,7 @@ static int copy_one_extent(struct btrfs_root *root, int fd, size_left -= offset; } - if (verbose && offset) - printf("offset is %Lu\n", offset); + pr_verbose(offset ? 1 : 0, "offset is %Lu\n", offset); inbuf = malloc(size_left); if (!inbuf) { @@ -820,11 +818,15 @@ static int overwrite_ok(const char * path) if (overwrite) return 2; - if (verbose || !warn) - printf("Skipping existing file" - " %s\n", path); - if (!warn) - printf("If you wish to overwrite use -o\n"); + if (!warn) { + pr_verbose(MUST_LOG, + "Skipping existing file %s\n", path); + pr_verbose(MUST_LOG, + "If you wish to overwrite use -o\n"); + } else { + pr_verbose(1, "Skipping existing file %s\n", path); + } + warn = 1; return 0; } @@ -899,8 +901,7 @@ static int copy_symlink(struct btrfs_root *root, struct btrfs_key *key, } } - if (verbose >= 2) - printf("SYMLINK: '%s' => '%s'\n", path_name, symlink_target); + pr_verbose(2, "SYMLINK: '%s' => '%s'\n", path_name, symlink_target); ret = 0; if (!restore_metadata) @@ -977,9 +978,8 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, leaf = path.nodes[0]; while (!leaf) { - if (verbose > 1) - printf("No leaf after search, looking for the next " - "leaf\n"); + pr_verbose(2, + "No leaf after search, looking for the next leaf\n"); ret = next_leaf(root, &path); if (ret < 0) { fprintf(stderr, "Error getting next leaf %d\n", @@ -987,9 +987,8 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, goto out; } else if (ret > 0) { /* No more leaves to search */ - if (verbose) - printf("Reached the end of the tree looking " - "for the directory\n"); + pr_verbose(1, + "Reached the end of the tree looking for the directory\n"); ret = 0; goto out; } @@ -1013,10 +1012,8 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, goto out; } else if (ret > 0) { /* No more leaves to search */ - if (verbose) - printf("Reached the end of " - "the tree searching the" - " directory\n"); + pr_verbose(1, + "Reached the end of the tree searching the directory\n"); ret = 0; goto out; } @@ -1026,14 +1023,12 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, } btrfs_item_key_to_cpu(leaf, &found_key, path.slots[0]); if (found_key.objectid != key->objectid) { - if (verbose > 1) - printf("Found objectid=%Lu, key=%Lu\n", - found_key.objectid, key->objectid); + pr_verbose(2, "Found objectid=%Lu, key=%Lu\n", + found_key.objectid, key->objectid); break; } if (found_key.type != key->type) { - if (verbose > 1) - printf("Found type=%u, want=%u\n", + pr_verbose(2, "Found type=%u, want=%u\n", found_key.type, key->type); break; } @@ -1062,8 +1057,7 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, if (!overwrite_ok(path_name)) goto next; - if (verbose) - printf("Restoring %s\n", path_name); + pr_verbose(1, "Restoring %s\n", path_name); if (dry_run) goto next; fd = open(path_name, O_CREAT|O_WRONLY, 0644); @@ -1135,8 +1129,7 @@ static int search_dir(struct btrfs_root *root, struct btrfs_key *key, location.objectid = BTRFS_FIRST_FREE_OBJECTID; } - if (verbose) - printf("Restoring %s\n", path_name); + pr_verbose(1, "Restoring %s\n", path_name); errno = 0; if (dry_run) @@ -1199,8 +1192,7 @@ next: } } - if (verbose) - printf("Done searching %s\n", in_dir); + pr_verbose(1, "Done searching %s\n", in_dir); out: btrfs_release_path(&path); return ret; @@ -1395,7 +1387,7 @@ static const char * const cmd_restore_usage[] = { "-x|--xattr restore extended attributes", "-m|--metadata restore owner, mode and times", "-S|--symlink restore symbolic links", - "-v|--verbose verbose", + "-v|--verbose verbose. This option is merged to the global verbose option", "-i|--ignore-errors ignore errors", "-o|--overwrite overwrite", "-t tree location", @@ -1410,6 +1402,8 @@ static const char * const cmd_restore_usage[] = { " you have to use following syntax (possibly quoted):", " ^/(|home(|/username(|/Desktop(|/.*))))$", "-c ignore case (--path-regex only)", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -1462,7 +1456,7 @@ static int cmd_restore(const struct cmd_struct *cmd, int argc, char **argv) get_snaps = 1; break; case 'v': - verbose++; + bconf_be_verbose(); break; case 'i': ignore_errors = 1; From patchwork Fri Jun 12 11:26:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA8F16A2 for ; Fri, 12 Jun 2020 11:37:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF139207D8 for ; Fri, 12 Jun 2020 11:37:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="IUztN2Na" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726024AbgFLLhU (ORCPT ); Fri, 12 Jun 2020 07:37:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48760 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725872AbgFLLhT (ORCPT ); Fri, 12 Jun 2020 07:37:19 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBR44r176619; Fri, 12 Jun 2020 11:37:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=H1dj24sC3/x0GsqF9E3RKr1EmeyygG7ixuelSU9tBiE=; b=IUztN2NaPCwD6RWdftSLnYheIq5jkn9+9xTFxY+8Y1soKHB1xv1OISe8LaqoBWAmK/bR Q0DqOrdnsUAObvwIF+QIz0j+NO+mw3IbU8NMURq94EgLMfnAGSVqsg/5cXx2S/+yPYgk JoqgWLPxZViQU1CTJE4smOG1W2XbDRPceVG6uRi7jDd/xD2k2dRBeZLSmXKzQRlrRW6A JIii51dvGOfJ+HVJqsNP0osZJsf+GTI3RaQZvUrz2g2SufzLr5FypHV+YTS6kmnshCx9 JtIoN6H30JIJJqOLR7Vxdz3JGbn++1F2wNKqCEdM8CWc9L2dEcBLjtmz6IV8bWkh50zY 0g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31g3sncgj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:37:15 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBWcwB086030; Fri, 12 Jun 2020 11:37:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 31m8x40e2y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:37:14 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05CBQabA028754; Fri, 12 Jun 2020 11:26:36 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:26:35 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 12/16] btrfs-progs: inspect-internal inode-resolve: use global verbose Date: Fri, 12 Jun 2020 19:26:27 +0800 Message-Id: <20200612112627.3962-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-13-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-13-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 suspectscore=1 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=1 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs inspect-internal inode-resolve sub-command. Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: update help and documentation v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose(), bconf_be_quiet() Documentation/btrfs-inspect-internal.asciidoc | 1 + cmds/inspect.c | 22 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Documentation/btrfs-inspect-internal.asciidoc b/Documentation/btrfs-inspect-internal.asciidoc index 0718070d8905..e8d4c861603d 100644 --- a/Documentation/btrfs-inspect-internal.asciidoc +++ b/Documentation/btrfs-inspect-internal.asciidoc @@ -139,6 +139,7 @@ at 'path', ie. all hardlinks + -v:::: verbose mode, print count of returned paths and ioctl() return value +This option is merged to the global verbose option *logical-resolve* [-Pvo] [-s ] :: (needs root privileges) diff --git a/cmds/inspect.c b/cmds/inspect.c index 5b946da08b72..b0d3c8102400 100644 --- a/cmds/inspect.c +++ b/cmds/inspect.c @@ -56,12 +56,11 @@ static int __ino_to_path_fd(u64 inum, int fd, int verbose, const char *prepend) goto out; } - if (verbose) - printf("ioctl ret=%d, bytes_left=%lu, bytes_missing=%lu, " - "cnt=%d, missed=%d\n", ret, - (unsigned long)fspath->bytes_left, - (unsigned long)fspath->bytes_missing, - fspath->elem_cnt, fspath->elem_missed); + pr_verbose(1, + "ioctl ret=%d, bytes_left=%lu, bytes_missing=%lu cnt=%d, missed=%d\n", + ret, (unsigned long)fspath->bytes_left, + (unsigned long)fspath->bytes_missing, fspath->elem_cnt, + fspath->elem_missed); for (i = 0; i < fspath->elem_cnt; ++i) { u64 ptr; @@ -83,7 +82,9 @@ static const char * const cmd_inspect_inode_resolve_usage[] = { "btrfs inspect-internal inode-resolve [-v] ", "Get file system paths for the given inode", "", - "-v verbose mode", + "-v verbose mode. This option is merged to the global verbose option", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -91,7 +92,6 @@ static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd, int argc, char **argv) { int fd; - int verbose = 0; int ret; DIR *dirstream = NULL; @@ -103,7 +103,7 @@ static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd, switch (c) { case 'v': - verbose = 1; + bconf_be_verbose(); break; default: usage_unknown_option(cmd, argv); @@ -117,8 +117,8 @@ static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd, if (fd < 0) return 1; - ret = __ino_to_path_fd(arg_strtou64(argv[optind]), fd, verbose, - argv[optind+1]); + ret = __ino_to_path_fd(arg_strtou64(argv[optind]), fd, + bconf.verbose, argv[optind+1]); close_file_or_dir(fd, dirstream); return !!ret; From patchwork Fri Jun 12 11:26:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 11601549 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D5041391 for ; Fri, 12 Jun 2020 11:26:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33C2220792 for ; Fri, 12 Jun 2020 11:26:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dd+PsrUS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726053AbgFLL0x (ORCPT ); Fri, 12 Jun 2020 07:26:53 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:42012 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbgFLL0x (ORCPT ); Fri, 12 Jun 2020 07:26:53 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBQXhq176445; Fri, 12 Jun 2020 11:26:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=lwlZjU42kMH0F/Iqs/etoB26xP/PGAOgtdB1XZlzssA=; b=dd+PsrUS4MG28qsP8BM7DMcKqfUozkj3/53gJDYNfwFPPnsqcHtLa3ZLyaSzRed09aak 9wK6wuKP3Umx8fhX1iRs3pDyV7Ylp6NryQCTVWg+4MXSfqYKYKWavygIgA++ABbsh2nH S0rFEozO97XAI41S7GmkztWnSxOKvS2Upu1Up5TGy+DXQi0mLrut3+2TXc/Mr9f54h3i oNdiA2d9I014LZ7zDLNW2riN/bNOFlROeMX5lNIhe8XhVnpS7iqYYMxWlxjH55HytH84 P4BTAYTuxfiBaA+shjrsZ8QYRLiGkYlD7am3Ttd/YIrtdIjwQqajBrFlc5P7zAgCq5Xy xw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 31g3sncfku-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 12 Jun 2020 11:26:48 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05CBOtgb156293; Fri, 12 Jun 2020 11:26:48 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 31m8te01rb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Jun 2020 11:26:48 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 05CBQl9A026214; Fri, 12 Jun 2020 11:26:47 GMT Received: from localhost.localdomain (/39.109.231.106) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Jun 2020 04:26:47 -0700 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com Subject: [PATCH v3 13/16] btrfs-progs: inspect-internal logical-resolve: use global verbose option Date: Fri, 12 Jun 2020 19:26:38 +0800 Message-Id: <20200612112638.4018-1-anand.jain@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <1574678357-22222-14-git-send-email-anand.jain@oracle.com> References: <1574678357-22222-14-git-send-email-anand.jain@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 suspectscore=1 bulkscore=0 malwarescore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120085 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9649 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=1 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006120086 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Transpire global --verbose option down to the btrfs inspect-internal logical-resolve sub-command. Command btrfs inspect-internal logical-resolve provides local verbose option this patch makes it enable-able by using the global --verbose option. Suggested-by: David Sterba Signed-off-by: Anand Jain --- v3: update help and documentation v2: Use new helper function bconf_be_verbose() Documentation/btrfs-inspect-internal.asciidoc | 1 + cmds/inspect.c | 25 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Documentation/btrfs-inspect-internal.asciidoc b/Documentation/btrfs-inspect-internal.asciidoc index e8d4c861603d..c0009e2e5382 100644 --- a/Documentation/btrfs-inspect-internal.asciidoc +++ b/Documentation/btrfs-inspect-internal.asciidoc @@ -152,6 +152,7 @@ resolve paths to all files at given 'logical' address in the linear filesystem s skip the path resolving and print the inodes instead -v:::: verbose mode, print count of returned paths and all ioctl() return values +This option is merged to the global verbose option -o:::: ignore offsets, find all references to an extent instead of a single block. Requires kernel support for the V2 ioctl (added in 4.15). The results might need diff --git a/cmds/inspect.c b/cmds/inspect.c index b0d3c8102400..bbbac4431ac7 100644 --- a/cmds/inspect.c +++ b/cmds/inspect.c @@ -38,7 +38,7 @@ static const char * const inspect_cmd_group_usage[] = { NULL }; -static int __ino_to_path_fd(u64 inum, int fd, int verbose, const char *prepend) +static int __ino_to_path_fd(u64 inum, int fd, const char *prepend) { int ret; int i; @@ -117,8 +117,7 @@ static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd, if (fd < 0) return 1; - ret = __ino_to_path_fd(arg_strtou64(argv[optind]), fd, - bconf.verbose, argv[optind+1]); + ret = __ino_to_path_fd(arg_strtou64(argv[optind]), fd, argv[optind+1]); close_file_or_dir(fd, dirstream); return !!ret; @@ -137,6 +136,8 @@ static const char * const cmd_inspect_logical_resolve_usage[] = { " container's size in case it is not enough to read all the ", " resolved results. The max value one can set is 64k with the", " v1 ioctl. Sizes over 64k will use the v2 ioctl (kernel 4.15+)", + HELPINFO_INSERT_GLOBALS, + HELPINFO_INSERT_VERBOSE, NULL }; @@ -146,7 +147,6 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd, int ret; int fd; int i; - int verbose = 0; int getpath = 1; int bytes_left; struct btrfs_ioctl_logical_ino_args loi = { 0 }; @@ -169,7 +169,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd, getpath = 0; break; case 'v': - verbose = 1; + bconf_be_verbose(); break; case 'o': flags |= BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET; @@ -211,13 +211,11 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd, goto out; } - if (verbose) - printf("ioctl ret=%d, total_size=%llu, bytes_left=%lu, " - "bytes_missing=%lu, cnt=%d, missed=%d\n", - ret, size, - (unsigned long)inodes->bytes_left, - (unsigned long)inodes->bytes_missing, - inodes->elem_cnt, inodes->elem_missed); + pr_verbose(1, +"ioctl ret=%d, total_size=%llu, bytes_left=%lu, bytes_missing=%lu, cnt=%d, missed=%d\n", + ret, size, (unsigned long)inodes->bytes_left, + (unsigned long)inodes->bytes_missing, inodes->elem_cnt, + inodes->elem_missed); bytes_left = sizeof(full_path); ret = snprintf(full_path, bytes_left, "%s/", argv[optind+1]); @@ -262,8 +260,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd, goto out; } } - ret = __ino_to_path_fd(inum, path_fd, verbose, - full_path); + ret = __ino_to_path_fd(inum, path_fd, full_path); if (path_fd != fd) close_file_or_dir(path_fd, dirs); } else {