Section: utils
Architecture: i386 armhf powerpc ppc64el amd64 ia64 arm64
Priority: optional
-Depends: lustre-iokit (= ${binary:Version}), lustre-dev (= ${binary:Version}), attr, rsync, perl, lsof, libtool, libtool-bin, mpi-default-bin, selinux-utils
+Depends: lustre-iokit (= ${binary:Version}), lustre-dev (= ${binary:Version}), attr, rsync, perl, lsof, mpi-default-bin, selinux-utils
Description: Test suite for the Lustre filesystem
Lustre is a scalable, secure, robust, highly-available cluster file system.
This release is maintained by Whamcloud and available from
Section: utils
Architecture: i386 armhf powerpc ppc64el amd64 ia64 arm64
Priority: optional
-Depends: lustre-iokit (= ${binary:Version}), lustre-dev (= ${binary:Version}), attr, rsync, perl, lsof, libtool, libtool-bin, mpi-default-bin, selinux-utils
+Depends: lustre-iokit (= ${binary:Version}), lustre-dev (= ${binary:Version}), attr, rsync, perl, lsof, mpi-default-bin, selinux-utils
Description: Test suite for the Lustre filesystem
Lustre is a scalable, secure, robust, highly-available cluster file system.
This release is maintained by Whamcloud and available from
Requires: %{requires_kmod_name} = %{requires_kmod_version}
Requires: %{requires_kmod_tests_name} = %{requires_kmod_version}
%endif
-Requires: attr, rsync, perl, lsof, libtool, /usr/bin/getconf
+Requires: attr, rsync, perl, lsof, /usr/bin/getconf
%if %{with mpi}
%if %{mpi_name} == "mpich"
BuildRequires: mpich-devel
echo "Before: ${facet} ${device} ${pre_max_sectors} ${max_hw_sectors}"
- do_facet ${facet} "libtool execute l_tunedisk ${device}"
+ do_facet ${facet} "l_tunedisk ${device}"
# Value after l_tunedisk
local post_max_sectors=$(get_max_sectors_kb ${facet} ${device})
search_copytools() {
local hosts=${1:-$(facet_active_host $SINGLEAGT)}
- do_nodesv $hosts "libtool execute pgrep -x $HSMTOOL"
+ do_nodesv $hosts "pgrep --pidfile=$HSMTOOL_PID_FILE hsmtool"
}
wait_copytools() {
local fid="$1"
case "$HSMTOOL" in
- lhsmtool_posix)
+ *lhsmtool_posix)
printf "%s" "$(hsm_root)/*/*/*/*/*/*/$fid"
;;
esac
copytool_suspend() {
local agents=${1:-$(facet_active_host $SINGLEAGT)}
- stack_trap \
- "do_nodesv $agents libtool execute pkill -CONT -x '$HSMTOOL' || true" EXIT
- do_nodesv $agents "libtool execute pkill -STOP -x $HSMTOOL" || return 0
+ stack_trap "pkill_copytools $agents CONT || true" EXIT
+ pkill_copytools $agents STOP || return 0
echo "Copytool is suspended on $agents"
}
# Lustre mount-point is mandatory and last parameter on
# copytool cmd-line.
- local mntpnt=$(do_rpc_nodes $agent libtool execute ps -C $HSMTOOL -o args= |
+ local mntpnt=$(do_rpc_nodes $agent \
+ pgrep --pidfile=$HSMTOOL_PID_FILE --list-full hsmtool |
awk '{print $NF}')
[ -n "$mntpnt" ] || error "Found no Agent or with no mount-point "\
"parameter"
export SINGLEAGT=${SINGLEAGT:-agt1}
export HSMTOOL=${HSMTOOL:-"lhsmtool_posix"}
+ export HSMTOOL_PID_FILE=${HSMTOOL_PID_FILE:-"/var/run/lhsmtool_posix.pid"}
export HSMTOOL_VERBOSE=${HSMTOOL_VERBOSE:-""}
export HSMTOOL_UPDATE_INTERVAL=${HSMTOOL_UPDATE_INTERVAL:=""}
export HSMTOOL_EVENT_FIFO=${HSMTOOL_EVENT_FIFO:=""}
export HSMTOOL_TESTDIR
+ if ! [[ $HSMTOOL =~ hsmtool ]]; then
+ echo "HSMTOOL = '$HSMTOOL' does not contain 'hsmtool', GLWT" >&2
+ fi
+
HSM_ARCHIVE_NUMBER=2
# The test only support up to 10 MDTs
done
}
+pkill_copytools() {
+ local hosts="$1"
+ local signal="$2"
+
+ do_nodes "$hosts" "pkill --pidfile=$HSMTOOL_PID_FILE --signal=$signal hsmtool"
+}
+
copytool_continue() {
local agents=${1:-$(facet_active_host $SINGLEAGT)}
- do_nodesv $agents "libtool execute pkill -CONT -x $HSMTOOL" || return 0
+ pkill_copytools "$agents" CONT || return 0
echo "Copytool is continued on $agents"
}
local hosts=${1:-$(facet_active_host $SINGLEAGT)}
echo "Killing existing copytools on $hosts"
- do_nodesv $hosts "libtool execute killall -q $HSMTOOL" || true
+ pkill_copytools "$hosts" TERM || return 0
copytool_continue "$hosts"
}
__lhsmtool_setup()
{
- local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --hsm-root \"$hsm_root\""
+ local host="$(facet_host "$facet")"
+ local cmd="$HSMTOOL $HSMTOOL_VERBOSE --daemon --pid-file=$HSMTOOL_PID_FILE --hsm-root \"$hsm_root\""
[ -n "$bandwidth" ] && cmd+=" --bandwidth $bandwidth"
[ -n "$archive_id" ] && cmd+=" --archive $archive_id"
[ ${#misc_options[@]} -gt 0 ] &&
cmd+=" $(IFS=" " echo "$@")"
cmd+=" \"$mountpoint\""
- echo "Starting copytool $facet on $(facet_host $facet)"
- stack_trap "do_facet $facet libtool execute pkill -x '$HSMTOOL' || true" EXIT
- do_facet $facet "$cmd < /dev/null > \"$(copytool_logfile $facet)\" 2>&1"
+ echo "Starting copytool '$facet' on '$host'"
+ stack_trap "pkill_copytools $host TERM || true" EXIT
+ do_node "$host" "$cmd < /dev/null > \"$(copytool_logfile $facet)\" 2>&1"
}
hsm_root() {
l_getidentity_LDADD := $(top_builddir)/libcfs/libcfs/libcfs.la
l_getidentity_DEPENDENCIES := $(top_builddir)/libcfs/libcfs/libcfs.la
-lhsmtool_posix_SOURCES = lhsmtool_posix.c
+lhsmtool_posix_SOURCES = lhsmtool_posix.c pid_file.c pid_file.h
lhsmtool_posix_LDADD := liblustreapi.la $(PTHREAD_LIBS)
lhsmtool_posix_DEPENDENCIES := liblustreapi.la
#include <libcfs/util/string.h>
#include <linux/lustre/lustre_fid.h>
#include <lustre/lustreapi.h>
+#include "pid_file.h"
/* Progress reporting period */
#define REPORT_INTERVAL_DEFAULT 30
char *o_hsm_root;
char *o_src; /* for import, or rebind */
char *o_dst; /* for import, or rebind */
+ char *o_pid_file;
};
/* everything else is zeroed */
static char cmd_name[PATH_MAX];
static char fs_name[MAX_OBD_NAME + 1];
+static int pid_file_fd = -1;
static struct hsm_copytool_private *ctdata;
" -c, --chunk-size <sz> I/O size used during data copy\n"
" (unit can be used, default is MB)\n"
" -f, --event-fifo <path> Write events stream to fifo\n"
+ " -P, --pid-file=PATH Lock and write PID to PATH\n"
" -p, --hsm-root <path> Target HSM mount point\n"
" -q, --quiet Produce less verbose output\n"
" -u, --update-interval <s> Interval between progress reports sent\n"
.flag = &opt.o_copy_xattrs },
{ .val = 0, .name = "no_xattr", .has_arg = no_argument,
.flag = &opt.o_copy_xattrs },
+ { .val = 'P', .name = "pid-file", .has_arg = required_argument },
{ .val = 'p', .name = "hsm-root", .has_arg = required_argument },
{ .val = 'p', .name = "hsm_root", .has_arg = required_argument },
{ .val = 'q', .name = "quiet", .has_arg = no_argument },
.has_arg = required_argument },
{ .val = 'v', .name = "verbose", .has_arg = no_argument },
{ .name = NULL } };
+
unsigned long long value;
unsigned long long unit;
bool all_id = false;
if (opt.o_archive_id == NULL)
return -ENOMEM;
repeat:
- while ((c = getopt_long(argc, argv, "A:b:c:f:hiMp:qru:v",
+ while ((c = getopt_long(argc, argv, "A:b:c:f:hiMp:P:qru:v",
long_opts, NULL)) != -1) {
switch (c) {
case 'A': {
case 'M':
opt.o_action = CA_MAXSEQ;
break;
+ case 'P':
+ opt.o_pid_file = optarg;
+ break;
case 'p':
opt.o_hsm_root = optarg;
break;
}
}
+ if (opt.o_pid_file != NULL) {
+ pid_file_fd = create_pid_file(opt.o_pid_file);
+ if (pid_file_fd < 0) {
+ rc = -errno;
+ CT_ERROR(rc, "cannot create PID file");
+ return rc;
+ }
+ }
+
setbuf(stdout, NULL);
if (opt.o_event_fifo != NULL) {
--- /dev/null
+/*
+ * LGPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * LGPL HEADER END
+ *
+ * Copyright 2020, DataDirect Networks Storage.
+ */
+#include <stddef.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include "pid_file.h"
+
+int create_pid_file(const char *path)
+{
+ char buf[3 * sizeof(long long) + 2];
+ size_t buf_len;
+ int fd = -1;
+ int rc2;
+
+ fd = open(path, O_RDWR|O_CREAT|O_CLOEXEC, 0600);
+ if (fd < 0) {
+ fprintf(stderr, "%s: cannot open '%s': %s\n",
+ program_invocation_short_name, path, strerror(errno));
+ return -1;
+ }
+
+ struct flock fl = {
+ .l_type = F_WRLCK,
+ .l_whence = SEEK_SET,
+ };
+
+ rc2 = fcntl(fd, F_SETLK, &fl);
+ if (rc2 < 0) {
+ fprintf(stderr, "%s: cannot lock '%s': %s\n",
+ program_invocation_short_name, path, strerror(errno));
+ goto out;
+ }
+
+ rc2 = ftruncate(fd, 0);
+ if (rc2 < 0) {
+ fprintf(stderr, "%s: cannot truncate '%s': %s\n",
+ program_invocation_short_name, path, strerror(errno));
+ goto out;
+ }
+
+ buf_len = snprintf(buf, sizeof(buf), "%lld\n", (long long)getpid());
+ rc2 = write(fd, buf, buf_len);
+ if (rc2 < 0) {
+ fprintf(stderr, "%s: cannot write '%s': %s\n",
+ program_invocation_short_name, path, strerror(errno));
+ goto out;
+ }
+out:
+ if (rc2 < 0 && !(fd < 0)) {
+ close(fd);
+ fd = -1;
+ }
+
+ return fd;
+}
--- /dev/null
+/*
+ * LGPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of the
+ * License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * LGPL HEADER END
+ *
+ * Copyright 2020, DataDirect Networks Storage.
+ */
+
+#ifndef _PID_FILE_H_
+#define _PID_FILE_H_
+
+int create_pid_file(const char *path);
+
+#endif