From 13971bc8da7c71566111309de2de45bef2523462 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Mon, 7 Dec 2020 14:22:02 +0800 Subject: [PATCH] mds/OpenFileTable: make the data length as long as possible for each op 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 --- src/mds/OpenFileTable.cc | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/mds/OpenFileTable.cc b/src/mds/OpenFileTable.cc index aaad09ae056..f021b574026 100644 --- a/src/mds/OpenFileTable.cc +++ b/src/mds/OpenFileTable.cc @@ -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++; } -- 2.47.3