From c769ba3025c59f110c38c44552a05142705c94c3 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 15 Aug 2019 16:40:06 -0400 Subject: [PATCH] LU-12137 osd-ldiskfs: refactor osd_ios_ROOT_scan With the change of osd_ios_scan_one() to handle a NULL dchild->d_inode we can migrate the scrub code after calling osd_ios_scan_one(). This can help reduce the code indentation as well as make the code clearer. Change-Id: Ieb59aa85c8199a1f1a1bee5cbe633e52b8e92a9a Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/35803 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_scrub.c | 77 ++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index dfdd87c..184c83a 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -2319,9 +2319,42 @@ osd_ios_ROOT_scan(struct osd_thread_info *info, struct osd_device *dev, scrub->os_convert_igif = 1; child = osd_ios_lookup_one_len(dot_lustre_name, dentry, strlen(dot_lustre_name)); - if (IS_ERR(child) && PTR_ERR(child) != -ENOENT) { - rc = PTR_ERR(child); - } else if (IS_ERR(child) || !child->d_inode) { + if (IS_ERR(child)) { + if (PTR_ERR(child) != -ENOENT) + RETURN(PTR_ERR(child)); + goto out_scrub; + } + + /* For lustre-2.x (x <= 3), the ".lustre" has NO FID-in-LMA, + * so the client will get IGIF for the ".lustre" object when + * the MDT restart. + * + * From the OI scrub view, when the MDT upgrade to Lustre-2.4, + * it does not know whether there are some old clients cached + * the ".lustre" IGIF during the upgrading. Two choices: + * + * 1) Generate IGIF-in-LMA and IGIF-in-OI for the ".lustre". + * It will allow the old connected clients to access the + * ".lustre" with cached IGIF. But it will cause others + * on the MDT failed to check "fid_is_dot_lustre()". + * + * 2) Use fixed FID {FID_SEQ_DOT_LUSTRE, FID_OID_DOT_LUSTRE, 0} + * for ".lustre" in spite of whether there are some clients + * cached the ".lustre" IGIF or not. It enables the check + * "fid_is_dot_lustre()" on the MDT, although it will cause + * that the old connected clients cannot access the ".lustre" + * with the cached IGIF. + * + * Usually, it is rare case for the old connected clients + * to access the ".lustre" with cached IGIF. So we prefer + * to the solution 2). + */ + rc = osd_ios_scan_one(info, dev, dentry->d_inode, + child->d_inode, &LU_DOT_LUSTRE_FID, + dot_lustre_name, + strlen(dot_lustre_name), 0); + if (rc == -ENOENT) { +out_scrub: /* It is 1.8 MDT device. */ if (!(sf->sf_flags & SF_UPGRADE)) { scrub_file_reset(scrub, dev->od_uuid, @@ -2331,41 +2364,11 @@ osd_ios_ROOT_scan(struct osd_thread_info *info, struct osd_device *dev, } else { rc = 0; } - if (!IS_ERR(child)) - dput(child); - } else { - /* For lustre-2.x (x <= 3), the ".lustre" has NO FID-in-LMA, - * so the client will get IGIF for the ".lustre" object when - * the MDT restart. - * - * From the OI scrub view, when the MDT upgrade to Lustre-2.4, - * it does not know whether there are some old clients cached - * the ".lustre" IGIF during the upgrading. Two choices: - * - * 1) Generate IGIF-in-LMA and IGIF-in-OI for the ".lustre". - * It will allow the old connected clients to access the - * ".lustre" with cached IGIF. But it will cause others - * on the MDT failed to check "fid_is_dot_lustre()". - * - * 2) Use fixed FID {FID_SEQ_DOT_LUSTRE, FID_OID_DOT_LUSTRE, 0} - * for ".lustre" in spite of whether there are some clients - * cached the ".lustre" IGIF or not. It enables the check - * "fid_is_dot_lustre()" on the MDT, although it will cause - * that the old connected clients cannot access the ".lustre" - * with the cached IGIF. - * - * Usually, it is rare case for the old connected clients - * to access the ".lustre" with cached IGIF. So we prefer - * to the solution 2). */ - rc = osd_ios_scan_one(info, dev, dentry->d_inode, - child->d_inode, &LU_DOT_LUSTRE_FID, - dot_lustre_name, - strlen(dot_lustre_name), 0); - if (rc == 0) - rc = osd_ios_new_item(dev, child, osd_ios_general_scan, - osd_ios_dl_fill); - dput(child); + } else if (rc == 0) { + rc = osd_ios_new_item(dev, child, osd_ios_general_scan, + osd_ios_dl_fill); } + dput(child); RETURN(rc); } -- 1.8.3.1