*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* lustre/llite/dir.c
*
lhash = hash;
fid_le_to_cpu(&fid, &ent->lde_fid);
ino = cl_fid_build_ino(&fid, is_api32);
- type = IFTODT(lu_dirent_type_get(ent));
+ type = S_DT(lu_dirent_type_get(ent));
/* For ll_nfs_get_name_filldir(), it will try to access
* 'ent' through 'lde_name', so the parameter 'name'
* for 'filldir()' must be part of the 'ent'. */
* <0 if the creation is failed.
*/
static int ll_dir_setdirstripe(struct dentry *dparent, struct lmv_user_md *lump,
- size_t len, const char *dirname, umode_t mode)
+ size_t len, const char *dirname, umode_t mode,
+ bool createonly)
{
struct inode *parent = dparent->d_inode;
struct ptlrpc_request *request = NULL;
!OBD_FAIL_CHECK(OBD_FAIL_LLITE_NO_CHECK_DEAD))
RETURN(-ENOENT);
+ /* MDS < 2.14 doesn't support 'crush' hash type, and cannot handle
+ * unknown hash if client doesn't set a valid one. switch to fnv_1a_64.
+ */
if (!(exp_connect_flags2(sbi->ll_md_exp) & OBD_CONNECT2_CRUSH)) {
- if ((lump->lum_hash_type & LMV_HASH_TYPE_MASK) ==
- LMV_HASH_TYPE_CRUSH) {
- /* if server doesn't support 'crush' hash type,
- * switch to fnv_1a_64.
- */
- lump->lum_hash_type &= ~LMV_HASH_TYPE_MASK;
- lump->lum_hash_type |= LMV_HASH_TYPE_FNV_1A_64;
- } else if ((lump->lum_hash_type & LMV_HASH_TYPE_MASK) ==
- LMV_HASH_TYPE_UNKNOWN) {
- /* from 2.14 MDT will choose default hash type if client
- * doesn't set a valid one, while old server doesn't
- * handle it.
- */
- lump->lum_hash_type &= ~LMV_HASH_TYPE_MASK;
- lump->lum_hash_type |= LMV_HASH_TYPE_DEFAULT;
- }
+ enum lmv_hash_type type = lump->lum_hash_type &
+ LMV_HASH_TYPE_MASK;
+
+ if (type == LMV_HASH_TYPE_CRUSH ||
+ type == LMV_HASH_TYPE_UNKNOWN)
+ lump->lum_hash_type = (lump->lum_hash_type ^ type) |
+ LMV_HASH_TYPE_FNV_1A_64;
}
if (unlikely(!lmv_user_magic_supported(cpu_to_le32(lump->lum_magic))))
}
op_data->op_cli_flags |= CLI_SET_MEA;
+ if (createonly)
+ op_data->op_bias |= MDS_SETSTRIPE_CREATE;
+
err = md_create(sbi->ll_md_exp, op_data, lump, len, mode,
from_kuid(&init_user_ns, current_fsuid()),
from_kgid(&init_user_ns, current_fsgid()),
}
out_inode:
- if (inode != NULL)
- iput(inode);
+ iput(inode);
out_request:
ptlrpc_req_finished(request);
out_op_data:
case LUSTRE_Q_SETDEFAULT:
case LUSTRE_Q_SETQUOTAPOOL:
case LUSTRE_Q_SETINFOPOOL:
- if (!cfs_capable(CAP_SYS_ADMIN))
+ case LUSTRE_Q_SETDEFAULT_POOL:
+ if (!capable(CAP_SYS_ADMIN))
RETURN(-EPERM);
break;
case Q_GETQUOTA:
case LUSTRE_Q_GETDEFAULT:
case LUSTRE_Q_GETQUOTAPOOL:
+ case LUSTRE_Q_GETDEFAULT_POOL:
if (check_owner(type, id) &&
- (!cfs_capable(CAP_SYS_ADMIN)))
+ (!capable(CAP_SYS_ADMIN)))
RETURN(-EPERM);
break;
case Q_GETINFO:
int i, rc, *rcs = NULL;
ENTRY;
- if (!cfs_capable(CAP_DAC_READ_SEARCH) &&
+ if (!capable(CAP_DAC_READ_SEARCH) &&
!(ll_i2sbi(file_inode(file))->ll_flags & LL_SBI_USER_FID2PATH))
RETURN(-EPERM);
/* Only need to get the buflen */
}
case LL_IOC_LMV_SETSTRIPE: {
struct lmv_user_md *lum;
- char *filename;
- int namelen = 0;
- int lumlen = 0;
- umode_t mode;
- int len;
- int rc;
+ char *filename;
+ int namelen = 0;
+ int lumlen = 0;
+ umode_t mode;
+ bool createonly = false;
+ int len;
+ int rc;
rc = obd_ioctl_getdata(&data, &len, (void __user *)arg);
if (rc)
}
mode = data->ioc_type;
- rc = ll_dir_setdirstripe(dentry, lum, lumlen, filename, mode);
+ createonly = data->ioc_obdo1.o_flags & OBD_FL_OBDMDEXISTS;
+ rc = ll_dir_setdirstripe(dentry, lum, lumlen, filename, mode,
+ createonly);
lmv_out_free:
OBD_FREE_LARGE(data, len);
RETURN(rc);
OBD_FREE(qctl, qctl_len);
RETURN(rc);
}
- case OBD_IOC_GETDTNAME:
- case OBD_IOC_GETMDNAME:
+ case OBD_IOC_GETNAME_OLD:
+ /* fall through */
+ case OBD_IOC_GETDTNAME:
+ /* fall through */
+ case OBD_IOC_GETMDNAME:
RETURN(ll_get_obd_name(inode, cmd, arg));
case LL_IOC_FLUSHCTX:
RETURN(ll_flush_ctx(inode));
RETURN(rc);
}
case LL_IOC_HSM_CT_START:
- if (!cfs_capable(CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
RETURN(-EPERM);
rc = copy_and_ct_start(cmd, sbi->ll_md_exp,