#include <libssh/callbacks.h>
#include "policy.h"
#include "list.h"
-#include "flist.h"
#include "debug.h"
#include "lipe_object_attrs.h"
#include "lipe_ssh.h"
static void usage(void)
{
- /*
- * internal option:
- * --iml-re-socket, unix domain socket to dump FIDs to resync
- * --iml-ex-socket, unix domain socket to dump FIDs to extend
- */
printf("\nUsage: %s [options]\n"
"options:\n"
"\t-a, --min-age, seconds before record handled (default: %u)\n"
struct pool_list *tgt_pools; /* target pool */
static void *lamigo_refresh_statfs_thread(void *arg);
-inline int are_agents_busy(void)
+static inline bool are_agents_busy(void)
{
- if (opt.o_iml_re_socket)
- return 0;
-
- if (lamigo_jobs_running >= lamigo_max_jobs)
- return 1;
-
- return 0;
+ return lamigo_jobs_running >= lamigo_max_jobs;
}
/* Convert human readable size string to and int; "1k" -> 1000 */
free(cmd);
}
-static struct lipe_flist *lamigo_flist_init(char *socket)
-{
- struct lipe_flist *flist = flist_alloc(NULL, 1024,
- socket, LDT_UNIX_SOCKET);
- if (flist == NULL) {
- llapi_error(LLAPI_MSG_ERROR|LLAPI_MSG_NO_ERRNO, 0,
- "failed to alloc fid list for socket %s: %s\n",
- socket,
- strerror(errno));
- return NULL;
- }
-
- return flist;
-}
-
void lamigo_usr1_handle(int sig)
{
struct resync_agent *a;
" open: %d\n", pl->pl_pool, pl->pl_ostnr,
pl->pl_avail, pl->pl_total, (int)pl->pl_open);
- if (opt.o_iml_re_socket)
- fprintf(f, " iml_re_socket: %s\n", opt.o_iml_re_socket);
- if (opt.o_iml_ex_socket)
- fprintf(f, " iml_ex_socket: %s\n", opt.o_iml_ex_socket);
-
fprintf(f, "stats:\n"
" read: %lu\n"
" skipped: %lu\n"
if (rc)
return rc;
- if (opt.o_iml_re_socket) {
- opt.o_re_flist = lamigo_flist_init(opt.o_iml_re_socket);
- if (opt.o_re_flist == NULL)
- return -errno;
- opt.o_ex_flist = lamigo_flist_init(opt.o_iml_ex_socket);
- if (opt.o_ex_flist == NULL)
- return -errno;
- }
-
return 0;
}
extern char **environ;
-/* json format: { "fid": "[FID]" }
- * written to either MIRROR or EXTEND socket
- */
-static int lamigo_flist_add_fid(struct lu_fid *fid, int resync)
-{
- int rc;
- const char *output;
- char fid_buf[FID_LEN + 1];
- struct json_object *obj_top;
-
- obj_top = json_object_new_object();
- snprintf(fid_buf, sizeof(fid_buf), DFID, PFID(fid));
- json_object_object_add(obj_top, "fid",
- json_object_new_string(fid_buf));
- output = json_object_to_json_string_ext(obj_top,
- JSON_C_TO_STRING_PLAIN);
- if (resync == AMIGO_RESYNC_RESYNC)
- rc = flist_add_one(opt.o_re_flist, output);
- else // AMIGO_RESYNC_EXTEND
- rc = flist_add_one(opt.o_ex_flist, output);
- json_object_put(obj_top);
-
- return rc;
-}
-
static int lamigo_exec_cmd(struct resync_agent *a, char *cmd)
{
struct resync_ssh_session *rss;
return 0;
}
- if (opt.o_iml_re_socket) {
- rc = lamigo_flist_add_fid(&f->fr_fh.fh_fid, resync);
- if (rc < 0) {
- llapi_error(LLAPI_MSG_DEBUG|LLAPI_MSG_NO_ERRNO, 0,
- "can't add "DFID": rc=%d\n",
- PFID(&f->fr_fh.fh_fid), rc);
- return 1;
- }
- return 0;
- }
-
rj = calloc(1, sizeof(struct resync_job));
if (rj == NULL) {
llapi_error(LLAPI_MSG_DEBUG|LLAPI_MSG_NO_ERRNO, 0, "can't allocate for a job\n");
}
}
- if (opt.o_iml_re_socket) {
- flist_write(opt.o_re_flist, true);
- flist_write(opt.o_ex_flist, true);
- }
-
return rc;
}
lamigo_agent_count++;
}
-#define LAMIGO_OPT_IML_RE_SOCKET 1
-#define LAMIGO_OPT_IML_EX_SOCKET 2
#define LAMIGO_OPT_POOL_REFRESH 3
#define LAMIGO_OPT_PROGRESS_INTV 4
#define LAMIGO_OPT_MIRROR_CMD 5
{ "heatfn", required_argument, NULL, 'H'},
{ "hot_after_idle", required_argument, NULL, 'I'},
{ "heat-dump", required_argument, NULL, 'W'},
- { "iml-re-socket", required_argument, NULL, LAMIGO_OPT_IML_RE_SOCKET},
- { "iml-ex-socket", required_argument, NULL, LAMIGO_OPT_IML_EX_SOCKET},
{ "max-cache", required_argument, NULL, 'c'},
{ "min-age", required_argument, NULL, 'a'},
{ "mirror-cmd", required_argument, NULL, LAMIGO_OPT_MIRROR_CMD},
exit(1);
}
break;
- case LAMIGO_OPT_IML_RE_SOCKET:
- opt.o_iml_re_socket = strdup(optarg);
- break;
- case LAMIGO_OPT_IML_EX_SOCKET:
- opt.o_iml_ex_socket = strdup(optarg);
- break;
case LAMIGO_OPT_MIRROR_CMD:
opt.o_mirror_cmd = strdup(optarg);
break;
exit(1);
}
- // Indepenedent operation vs IML integration
- if (opt.o_iml_re_socket || opt.o_iml_ex_socket) {
- if (opt.o_iml_re_socket == NULL ||
- opt.o_iml_ex_socket == NULL) {
- llapi_err_noerrno(LLAPI_MSG_ERROR,
- "Both or neither sockets must be defined");
- exit(1);
- }
-
- } else if (lipe_list_empty(&lamigo_agent_list)) {
+ if (lipe_list_empty(&lamigo_agent_list)) {
llapi_err_noerrno(LLAPI_MSG_ERROR, "no agents configured?\n");
exit(1);
}
struct mirror_opts *mo)
{
struct resync_job *rj;
- int rc;
-
- if (opt.o_iml_re_socket) {
- rc = lamigo_flist_add_fid(fid, resync);
- if (rc < 0) {
- llapi_error(LLAPI_MSG_DEBUG|LLAPI_MSG_NO_ERRNO, 0,
- "can't add "DFID": rc=%d\n",
- PFID(fid), rc);
- return 1;
- }
- return 0;
- }
rj = calloc(1, sizeof(struct resync_job));
if (rj == NULL) {
char *o_device;
char *o_dumpfile;
char *o_fids_dumpfile;
- char *o_iml_socket;
char *o_mountpoint;
char *o_pool;
unsigned int o_max_jobs;
void load_config(char *name);
-struct lipe_flist *lflist;
#define LPURGE_FLIST_SIZE (1024 * 1024)
-static int lpurge_init_flist(void)
-{
- if (opt.o_iml_socket) {
- lflist = flist_alloc(NULL, LPURGE_FLIST_SIZE,
- opt.o_iml_socket,
- LDT_UNIX_SOCKET);
- } else {
- llapi_printf(LLAPI_MSG_FATAL,
- "no valid output found, exit\n");
- return -1;
- }
-
- if (lflist == NULL) {
- llapi_printf(LLAPI_MSG_FATAL,
- "failed to alloc fid list, %s\n",
- strerror(errno));
- return -errno;
- }
-
- return 0;
-}
-
static void sig_handler(int signal)
{
psignal(signal, "exiting");
- if (lflist)
- flist_free(lflist);
_exit(0);
}
"\t-h, --freehi, high watermark, %% of space (default: %u)\n"
"\t--help, print this help message\n"
"\t-i, --interval, seconds to next check (default: %u)\n"
- "\t--iml_socket, do not purge, just dump found objects to domain socket\n"
"\t-j, --max_jobs, max.jobs to release replicas (default: %u)\n"
"\t-l, --freelo, low watermark, %% of space (default: %u)\n"
"\t-m, --mds, MDS idx:host:mountpoint (can specify multiple)\n"
"\tpool=<pool>\n"
"\tmds=0:mds1host:/mnt/lustre\n"
"\tmds=1:mds2host:/mnt/lustre2\n");
- printf(" config example dryrun:\n"
- "\tdevice=lustre-OST0000\n"
- "\timl_socket=/tmp/socket.lpurge\n"
- "\tfreelo=20\n"
- "\tfreehi=30\n"
- "\tpool=<pool>\n");
exit(0);
}
}
}
-#define LPURGE_INTERNAL_DUMP_FIDS 1
-#define LPURGE_OPT_IML_SOCKET 2
-#define LPURGE_OPT_VERSION 3
+#define LPURGE_INTERNAL_DUMP_FIDS 1
+#define LPURGE_OPT_VERSION 2
static struct option options[] = {
{ "device", required_argument, NULL, 'D'},
{ "freelo", required_argument, NULL, 'l'},
{ "help", no_argument, NULL, 'H' },
{ "interval", required_argument, NULL, 'i'},
- { "iml_socket", required_argument, NULL, LPURGE_OPT_IML_SOCKET},
- { "listen_socket", required_argument, NULL, 's'},
{ "max_jobs", required_argument, NULL, 'j'},
{ "mds", required_argument, NULL, 'm'},
{ "mount", required_argument, NULL, 'M'},
}
opt.o_scan_rate = value;
break;
- case 's':
- llapi_printf(LLAPI_MSG_WARN,
- "'-s' and '--listen-socket' are deprecated, use '--iml-socket' instead\n");
- case LPURGE_OPT_IML_SOCKET:
- opt.o_iml_socket = strdup(optarg);
- break;
case 'S':
value = strtol(optarg, &endptr, 10);
if (*endptr != '\0' || value < 0) {
opt.o_fids_dumpfile = strdup(buf);
}
- if (opt.o_iml_socket == NULL && lustre_fd < 0) {
+ if (lustre_fd < 0) {
llapi_printf(LLAPI_MSG_ERROR,
"client mountpoint is not defined\n");
exit(1);
sysconf(_SC_NPROCESSORS_ONLN));
}
- // IML Integration
- if (opt.o_iml_socket) {
- int rc;
-
- rc = lpurge_init_flist();
- if (rc)
- exit(rc);
- return;
- }
-
if (opt.o_max_jobs < 1 || opt.o_max_jobs > 1024) {
llapi_printf(LLAPI_MSG_FATAL,
"invalid max_jobs: %d\n", opt.o_max_jobs);
int c;
while ((c = getopt_long(argc, argv,
- "dD:b::nh:l:i:s:j:M:m:p:R:t:S:f:w:?",
+ "dD:b::nh:l:i:j:M:m:p:R:t:S:f:w:?",
options, NULL))
!= EOF) {
/* Don't do further process if invalid option found */
opt.o_device, opt.o_mountpoint, opt.o_pool,
opt.o_max_jobs, opt.o_interval, opt.o_scan_rate,
opt.o_scan_threads, opt.o_slot_size);
- if (opt.o_iml_socket)
- fprintf(f, " iml_socket: %s\n", opt.o_iml_socket);
fprintf(f, "stats:\n"
" scans: %lu\n"