From e5782240c724639d075d0b0c78ea88b91d335013 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 12 Mar 2024 00:51:24 +0300 Subject: [PATCH] Erase verf key left from creation from ientries on every modification --- src/nfs_kv.cpp | 7 ++++--- src/nfs_kv_rename.cpp | 2 ++ src/nfs_kv_setattr.cpp | 1 + src/nfs_kv_write.cpp | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/nfs_kv.cpp b/src/nfs_kv.cpp index c9a1e5db..721d4a57 100644 --- a/src/nfs_kv.cpp +++ b/src/nfs_kv.cpp @@ -281,9 +281,10 @@ static void touch_inode(nfs_proxy_t *proxy, inode_t ino, bool allow_cache) { if (!res) { - auto acopy = attrs.object_items(); - acopy["mtime"] = nfstime_now_str(); - proxy->db->set(kv_inode_key(ino), json11::Json(acopy).dump(), [proxy, ino](int res) + auto ientry = attrs.object_items(); + ientry["mtime"] = nfstime_now_str(); + ientry.erase("verf"); + proxy->db->set(kv_inode_key(ino), json11::Json(ientry).dump(), [proxy, ino](int res) { if (res == -EAGAIN) { diff --git a/src/nfs_kv_rename.cpp b/src/nfs_kv_rename.cpp index 1430e718..8e3ccb6e 100644 --- a/src/nfs_kv_rename.cpp +++ b/src/nfs_kv_rename.cpp @@ -238,6 +238,7 @@ resume_7: { auto copy = st->new_ientry.object_items(); copy["nlink"] = st->new_ientry["nlink"].uint64_value()-1; + copy.erase("verf"); st->self->parent->db->set(kv_inode_key(st->new_direntry["ino"].uint64_value()), json11::Json(copy).dump(), [st](int res) { st->res = res; @@ -324,6 +325,7 @@ resume_11: { auto ientry_new = st->old_ientry.object_items(); ientry_new["parent_ino"] = st->new_dir_ino; + ientry_new.erase("verf"); st->self->parent->db->set(kv_inode_key(st->old_direntry["ino"].uint64_value()), json11::Json(ientry_new).dump(), [st](int res) { st->res = res; diff --git a/src/nfs_kv_setattr.cpp b/src/nfs_kv_setattr.cpp index 8dc88260..e6e0f83b 100644 --- a/src/nfs_kv_setattr.cpp +++ b/src/nfs_kv_setattr.cpp @@ -71,6 +71,7 @@ resume_1: } st->new_attrs[kv.first] = kv.second; } + st->new_attrs.erase("verf"); st->self->parent->db->set(kv_inode_key(st->ino), json11::Json(st->new_attrs).dump(), [st](int res) { st->res = res; diff --git a/src/nfs_kv_write.cpp b/src/nfs_kv_write.cpp index 0d9f71f0..2ee4d611 100644 --- a/src/nfs_kv_write.cpp +++ b/src/nfs_kv_write.cpp @@ -546,6 +546,7 @@ static std::string new_normal_ientry(nfs_kv_write_state *st) ni.erase("shared_ver"); ni["size"] = st->ext->cur_extend; ni["mtime"] = nfstime_now_str(); + ni.erase("verf"); return json11::Json(ni).dump(); } @@ -559,6 +560,7 @@ static std::string new_moved_ientry(nfs_kv_write_state *st) ni.erase("shared_ver"); ni["size"] = st->new_size; ni["mtime"] = nfstime_now_str(); + ni.erase("verf"); return json11::Json(ni).dump(); } @@ -569,6 +571,7 @@ static std::string new_shared_ientry(nfs_kv_write_state *st) ni["size"] = st->new_size; ni["mtime"] = nfstime_now_str(); ni["shared_ver"] = ni["shared_ver"].uint64_value()+1; + ni.erase("verf"); return json11::Json(ni).dump(); } @@ -581,6 +584,7 @@ static std::string new_unshared_ientry(nfs_kv_write_state *st) ni.erase("shared_alloc"); ni.erase("shared_ver"); ni["mtime"] = nfstime_now_str(); + ni.erase("verf"); return json11::Json(ni).dump(); }