]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/CDir: make the data length as long as possible for each op 38364/head
authorXiubo Li <xiubli@redhat.com>
Tue, 1 Dec 2020 04:28:37 +0000 (12:28 +0800)
committerXiubo Li <xiubli@redhat.com>
Tue, 1 Dec 2020 04:36:34 +0000 (12:36 +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/CDir.cc

index c28a3d638d2010c4a49ef01bcb898338a13d2bc0..a68f5cd54176f316a55abebaf9280db545b97f86 100644 (file)
@@ -2249,21 +2249,23 @@ void CDir::_omap_commit_ops(int r, int op_prio, version_t version, bool _new, bu
   };
 
   for (auto &key : stales) {
-    write_size += key.length() + sizeof(__u32);
-    _rm.emplace(key);
-
-    if (write_size >= max_write_size)
+    unsigned size = key.length() + sizeof(__u32);
+    if (write_size + size > max_write_size)
       commit_one();
+
+    write_size += size;
+    _rm.emplace(key);
   }
 
   for (auto &k : to_remove) {
     string key;
     k.encode(key);
-    write_size += key.length() + sizeof(__u32);
-    _rm.emplace(std::move(key));
-
-    if (write_size >= max_write_size)
+    unsigned size = key.length() + sizeof(__u32);
+    if (write_size + size > max_write_size)
       commit_one();
+
+    write_size += size;
+    _rm.emplace(std::move(key));
   }
 
   uint64_t off = 0;
@@ -2312,10 +2314,12 @@ void CDir::_omap_commit_ops(int r, int op_prio, version_t version, bool _new, bu
     }
     off += item.dft_len;
 
-    write_size += key.length() + bl.length() + 2 * sizeof(__u32);
-    _set[std::move(key)].swap(bl);
-    if (write_size >= max_write_size)
+    unsigned size = key.length() + bl.length() + 2 * sizeof(__u32);
+    if (write_size + size > max_write_size)
       commit_one();
+
+    write_size += size;
+    _set[std::move(key)].swap(bl);
   }
 
   commit_one(true);