cmd->u.pccc_add.pccc_flags |= PCC_DATASET_PROJ_QUOTA;
else
cmd->u.pccc_add.pccc_flags &= ~PCC_DATASET_PROJ_QUOTA;
+ } else if (strcmp(key, PCC_YAML_HSMTOOL) == 0) {
+ cmd->u.pccc_add.pccc_hsmtool_type = hsmtool_string2type(val);
+ if (cmd->u.pccc_add.pccc_hsmtool_type != HSMTOOL_POSIX_V1 &&
+ cmd->u.pccc_add.pccc_hsmtool_type != HSMTOOL_POSIX_V2)
+ return -EINVAL;
} else {
return -EINVAL;
}
switch (cmd->pccc_cmd) {
case PCC_ADD_DATASET:
+ cmd->u.pccc_add.pccc_hsmtool_type = HSMTOOL_UNKNOWN;
/* Enable these features by default */
cmd->u.pccc_add.pccc_flags |= PCC_DATASET_AUTO_ATTACH |
PCC_DATASET_MMAP_CONV |
cmd->u.pccc_add.pccc_flags & PCC_DATASET_ROPCC)
cmd->u.pccc_add.pccc_roid = cmd->u.pccc_add.pccc_rwid;
+ if (cmd->u.pccc_add.pccc_hsmtool_type == HSMTOOL_UNKNOWN)
+ cmd->u.pccc_add.pccc_hsmtool_type = HSMTOOL_DEFAULT;
+
return 0;
}
dataset->pccd_rwid = cmd->u.pccc_add.pccc_rwid;
dataset->pccd_roid = cmd->u.pccc_add.pccc_roid;
dataset->pccd_flags = cmd->u.pccc_add.pccc_flags;
+ dataset->pccd_hsmtool_type = cmd->u.pccc_add.pccc_hsmtool_type;
atomic_set(&dataset->pccd_refcount, 1);
- dataset->pccd_hsmtool_type = HSMTOOL_POSIX;
rc = pcc_dataset_rule_init(&dataset->pccd_rule, cmd);
if (rc) {
* (fid->f_oid >> 16 & oxFFFF)/FID
*/
#define MAX_PCC_DATABASE_PATH (6 * 5 + FID_NOBRACE_LEN + 1)
-static int pcc_fid2dataset_path(char *buf, int sz, struct lu_fid *fid)
-{
- return snprintf(buf, sz, "%04x/%04x/%04x/%04x/%04x/%04x/"
- DFID_NOBRACE,
- (fid)->f_oid & 0xFFFF,
- (fid)->f_oid >> 16 & 0xFFFF,
- (unsigned int)((fid)->f_seq & 0xFFFF),
- (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
- (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
- (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
- PFID(fid));
+static int pcc_fid2dataset_path(struct pcc_dataset *dataset, char *buf,
+ int sz, struct lu_fid *fid)
+{
+ switch (dataset->pccd_hsmtool_type) {
+ case HSMTOOL_POSIX_V1:
+ return snprintf(buf, sz, "%04x/%04x/%04x/%04x/%04x/%04x/"
+ DFID_NOBRACE,
+ (fid)->f_oid & 0xFFFF,
+ (fid)->f_oid >> 16 & 0xFFFF,
+ (unsigned int)((fid)->f_seq & 0xFFFF),
+ (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
+ (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
+ (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
+ PFID(fid));
+ case HSMTOOL_POSIX_V2:
+ return snprintf(buf, sz, "%04x/"DFID_NOBRACE,
+ (__u32)((fid)->f_oid ^ (fid)->f_seq) & 0XFFFF,
+ PFID(fid));
+ default:
+ return -EINVAL;
+ }
}
static inline const struct cred *pcc_super_cred(struct super_block *sb)
static int pcc_fid2dataset_fullpath(char *buf, int sz, struct lu_fid *fid,
struct pcc_dataset *dataset)
{
- return snprintf(buf, sz, "%s/%04x/%04x/%04x/%04x/%04x/%04x/"
- DFID_NOBRACE,
- dataset->pccd_pathname,
- (fid)->f_oid & 0xFFFF,
- (fid)->f_oid >> 16 & 0xFFFF,
- (unsigned int)((fid)->f_seq & 0xFFFF),
- (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
- (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
- (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
- PFID(fid));
+ switch (dataset->pccd_hsmtool_type) {
+ case HSMTOOL_POSIX_V1:
+ return snprintf(buf, sz, "%s/%04x/%04x/%04x/%04x/%04x/%04x/"
+ DFID_NOBRACE,
+ dataset->pccd_pathname,
+ (fid)->f_oid & 0xFFFF,
+ (fid)->f_oid >> 16 & 0xFFFF,
+ (unsigned int)((fid)->f_seq & 0xFFFF),
+ (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
+ (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
+ (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
+ PFID(fid));
+ case HSMTOOL_POSIX_V2:
+ return snprintf(buf, sz, "%s/%04x/"DFID_NOBRACE,
+ dataset->pccd_pathname,
+ (__u32)((fid)->f_oid ^ (fid)->f_seq) & 0XFFFF,
+ PFID(fid));
+ default:
+ return -EINVAL;
+ }
}
/* Must be called with pcci->pcci_lock held */
if (path == NULL)
return -ENOMEM;
- pcc_fid2dataset_path(path, MAX_PCC_DATABASE_PATH, fid);
+ pcc_fid2dataset_path(dataset, path, MAX_PCC_DATABASE_PATH, fid);
base = pcc_mkdir_p(dataset->pccd_path.dentry, path, 0);
if (IS_ERR(base)) {
strcmp(ent->d_name, "shadow") == 0) {
llapi_printf(LLAPI_MSG_DEBUG,
"skipping check of 'shadow' directory.\n");
- } else if (depth < 6) {
- /* No regular file under this directory level */
+ } else {
if (ent->d_type == DT_REG) {
- llapi_printf(LLAPI_MSG_DEBUG,
- "improved HSM layout for '%s' under directory '%s'?\n",
- ent->d_name, pathname);
ret = hsc->hsc_func(pathname, ent->d_name, hsc);
if (ret && !rc) {
hsc->hsc_errnum++;
rc = hsm_scan_item_alloc(head, fullname,
depth + 1);
}
- } else if (depth == 6) {
- /* This is the directory level that should has files */
- if (ent->d_type == DT_DIR) {
- llapi_err_noerrno(LLAPI_MSG_DEBUG,
- "ignore too deep subdir '%s' under directory '%s'\n",
- ent->d_name, pathname);
- hsc->hsc_errnum++;
- } else if (ent->d_type == DT_REG) {
- ret = hsc->hsc_func(pathname, ent->d_name, hsc);
- if (ret && !rc) {
- hsc->hsc_errnum++;
- rc = ret;
- /* ignore error, continue to check */
- }
- }
- } else {
- hsc->hsc_errnum++;
- ret = -EINVAL;
- llapi_error(LLAPI_MSG_ERROR, ret,
- "ignore too deep directory '%s'", pathname);
}
}
int ret = 0;
int rc;
- if (hsc->hsc_type != HSMTOOL_POSIX)
+ if (hsc->hsc_type != HSMTOOL_POSIX_V1 &&
+ hsc->hsc_type != HSMTOOL_POSIX_V2)
return -EOPNOTSUPP;
rc = stat(hsc->hsc_hsmpath, &st);