From 62ac9c6572e5d42183a9bf5fbbd6a8ead62408cd Mon Sep 17 00:00:00 2001
From: "John L. Hammond" <john.hammond@intel.com>
Date: Wed, 2 May 2018 09:43:07 -0500
Subject: [PATCH] LU-10989 utils: correct lustre_rsync changelog clear logic

In the non-extended rename case of lr_replicate() copy the record
number from ext to info. Then remove the spurious rename record
handling from lr_clear_cl().

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I615ec2f384f5f9d7807156acb3ce66ac47ca1e77
Reviewed-on: https://review.whamcloud.com/32247
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
 lustre/utils/lustre_rsync.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/lustre/utils/lustre_rsync.c b/lustre/utils/lustre_rsync.c
index e4bc0e5dc5..a54ac2578a 100644
--- a/lustre/utils/lustre_rsync.c
+++ b/lustre/utils/lustre_rsync.c
@@ -1396,14 +1396,9 @@ int lr_read_log()
 int lr_clear_cl(struct lr_info *info, int force)
 {
 	char		mdt_device[LR_NAME_MAXLEN + 1];
-	long long	rec;
 	int		rc = 0;
 
         if (force || info->recno > status->ls_last_recno + CLEAR_INTERVAL) {
-                if (info->type == CL_RENAME)
-                        rec = info->recno + 1;
-                else
-                        rec = info->recno;
                 if (!noclear && !dryrun) {
                         /* llapi_changelog_clear modifies the mdt
                          * device name so make a copy of it until this
@@ -1413,20 +1408,21 @@ int lr_clear_cl(struct lr_info *info, int force)
 				 status->ls_mdt_device);
                         rc = llapi_changelog_clear(mdt_device,
                                                    status->ls_registration,
-                                                   rec);
+						   info->recno);
                         if (rc)
-                                printf("Changelog clear (%s, %s, %lld) "
-                                       "returned %d\n", status->ls_mdt_device,
-                                       status->ls_registration, rec, rc);
-                }
-                if (!rc && !dryrun) {
-                        status->ls_last_recno = rec;
-                        lr_write_log();
+				printf("Changelog clear (%s, %s, %lld) "
+				       "returned %d\n", status->ls_mdt_device,
+				       status->ls_registration, info->recno,
+				       rc);
+		}
 
-                }
-        }
+		if (!rc && !dryrun) {
+			status->ls_last_recno = info->recno;
+			lr_write_log();
+		}
+	}
 
-        return rc;
+	return rc;
 }
 
 /* Locate a usable version of rsync. At this point we'll use any
@@ -1611,6 +1607,7 @@ int lr_replicate()
 			snprintf(info->name, sizeof(info->name), "%s",
 				 ext->name);
 			info->is_extended = 1;
+			info->recno = ext->recno; /* For lr_clear_cl(). */
 		}
 
                 if (dryrun)
-- 
GitLab