X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_object.c;h=a177f05d2571cc5859f942e803c4b6581f26d915;hb=f8412db9911dbbfe0e25d357400cb17b9a7402bd;hp=b45d37bfbf09e2fbe850ff06e0d74f242a5f253f;hpb=d2d56f38da01001c92a09afc6b52b5acbd9bc13c;p=fs%2Flustre-release.git diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index b45d37b..a177f05 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -285,6 +285,29 @@ int mdd_iattr_get(const struct lu_env *env, struct mdd_object *mdd_obj, RETURN(rc); } +static int mdd_get_default_md(struct mdd_object *mdd_obj, + struct lov_mds_md *lmm, int *size) +{ + struct lov_desc *ldesc; + struct mdd_device *mdd = mdo2mdd(&mdd_obj->mod_obj); + ENTRY; + + ldesc = &mdd->mdd_obd_dev->u.mds.mds_lov_desc; + LASSERT(ldesc != NULL); + + if (!lmm) + RETURN(0); + + lmm->lmm_magic = LOV_MAGIC_V1; + lmm->lmm_object_gr = LOV_OBJECT_GROUP_DEFAULT; + lmm->lmm_pattern = ldesc->ld_pattern; + lmm->lmm_stripe_size = ldesc->ld_default_stripe_size; + lmm->lmm_stripe_count = ldesc->ld_default_stripe_count; + *size = sizeof(struct lov_mds_md); + + RETURN(sizeof(struct lov_mds_md)); +} + /* get lov EA only */ static int __mdd_lmm_get(const struct lu_env *env, struct mdd_object *mdd_obj, struct md_attr *ma) @@ -297,6 +320,12 @@ static int __mdd_lmm_get(const struct lu_env *env, rc = mdd_get_md(env, mdd_obj, ma->ma_lmm, &ma->ma_lmm_size, MDS_LOV_MD_NAME); + + if (rc == 0 && (ma->ma_need & MA_LOV_DEF)) { + rc = mdd_get_default_md(mdd_obj, ma->ma_lmm, + &ma->ma_lmm_size); + } + if (rc > 0) { ma->ma_valid |= MA_LOV; rc = 0; @@ -571,7 +600,8 @@ static int mdd_fix_attr(const struct lu_env *env, struct mdd_object *obj, if (la->la_valid == LA_ATIME) { /* This is atime only set for read atime update on close. */ - if (la->la_atime <= tmp_la->la_atime + 0/*XXX:mds_atime_diff*/) + if (la->la_atime <= tmp_la->la_atime + + mdd_obj2mdd_dev(obj)->mdd_atime_diff) la->la_valid &= ~LA_ATIME; RETURN(0); } @@ -635,7 +665,7 @@ static int mdd_fix_attr(const struct lu_env *env, struct mdd_object *obj, (tmp_la->la_mode & ~S_IALLUGO); /* Also check the setgid bit! */ - if (!mdd_in_group_p(uc, (la->la_valid & LA_GID) ? la->la_gid : + if (!lustre_in_group_p(uc, (la->la_valid & LA_GID) ? la->la_gid : tmp_la->la_gid) && !mdd_capable(uc, CAP_FSETID)) la->la_mode &= ~S_ISGID; } else { @@ -675,7 +705,7 @@ static int mdd_fix_attr(const struct lu_env *env, struct mdd_object *obj, la->la_gid = tmp_la->la_gid; if (((uc->mu_fsuid != tmp_la->la_uid) || ((la->la_gid != tmp_la->la_gid) && - !mdd_in_group_p(uc, la->la_gid))) && + !lustre_in_group_p(uc, la->la_gid))) && !mdd_capable(uc, CAP_CHOWN)) RETURN(-EPERM); @@ -872,7 +902,7 @@ static int mdd_xattr_set(const struct lu_env *env, struct md_object *obj, rc = mdd_xattr_set_txn(env, md2mdd_obj(obj), buf, name, fl, handle); if (rc == 0) { - la_copy->la_ctime = CURRENT_SECONDS; + la_copy->la_ctime = cfs_time_current_sec(); la_copy->la_valid = LA_CTIME; rc = mdd_attr_set_internal_locked(env, mdd_obj, la_copy, handle, 0); @@ -906,7 +936,7 @@ int mdd_xattr_del(const struct lu_env *env, struct md_object *obj, mdd_object_capa(env, mdd_obj)); mdd_write_unlock(env, mdd_obj); if (rc == 0) { - la_copy->la_ctime = CURRENT_SECONDS; + la_copy->la_ctime = cfs_time_current_sec(); la_copy->la_valid = LA_CTIME; rc = mdd_attr_set_internal_locked(env, mdd_obj, la_copy, handle, 0); @@ -1285,7 +1315,7 @@ static int mdd_readpage_sanity_check(const struct lu_env *env, static int mdd_dir_page_build(const struct lu_env *env, int first, void *area, int nob, struct dt_it_ops *iops, - struct dt_it *it, __u32 *start, __u32 *end, + struct dt_it *it, __u64 *start, __u64 *end, struct lu_dirent **last) { struct lu_fid *fid = &mdd_env_info(env)->mti_fid2; @@ -1308,19 +1338,21 @@ static int mdd_dir_page_build(const struct lu_env *env, int first, char *name; int len; int recsize; - __u32 hash; + __u64 hash; name = (char *)iops->key(env, it); len = iops->key_size(env, it); pack = (struct lu_fid_pack *)iops->rec(env, it); - fid_unpack(pack, fid); + result = fid_unpack(pack, fid); + if (result != 0) + break; - recsize = (sizeof(*ent) + len + 3) & ~3; + recsize = (sizeof(*ent) + len + 7) & ~7; hash = iops->store(env, it); *end = hash; - CDEBUG(D_INFO, "%p %p %d "DFID": %#8.8x (%d) \"%*.*s\"\n", + CDEBUG(D_INFO, "%p %p %d "DFID": "LPU64" (%d) \"%*.*s\"\n", name, ent, nob, PFID(fid), hash, len, len, len, name); if (nob >= recsize) { @@ -1362,8 +1394,8 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj, int i; int rc; int nob; - __u32 hash_start; - __u32 hash_end; + __u64 hash_start; + __u64 hash_end; LASSERT(rdpg->rp_pages != NULL); LASSERT(next->do_index_ops != NULL); @@ -1376,8 +1408,8 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj, */ iops = &next->do_index_ops->dio_it; it = iops->init(env, next, 0, mdd_object_capa(env, obj)); - if (it == NULL) - return -ENOMEM; + if (IS_ERR(it)) + return PTR_ERR(it); rc = iops->load(env, it, rdpg->rp_hash); @@ -1408,12 +1440,12 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj, i++, nob -= CFS_PAGE_SIZE) { LASSERT(i < rdpg->rp_npages); pg = rdpg->rp_pages[i]; - rc = mdd_dir_page_build(env, !i, kmap(pg), + rc = mdd_dir_page_build(env, !i, cfs_kmap(pg), min_t(int, nob, CFS_PAGE_SIZE), iops, it, &hash_start, &hash_end, &last); if (rc != 0 || i == rdpg->rp_npages - 1) last->lde_reclen = 0; - kunmap(pg); + cfs_kunmap(pg); } if (rc > 0) { /* @@ -1425,7 +1457,7 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj, if (rc == 0) { struct lu_dirpage *dp; - dp = kmap(rdpg->rp_pages[0]); + dp = cfs_kmap(rdpg->rp_pages[0]); dp->ldp_hash_start = rdpg->rp_hash; dp->ldp_hash_end = hash_end; if (i == 0) @@ -1433,8 +1465,8 @@ static int __mdd_readpage(const struct lu_env *env, struct mdd_object *obj, * No pages were processed, mark this. */ dp->ldp_flags |= LDF_EMPTY; - dp->ldp_flags = cpu_to_le16(dp->ldp_flags); - kunmap(rdpg->rp_pages[0]); + dp->ldp_flags = cpu_to_le32(dp->ldp_flags); + cfs_kunmap(rdpg->rp_pages[0]); } iops->put(env, it); iops->fini(env, it); @@ -1472,13 +1504,13 @@ static int mdd_readpage(const struct lu_env *env, struct md_object *obj, LASSERT(rdpg->rp_pages != NULL); pg = rdpg->rp_pages[0]; - dp = (struct lu_dirpage*)kmap(pg); + dp = (struct lu_dirpage*)cfs_kmap(pg); memset(dp, 0 , sizeof(struct lu_dirpage)); dp->ldp_hash_start = rdpg->rp_hash; dp->ldp_hash_end = DIR_END_OFF; dp->ldp_flags |= LDF_EMPTY; - dp->ldp_flags = cpu_to_le16(dp->ldp_flags); - kunmap(pg); + dp->ldp_flags = cpu_to_le32(dp->ldp_flags); + cfs_kunmap(pg); GOTO(out_unlock, rc = 0); }