Whamcloud - gitweb
LU-10989 utils: correct lustre_rsync changelog clear logic
[fs/lustre-release.git] / lustre / utils / lustre_rsync.c
index e4bc0e5..a54ac25 100644 (file)
@@ -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)