Compare commits
16 Commits
f8397e1a03
...
e58554c298
Author | SHA1 | Date |
---|---|---|
Vitaliy Filippov | e58554c298 | |
Vitaliy Filippov | e2f59c3885 | |
Vitaliy Filippov | 8239e4bcfe | |
Vitaliy Filippov | 955ce0bb60 | |
Vitaliy Filippov | 584ef40b16 | |
Vitaliy Filippov | df8f5bd69e | |
Vitaliy Filippov | 4af3c61bd2 | |
Vitaliy Filippov | d73601d7d7 | |
Vitaliy Filippov | 558cf369c0 | |
Vitaliy Filippov | 4d733e3159 | |
Vitaliy Filippov | bcb507be7a | |
Vitaliy Filippov | 70773deaf1 | |
Vitaliy Filippov | d5e3d70851 | |
Vitaliy Filippov | 3b233eb0f4 | |
Vitaliy Filippov | 7e6f2aa077 | |
Vitaliy Filippov | ffbeaf736b |
|
@ -1213,10 +1213,6 @@ void cluster_client_t::handle_op_part(cluster_op_part_t *part)
|
||||||
op->retry_after = op->retval == -EIO ? client_eio_retry_interval : client_retry_interval;
|
op->retry_after = op->retval == -EIO ? client_eio_retry_interval : client_retry_interval;
|
||||||
}
|
}
|
||||||
reset_retry_timer(op->retry_after);
|
reset_retry_timer(op->retry_after);
|
||||||
if (stop_fd >= 0)
|
|
||||||
{
|
|
||||||
msgr.stop_client(stop_fd);
|
|
||||||
}
|
|
||||||
if (op->inflight_count == 0)
|
if (op->inflight_count == 0)
|
||||||
{
|
{
|
||||||
if (op->opcode == OSD_OP_SYNC)
|
if (op->opcode == OSD_OP_SYNC)
|
||||||
|
@ -1224,6 +1220,10 @@ void cluster_client_t::handle_op_part(cluster_op_part_t *part)
|
||||||
else
|
else
|
||||||
continue_rw(op);
|
continue_rw(op);
|
||||||
}
|
}
|
||||||
|
if (stop_fd >= 0)
|
||||||
|
{
|
||||||
|
msgr.stop_client(stop_fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,7 @@ struct nfs_kv_setattr_state
|
||||||
rpc_op_t *rop = NULL;
|
rpc_op_t *rop = NULL;
|
||||||
uint64_t ino = 0;
|
uint64_t ino = 0;
|
||||||
uint64_t old_size = 0, new_size = 0;
|
uint64_t old_size = 0, new_size = 0;
|
||||||
|
std::string expected_ctime;
|
||||||
json11::Json::object set_attrs;
|
json11::Json::object set_attrs;
|
||||||
int res = 0, cas_res = 0;
|
int res = 0, cas_res = 0;
|
||||||
std::string ientry_text;
|
std::string ientry_text;
|
||||||
|
@ -59,6 +60,12 @@ resume_1:
|
||||||
cb(-EINVAL);
|
cb(-EINVAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (st->expected_ctime != "" && st->ientry["ctime"].string_value() != st->expected_ctime)
|
||||||
|
{
|
||||||
|
auto cb = std::move(st->cb);
|
||||||
|
cb(NFS3ERR_NOT_SYNC);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Now we can update it
|
// Now we can update it
|
||||||
st->new_attrs = st->ientry.object_items();
|
st->new_attrs = st->ientry.object_items();
|
||||||
st->old_size = st->ientry["size"].uint64_value();
|
st->old_size = st->ientry["size"].uint64_value();
|
||||||
|
@ -140,6 +147,8 @@ int kv_nfs3_setattr_proc(void *opaque, rpc_op_t *rop)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
st->ino = kv_fh_inode(fh);
|
st->ino = kv_fh_inode(fh);
|
||||||
|
if (args->guard.check)
|
||||||
|
st->expected_ctime = nfstime_to_str(args->guard.obj_ctime);
|
||||||
if (args->new_attributes.size.set_it)
|
if (args->new_attributes.size.set_it)
|
||||||
st->set_attrs["size"] = args->new_attributes.size.size;
|
st->set_attrs["size"] = args->new_attributes.size.size;
|
||||||
if (args->new_attributes.mode.set_it)
|
if (args->new_attributes.mode.set_it)
|
||||||
|
|
|
@ -58,11 +58,10 @@ static const char* help_text =
|
||||||
"Vitastor NFS 3.0 proxy " VERSION "\n"
|
"Vitastor NFS 3.0 proxy " VERSION "\n"
|
||||||
"(c) Vitaliy Filippov, 2021+ (VNPL-1.1)\n"
|
"(c) Vitaliy Filippov, 2021+ (VNPL-1.1)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-nfs (--fs <NAME> | --block) [-o <OPT>] mount <MOUNTPOINT>\n"
|
"vitastor-nfs (--fs <NAME> | --block) mount <MOUNTPOINT>\n"
|
||||||
" Start local filesystem server and mount file system to <MOUNTPOINT>.\n"
|
" Start local filesystem server and mount file system to <MOUNTPOINT>.\n"
|
||||||
" Use regular `umount <MOUNTPOINT>` to unmount the FS.\n"
|
" Use regular `umount <MOUNTPOINT>` to unmount the FS.\n"
|
||||||
" The server will be automatically stopped when the FS is unmounted.\n"
|
" The server will be automatically stopped when the FS is unmounted.\n"
|
||||||
" -o|--options <OPT> Pass additional NFS mount options (ex.: -o async).\n"
|
|
||||||
"\n"
|
"\n"
|
||||||
"vitastor-nfs (--fs <NAME> | --block) start\n"
|
"vitastor-nfs (--fs <NAME> | --block) start\n"
|
||||||
" Start network NFS server. Options:\n"
|
" Start network NFS server. Options:\n"
|
||||||
|
@ -102,16 +101,6 @@ json11::Json::object nfs_proxy_t::parse_args(int narg, const char *args[])
|
||||||
printf("%s", help_text);
|
printf("%s", help_text);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if (!strcmp(args[i], "-o") || !strcmp(args[i], "--options"))
|
|
||||||
{
|
|
||||||
if (i >= narg-1)
|
|
||||||
{
|
|
||||||
printf("%s", help_text);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
const std::string & old = cfg["options"].string_value();
|
|
||||||
cfg["options"] = old != "" ? old+","+args[i+1] : args[i+1];
|
|
||||||
}
|
|
||||||
else if (args[i][0] == '-' && args[i][1] == '-')
|
else if (args[i][0] == '-' && args[i][1] == '-')
|
||||||
{
|
{
|
||||||
const char *opt = args[i]+2;
|
const char *opt = args[i]+2;
|
||||||
|
@ -180,7 +169,6 @@ void nfs_proxy_t::run(json11::Json cfg)
|
||||||
portmap_enabled = false;
|
portmap_enabled = false;
|
||||||
exit_on_umount = true;
|
exit_on_umount = true;
|
||||||
}
|
}
|
||||||
mountopts = cfg["options"].string_value();
|
|
||||||
fsname = cfg["fs"].string_value();
|
fsname = cfg["fs"].string_value();
|
||||||
// Create client
|
// Create client
|
||||||
ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
|
ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
|
||||||
|
@ -1076,25 +1064,7 @@ void nfs_proxy_t::mount_fs()
|
||||||
{
|
{
|
||||||
// Child
|
// Child
|
||||||
std::string src = ("localhost:"+export_root);
|
std::string src = ("localhost:"+export_root);
|
||||||
std::string opts = ("port="+std::to_string(listening_port)+",mountport="+std::to_string(listening_port)+",nfsvers=3,nolock,tcp");
|
std::string opts = ("port="+std::to_string(listening_port)+",mountport="+std::to_string(listening_port)+",nfsvers=3,soft,nolock,tcp");
|
||||||
bool hard = false, async = false;
|
|
||||||
for (auto & opt: explode(",", mountopts, true))
|
|
||||||
{
|
|
||||||
if (opt == "hard")
|
|
||||||
hard = true;
|
|
||||||
else if (opt == "async")
|
|
||||||
async = true;
|
|
||||||
else if (opt.substr(0, 4) != "port" && opt.substr(0, 9) != "mountport" &&
|
|
||||||
opt.substr(0, 7) != "nfsvers" && opt.substr(0, 5) != "proto" &&
|
|
||||||
opt != "udp" && opt != "tcp" && opt != "rdma")
|
|
||||||
{
|
|
||||||
opts += ","+opt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hard)
|
|
||||||
opts += ",soft";
|
|
||||||
if (!async)
|
|
||||||
opts += ",sync";
|
|
||||||
const char *args[] = { "mount", src.c_str(), mountpoint.c_str(), "-o", opts.c_str(), NULL };
|
const char *args[] = { "mount", src.c_str(), mountpoint.c_str(), "-o", opts.c_str(), NULL };
|
||||||
execvp("mount", (char* const*)args);
|
execvp("mount", (char* const*)args);
|
||||||
fprintf(stderr, "Failed to run mount %s %s -o %s: %s (code %d)\n",
|
fprintf(stderr, "Failed to run mount %s %s -o %s: %s (code %d)\n",
|
||||||
|
|
|
@ -32,7 +32,6 @@ public:
|
||||||
std::string pidfile;
|
std::string pidfile;
|
||||||
bool exit_on_umount = false;
|
bool exit_on_umount = false;
|
||||||
std::string mountpoint;
|
std::string mountpoint;
|
||||||
std::string mountopts;
|
|
||||||
std::string fsname;
|
std::string fsname;
|
||||||
|
|
||||||
int active_connections = 0;
|
int active_connections = 0;
|
||||||
|
|
|
@ -388,14 +388,14 @@ void osd_t::on_change_etcd_state_hook(std::map<std::string, etcd_kv_t> & changes
|
||||||
etcd_global_config = changes[st_cli.etcd_prefix+"/config/global"].value.object_items();
|
etcd_global_config = changes[st_cli.etcd_prefix+"/config/global"].value.object_items();
|
||||||
parse_config(false);
|
parse_config(false);
|
||||||
}
|
}
|
||||||
|
if (run_primary)
|
||||||
|
{
|
||||||
bool pools = changes.find(st_cli.etcd_prefix+"/config/pools") != changes.end();
|
bool pools = changes.find(st_cli.etcd_prefix+"/config/pools") != changes.end();
|
||||||
|
bool pgs = changes.find(st_cli.etcd_prefix+"/config/pgs") != changes.end();
|
||||||
if (pools)
|
if (pools)
|
||||||
{
|
{
|
||||||
apply_no_inode_stats();
|
apply_no_inode_stats();
|
||||||
}
|
}
|
||||||
if (run_primary)
|
|
||||||
{
|
|
||||||
bool pgs = changes.find(st_cli.etcd_prefix+"/config/pgs") != changes.end();
|
|
||||||
if (pools || pgs)
|
if (pools || pgs)
|
||||||
{
|
{
|
||||||
apply_pg_count();
|
apply_pg_count();
|
||||||
|
@ -423,8 +423,6 @@ void osd_t::on_reload_config_hook(json11::Json::object & global_config)
|
||||||
// Acquire lease
|
// Acquire lease
|
||||||
void osd_t::acquire_lease()
|
void osd_t::acquire_lease()
|
||||||
{
|
{
|
||||||
// Apply no_inode_stats before the first statistics report
|
|
||||||
apply_no_inode_stats();
|
|
||||||
// Maximum lease TTL is (report interval) + retries * (timeout + repeat interval)
|
// Maximum lease TTL is (report interval) + retries * (timeout + repeat interval)
|
||||||
st_cli.etcd_call("/lease/grant", json11::Json::object {
|
st_cli.etcd_call("/lease/grant", json11::Json::object {
|
||||||
{ "TTL", etcd_report_interval+(st_cli.max_etcd_attempts*(2*st_cli.etcd_quick_timeout)+999)/1000 }
|
{ "TTL", etcd_report_interval+(st_cli.max_etcd_attempts*(2*st_cli.etcd_quick_timeout)+999)/1000 }
|
||||||
|
@ -613,9 +611,9 @@ void osd_t::on_load_pgs_hook(bool success)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
peering_state &= ~OSD_LOADING_PGS;
|
peering_state &= ~OSD_LOADING_PGS;
|
||||||
apply_no_inode_stats();
|
|
||||||
if (run_primary)
|
if (run_primary)
|
||||||
{
|
{
|
||||||
|
apply_no_inode_stats();
|
||||||
apply_pg_count();
|
apply_pg_count();
|
||||||
apply_pg_config();
|
apply_pg_config();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue