Skip to content

Commit

Permalink
Chirp-FUSE: Single Server Mode (#3980)
Browse files Browse the repository at this point in the history
* Add --single-server mode to hide global namespace when needed.

* Update man page to reflect single-server option.
  • Loading branch information
dthain authored Nov 18, 2024
1 parent ba16439 commit 7b2a7d3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
25 changes: 24 additions & 1 deletion chirp/src/chirp_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -574,6 +592,7 @@ static void show_help(const char *cmd)
fprintf(stdout, " %-30s Require this authentication mode.\n", "-a,--auth=<flag>");
fprintf(stdout, " %-30s Block size for network I/O. (default is %ds)\n", "-b,--block-size=<bytes>", (int) chirp_reli_blocksize_get());
fprintf(stdout, " %-30s Enable debugging for this subsystem.\n", "-d,--debug=<flag>");
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=<files>");
Expand Down Expand Up @@ -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'},
Expand All @@ -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);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions doc/man/m4/chirp_fuse.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions doc/man/md/chirp_fuse.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ For complete details with examples, see the
- **-d**,**--debug=_&lt;flag&gt;_**<br />Enable debugging for this subsystem.
- **-D**,**--no-optimize**<br />Disable small file optimizations such as recursive delete.
- **-f**,**--foreground**<br />Run in foreground for debugging.
- **-s**,**--single-server=_&lt;hostport&gt;_**<br />Connect only to the named host:port and hide the global namespace.
- **-i**,**--tickets=_&lt;files&gt;_**<br />Comma-delimited list of tickets to use for authentication.
- **-m**,**--mount-option=_&lt;option&gt;_**<br />Pass mount option to FUSE. Can be specified multiple times.
- **-o**,**--debug-file=_&lt;file&gt;_**<br />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.
Expand Down

0 comments on commit 7b2a7d3

Please sign in to comment.