From: James Simmons Date: Sat, 3 Aug 2019 13:59:16 +0000 (-0400) Subject: LU-12137 osd-ldiskfs: implement proper error handling in osd_ios_OBJECTS_scan X-Git-Tag: 2.12.57~14 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=752dec2f36cef0e4893f9c68d7cc2b9505488471;p=fs%2Flustre-release.git LU-12137 osd-ldiskfs: implement proper error handling in osd_ios_OBJECTS_scan 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 Change-Id: Idd3b91218f80a88d69206d3c2570bea22ff1fbb1 Reviewed-on: https://review.whamcloud.com/35644 Tested-by: jenkins Reviewed-by: Neil Brown Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Andreas Dilger --- diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index 9ac3fca..dfdd87c 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -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,