From 7b2a7d3a2b3bb8472fd275330018016044564168 Mon Sep 17 00:00:00 2001 From: Douglas Thain Date: Mon, 18 Nov 2024 09:56:11 -0500 Subject: [PATCH] Chirp-FUSE: Single Server Mode (#3980) * Add --single-server mode to hide global namespace when needed. * Update man page to reflect single-server option. --- chirp/src/chirp_fuse.c | 25 ++++++++++++++++++++++++- doc/man/m4/chirp_fuse.m4 | 1 + doc/man/md/chirp_fuse.md | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/chirp/src/chirp_fuse.c b/chirp/src/chirp_fuse.c index b48e7980c2..9c1a0e84dd 100644 --- a/chirp/src/chirp_fuse.c +++ b/chirp/src/chirp_fuse.c @@ -46,8 +46,26 @@ static int enable_small_file_optimizations = 1; static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; +/* If set, connect the client to this hostport and no other. */ + +static const char *single_hostport = 0; + +/* +Given an input path string, determine the hostname and subpath to use with chirp. +When a single host is configured, the host part is fixed and path -> newpath. +Otherwise, the path is parsed to separate the host and path. +*/ + static void parsepath(const char *path, char *newpath, char *host) { + /* Shortcut to handle case of single host. */ + if(single_hostport) { + strcpy(host,single_hostport); + strcpy(newpath,path); + return; + } + + /* Otherwise parse out the host and path in global mode. */ memset(newpath, 0, CHIRP_PATH_MAX); memset(host, 0, CHIRP_PATH_MAX); @@ -574,6 +592,7 @@ static void show_help(const char *cmd) fprintf(stdout, " %-30s Require this authentication mode.\n", "-a,--auth="); fprintf(stdout, " %-30s Block size for network I/O. (default is %ds)\n", "-b,--block-size=", (int) chirp_reli_blocksize_get()); fprintf(stdout, " %-30s Enable debugging for this subsystem.\n", "-d,--debug="); + fprintf(stdout, " %-30s Connect only to the named host:port and hide the global namespace.\n", "-s --single-server"); fprintf(stdout, " %-30s Disable small file optimizations such as recursive delete.\n", "-D,--no-optimize"); fprintf(stdout, " %-30s Run in foreground for debugging.\n", "-f,--foreground"); fprintf(stdout, " %-30s Comma-delimited list of tickets to use for authentication.\n", "-i,--tickets="); @@ -601,6 +620,7 @@ int main(int argc, char *argv[]) {"debug", required_argument, 0, 'd'}, {"no-optimize", no_argument, 0, 'D'}, {"foreground", no_argument, 0, 'f'}, + {"single-server", required_argument, 0, 's'}, {"tickets", required_argument, 0, 'i'}, {"mount-option", required_argument, 0, 'm'}, {"debug-file", required_argument, 0, 'o'}, @@ -610,7 +630,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0} }; - while((c = getopt_long(argc, argv, "a:b:d:Dfhi:m:o:t:v", long_options, NULL)) > -1) { + while((c = getopt_long(argc, argv, "a:b:d:Dfhi:m:o:s:t:v", long_options, NULL)) > -1) { switch (c) { case 'd': debug_flags_set(optarg); @@ -635,6 +655,9 @@ int main(int argc, char *argv[]) fatal("could not register authentication method `%s': %s", optarg, strerror(errno)); did_explicit_auth = 1; break; + case 's': + single_hostport = optarg; + break; case 't': chirp_fuse_timeout = string_time_parse(optarg); break; diff --git a/doc/man/m4/chirp_fuse.m4 b/doc/man/m4/chirp_fuse.m4 index cd68ccd179..e2ed5e423d 100644 --- a/doc/man/m4/chirp_fuse.m4 +++ b/doc/man/m4/chirp_fuse.m4 @@ -33,6 +33,7 @@ OPTION_ARG(b,block-size,bytes)Block size for network I/O. (default is 65536s) OPTION_ARG(d,debug,flag)Enable debugging for this subsystem. OPTION_FLAG(D,no-optimize)Disable small file optimizations such as recursive delete. OPTION_FLAG(f,foreground)Run in foreground for debugging. +OPTION_ARG(s,single-server,hostport)Connect only to the named host:port and hide the global namespace. OPTION_ARG(i,tickets,files)Comma-delimited list of tickets to use for authentication. OPTION_ARG(m,mount-option,option)Pass mount option to FUSE. Can be specified multiple times. OPTION_ARG(o,debug-file,file)Write debugging output to this file. By default, debugging is sent to stderr (":stderr"). You may specify logs to be sent to stdout (":stdout") instead. diff --git a/doc/man/md/chirp_fuse.md b/doc/man/md/chirp_fuse.md index 9daed25b49..7187639afa 100644 --- a/doc/man/md/chirp_fuse.md +++ b/doc/man/md/chirp_fuse.md @@ -55,6 +55,7 @@ For complete details with examples, see the - **-d**,**--debug=_<flag>_**
Enable debugging for this subsystem. - **-D**,**--no-optimize**
Disable small file optimizations such as recursive delete. - **-f**,**--foreground**
Run in foreground for debugging. +- **-s**,**--single-server=_<hostport>_**
Connect only to the named host:port and hide the global namespace. - **-i**,**--tickets=_<files>_**
Comma-delimited list of tickets to use for authentication. - **-m**,**--mount-option=_<option>_**
Pass mount option to FUSE. Can be specified multiple times. - **-o**,**--debug-file=_<file>_**
Write debugging output to this file. By default, debugging is sent to stderr (":stderr"). You may specify logs to be sent to stdout (":stdout") instead.