.br
.B lfs changelog_clear <\fImdtname\fR> <\fIid\fR> <\fIendrec\fR>
.br
-.B lfs check \fR<\fBmgts\fR|\fBmdts\fR|\fBosts\fR|\fBall\fR>
+.B lfs check \fR<\fBmgts\fR|\fBmdts\fR|\fBosts\fR|\fBall\fR> [\fIpath\fR]
.br
.B lfs data_version \fR[\fB-nrw\fR] \fB<\fIfilename\fR>
.br
free up disk space. An <endrec> of 0 indicates the current last record.
Changelog consumers must be registered on the MDT node using \fBlctl\fR.
.TP
-.B check <mgts|mdts|osts|all>
+.B check <mgts|mdts|osts|all> [path]
Display the status of the MGTs, MDTs or OSTs (as specified in the command) or
-all the servers (MGTs, MDTs and OSTs).
+all the servers (MGTs, MDTs and OSTs). If \fBpath\fR is provided, display
+the status of the lustre file system mounted at specified \fBpath\fR only.
.TP
.B data_version [-nrw] <filename>
Display the current version of file data. If -n is specified, the data version
$LFS setstripe -c -1 $file1 # b=10919
$LCTL set_param ldlm.namespaces.*.lru_size=clear
-
+
# direct write on one client and direct read from another
dd if=/dev/urandom of=$file1 bs=1M count=100 oflag=direct
dd if=$file2 of=$tmpfile iflag=direct bs=1M
run_test 109 "Race with several mount instances on 1 node"
+test_113 () {
+ (( MDS1_VERSION >= $(version_code 2.14.0) )) ||
+ skip "Need server version at least 2.14.0"
+
+ local instance
+ local nid
+
+ instance=$($LFS getname -i $DIR1) ||
+ error "cannot get instance of $DIR1"
+
+ $LFS check osts $DIR1 | grep $instance ||
+ error "cannot find OSTs of instance $instance"
+
+ $LFS check osts $DIR1 | grep -v $instance
+ if (( $? == 0 )); then
+ error "find OSTs other than instance $instance"
+ fi
+
+ $LFS check osts | grep $instance ||
+ error "cannot find other OSTs"
+
+ nid=$(df $DIR2 | tail -1 | sed 's%:/.*%%') ||
+ error "cannot parse nid for $DIR2"
+
+ $LFS check mgts $DIR2 | grep MGC$nid ||
+ error "cannot find mgc of $nid"
+
+ $LFS check mgts $DIR2 | grep -v MGC$nid
+ if (( $? == 0 )); then
+ error "find MGTs other than nid $nid"
+ fi
+}
+run_test 113 "check servers of specified fs"
+
log "cleanup: ======================================================"
# kill and wait in each test only guarentee script finish, but command in script
"\t ^: used before a flag indicates to exclude it\n"},
{"check", lfs_check, 0,
"Display the status of MGTs, MDTs or OSTs (as specified in the command)\n"
- "or all the servers (MGTs, MDTs and OSTs).\n"
- "usage: check <mgts|osts|mdts|all>"},
+ "or all the servers (MGTs, MDTs and OSTs) [for specified path only].\n"
+ "usage: check {mgts|osts|mdts|all} [path]"},
{"osts", lfs_osts, 0, "list OSTs connected to client "
"[for specified path only]\n" "usage: osts [path]"},
{"mdts", lfs_mdts, 0, "list MDTs connected to client "
static int lfs_check(int argc, char **argv)
{
- char mntdir[PATH_MAX] = {'\0'};
+ char mntdir[PATH_MAX] = {'\0'}, path[PATH_MAX] = {'\0'};
int num_types = 1;
char *obd_types[3];
char obd_type1[4];
char obd_type3[4];
int rc;
- if (argc != 2) {
+ if (argc < 2 || argc > 3) {
fprintf(stderr, "%s check: server type must be specified\n",
progname);
return CMD_HELP;
return CMD_HELP;
}
- rc = llapi_search_mounts(NULL, 0, mntdir, NULL);
+ if (argc >= 3 && !realpath(argv[2], path)) {
+ rc = -errno;
+ fprintf(stderr, "error: invalid path '%s': %s\n",
+ argv[2], strerror(-rc));
+ return rc;
+ }
+
+ rc = llapi_search_mounts(path, 0, mntdir, NULL);
if (rc < 0 || mntdir[0] == '\0') {
fprintf(stderr,
"%s check: cannot find mounted Lustre filesystem: %s\n",
return rc;
}
- rc = llapi_target_check(num_types, obd_types, mntdir);
+ rc = llapi_target_check(num_types, obd_types, path);
if (rc)
fprintf(stderr, "%s check: cannot check target '%s': %s\n",
progname, argv[1], strerror(-rc));
#include "lstddef.h"
#define FORMATTED_BUF_LEN 1024
+#define MAX_LINE_LEN 256
+#define MAX_INSTANCE_LEN 32
static int llapi_msg_level = LLAPI_MSG_MAX;
const char *liblustreapi_cmd;
* Find the fsname, the full path, and/or an open fd.
* Either the fsname or path must not be NULL
*/
-int get_root_path(int want, char *fsname, int *outfd, char *path, int index)
+int get_root_path(int want, char *fsname, int *outfd, char *path, int index,
+ char *nid)
{
struct mntent mnt;
char buf[PATH_MAX], mntdir[PATH_MAX];
rc = -errno;
llapi_error(LLAPI_MSG_ERROR, rc,
"cannot open '%s'", mntdir);
-
} else {
*outfd = fd;
}
}
+ if ((want & WANT_NID) && nid) {
+ ptr_end = strchr(mnt.mnt_fsname, ':');
+ strncpy(nid, mnt.mnt_fsname, ptr_end - mnt.mnt_fsname);
+ nid[ptr_end - mnt.mnt_fsname] = '\0';
+ }
} else if (want & WANT_ERROR)
llapi_err_noerrno(LLAPI_MSG_ERROR,
"'%s' not on a mounted Lustre filesystem",
if (fsname)
want |= WANT_FSNAME;
- return get_root_path(want, fsname, NULL, mntdir, idx);
+ return get_root_path(want, fsname, NULL, mntdir, idx, NULL);
}
/* Given a path, find the corresponding Lustre fsname */
}
}
}
- rc = get_root_path(WANT_FSNAME | WANT_ERROR, fsname, NULL, path, -1);
+ rc = get_root_path(WANT_FSNAME | WANT_ERROR, fsname, NULL, path, -1,
+ NULL);
free(path);
return rc;
}
* clear it for safety
*/
pathname[0] = 0;
- return get_root_path(WANT_PATH, (char *)fsname, NULL, pathname, -1);
+ return get_root_path(WANT_PATH, (char *)fsname, NULL, pathname, -1,
+ NULL);
}
/**
return rc;
}
+struct check_target_filter {
+ char *nid;
+ char *instance;
+};
+
static void do_target_check(char *obd_type_name, char *obd_name,
char *obd_uuid, void *args)
{
int rc;
+ struct check_target_filter *filter = args;
+
+ if (filter != NULL) {
+ /* check nid if obd type is mgc */
+ if (strcmp(obd_type_name, "mgc") == 0) {
+ if (strcmp(obd_name + 3, filter->nid) != 0)
+ return;
+ }
+ /* check instance for other types of device (osc/mdc) */
+ else if (strstr(obd_name, filter->instance) == NULL)
+ return;
+ }
rc = llapi_ping(obd_type_name, obd_name);
if (rc == ENOTCONN)
int llapi_target_check(int type_num, char **obd_type, char *dir)
{
- return llapi_target_iterate(type_num, obd_type, NULL, do_target_check);
+ char nid[MAX_LINE_LEN], instance[MAX_INSTANCE_LEN];
+ struct check_target_filter filter = {NULL, NULL};
+ int rc;
+
+ if (dir == NULL || dir[0] == '\0')
+ return llapi_target_iterate(type_num, obd_type, NULL,
+ do_target_check);
+
+ rc = get_root_path(WANT_NID | WANT_ERROR, NULL, NULL, dir, -1, nid);
+ if (rc) {
+ llapi_error(LLAPI_MSG_ERROR, rc,
+ "cannot get nid of path '%s'", dir);
+ return rc;
+ }
+ filter.nid = nid;
+
+ rc = llapi_get_instance(dir, instance, ARRAY_SIZE(instance));
+ if (rc)
+ return rc;
+ filter.instance = instance;
+
+ return llapi_target_iterate(type_num, obd_type, &filter,
+ do_target_check);
}
#undef MAX_STRING_SIZE
if (*path_or_device == '/')
rc = get_root_path(WANT_FD, NULL, &mnt_fd,
- (char *)path_or_device, -1);
+ (char *)path_or_device, -1, NULL);
else
rc = get_root_path(WANT_FD, (char *)path_or_device,
- &mnt_fd, NULL, -1);
+ &mnt_fd, NULL, -1, NULL);
if (rc < 0)
goto out;
int rc;
int fd;
- rc = get_root_path(WANT_FD, NULL, &fd, (char *)path, -1);
+ rc = get_root_path(WANT_FD, NULL, &fd, (char *)path, -1, NULL);
if (rc)
return rc;
int fd;
struct lu_pcc_detach_fid detach;
- rc = get_root_path(WANT_FD, NULL, &fd, (char *)mntpath, -1);
+ rc = get_root_path(WANT_FD, NULL, &fd, (char *)mntpath, -1, NULL);
if (rc) {
llapi_error(LLAPI_MSG_ERROR, rc, "cannot get root path: %s",
mntpath);
#define WANT_FD 0x4
#define WANT_INDEX 0x8
#define WANT_ERROR 0x10
+#define WANT_DEV 0x20
+#define WANT_NID 0x40
/* Define a fixed 4096-byte encryption unit size */
#define LUSTRE_ENCRYPTION_BLOCKBITS 12
#define PROC_MOUNTS "/proc/mounts"
#endif
-int get_root_path(int want, char *fsname, int *outfd, char *path, int index);
+int get_root_path(int want, char *fsname, int *outfd, char *path, int index,
+ char *nid);
int llapi_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len);
int llapi_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len);
int sattr_cache_get_defaults(const char *const fsname,