return rc;
}
+int op_create_dir(char *name, int stripe_count)
+{
+ struct ll_user_mkdir_stripe lums = { 0 };
+ int fd, rc = 0;
+ char *dot = ".";
+ char *dirname;
+
+ dirname = rindex(name, '/');
+ if (!dirname) {
+ dirname = "name";
+ name = dot;
+ } else {
+ *dirname = 0;
+ dirname++;
+ }
+ lums.lums_nstripes = stripe_count;
+ lums.lums_namelen = strlen(dirname);
+ lums.lums_name = dirname;
+ /* XXX: Probably users might want to specify permissions as well? */
+ lums.lums_mode = 0755;
+
+ fd = open(name, O_RDONLY|O_DIRECTORY);
+ if (name != dot)
+ *(dirname-1) = '/';
+ if (fd < 0) {
+ err_msg("unable to open '%s'",name);
+ rc = -errno;
+ return rc;
+ }
+
+ if (ioctl(fd, LL_IOC_MDC_MKDIRSTRIPE, &lums)) {
+ char *errmsg = strerror(errno);
+
+ fprintf(stderr, "error on ioctl for '%s' (%d): %s\n",
+ name, fd, errmsg);
+ rc = -errno;
+ }
+ if (close(fd) < 0) {
+ err_msg("error on close for '%s' (%d)", name, fd);
+ if (rc == 0)
+ rc = -errno;
+ }
+ return rc;
+}
+
/* short term backwards compat only */
int op_create_file(char *name, long stripe_size, int stripe_offset,
int stripe_count)
struct lov_user_md *lum;
int got_uuids;
int obdindex;
+ __u32 *obdgens;
};
/* XXX Max obds per lov currently hardcoded to 1000 in lov/lov_obd.c */
free(param->lum);
}
-int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, int *ost_count)
+int llapi_lov_get_uuids(int fd, struct obd_uuid *uuidp, __u32 *obdgens,
+ int *ost_count)
{
struct obd_ioctl_data data = { 0, };
struct lov_desc desc = { 0, };
int max_ost_count, rc;
max_ost_count = (OBD_MAX_IOCTL_BUFFER - size_round(sizeof(data)) -
- size_round(sizeof(desc))) / sizeof(*uuidp);
+ size_round(sizeof(desc))) /
+ (sizeof(*uuidp) + sizeof(*obdgens));
if (max_ost_count > *ost_count)
max_ost_count = *ost_count;
data.ioc_inlbuf1 = (char *)&desc;
data.ioc_inllen2 = size_round(max_ost_count * sizeof(*uuidp));
data.ioc_inlbuf2 = (char *)uuidp;
+ data.ioc_inllen3 = size_round(max_ost_count * sizeof(*obdgens));
+ data.ioc_inlbuf3 = (char *)obdgens;
desc.ld_tgt_count = max_ost_count;
static int setup_obd_uuids(DIR *dir, char *dname, struct find_param *param)
{
struct obd_uuid uuids[1024], *uuidp;
+ __u32 obdgens[1024], *genp;
+
int obdcount = 1024;
int rc, i;
param->got_uuids = 1;
- rc = llapi_lov_get_uuids(dirfd(dir), uuids, &obdcount);
+ rc = llapi_lov_get_uuids(dirfd(dir), uuids, obdgens, &obdcount);
if (rc != 0)
return (param->obduuid ? rc : 0);
return EINVAL;
}
} else if (!param->quiet) {
- printf("OBDS:\n");
- for (i = 0, uuidp = uuids; i < obdcount; i++, uuidp++)
- printf("%4d: %s\n", i, uuidp->uuid);
- }
+ printf("OBDS:\tobdidx\t\tobdgen\t\t obduuid\n");
+ uuidp = uuids;
+ genp = obdgens;
+ for (i = 0; i < obdcount; i++, uuidp++, genp++) {
+ if (obd_uuid_empty(uuidp))
+ continue;
+ printf("\t%6u\t%14u\t\t %s\n", i, *genp, uuidp->uuid);
+ }
+ }
return 0;
}
if (body) {
if ((!quiet) && (obdstripe == 1))
- printf("\tobdidx\t\t objid\t\tobjid\t\t group\n");
+ printf("\tobdidx\t\t obdgen\t\t objid\t\tobjid\t\t group\n");
for (i = 0; i < lum->lmm_stripe_count; i++) {
int idx = lum->lmm_objects[i].l_ost_idx;
long long oid = lum->lmm_objects[i].l_object_id;
+ int gen = lum->lmm_objects[i].l_ost_gen;
long long gr = lum->lmm_objects[i].l_object_gr;
if ((obdindex == OBD_NOT_FOUND) || (obdindex == idx))
- printf("\t%6u\t%14llu\t%#13llx\t%14llu%s\n",
- idx, oid, oid, gr,
- obdindex == idx ? " *" : "");
+ printf("\t%6u\t%14u\t%14llu\t%#13llx\t%14lld%s\n",
+ idx, gen, oid, oid, gr,
+ obdindex == idx ? " *" : "");
}
printf("\n");
}