]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: simplify the iterating code
authorXiubo Li <xiubli@redhat.com>
Wed, 30 Dec 2020 09:17:56 +0000 (17:17 +0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 9 Apr 2021 09:01:34 +0000 (11:01 +0200)
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 1bea6e5135148169baaf656563bb1acbe6a593b6)

src/client/Client.cc

index 62a4a2b0566d5f8c67290bc58e3c9c0e3dc952e5..06d3b510fa7e01d26874a4b647420f9c3eb4a10f 100755 (executable)
@@ -4738,18 +4738,12 @@ void Client::update_snap_trace(const bufferlist& bl, SnapRealm **realm_ret, bool
       put_snap_realm(realm);
   }
 
-  for (map<SnapRealm*, SnapContext>::iterator q = dirty_realms.begin();
-       q != dirty_realms.end();
-       ++q) {
-    SnapRealm *realm = q->first;
+  for (auto &[realm, snapc] : dirty_realms) {
     // if there are new snaps ?
-    if (has_new_snaps(q->second, realm->get_snap_context())) {
+    if (has_new_snaps(snapc, realm->get_snap_context())) {
       ldout(cct, 10) << " flushing caps on " << *realm << dendl;
-      xlist<Inode*>::iterator r = realm->inodes_with_caps.begin();
-      while (!r.end()) {
-       Inode *in = *r;
-       ++r;
-       queue_cap_snap(in, q->second);
+      for (auto&& in : realm->inodes_with_caps) {
+       queue_cap_snap(in, snapc);
       }
     } else {
       ldout(cct, 10) << " no new snap on " << *realm << dendl;