forked from vitalif/vitastor
Support ctime
parent
4f4b2dab80
commit
87310ef7bb
|
@ -72,6 +72,7 @@ fattr3 get_kv_attributes(nfs_client_t *self, uint64_t ino, json11::Json attrs)
|
|||
auto nlink = attrs["nlink"].uint64_value();
|
||||
nfstime3 mtime = nfstime_from_str(attrs["mtime"].string_value());
|
||||
nfstime3 atime = attrs["atime"].is_null() ? mtime : nfstime_from_str(attrs["atime"].string_value());
|
||||
nfstime3 ctime = attrs["ctime"].is_null() ? mtime : nfstime_from_str(attrs["ctime"].string_value());
|
||||
// In theory we could store the binary structure itself, but JSON is simpler :-)
|
||||
return (fattr3){
|
||||
.type = (type == 0 ? NF3REG : (ftype3)type),
|
||||
|
@ -89,7 +90,7 @@ fattr3 get_kv_attributes(nfs_client_t *self, uint64_t ino, json11::Json attrs)
|
|||
.fileid = ino,
|
||||
.atime = atime,
|
||||
.mtime = mtime,
|
||||
.ctime = mtime,
|
||||
.ctime = ctime,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -282,7 +283,7 @@ static void touch_inode(nfs_proxy_t *proxy, inode_t ino, bool allow_cache)
|
|||
if (!res)
|
||||
{
|
||||
auto ientry = attrs.object_items();
|
||||
ientry["mtime"] = nfstime_now_str();
|
||||
ientry["mtime"] = ientry["ctime"] = nfstime_now_str();
|
||||
ientry.erase("verf");
|
||||
// FIXME: Use "update" query
|
||||
bool *found = new bool;
|
||||
|
|
|
@ -101,10 +101,9 @@ static void kv_continue_create(kv_create_state *st, int state)
|
|||
cb(-EINVAL);
|
||||
return;
|
||||
}
|
||||
st->attrobj["ctime"] = nfstime_now_str();
|
||||
if (st->attrobj.find("mtime") == st->attrobj.end())
|
||||
st->attrobj["mtime"] = nfstime_now_str();
|
||||
if (st->attrobj.find("atime") == st->attrobj.end())
|
||||
st->attrobj["atime"] = st->attrobj["mtime"];
|
||||
st->attrobj["mtime"] = st->attrobj["ctime"];
|
||||
st->attrs = std::move(st->attrobj);
|
||||
resume_1:
|
||||
// Generate inode ID
|
||||
|
|
|
@ -99,6 +99,7 @@ resume_2:
|
|||
auto new_ientry = st->ientry.object_items();
|
||||
auto nlink = new_ientry["nlink"].uint64_value();
|
||||
new_ientry["nlink"] = nlink ? nlink+1 : 2;
|
||||
new_ientry["ctime"] = nfstime_now_str();
|
||||
st->ientry = new_ientry;
|
||||
}
|
||||
st->self->parent->db->set(kv_inode_key(st->ino), st->ientry.dump(), [st](int res)
|
||||
|
|
|
@ -196,6 +196,7 @@ resume_5:
|
|||
{
|
||||
auto copy = st->ientry.object_items();
|
||||
copy["nlink"] = st->ientry["nlink"].uint64_value()-1;
|
||||
copy["ctime"] = nfstime_now_str();
|
||||
st->self->parent->db->set(kv_inode_key(st->ino), json11::Json(copy).dump(), [st](int res)
|
||||
{
|
||||
st->res = res;
|
||||
|
|
|
@ -238,6 +238,7 @@ resume_7:
|
|||
{
|
||||
auto copy = st->new_ientry.object_items();
|
||||
copy["nlink"] = st->new_ientry["nlink"].uint64_value()-1;
|
||||
copy["ctime"] = nfstime_now_str();
|
||||
copy.erase("verf");
|
||||
st->self->parent->db->set(kv_inode_key(st->new_direntry["ino"].uint64_value()), json11::Json(copy).dump(), [st](int res)
|
||||
{
|
||||
|
@ -325,6 +326,7 @@ resume_11:
|
|||
{
|
||||
auto ientry_new = st->old_ientry.object_items();
|
||||
ientry_new["parent_ino"] = st->new_dir_ino;
|
||||
ientry_new["ctime"] = nfstime_now_str();
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -72,6 +72,7 @@ resume_1:
|
|||
st->new_attrs[kv.first] = kv.second;
|
||||
}
|
||||
st->new_attrs.erase("verf");
|
||||
st->new_attrs["ctime"] = nfstime_now_str();
|
||||
st->self->parent->db->set(kv_inode_key(st->ino), json11::Json(st->new_attrs).dump(), [st](int res)
|
||||
{
|
||||
st->res = res;
|
||||
|
|
|
@ -545,7 +545,7 @@ static std::string new_normal_ientry(nfs_kv_write_state *st)
|
|||
ni.erase("shared_alloc");
|
||||
ni.erase("shared_ver");
|
||||
ni["size"] = st->ext->cur_extend;
|
||||
ni["mtime"] = nfstime_now_str();
|
||||
ni["ctime"] = ni["mtime"] = nfstime_now_str();
|
||||
ni.erase("verf");
|
||||
return json11::Json(ni).dump();
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ static std::string new_moved_ientry(nfs_kv_write_state *st)
|
|||
ni["shared_alloc"] = st->shared_alloc;
|
||||
ni.erase("shared_ver");
|
||||
ni["size"] = st->new_size;
|
||||
ni["mtime"] = nfstime_now_str();
|
||||
ni["ctime"] = ni["mtime"] = nfstime_now_str();
|
||||
ni.erase("verf");
|
||||
return json11::Json(ni).dump();
|
||||
}
|
||||
|
@ -569,7 +569,7 @@ static std::string new_shared_ientry(nfs_kv_write_state *st)
|
|||
auto ni = st->ientry.object_items();
|
||||
ni.erase("empty");
|
||||
ni["size"] = st->new_size;
|
||||
ni["mtime"] = nfstime_now_str();
|
||||
ni["ctime"] = ni["mtime"] = nfstime_now_str();
|
||||
ni["shared_ver"] = ni["shared_ver"].uint64_value()+1;
|
||||
ni.erase("verf");
|
||||
return json11::Json(ni).dump();
|
||||
|
@ -583,7 +583,7 @@ static std::string new_unshared_ientry(nfs_kv_write_state *st)
|
|||
ni.erase("shared_offset");
|
||||
ni.erase("shared_alloc");
|
||||
ni.erase("shared_ver");
|
||||
ni["mtime"] = nfstime_now_str();
|
||||
ni["ctime"] = ni["mtime"] = nfstime_now_str();
|
||||
ni.erase("verf");
|
||||
return json11::Json(ni).dump();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue