From: Li Xi Date: Sun, 12 Dec 2021 05:21:32 +0000 (+0800) Subject: LU-15362 util: fix silent failure of component delete X-Git-Tag: 2.14.57~48 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=99db47f23686103677ec91e3666666da8176acbb LU-15362 util: fix silent failure of component delete When no component ID is specified, no error message is printed when the command of component deletion fails. The failure thus could be easily ignored. And the failure reason is hard to be understood without any error message. Test-Parameters: trivial Signed-off-by: Li Xi Change-Id: Id20b55a3e12a7152198ee475e55f6dd764a55219 Reviewed-on: https://review.whamcloud.com/45833 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 048b958..095baf4 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -1126,14 +1126,29 @@ static int lfs_component_del(char *fname, __u32 comp_id, { int rc = 0; - if (flags && neg_flags) + if (flags && neg_flags) { + fprintf(stderr, + "%s: cannot specify both positive and negative flags\n", + progname); return -EINVAL; + } if (!flags && neg_flags) flags = neg_flags | LCME_FL_NEG; - if ((flags && comp_id) || (!flags && !comp_id)) + if (flags && comp_id) { + fprintf(stderr, + "%s: cannot specify component ID and flags at the same time\n", + progname); return -EINVAL; + } + + if (!flags && !comp_id) { + fprintf(stderr, + "%s: neither flags nor component ID is specified\n", + progname); + return -EINVAL; + } if (flags) { if (flags & ~LCME_KNOWN_FLAGS) {