}
/**
- * size_units is unchanged if no specifier used
+ * size_units is to be initialized (or zeroed) by caller.
*/
int parse_size(char *optarg, unsigned long long *size,
unsigned long long *size_units, int bytes_spec)
{
char *end;
+ if (strncmp(optarg, "-", 1) == 0)
+ return -1;
+
+ if (*size_units == 0)
+ *size_units = 1;
+
*size = strtoull(optarg, &end, 0);
if (*end != '\0') {
if ((*end == 'b') && *(end+1) == '\0' &&
(*size & (~0ULL << (64 - 9))) == 0 &&
!bytes_spec) {
- *size <<= 9;
*size_units = 1 << 9;
} else if ((*end == 'b') && *(end+1) == '\0' &&
bytes_spec) {
} else if ((*end == 'k' || *end == 'K') &&
*(end+1) == '\0' && (*size &
(~0ULL << (64 - 10))) == 0) {
- *size <<= 10;
*size_units = 1 << 10;
} else if ((*end == 'm' || *end == 'M') &&
*(end+1) == '\0' && (*size &
(~0ULL << (64 - 20))) == 0) {
- *size <<= 20;
*size_units = 1 << 20;
} else if ((*end == 'g' || *end == 'G') &&
*(end+1) == '\0' && (*size &
(~0ULL << (64 - 30))) == 0) {
- *size <<= 30;
*size_units = 1 << 30;
} else if ((*end == 't' || *end == 'T') &&
*(end+1) == '\0' && (*size &
(~0ULL << (64 - 40))) == 0) {
- *size <<= 40;
*size_units = 1ULL << 40;
} else if ((*end == 'p' || *end == 'P') &&
*(end+1) == '\0' && (*size &
(~0ULL << (64 - 50))) == 0) {
- *size <<= 50;
*size_units = 1ULL << 50;
} else if ((*end == 'e' || *end == 'E') &&
*(end+1) == '\0' && (*size &
(~0ULL << (64 - 60))) == 0) {
- *size <<= 60;
*size_units = 1ULL << 60;
} else {
return -1;
}
}
-
+ *size *= *size_units;
return 0;
}
return rc;
}
+int llapi_getname(const char *path, char *buf, size_t size)
+{
+ struct obd_uuid uuid_buf;
+ char *uuid = uuid_buf.uuid;
+ int rc, nr;
+
+ memset(&uuid_buf, 0, sizeof(uuid_buf));
+ rc = llapi_file_get_lov_uuid(path, &uuid_buf);
+ if (rc)
+ return rc;
+
+ /* We want to turn lustre-clilov-ffff88002738bc00 into
+ * lustre-ffff88002738bc00. */
+
+ nr = snprintf(buf, size, "%.*s-%s",
+ (int) (strlen(uuid) - 24), uuid,
+ uuid + strlen(uuid) - 16);
+
+ if (nr >= size)
+ rc = -ENAMETOOLONG;
+
+ return rc;
+}
+
+
/* return the first file matching this pattern */
static int first_match(char *pattern, char *buffer)
{
&scount, NULL,
NULL);
if (rc == 0)
- llapi_printf(LLAPI_MSG_NORMAL, "%u%c",
+ llapi_printf(LLAPI_MSG_NORMAL, "%d%c",
scount, nl);
else
llapi_error(LLAPI_MSG_ERROR, rc,
lum->lmm_pattern, nl);
}
+ if ((verbose & VERBOSE_GENERATION) && !is_dir) {
+ if (verbose & ~VERBOSE_GENERATION)
+ llapi_printf(LLAPI_MSG_NORMAL, "%slayout_gen: ",
+ prefix);
+ llapi_printf(LLAPI_MSG_NORMAL, "%u%c",
+ (int)lum->u.lum_layout_gen, nl);
+ }
+
if (verbose & VERBOSE_OFFSET) {
if (verbose & ~VERBOSE_OFFSET)
llapi_printf(LLAPI_MSG_NORMAL, "%sstripe_offset: ",
* sign), 1st column is the answer for the MDS value, the 2nd is for the OST:
* --------------------------------------
* 1 | file > limit; sign > 0 | -1 / -1 |
- * 2 | file = limit; sign > 0 | ? / 1 |
+ * 2 | file = limit; sign > 0 | -1 / -1 |
* 3 | file < limit; sign > 0 | ? / 1 |
* 4 | file > limit; sign = 0 | -1 / -1 |
* 5 | file = limit; sign = 0 | ? / 1 | <- (see the Note below)
* --------------------------------------
* Note: 5th actually means that the value is within the interval
* (limit - margin, limit]. */
-static int find_value_cmp(unsigned int file, unsigned int limit, int sign,
- int negopt, unsigned long long margin, int mds)
+static int find_value_cmp(unsigned long long file, unsigned long long limit,
+ int sign, int negopt, unsigned long long margin,
+ int mds)
{
int ret = -1;
if (sign > 0) {
- if (file <= limit)
+ /* Drop the fraction of margin (of days). */
+ if (file + margin <= limit)
ret = mds ? 0 : 1;
} else if (sign == 0) {
- if (file <= limit && file + margin >= limit)
+ if (file <= limit && file + margin > limit)
ret = mds ? 0 : 1;
else if (file + margin <= limit)
ret = mds ? 0 : -1;
} else if (sign < 0) {
- if (file >= limit)
+ if (file > limit)
ret = 1;
else if (mds)
ret = 0;
static int find_time_check(lstat_t *st, struct find_param *param, int mds)
{
int ret;
- int rc = 0;
+ int rc = 1;
/* Check if file is accepted. */
if (param->atime) {
ret = find_value_cmp(st->st_atime, param->atime,
- param->asign, param->exclude_atime,
+ param->asign, param->exclude_atime,
24 * 60 * 60, mds);
if (ret < 0)
return ret;
if (param->mtime) {
ret = find_value_cmp(st->st_mtime, param->mtime,
- param->msign, param->exclude_mtime,
+ param->msign, param->exclude_mtime,
24 * 60 * 60, mds);
if (ret < 0)
return ret;
LASSERT(parent != NULL || dir != NULL);
- param->lmd->lmd_lmm.lmm_stripe_count = 0;
+ if (param->have_fileinfo == 0)
+ param->lmd->lmd_lmm.lmm_stripe_count = 0;
/* If a regular expression is presented, make the initial decision */
if (param->pattern != NULL) {
}
- /* If a time or OST should be checked, the decision is not taken yet. */
- if (param->atime || param->ctime || param->mtime || param->obduuid ||
- param->check_size)
+ ret = 0;
+
+ /* Request MDS for the stat info if some of these parameters need
+ * to be compared. */
+ if (param->obduuid || param->check_uid || param->check_gid ||
+ param->check_pool || param->atime || param->ctime ||
+ param->mtime || param->check_size)
+ decision = 0;
+ if (param->type && checked_type == 0)
decision = 0;
- ret = 0;
- /* Request MDS for the stat info. */
- if (param->have_fileinfo == 0) {
+ if (param->have_fileinfo == 0 && decision == 0) {
if (dir) {
/* retrieve needed file info */
ret = ioctl(dirfd(dir), LL_IOC_MDC_GETINFO,
lmm_objects[i].l_ost_idx) {
if (param->exclude_obd)
goto decided;
- goto obd_matches;
+ break;
}
}
+ /* If an OBD matches, just break */
+ if (j != param->num_obds)
+ break;
}
if (i == param->lmd->lmd_lmm.lmm_stripe_count) {
- if (param->exclude_obd)
- goto obd_matches;
- goto decided;
+ if (!param->exclude_obd)
+ goto decided;
}
}
}
}
/* Check the time on mds. */
- if (!decision) {
+ decision = 1;
+ if (param->atime || param->ctime || param->mtime) {
int for_mds;
for_mds = lustre_fs ? (S_ISREG(st->st_mode) &&
param->lmd->lmd_lmm.lmm_stripe_count)
: 0;
decision = find_time_check(st, param, for_mds);
+ if (decision == -1)
+ goto decided;
}
-obd_matches:
/* If file still fits the request, ask ost for updated info.
The regular stat is almost of the same speed as some new
'glimpse-size-ioctl'. */
- if (!decision && S_ISREG(st->st_mode) &&
- param->lmd->lmd_lmm.lmm_stripe_count &&
- (param->check_size ||param->atime || param->mtime || param->ctime)) {
+
+ if (param->check_size && S_ISREG(st->st_mode) &&
+ param->lmd->lmd_lmm.lmm_stripe_count)
+ decision = 0;
+
+ while (!decision) {
+ /* For regular files with the stripe the decision may have not
+ * been taken yet if *time or size is to be checked. */
+ LASSERT(S_ISREG(st->st_mode) &&
+ param->lmd->lmd_lmm.lmm_stripe_count);
+
if (param->obdindex != OBD_NOT_FOUND) {
/* Check whether the obd is active or not, if it is
* not active, just print the object affected by this
"obd_uuid: %s failed %s ",
param->obduuid->uuid,
strerror(errno));
- goto print_path;
+ break;
}
}
if (dir) {
decision = find_time_check(st, param, 0);
if (decision == -1)
goto decided;
+
+ break;
}
if (param->check_size)
param->size_sign, param->exclude_size,
param->size_units, 0);
-print_path:
if (decision != -1) {
llapi_printf(LLAPI_MSG_NORMAL, "%s", path);
if (param->zeroend)
char *obd_name = NULL;
char *obd_uuid = NULL;
char *bufp = buf;
- struct obd_ioctl_data datal = { 0, };
struct obd_statfs osfs_buffer;
while(bufp[0] == ' ')
memset(&osfs_buffer, 0, sizeof (osfs_buffer));
- datal.ioc_pbuf1 = (char *)&osfs_buffer;
- datal.ioc_plen1 = sizeof(osfs_buffer);
-
for (i = 0; i < type_num; i++) {
if (strcmp(obd_type_name, obd_type[i]) != 0)
continue;