/* Always remove the page for striped dir, because the page is
* built from temporarily in LMV layer */
- if (inode != NULL && S_ISDIR(inode->i_mode) &&
- ll_i2info(inode)->lli_lsm_md != NULL) {
+ if (inode && ll_dir_striped(inode)) {
__free_page(page);
return;
}
if (remove) {
lock_page(page);
if (likely(page->mapping != NULL))
- truncate_complete_page(page->mapping, page);
+ delete_from_page_cache(page);
unlock_page(page);
}
put_page(page);
static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
#endif
{
- struct inode *inode = file_inode(filp);
- struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp);
- struct ll_sb_info *sbi = ll_i2sbi(inode);
- int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH;
- int api32 = ll_need_32bit_api(sbi);
- struct md_op_data *op_data;
- struct lu_fid pfid = { 0 };
- __u64 pos;
- int rc;
+ struct inode *inode = file_inode(filp);
+ struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp);
+ struct ll_sb_info *sbi = ll_i2sbi(inode);
+ int hash64 = sbi->ll_flags & LL_SBI_64BIT_HASH;
+ int api32 = ll_need_32bit_api(sbi);
+ struct md_op_data *op_data;
+ struct lu_fid pfid = { 0 };
+ ktime_t kstart = ktime_get();
+ __u64 pos;
+ int rc;
ENTRY;
if (lfd != NULL)
*/
GOTO(out, rc = 0);
- if (unlikely(ll_i2info(inode)->lli_lsm_md != NULL)) {
- /* This is only needed for striped dir to fill ..,
- * see lmv_read_entry */
+ if (unlikely(ll_dir_striped(inode))) {
+ /*
+ * This is only needed for striped dir to fill ..,
+ * see lmv_read_page()
+ */
if (file_dentry(filp)->d_parent != NULL &&
file_dentry(filp)->d_parent->d_inode != NULL) {
- __u64 ibits = MDS_INODELOCK_UPDATE;
+ __u64 ibits = MDS_INODELOCK_LOOKUP;
struct inode *parent =
file_dentry(filp)->d_parent->d_inode;
LUSTRE_OPC_ANY, inode);
if (IS_ERR(op_data))
GOTO(out, rc = PTR_ERR(op_data));
+
+ /* foreign dirs are browsed out of Lustre */
+ if (unlikely(op_data->op_mea1 != NULL &&
+ op_data->op_mea1->lsm_md_magic == LMV_MAGIC_FOREIGN)) {
+ ll_finish_md_op_data(op_data);
+ RETURN(-ENODATA);
+ }
+
op_data->op_fid3 = pfid;
#ifdef HAVE_DIR_CONTEXT
out:
if (!rc)
- ll_stats_ops_tally(sbi, LPROC_LL_READDIR, 1);
+ ll_stats_ops_tally(sbi, LPROC_LL_READDIR,
+ ktime_us_delta(ktime_get(), kstart));
RETURN(rc);
}
int err;
ENTRY;
- if (unlikely(lump->lum_magic != LMV_USER_MAGIC &&
- lump->lum_magic != LMV_USER_MAGIC_SPECIFIC))
+ if (unlikely(!lmv_magic_supported(lump->lum_magic)))
RETURN(-EINVAL);
- CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p) name %s "
- "stripe_offset %d, stripe_count: %u\n",
- PFID(ll_inode2fid(parent)), parent, dirname,
- (int)lump->lum_stripe_offset, lump->lum_stripe_count);
+ if (lump->lum_magic != LMV_MAGIC_FOREIGN) {
+ CDEBUG(D_VFSTRACE,
+ "VFS Op:inode="DFID"(%p) name %s stripe_offset %d, stripe_count: %u\n",
+ PFID(ll_inode2fid(parent)), parent, dirname,
+ (int)lump->lum_stripe_offset, lump->lum_stripe_count);
+ } else {
+ struct lmv_foreign_md *lfm = (struct lmv_foreign_md *)lump;
+
+ CDEBUG(D_VFSTRACE,
+ "VFS Op:inode="DFID"(%p) name %s foreign, length %u, value '%.*s'\n",
+ PFID(ll_inode2fid(parent)), parent, dirname,
+ lfm->lfm_length, lfm->lfm_length, lfm->lfm_value);
+ }
if (lump->lum_stripe_count > 1 &&
!(exp_connect_flags(sbi->ll_md_exp) & OBD_CONNECT_DIR_STRIPE))
!OBD_FAIL_CHECK(OBD_FAIL_LLITE_NO_CHECK_DEAD))
RETURN(-ENOENT);
- if (lump->lum_magic != cpu_to_le32(LMV_USER_MAGIC) &&
- lump->lum_magic != cpu_to_le32(LMV_USER_MAGIC_SPECIFIC))
+ if (unlikely(!lmv_magic_supported(cpu_to_le32(lump->lum_magic))))
lustre_swab_lmv_user_md(lump);
if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent)))
int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
int set_default)
{
- struct ll_sb_info *sbi = ll_i2sbi(inode);
- struct md_op_data *op_data;
- struct ptlrpc_request *req = NULL;
- int rc = 0;
+ struct ll_sb_info *sbi = ll_i2sbi(inode);
+ struct md_op_data *op_data;
+ struct ptlrpc_request *req = NULL;
+ int rc = 0;
#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 13, 53, 0)
- struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
- struct obd_device *mgc = lsi->lsi_mgc;
+ struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
+ struct obd_device *mgc = lsi->lsi_mgc;
#endif
- int lum_size;
+ int lum_size;
ENTRY;
- if (lump != NULL) {
- /*
- * This is coming from userspace, so should be in
- * local endian. But the MDS would like it in little
- * endian, so we swab it before we send it.
- */
- switch (lump->lmm_magic) {
- case LOV_USER_MAGIC_V1: {
- if (lump->lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V1))
- lustre_swab_lov_user_md_v1(lump);
- lum_size = sizeof(struct lov_user_md_v1);
- break;
- }
- case LOV_USER_MAGIC_V3: {
- if (lump->lmm_magic != cpu_to_le32(LOV_USER_MAGIC_V3))
- lustre_swab_lov_user_md_v3(
- (struct lov_user_md_v3 *)lump);
- lum_size = sizeof(struct lov_user_md_v3);
- break;
- }
- case LOV_USER_MAGIC_COMP_V1: {
- if (lump->lmm_magic !=
- cpu_to_le32(LOV_USER_MAGIC_COMP_V1))
- lustre_swab_lov_comp_md_v1(
- (struct lov_comp_md_v1 *)lump);
- lum_size = le32_to_cpu(
- ((struct lov_comp_md_v1 *)lump)->lcm_size);
+ if (lump != NULL) {
+ switch (lump->lmm_magic) {
+ case LOV_USER_MAGIC_V1:
+ lum_size = sizeof(struct lov_user_md_v1);
break;
- }
- case LMV_USER_MAGIC: {
+ case LOV_USER_MAGIC_V3:
+ lum_size = sizeof(struct lov_user_md_v3);
+ break;
+ case LOV_USER_MAGIC_COMP_V1:
+ lum_size = ((struct lov_comp_md_v1 *)lump)->lcm_size;
+ break;
+ case LMV_USER_MAGIC:
if (lump->lmm_magic != cpu_to_le32(LMV_USER_MAGIC))
lustre_swab_lmv_user_md(
(struct lmv_user_md *)lump);
lum_size = sizeof(struct lmv_user_md);
break;
- }
case LOV_USER_MAGIC_SPECIFIC: {
struct lov_user_md_v3 *v3 =
- (struct lov_user_md_v3 *)lump;
+ (struct lov_user_md_v3 *)lump;
if (v3->lmm_stripe_count > LOV_MAX_STRIPE_COUNT)
RETURN(-EINVAL);
- if (lump->lmm_magic !=
- cpu_to_le32(LOV_USER_MAGIC_SPECIFIC)) {
- lustre_swab_lov_user_md_v3(v3);
- lustre_swab_lov_user_md_objects(v3->lmm_objects,
- v3->lmm_stripe_count);
- }
lum_size = lov_user_md_size(v3->lmm_stripe_count,
LOV_USER_MAGIC_SPECIFIC);
break;
}
- default: {
+ default:
CDEBUG(D_IOCTL, "bad userland LOV MAGIC:"
" %#08x != %#08x nor %#08x\n",
lump->lmm_magic, LOV_USER_MAGIC_V1,
LOV_USER_MAGIC_V3);
RETURN(-EINVAL);
}
- }
- } else {
- lum_size = sizeof(struct lov_user_md_v1);
- }
- op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
- LUSTRE_OPC_ANY, NULL);
- if (IS_ERR(op_data))
- RETURN(PTR_ERR(op_data));
+ /*
+ * This is coming from userspace, so should be in
+ * local endian. But the MDS would like it in little
+ * endian, so we swab it before we send it.
+ */
+ if ((__swab32(lump->lmm_magic) & le32_to_cpu(LOV_MAGIC_MASK)) ==
+ le32_to_cpu(LOV_MAGIC_MAGIC))
+ lustre_swab_lov_user_md(lump, 0);
+ } else {
+ lum_size = sizeof(struct lov_user_md_v1);
+ }
+
+ op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
+ LUSTRE_OPC_ANY, NULL);
+ if (IS_ERR(op_data))
+ RETURN(PTR_ERR(op_data));
/* swabbing is done in lov_setstripe() on server side */
rc = md_setattr(sbi->ll_md_exp, op_data, lump, lum_size, &req);
/* We don't swab objects for directories */
switch (le32_to_cpu(lmm->lmm_magic)) {
case LOV_MAGIC_V1:
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))
- lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm);
- break;
case LOV_MAGIC_V3:
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))
- lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm);
- break;
case LOV_MAGIC_COMP_V1:
+ case LOV_USER_MAGIC_SPECIFIC:
if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))
- lustre_swab_lov_comp_md_v1(
- (struct lov_comp_md_v1 *)lmm);
+ lustre_swab_lov_user_md((struct lov_user_md *)lmm, 0);
break;
case LMV_MAGIC_V1:
if (LMV_MAGIC != cpu_to_le32(LMV_MAGIC))
if (LMV_USER_MAGIC != cpu_to_le32(LMV_USER_MAGIC))
lustre_swab_lmv_user_md((struct lmv_user_md *)lmm);
break;
- case LOV_USER_MAGIC_SPECIFIC: {
- struct lov_user_md_v3 *v3 = (struct lov_user_md_v3 *)lmm;
-
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) {
- lustre_swab_lov_user_md_v3(v3);
- lustre_swab_lov_user_md_objects(v3->lmm_objects,
- v3->lmm_stripe_count);
- }
+ case LMV_MAGIC_FOREIGN: {
+ struct lmv_foreign_md *lfm = (struct lmv_foreign_md *)lmm;
+
+ if (LMV_MAGIC_FOREIGN != cpu_to_le32(LMV_MAGIC_FOREIGN)) {
+ __swab32s(&lfm->lfm_magic);
+ __swab32s(&lfm->lfm_length);
+ __swab32s(&lfm->lfm_type);
+ __swab32s(&lfm->lfm_flags);
}
break;
+ }
default:
CERROR("unknown magic: %lX\n", (unsigned long)lmm->lmm_magic);
rc = -EPROTO;
RETURN(rc);
}
+int ll_rmfid(struct file *file, void __user *arg)
+{
+ const struct fid_array __user *ufa = arg;
+ struct fid_array *lfa = NULL;
+ size_t size;
+ unsigned nr;
+ int i, rc, *rcs = NULL;
+ ENTRY;
+
+ if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) &&
+ !(ll_i2sbi(file_inode(file))->ll_flags & LL_SBI_USER_FID2PATH))
+ RETURN(-EPERM);
+ /* Only need to get the buflen */
+ if (get_user(nr, &ufa->fa_nr))
+ RETURN(-EFAULT);
+ /* DoS protection */
+ if (nr > OBD_MAX_FIDS_IN_ARRAY)
+ RETURN(-E2BIG);
+
+ size = offsetof(struct fid_array, fa_fids[nr]);
+ OBD_ALLOC(lfa, size);
+ if (!lfa)
+ RETURN(-ENOMEM);
+ OBD_ALLOC(rcs, sizeof(int) * nr);
+ if (!rcs)
+ GOTO(free_lfa, rc = -ENOMEM);
+
+ if (copy_from_user(lfa, arg, size))
+ GOTO(free_rcs, rc = -EFAULT);
+
+ /* Call mdc_iocontrol */
+ rc = md_rmfid(ll_i2mdexp(file_inode(file)), lfa, rcs, NULL);
+ if (!rc) {
+ for (i = 0; i < nr; i++)
+ if (rcs[i])
+ lfa->fa_fids[i].f_ver = rcs[i];
+ if (copy_to_user(arg, lfa, size))
+ rc = -EFAULT;
+ }
+
+free_rcs:
+ OBD_FREE(rcs, sizeof(int) * nr);
+free_lfa:
+ OBD_FREE(lfa, size);
+
+ RETURN(rc);
+}
+
/* This function tries to get a single name component,
* to send to the server. No actual path traversal involved,
* so we limit to NAME_MAX */
lum = (struct lmv_user_md *)data->ioc_inlbuf2;
lumlen = data->ioc_inllen2;
- if ((lum->lum_magic != LMV_USER_MAGIC &&
- lum->lum_magic != LMV_USER_MAGIC_SPECIFIC) ||
+ if (!lmv_magic_supported(lum->lum_magic)) {
+ CERROR("%s: wrong lum magic %x : rc = %d\n", filename,
+ lum->lum_magic, -EINVAL);
+ GOTO(lmv_out_free, rc = -EINVAL);
+ }
+
+ if ((lum->lum_magic == LMV_USER_MAGIC ||
+ lum->lum_magic == LMV_USER_MAGIC_SPECIFIC) &&
lumlen < sizeof(*lum)) {
+ CERROR("%s: wrong lum size %d for magic %x : rc = %d\n",
+ filename, lumlen, lum->lum_magic, -EINVAL);
+ GOTO(lmv_out_free, rc = -EINVAL);
+ }
+
+ if (lum->lum_magic == LMV_MAGIC_FOREIGN &&
+ lumlen < sizeof(struct lmv_foreign_md)) {
CERROR("%s: wrong lum magic %x or size %d: rc = %d\n",
filename, lum->lum_magic, lumlen, -EFAULT);
GOTO(lmv_out_free, rc = -EINVAL);
GOTO(finish_req, rc);
}
- stripe_count = lmv_mds_md_stripe_count_get(lmm);
+ /* if foreign LMV case, fake stripes number */
+ if (lmm->lmv_magic == LMV_MAGIC_FOREIGN) {
+ struct lmv_foreign_md *lfm;
+
+ lfm = (struct lmv_foreign_md *)lmm;
+ if (lfm->lfm_length < XATTR_SIZE_MAX -
+ offsetof(typeof(*lfm), lfm_value)) {
+ __u32 size = lfm->lfm_length +
+ offsetof(typeof(*lfm), lfm_value);
+
+ stripe_count = lmv_foreign_to_md_stripes(size);
+ } else {
+ CERROR("invalid %d foreign size returned\n",
+ lfm->lfm_length);
+ return -EINVAL;
+ }
+ } else {
+ stripe_count = lmv_mds_md_stripe_count_get(lmm);
+ }
if (max_stripe_count < stripe_count) {
lum.lum_stripe_count = stripe_count;
if (copy_to_user(ulmv, &lum, sizeof(lum)))
GOTO(finish_req, rc = -E2BIG);
}
+ /* enough room on user side and foreign case */
+ if (lmm->lmv_magic == LMV_MAGIC_FOREIGN) {
+ struct lmv_foreign_md *lfm;
+ __u32 size;
+
+ lfm = (struct lmv_foreign_md *)lmm;
+ size = lfm->lfm_length +
+ offsetof(struct lmv_foreign_md, lfm_value);
+ if (copy_to_user(ulmv, lfm, size))
+ GOTO(finish_req, rc = -EFAULT);
+ GOTO(finish_req, rc);
+ }
+
lum_size = lmv_user_md_size(stripe_count,
LMV_USER_MAGIC_SPECIFIC);
OBD_ALLOC(tmp, lum_size);
struct lu_fid fid;
fid_le_to_cpu(&fid, &lmm->lmv_md_v1.lmv_stripe_fids[i]);
- mdt_index = ll_get_mdt_idx_by_fid(sbi, &fid);
- if (mdt_index < 0)
- GOTO(out_tmp, rc = mdt_index);
+ if (fid_is_sane(&fid)) {
+ mdt_index = ll_get_mdt_idx_by_fid(sbi, &fid);
+ if (mdt_index < 0)
+ GOTO(out_tmp, rc = mdt_index);
+
+ tmp->lum_objects[i].lum_mds = mdt_index;
+ tmp->lum_objects[i].lum_fid = fid;
+ }
- tmp->lum_objects[i].lum_mds = mdt_index;
- tmp->lum_objects[i].lum_fid = fid;
tmp->lum_stripe_count++;
}
ll_putname(filename);
RETURN(rc);
}
+ case LL_IOC_RMFID:
+ RETURN(ll_rmfid(file, (void __user *)arg));
case LL_IOC_LOV_SWAP_LAYOUTS:
RETURN(-EPERM);
case IOC_OBD_STATFS:
case LL_IOC_LOV_GETSTRIPE:
case LL_IOC_LOV_GETSTRIPE_NEW:
case LL_IOC_MDC_GETINFO:
+ case LL_IOC_MDC_GETINFO_OLD:
case IOC_MDC_GETFILEINFO:
+ case IOC_MDC_GETFILEINFO_OLD:
case IOC_MDC_GETFILESTRIPE: {
struct ptlrpc_request *request = NULL;
struct lov_user_md __user *lump;
- struct lov_mds_md *lmm = NULL;
- struct mdt_body *body;
- char *filename = NULL;
- int lmmsize;
-
- if (cmd == IOC_MDC_GETFILEINFO ||
- cmd == IOC_MDC_GETFILESTRIPE) {
+ struct lov_mds_md *lmm = NULL;
+ struct mdt_body *body;
+ char *filename = NULL;
+ lstat_t __user *statp = NULL;
+ lstatx_t __user *stxp = NULL;
+ __u64 __user *flagsp = NULL;
+ __u32 __user *lmmsizep = NULL;
+ struct lu_fid __user *fidp = NULL;
+ int lmmsize;
+
+ if (cmd == IOC_MDC_GETFILEINFO_OLD ||
+ cmd == IOC_MDC_GETFILEINFO ||
+ cmd == IOC_MDC_GETFILESTRIPE) {
filename = ll_getname((const char __user *)arg);
- if (IS_ERR(filename))
- RETURN(PTR_ERR(filename));
+ if (IS_ERR(filename))
+ RETURN(PTR_ERR(filename));
- rc = ll_lov_getstripe_ea_info(inode, filename, &lmm,
- &lmmsize, &request);
+ rc = ll_lov_getstripe_ea_info(inode, filename, &lmm,
+ &lmmsize, &request);
} else {
rc = ll_dir_getstripe(inode, (void **)&lmm, &lmmsize,
&request, 0);
}
- if (request) {
- body = req_capsule_server_get(&request->rq_pill,
- &RMF_MDT_BODY);
- LASSERT(body != NULL);
- } else {
- GOTO(out_req, rc);
- }
+ if (request) {
+ body = req_capsule_server_get(&request->rq_pill,
+ &RMF_MDT_BODY);
+ LASSERT(body != NULL);
+ } else {
+ GOTO(out_req, rc);
+ }
if (rc == -ENODATA && (cmd == IOC_MDC_GETFILEINFO ||
- cmd == LL_IOC_MDC_GETINFO)) {
+ cmd == LL_IOC_MDC_GETINFO ||
+ cmd == IOC_MDC_GETFILEINFO_OLD ||
+ cmd == LL_IOC_MDC_GETINFO_OLD)) {
lmmsize = 0;
rc = 0;
}
cmd == LL_IOC_LOV_GETSTRIPE ||
cmd == LL_IOC_LOV_GETSTRIPE_NEW) {
lump = (struct lov_user_md __user *)arg;
- } else {
+ } else if (cmd == IOC_MDC_GETFILEINFO_OLD ||
+ cmd == LL_IOC_MDC_GETINFO_OLD){
+ struct lov_user_mds_data_v1 __user *lmdp;
+
+ lmdp = (struct lov_user_mds_data_v1 __user *)arg;
+ statp = &lmdp->lmd_st;
+ lump = &lmdp->lmd_lmm;
+ } else {
struct lov_user_mds_data __user *lmdp;
+
lmdp = (struct lov_user_mds_data __user *)arg;
- lump = &lmdp->lmd_lmm;
- }
+ fidp = &lmdp->lmd_fid;
+ stxp = &lmdp->lmd_stx;
+ flagsp = &lmdp->lmd_flags;
+ lmmsizep = &lmdp->lmd_lmmsize;
+ lump = &lmdp->lmd_lmm;
+ }
if (lmmsize == 0) {
/* If the file has no striping then zero out *lump so
rc = -EOVERFLOW;
}
- if (cmd == IOC_MDC_GETFILEINFO || cmd == LL_IOC_MDC_GETINFO) {
- struct lov_user_mds_data __user *lmdp;
- lstat_t st = { 0 };
+ if (cmd == IOC_MDC_GETFILEINFO_OLD ||
+ cmd == LL_IOC_MDC_GETINFO_OLD) {
+ lstat_t st = { 0 };
st.st_dev = inode->i_sb->s_dev;
st.st_mode = body->mbo_mode;
sbi->ll_flags &
LL_SBI_32BIT_API);
- lmdp = (struct lov_user_mds_data __user *)arg;
- if (copy_to_user(&lmdp->lmd_st, &st, sizeof(st)))
- GOTO(out_req, rc = -EFAULT);
- }
+ if (copy_to_user(statp, &st, sizeof(st)))
+ GOTO(out_req, rc = -EFAULT);
+ } else if (cmd == IOC_MDC_GETFILEINFO ||
+ cmd == LL_IOC_MDC_GETINFO) {
+ lstatx_t stx = { 0 };
+ __u64 valid = body->mbo_valid;
+
+ stx.stx_blksize = PAGE_SIZE;
+ stx.stx_nlink = body->mbo_nlink;
+ stx.stx_uid = body->mbo_uid;
+ stx.stx_gid = body->mbo_gid;
+ stx.stx_mode = body->mbo_mode;
+ stx.stx_ino = cl_fid_build_ino(&body->mbo_fid1,
+ sbi->ll_flags &
+ LL_SBI_32BIT_API);
+ stx.stx_size = body->mbo_size;
+ stx.stx_blocks = body->mbo_blocks;
+ stx.stx_atime.tv_sec = body->mbo_atime;
+ stx.stx_ctime.tv_sec = body->mbo_ctime;
+ stx.stx_mtime.tv_sec = body->mbo_mtime;
+ stx.stx_rdev_major = MAJOR(body->mbo_rdev);
+ stx.stx_rdev_minor = MINOR(body->mbo_rdev);
+ stx.stx_dev_major = MAJOR(inode->i_sb->s_dev);
+ stx.stx_dev_minor = MINOR(inode->i_sb->s_dev);
+ stx.stx_mask |= STATX_BASIC_STATS;
- EXIT;
- out_req:
- ptlrpc_req_finished(request);
- if (filename)
- ll_putname(filename);
- return rc;
- }
+ /*
+ * For a striped directory, the size and blocks returned
+ * from MDT is not correct.
+ * The size and blocks are aggregated by client across
+ * all stripes.
+ * Thus for a striped directory, do not return the valid
+ * FLSIZE and FLBLOCKS flags to the caller.
+ * However, this whould be better decided by the MDS
+ * instead of the client.
+ */
+ if (cmd == LL_IOC_MDC_GETINFO &&
+ ll_i2info(inode)->lli_lsm_md != NULL)
+ valid &= ~(OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
+
+ if (flagsp && copy_to_user(flagsp, &valid,
+ sizeof(*flagsp)))
+ GOTO(out_req, rc = -EFAULT);
+
+ if (fidp && copy_to_user(fidp, &body->mbo_fid1,
+ sizeof(*fidp)))
+ GOTO(out_req, rc = -EFAULT);
+
+ if (!(valid & OBD_MD_FLSIZE))
+ stx.stx_mask &= ~STATX_SIZE;
+ if (!(valid & OBD_MD_FLBLOCKS))
+ stx.stx_mask &= ~STATX_BLOCKS;
+
+ if (stxp && copy_to_user(stxp, &stx, sizeof(stx)))
+ GOTO(out_req, rc = -EFAULT);
+
+ if (lmmsizep && copy_to_user(lmmsizep, &lmmsize,
+ sizeof(*lmmsizep)))
+ GOTO(out_req, rc = -EFAULT);
+ }
+
+ EXIT;
+out_req:
+ ptlrpc_req_finished(request);
+ if (filename)
+ ll_putname(filename);
+ return rc;
+ }
case OBD_IOC_QUOTACTL: {
struct if_quotactl *qctl;
RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg));
case LL_IOC_FSSETXATTR:
RETURN(ll_ioctl_fssetxattr(inode, cmd, arg));
+ case LL_IOC_PCC_DETACH_BY_FID: {
+ struct lu_pcc_detach_fid *detach;
+ struct lu_fid *fid;
+ struct inode *inode2;
+ unsigned long ino;
+
+ OBD_ALLOC_PTR(detach);
+ if (detach == NULL)
+ RETURN(-ENOMEM);
+
+ if (copy_from_user(detach,
+ (const struct lu_pcc_detach_fid __user *)arg,
+ sizeof(*detach)))
+ GOTO(out_detach, rc = -EFAULT);
+
+ fid = &detach->pccd_fid;
+ ino = cl_fid_build_ino(fid, ll_need_32bit_api(sbi));
+ inode2 = ilookup5(inode->i_sb, ino, ll_test_inode_by_fid, fid);
+ if (inode2 == NULL)
+ /* Target inode is not in inode cache, and PCC file
+ * has aleady released, return immdiately.
+ */
+ GOTO(out_detach, rc = 0);
+
+ if (!S_ISREG(inode2->i_mode))
+ GOTO(out_iput, rc = -EINVAL);
+
+ if (!inode_owner_or_capable(inode2))
+ GOTO(out_iput, rc = -EPERM);
+
+ rc = pcc_ioctl_detach(inode2, detach->pccd_opt);
+out_iput:
+ iput(inode2);
+out_detach:
+ OBD_FREE_PTR(detach);
+ RETURN(rc);
+ }
default:
RETURN(obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL,
(void __user *)arg));
.release = ll_dir_release,
.read = generic_read_dir,
#ifdef HAVE_DIR_CONTEXT
- .iterate = ll_iterate,
+ .iterate_shared = ll_iterate,
#else
.readdir = ll_readdir,
#endif