__u32 lun_end;
};
+struct nvm_ioctl_create_extended {
+ __u16 lun_begin;
+ __u16 lun_end;
+ __u16 over_prov;
+ __u16 rsv;
+};
+
enum {
NVM_CONFIG_TYPE_SIMPLE = 0,
+ NVM_CONFIG_TYPE_EXTENDED = 1,
};
struct nvm_ioctl_create_conf {
__u32 type;
union {
struct nvm_ioctl_create_simple s;
+ struct nvm_ioctl_create_extended e;
};
};
const char *tgttype = "identifier of target type. e.g. pblk.";
const char *lun_begin = "Define begin of luns to use for target.";
const char *lun_end = "Define set of luns to use for target.";
+ const char *over_prov = "Define over-provision percentage for target.";
const char *flag_factory = "Create target in factory mode";
int flags;
char *tgttype;
__u32 lun_begin;
__u32 lun_end;
+ __u32 over_prov;
+
/* flags */
__u32 factory;
};
.tgttype = "",
.lun_begin = -1,
.lun_end = -1,
+ .over_prov = -1,
.factory = 0,
};
{"target-type", 't', "TARGETTYPE", CFG_STRING, &cfg.tgttype, required_argument, tgttype},
{"lun-begin", 'b', "NUM", CFG_POSITIVE, &cfg.lun_begin, required_argument, lun_begin},
{"lun-end", 'e', "NUM", CFG_POSITIVE, &cfg.lun_end, required_argument, lun_end},
- {"factory", 'f', "FLAG", CFG_NONE, &cfg.factory, no_argument, flag_factory},
+ {"over-prov", 'o', "NUM", CFG_POSITIVE, &cfg.over_prov, required_argument, over_prov},
+ {"factory", 'f', "FLAG", CFG_NONE, &cfg.factory, no_argument, flag_factory},
{NULL}
};
if (cfg.factory)
flags |= NVM_TARGET_FACTORY;
- return lnvm_do_create_tgt(cfg.devname, cfg.tgtname, cfg.tgttype, cfg.lun_begin, cfg.lun_end, flags);
+ return lnvm_do_create_tgt(cfg.devname, cfg.tgtname, cfg.tgttype, cfg.lun_begin, cfg.lun_end, cfg.over_prov, flags);
}
static int lnvm_remove_tgt(int argc, char **argv, struct command *cmd, struct plugin *plugin)
}
int lnvm_do_create_tgt(char *devname, char *tgtname, char *tgttype,
- int lun_begin, int lun_end, int flags)
+ int lun_begin, int lun_end,
+ int over_prov, int flags)
{
struct nvm_ioctl_create c;
int fd, ret;
strncpy(c.dev, devname, DISK_NAME_LEN);
strncpy(c.tgtname, tgtname, DISK_NAME_LEN);
strncpy(c.tgttype, tgttype, NVM_TTYPE_NAME_MAX);
- c.flags = 0;
- c.conf.type = 0;
- c.conf.s.lun_begin = lun_begin;
- c.conf.s.lun_end = lun_end;
c.flags = flags;
+ /* Fall back into simple IOCTL version if no extended attributes used */
+ if (over_prov != -1) {
+ c.conf.type = NVM_CONFIG_TYPE_EXTENDED;
+ c.conf.e.lun_begin = lun_begin;
+ c.conf.e.lun_end = lun_end;
+ c.conf.e.over_prov = over_prov;
+ } else {
+ c.conf.type = NVM_CONFIG_TYPE_SIMPLE;
+ c.conf.s.lun_begin = lun_begin;
+ c.conf.s.lun_end = lun_end;
+ }
+
ret = ioctl(fd, NVM_DEV_CREATE, &c);
if (ret)
fprintf(stderr, "Creation of target failed. Please see dmesg.\n");
int lnvm_do_init(char *, char *);
int lnvm_do_list_devices(void);
int lnvm_do_info(void);
-int lnvm_do_create_tgt(char *, char *, char *, int, int, int);
+int lnvm_do_create_tgt(char *, char *, char *, int, int, int, int);
int lnvm_do_remove_tgt(char *);
int lnvm_do_factory_init(char *, int, int, int);
int lnvm_do_id_ns(int, int, unsigned int);