From 018e89f8679507bfe0d299b108a9bbdffcf7333d 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 | 1 + src/nfs_kv_rename.cpp | 2 ++ src/nfs_kv_setattr.cpp | 1 + src/nfs_kv_write.cpp | 4 ++++ 4 files changed, 8 insertions(+) diff --git a/src/nfs_kv.cpp b/src/nfs_kv.cpp index eccade10..82abcfed 100644 --- a/src/nfs_kv.cpp +++ b/src/nfs_kv.cpp @@ -283,6 +283,7 @@ static void touch_inode(nfs_proxy_t *proxy, inode_t ino, bool allow_cache) { auto ientry = attrs.object_items(); ientry["mtime"] = nfstime_now_str(); + ientry.erase("verf"); // FIXME: Use "update" query bool *found = new bool; *found = true; 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(); }