]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/OpenFileTable: make the data length as long as possible for each op 38464/head
authorXiubo Li <xiubli@redhat.com>
Mon, 7 Dec 2020 06:22:02 +0000 (14:22 +0800)
committerXiubo Li <xiubli@redhat.com>
Mon, 7 Dec 2020 06:31:13 +0000 (14:31 +0800)
The max_write_size is 10M as default, and every time when the len
of the op data exceed it with a very small size it will be split
into two ops, one of which will always be very small.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
src/mds/OpenFileTable.cc

index aaad09ae056a77964574cab8d064cd38f1f29940..f021b574026e8d7e4b89ad081af5b1cb4c1b7c62 100644 (file)
@@ -518,7 +518,10 @@ void OpenFileTable::commit(MDSContext *c, uint64_t log_seq, int op_prio)
        first_free_idx = omap_idx;
     }
     auto& ctl = omap_updates.at(omap_idx);
-
+    if (ctl.write_size >= max_write_size) {
+      journal_func(omap_idx);
+      ctl.write_size = 0;
+    }
     if (p != anchor_map.end()) {
       bufferlist bl;
       encode(p->second, bl);
@@ -530,11 +533,6 @@ void OpenFileTable::commit(MDSContext *c, uint64_t log_seq, int op_prio)
       ctl.write_size += len + sizeof(__u32);
       ctl.to_remove.emplace(key);
     }
-
-    if (ctl.write_size >= max_write_size) {
-      journal_func(omap_idx);
-      ctl.write_size = 0;
-    }
   }
 
   dirty_items.clear();
@@ -550,13 +548,12 @@ void OpenFileTable::commit(MDSContext *c, uint64_t log_seq, int op_prio)
       --count;
 
       auto& ctl = omap_updates.at(omap_idx);
-      ctl.write_size += len + sizeof(__u32);
-      ctl.to_remove.emplace(key);
-
       if (ctl.write_size >= max_write_size) {
-       journal_func(omap_idx);
-       ctl.write_size = 0;
+        journal_func(omap_idx);
+        ctl.write_size = 0;
       }
+      ctl.write_size += len + sizeof(__u32);
+      ctl.to_remove.emplace(key);
     }
     loaded_anchor_map.clear();
   }
@@ -624,24 +621,25 @@ void OpenFileTable::commit(MDSContext *c, uint64_t log_seq, int op_prio)
 
     bool first = true;
     for (auto& it : ctl.journaled_update) {
-      ctl.write_size += it.first.length() + it.second.length() + 2 * sizeof(__u32);
-      ctl.to_update[it.first].swap(it.second);
       if (ctl.write_size >= max_write_size) {
-       create_op_func(omap_idx, first);
-       ctl.write_size = 0;
-       first = false;
+        create_op_func(omap_idx, first);
+        ctl.write_size = 0;
+        first = false;
       }
+      ctl.write_size += it.first.length() + it.second.length() + 2 * sizeof(__u32);
+      ctl.to_update[it.first].swap(it.second);
       total_updates++;
     }
 
     for (auto& key : ctl.journaled_remove) {
-      ctl.write_size += key.length() + sizeof(__u32);
-      ctl.to_remove.emplace(key);
       if (ctl.write_size >= max_write_size) {
-       create_op_func(omap_idx, first);
-       ctl.write_size = 0;
-       first = false;
+        create_op_func(omap_idx, first);
+        ctl.write_size = 0;
+        first = false;
       }
+
+      ctl.write_size += key.length() + sizeof(__u32);
+      ctl.to_remove.emplace(key);
       total_removes++;
     }