Whamcloud - gitweb
LU-12137 osd-ldiskfs: implement proper error handling in osd_ios_OBJECTS_scan 44/35644/3
authorJames Simmons <jsimmons@infradead.org>
Sat, 3 Aug 2019 13:59:16 +0000 (09:59 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 15 Aug 2019 07:54:43 +0000 (07:54 +0000)
In the linux kernel it is considered proper coding style to
handle error codes returned by functions instead of successful
completions. Reverse the error handling of the return values from
osd_ios_lookup_one_len(). This also reduces the code indentation
and makes it easier to follow.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Change-Id: Idd3b91218f80a88d69206d3c2570bea22ff1fbb1
Reviewed-on: https://review.whamcloud.com/35644
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osd-ldiskfs/osd_scrub.c

index 9ac3fca..dfdd87c 100644 (file)
@@ -2388,32 +2388,28 @@ osd_ios_OBJECTS_scan(struct osd_thread_info *info, struct osd_device *dev,
        }
 
        child = osd_ios_lookup_one_len(ADMIN_USR, dentry, strlen(ADMIN_USR));
-       if (!IS_ERR(child)) {
+       if (IS_ERR(child)) {
+               rc = PTR_ERR(child);
+       } else {
                rc = osd_ios_scan_one(info, dev, dentry->d_inode,
                                      child->d_inode, NULL, ADMIN_USR,
                                      strlen(ADMIN_USR), 0);
                dput(child);
-       } else {
-               rc = PTR_ERR(child);
        }
 
        if (rc != 0 && rc != -ENOENT)
-               RETURN(rc);
+               GOTO(out, rc);
 
        child = osd_ios_lookup_one_len(ADMIN_GRP, dentry, strlen(ADMIN_GRP));
-       if (!IS_ERR(child)) {
-               rc = osd_ios_scan_one(info, dev, dentry->d_inode,
-                                     child->d_inode, NULL, ADMIN_GRP,
-                                     strlen(ADMIN_GRP), 0);
-               dput(child);
-       } else {
-               rc = PTR_ERR(child);
-       }
-
-       if (rc == -ENOENT)
-               rc = 0;
+       if (IS_ERR(child))
+               GOTO(out, rc = PTR_ERR(child));
 
-       RETURN(rc);
+       rc = osd_ios_scan_one(info, dev, dentry->d_inode,
+                             child->d_inode, NULL, ADMIN_GRP,
+                             strlen(ADMIN_GRP), 0);
+       dput(child);
+out:
+       RETURN(rc == -ENOENT ? 0 : rc);
 }
 
 static void osd_initial_OI_scrub(struct osd_thread_info *info,