Whamcloud - gitweb
LU-15362 util: fix silent failure of component delete 33/45833/6
authorLi Xi <lixi@ddn.com>
Sun, 12 Dec 2021 05:21:32 +0000 (13:21 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Jan 2022 22:04:16 +0000 (22:04 +0000)
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 <lixi@ddn.com>
Change-Id: Id20b55a3e12a7152198ee475e55f6dd764a55219
Reviewed-on: https://review.whamcloud.com/45833
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/lfs.c

index 048b958..095baf4 100644 (file)
@@ -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) {