forked from vitalif/vitastor
Fix shared file overlap, add FIXMEs
parent
88f9d18be3
commit
d03f19ebe5
|
@ -153,6 +153,7 @@ void cli_tool_t::loop_and_wait(std::function<bool(cli_result_t &)> loop_cb, std:
|
||||||
ringloop->unregister_consumer(&looper->consumer);
|
ringloop->unregister_consumer(&looper->consumer);
|
||||||
looper->loop_cb = NULL;
|
looper->loop_cb = NULL;
|
||||||
looper->complete_cb(looper->result);
|
looper->complete_cb(looper->result);
|
||||||
|
ringloop->submit();
|
||||||
delete looper;
|
delete looper;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ struct nfs_kv_setattr_state
|
||||||
|
|
||||||
static void nfs_kv_continue_setattr(nfs_kv_setattr_state *st, int state)
|
static void nfs_kv_continue_setattr(nfs_kv_setattr_state *st, int state)
|
||||||
{
|
{
|
||||||
|
// FIXME: NFS client does a lot of setattr calls, so maybe process them asynchronously
|
||||||
if (state == 0) {}
|
if (state == 0) {}
|
||||||
else if (state == 1) goto resume_1;
|
else if (state == 1) goto resume_1;
|
||||||
else if (state == 2) goto resume_2;
|
else if (state == 2) goto resume_2;
|
||||||
|
@ -50,8 +51,7 @@ resume_1:
|
||||||
cb(st->res);
|
cb(st->res);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (st->ientry["type"].string_value() == "link" ||
|
if (st->ientry["type"].string_value() != "file" &&
|
||||||
st->ientry["type"].string_value() != "file" &&
|
|
||||||
st->ientry["type"].string_value() != "" &&
|
st->ientry["type"].string_value() != "" &&
|
||||||
!st->set_attrs["size"].is_null())
|
!st->set_attrs["size"].is_null())
|
||||||
{
|
{
|
||||||
|
|
|
@ -151,9 +151,11 @@ static void nfs_do_write(uint64_t ino, uint64_t offset, uint64_t size, std::func
|
||||||
|
|
||||||
static void nfs_do_unshare_write(nfs_kv_write_state *st, int state)
|
static void nfs_do_unshare_write(nfs_kv_write_state *st, int state)
|
||||||
{
|
{
|
||||||
nfs_do_write(st->ino, 0, st->aligned_size - sizeof(shared_file_header_t), [&](cluster_op_t *op)
|
uint64_t unshare_size = (st->ientry["size"].uint64_value() + st->self->parent->pool_alignment-1)
|
||||||
|
& ~(st->self->parent->pool_alignment-1);
|
||||||
|
nfs_do_write(st->ino, 0, unshare_size, [&](cluster_op_t *op)
|
||||||
{
|
{
|
||||||
op->iov.push_back(st->aligned_buf + sizeof(shared_file_header_t), st->aligned_size - sizeof(shared_file_header_t));
|
op->iov.push_back(st->aligned_buf + sizeof(shared_file_header_t), unshare_size);
|
||||||
}, st, state);
|
}, st, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,6 +294,7 @@ static bool nfs_do_shared_readmodify(nfs_kv_write_state *st, int base_state, int
|
||||||
? sizeof(shared_file_header_t) + ((st->new_size + st->self->parent->pool_alignment-1) & ~(st->self->parent->pool_alignment-1))
|
? sizeof(shared_file_header_t) + ((st->new_size + st->self->parent->pool_alignment-1) & ~(st->self->parent->pool_alignment-1))
|
||||||
: align_shared_size(st->self, st->new_size);
|
: align_shared_size(st->self, st->new_size);
|
||||||
st->aligned_buf = (uint8_t*)malloc_or_die(st->aligned_size);
|
st->aligned_buf = (uint8_t*)malloc_or_die(st->aligned_size);
|
||||||
|
// FIXME do not allocate zeroes if we only need zeroes
|
||||||
memset(st->aligned_buf + sizeof(shared_file_header_t), 0, st->offset);
|
memset(st->aligned_buf + sizeof(shared_file_header_t), 0, st->offset);
|
||||||
memset(st->aligned_buf + sizeof(shared_file_header_t) + st->offset + st->size, 0,
|
memset(st->aligned_buf + sizeof(shared_file_header_t) + st->offset + st->size, 0,
|
||||||
st->aligned_size - sizeof(shared_file_header_t) - st->offset - st->size);
|
st->aligned_size - sizeof(shared_file_header_t) - st->offset - st->size);
|
||||||
|
@ -319,6 +322,7 @@ resume_0:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// FIXME put shared_file_header_t after data to not break alignment
|
||||||
*((shared_file_header_t*)st->aligned_buf) = {
|
*((shared_file_header_t*)st->aligned_buf) = {
|
||||||
.magic = SHARED_FILE_MAGIC_V1,
|
.magic = SHARED_FILE_MAGIC_V1,
|
||||||
.inode = st->ino,
|
.inode = st->ino,
|
||||||
|
@ -679,7 +683,7 @@ resume_1:
|
||||||
st->ientry["shared_alloc"].uint64_value() < sizeof(shared_file_header_t)+st->offset+st->size)
|
st->ientry["shared_alloc"].uint64_value() < sizeof(shared_file_header_t)+st->offset+st->size)
|
||||||
{
|
{
|
||||||
// Either empty, or shared and requires moving into a larger place (redirect-write)
|
// Either empty, or shared and requires moving into a larger place (redirect-write)
|
||||||
allocate_shared_inode(st, 2, st->new_size);
|
allocate_shared_inode(st, 2, align_shared_size(st->self, st->new_size));
|
||||||
return;
|
return;
|
||||||
resume_2:
|
resume_2:
|
||||||
if (st->res < 0)
|
if (st->res < 0)
|
||||||
|
@ -783,7 +787,12 @@ resume_10:
|
||||||
nfs_do_unshare_write(st, 11);
|
nfs_do_unshare_write(st, 11);
|
||||||
return;
|
return;
|
||||||
resume_11:
|
resume_11:
|
||||||
;
|
if (st->res < 0)
|
||||||
|
{
|
||||||
|
auto cb = std::move(st->cb);
|
||||||
|
cb(st->res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
st->self->parent->db->set(kv_inode_key(st->ino), new_unshared_ientry(st), [st](int res)
|
st->self->parent->db->set(kv_inode_key(st->ino), new_unshared_ientry(st), [st](int res)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue