From 752dec2f36cef0e4893f9c68d7cc2b9505488471 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sat, 3 Aug 2019 09:59:16 -0400 Subject: [PATCH] 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 --- lustre/osd-ldiskfs/osd_scrub.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) 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, -- 1.8.3.1