[sheepdog-users] [PATCH stable-0.7 3/5] sheep: add an option for selecting the output directory of sheep.log
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Thu Dec 12 10:46:43 CET 2013
From: Teruaki Ishizaki <ishizaki.teruaki at lab.ntt.co.jp>
Previously sheep.log was saved in the Sheepdog store directory,
and used size of Sheepdog store directory included log file size.
So, administrator couldn't do capacity planning simply.
This patch adds an option for setting the output directory of sheep.log.
Usage:
$ sheep -L dir=<log_output_dir>
Example:
$ sheep -L dir=/logdir /datastore
[ Fixed a over-80 char style by using "?:" operator - Yuan]
Signed-off-by: Teruaki Ishizaki <ishizaki.teruaki at lab.ntt.co.jp>
Signed-off-by: Liu Yuan <namei.unix at gmail.com>
Conflicts:
sheep/sheep.c
Conflicts resolved by Hitoshi Mitake.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
sheep/sheep.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/sheep/sheep.c b/sheep/sheep.c
index d3192fc..c6ac8f6 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -95,6 +95,12 @@ static const char cache_help[] =
"This tries to use /my_ssd as the cache storage with 200G allocted to the\n"
"cache in directio mode\n";
+static const char logdir_help[] =
+"Example:\n\t$ sheep -L dir=/var/log/ ...\n"
+"Available arguments:\n"
+"\tdir=: path to the location of sheep.log\n"
+"if not specified use metastore directory\n";
+
static struct sd_option sheep_options[] = {
{'b', "bindaddr", true, "specify IP address of interface to listen on",
bind_help},
@@ -113,6 +119,7 @@ static struct sd_option sheep_options[] = {
"operations", journal_help},
{'l', "loglevel", true, "specify the level of logging detail "
"(default: 6 [SDOG_INFO])", loglevel_help},
+ {'L', "logdir", true, "output directory of sheep.log", logdir_help},
{'n', "nosync", false, "drop O_SYNC for write of backend"},
{'o', "stdout", false, "log to stdout instead of shared logger"},
{'p', "port", true, "specify the TCP port on which to listen "
@@ -585,7 +592,7 @@ int main(int argc, char **argv)
int log_level = SDOG_INFO, nr_vnodes = SD_DEFAULT_VNODES;
const char *dirp = DEFAULT_OBJECT_DIR, *short_options;
char *dir, *p, *pid_file = NULL, *bindaddr = NULL, path[PATH_MAX],
- *argp = NULL;
+ *argp = NULL, *logdir = NULL;
bool is_daemon = true, to_stdout = false, explicit_addr = false;
int64_t zone = -1;
struct cluster_driver *cdrv;
@@ -629,6 +636,13 @@ int main(int argc, char **argv)
exit(1);
}
break;
+ case 'L':
+ logdir = realpath(optarg, NULL);
+ if (!logdir) {
+ sd_err("%m");
+ exit(1);
+ }
+ break;
case 'n':
sys->nosync = true;
break;
@@ -751,7 +765,9 @@ int main(int argc, char **argv)
exit(1);
}
- snprintf(path, sizeof(path), "%s/" LOG_FILE_NAME, dir);
+ snprintf(path, sizeof(path), "%s/" LOG_FILE_NAME, logdir ?: dir);
+
+ free(logdir);
srandom(port);
--
1.7.10.4
More information about the sheepdog-users
mailing list