]> 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)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 6 Apr 2021 19:21:11 +0000 (12:21 -0700)
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 1bea6e5135148169baaf656563bb1acbe6a593b6)

src/client/Client.cc

index b6e5a1cc3e6237f69cebac3d25de7ae5e3575ed9..06f3996791edb5ed699a287f39417e006384e8b7 100644 (file)
@@ -4948,18 +4948,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;