]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Merge pull request #54620 from rishabh-d-dave/mgr-vol-clone-stats
authorVenky Shankar <vshankar@redhat.com>
Mon, 26 Aug 2024 10:14:53 +0000 (15:44 +0530)
committerGitHub <noreply@github.com>
Mon, 26 Aug 2024 10:14:53 +0000 (15:44 +0530)
mgr/vol: show progress and stats for the subvolume snapshot clones

Reviewed-by: Venky Shankar <vshankar@redhat.com>
1  2 
PendingReleaseNotes
doc/cephfs/fs-volumes.rst
qa/tasks/cephfs/mount.py
src/pybind/mgr/volumes/fs/operations/clone_index.py

Simple merge
Simple merge
Simple merge
index 1f16500a6bd85151a4e7ee773617419b5712c0ad,edcc01921c683a6790ab9a73997f5f9755d72fcd..f8ab7e2b294e5da9a258eb427d4e47f0629936de
@@@ -47,27 -49,45 +49,47 @@@ class CloneIndex(Index)
          except cephfs.Error as e:
              raise IndexException(-e.args[0], e.args[1])
  
+     def list_entries_by_ctime_order(self):
+         entry_names = listdir(self.fs, self.path, filter_files=False)
+         if not entry_names:
+             return []
+         # clone entries with ctime obtained by statig them. basically,
+         # following is a list of tuples where each tuple has 2 memebers.
+         ens_with_ctime = []
+         for en in entry_names:
+             d_path = os.path.join(self.path, en)
+             stb = self.fs.lstat(d_path)
+             # add ctime next to clone entry
+             ens_with_ctime.append((en, stb.st_ctime))
+         ens_with_ctime.sort(key=lambda ctime: en[1])
+         # remove ctime and return list of clone entries sorted by ctime.
+         return [i[0] for i in ens_with_ctime]
      def get_oldest_clone_entry(self, exclude=[]):
 -        min_ctime_entry = None
 -        exclude_tracking_ids = [v[0] for v in exclude]
 -        log.debug("excluded tracking ids: {0}".format(exclude_tracking_ids))
 -        for entry in list_one_entry_at_a_time(self.fs, self.path):
 -            dname = entry.d_name
 -            dpath = os.path.join(self.path, dname)
 -            st = self.fs.lstat(dpath)
 -            if dname not in exclude_tracking_ids and stat.S_ISLNK(st.st_mode):
 -                if min_ctime_entry is None or st.st_ctime < min_ctime_entry[1].st_ctime:
 -                    min_ctime_entry = (dname, st)
 -        if min_ctime_entry:
 -            try:
 +        try:
 +            min_ctime_entry = None
 +            exclude_tracking_ids = [v[0] for v in exclude]
 +            log.debug("excluded tracking ids: {0}".format(exclude_tracking_ids))
 +            for entry in list_one_entry_at_a_time(self.fs, self.path):
 +                dname = entry.d_name
 +                dpath = os.path.join(self.path, dname)
 +                st = self.fs.lstat(dpath)
 +                if dname not in exclude_tracking_ids and stat.S_ISLNK(st.st_mode):
 +                    if min_ctime_entry is None or st.st_ctime < min_ctime_entry[1].st_ctime:
 +                        min_ctime_entry = (dname, st)
 +            if min_ctime_entry:
                  linklen = min_ctime_entry[1].st_size
-                 sink_path = self.fs.readlink(os.path.join(self.path, min_ctime_entry[0]), CloneIndex.PATH_MAX)
+                 sink_path = self.fs.readlink(os.path.join(self.path, min_ctime_entry[0]), PATH_MAX)
                  return (min_ctime_entry[0], sink_path[:linklen])
 -            except cephfs.Error as e:
 -                raise IndexException(-e.args[0], e.args[1])
 -        return None
 +            return None
 +        except cephfs.Error as e:
 +            log.debug('Exception cephfs.Error has been caught. Printing '
 +                      f'the exception - {e}')
 +            raise IndexException(-e.args[0], e.args[1])
  
      def find_clone_entry_index(self, sink_path):
          try: