}
/*
- * Attr of this object.
- */
-static inline const __u32 lu_object_attr(const struct lu_object *o)
-{
- return o->lo_header->loh_attr;
-}
-
-/*
* return device operations vector for this object
*/
static inline struct lu_device_operations *
return lu_object_exists(ctx, o) <= 0;
}
+/*
+ * Attr of this object.
+ */
+static inline const __u32 lu_object_attr(const struct lu_context *ctx,
+ const struct lu_object *o)
+{
+ LASSERT(lu_object_exists(ctx, o) > 0);
+ return o->lo_header->loh_attr;
+}
+
struct lu_rdpg {
/* input params, should be filled out by mdt */
__u32 rp_hash; /* hash */
/*TODO:check append flags*/
if (is_dir) {
- if (!S_ISDIR(mdd_object_type(cobj)))
+ if (!S_ISDIR(mdd_object_type(ctxt, cobj)))
RETURN(-ENOTDIR);
if (lu_fid_eq(mdo2fid(cobj), &mdd->mdd_root_fid))
RETURN(-EBUSY);
- } else if (S_ISDIR(mdd_object_type(cobj)))
+ } else if (S_ISDIR(mdd_object_type(ctxt, cobj)))
RETURN(-EISDIR);
if (mdd_is_dead_obj(pobj))
rc = __mdd_iattr_get(ctxt, mdd_obj, ma);
if (rc == 0 && ma->ma_need & MA_LOV) {
- if (S_ISREG(lu_object_attr(mdd2lu_obj(mdd_obj))) ||
- S_ISDIR(lu_object_attr(mdd2lu_obj(mdd_obj)))) {
+ if (S_ISREG(lu_object_attr(ctxt, mdd2lu_obj(mdd_obj))) ||
+ S_ISDIR(lu_object_attr(ctxt, mdd2lu_obj(mdd_obj)))) {
rc = __mdd_lmm_get(ctxt, mdd_obj, ma);
}
}
return next->do_ops->do_attr_set(ctxt, next, attr, handle);
}
-int mdd_attr_set_internal_locked(const struct lu_context *ctxt,
+int mdd_attr_set_internal_locked(const struct lu_context *ctxt,
struct mdd_object *o,
- const struct lu_attr *attr,
+ const struct lu_attr *attr,
struct thandle *handle)
{
int rc;
RETURN(PTR_ERR(handle));
/*TODO: add lock here*/
/* start a log jounal handle if needed */
- if (S_ISREG(mdd_object_type(mdd_obj)) &&
+ if (S_ISREG(mdd_object_type(ctxt, mdd_obj)) &&
ma->ma_attr.la_valid & (LA_UID | LA_GID)) {
max_size = mdd_lov_mdsize(ctxt, mdd);
OBD_ALLOC(lmm, max_size);
rc = mdd_fix_attr(ctxt, mdd_obj, ma, la_copy);
if (rc)
GOTO(cleanup, rc);
-
+
if (ma->ma_valid & MA_FLAGS) {
la_copy->la_flags = ma->ma_attr_flags;
la_copy->la_valid |= LA_FLAGS;
rc = mdd_attr_set_internal_locked(ctxt, mdd_obj, la_copy,
handle);
- }else if (la_copy->la_valid) { /* setattr */
+ } else if (la_copy->la_valid) { /* setattr */
rc = mdd_attr_set_internal_locked(ctxt, mdd_obj, la_copy,
handle);
/* journal chown/chgrp in llog, just like unlink */
}
if (rc == 0 && ma->ma_valid & MA_LOV) {
- if ((S_ISREG(mdd_object_type(mdd_obj)) ||
- S_ISDIR(mdd_object_type(mdd_obj)))) {
+ umode_t mode;
+
+ mode = mdd_object_type(ctxt, mdd_obj);
+ if (S_ISREG(mode) || S_ISDIR(mode)) {
/*TODO check permission*/
rc = mdd_lov_set_md(ctxt, NULL, mdd_obj, ma->ma_lmm,
ma->ma_lmm_size, handle, 1);
rc = mdd_may_create(ctxt, tgt_obj, NULL);
if (rc)
RETURN(rc);
- if (S_ISDIR(mdd_object_type(src_obj)))
+ if (S_ISDIR(mdd_object_type(ctxt, src_obj)))
RETURN(-EPERM);
RETURN(rc);
if (rc == 0) {
if (atomic_read(&obj->mod_count) == 0 &&
ma->ma_attr.la_nlink == 0 &&
- S_ISREG(mdd_object_type(obj))) {
+ S_ISREG(mdd_object_type(ctxt, obj))) {
rc = __mdd_lmm_get(ctxt, obj, ma);
if (rc == 0 && ma->ma_valid & MA_LOV)
rc = mdd_unlink_log(ctxt,
if (rc)
RETURN(rc);
- if (S_ISDIR(mdd_object_type(cobj)) &&
+ if (S_ISDIR(mdd_object_type(ctxt, cobj)) &&
dt_try_as_dir(ctxt, dt_cobj)) {
rc = mdd_dir_is_empty(ctxt, cobj);
if (rc != 0)
GOTO(cleanup, rc);
__mdd_ref_del(ctxt, mdd_cobj, handle);
- if (S_ISDIR(lu_object_attr(&cobj->mo_lu))) {
+ if (S_ISDIR(lu_object_attr(ctxt, &cobj->mo_lu))) {
/* unlink dot */
__mdd_ref_del(ctxt, mdd_cobj, handle);
/* unlink dotdot */
int rc = 0, src_is_dir, tgt_is_dir;
ENTRY;
- src_is_dir = S_ISDIR(mdd_object_type(sobj));
+ src_is_dir = S_ISDIR(mdd_object_type(ctxt, sobj));
rc = mdd_may_delete(ctxt, src_pobj, sobj, src_is_dir);
if (rc)
GOTO(out, rc);
if (rc)
GOTO(out, rc);
- tgt_is_dir = S_ISDIR(mdd_object_type(tobj));
+ tgt_is_dir = S_ISDIR(mdd_object_type(ctxt, tobj));
if (tgt_is_dir && mdd_dir_is_empty(ctxt, tobj))
GOTO(out, rc = -ENOTEMPTY);
out:
GOTO(cleanup, rc);
/*if sobj is dir, its parent object nlink should be dec too*/
- if (S_ISDIR(mdd_object_type(mdd_sobj)))
+ if (S_ISDIR(mdd_object_type(ctxt, mdd_sobj)))
__mdd_ref_del(ctxt, mdd_spobj, handle);
if (tobj) {
if (tobj && lu_object_exists(ctxt, &tobj->mo_lu)) {
__mdd_ref_del(ctxt, mdd_tobj, handle);
/* remove dot reference */
- if (S_ISDIR(mdd_object_type(mdd_tobj)))
+ if (S_ISDIR(mdd_object_type(ctxt, mdd_tobj)))
__mdd_ref_del(ctxt, mdd_tobj, handle);
rc = __mdd_finish_unlink(ctxt, mdd_tobj, ma);
if (mdd_is_dead_obj(mdd_obj))
RETURN(-ESTALE);
mdd_lock(ctxt, mdd_obj, DT_READ_LOCK);
- if (S_ISDIR(mdd_object_type(mdd_obj)) && dt_try_as_dir(ctxt, dir))
+ if (S_ISDIR(mdd_object_type(ctxt, mdd_obj)) && dt_try_as_dir(ctxt, dir))
rc = dir->do_index_ops->dio_lookup(ctxt, dir, rec, key);
else
rc = -ENOTDIR;
mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK);
/* rmdir checks */
- if (S_ISDIR(lu_object_attr(&obj->mo_lu)) &&
+ if (S_ISDIR(lu_object_attr(ctxt, &obj->mo_lu)) &&
dt_try_as_dir(ctxt, mdd_object_child(mdd_obj))) {
rc = mdd_dir_is_empty(ctxt, mdd_obj);
if (rc != 0)
__mdd_ref_del(ctxt, mdd_obj, handle);
- if (S_ISDIR(lu_object_attr(&obj->mo_lu))) {
+ if (S_ISDIR(lu_object_attr(ctxt, &obj->mo_lu))) {
/* unlink dot */
__mdd_ref_del(ctxt, mdd_obj, handle);
}
next = mdd_object_child(mdd_obj);
mdd_lock(ctxt, mdd_obj, DT_READ_LOCK);
- if (S_ISDIR(mdd_object_type(mdd_obj)) && dt_try_as_dir(ctxt, next))
+ if (S_ISDIR(mdd_object_type(ctxt, mdd_obj)) &&
+ dt_try_as_dir(ctxt, next))
rc = next->do_ops->do_readpage(ctxt, next, rdpg);
else
rc = -ENOTDIR;
enum mod_flags {
/*The dir object has been unlinked*/
- DEAD_OBJ = 1 << 0,
+ DEAD_OBJ = 1 << 0,
};
struct mdd_object {
struct mdd_thread_info *mdd_ctx_info(const struct lu_context *ctx);
-void mdd_lock(const struct lu_context *ctxt, struct mdd_object *obj,
+void mdd_lock(const struct lu_context *ctxt, struct mdd_object *obj,
enum dt_lock_mode mode);
-void mdd_unlock(const struct lu_context *ctxt, struct mdd_object *obj,
+void mdd_unlock(const struct lu_context *ctxt, struct mdd_object *obj,
enum dt_lock_mode mode);
extern struct lu_device_operations mdd_lu_ops;
static inline int lu_device_is_mdd(struct lu_device *d)
return lu_object_fid(&obj->mod_obj.mo_lu);
}
-static inline umode_t mdd_object_type(const struct mdd_object *obj)
+static inline umode_t mdd_object_type(const struct lu_context *ctxt,
+ const struct mdd_object *obj)
{
- return lu_object_attr(&obj->mod_obj.mo_lu);
+ return lu_object_attr(ctxt, &obj->mod_obj.mo_lu);
}
-static inline int mdd_lov_mdsize(const struct lu_context *ctxt,
+static inline int mdd_lov_mdsize(const struct lu_context *ctxt,
struct mdd_device *mdd)
{
struct obd_device *obd = mdd2_obd(mdd);
return obd->u.mds.mds_max_mdsize;
}
-static inline int mdd_lov_cookiesize(const struct lu_context *ctxt,
+static inline int mdd_lov_cookiesize(const struct lu_context *ctxt,
struct mdd_device *mdd)
{
struct obd_device *obd = mdd2_obd(mdd);
struct lov_stripe_md *lsm = NULL;
int rc;
ENTRY;
-
- LASSERT(S_ISDIR(mdd_object_type(obj)) || S_ISREG(mdd_object_type(obj)));
+
+ LASSERT(S_ISDIR(mdd_object_type(ctxt, obj)) ||
+ S_ISREG(mdd_object_type(ctxt, obj)));
rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE, lov_exp, 0, &lsm, lmmp);
if (rc)
RETURN(rc);
obd_free_memmd(lov_exp, &lsm);
- rc = mdd_xattr_set_txn(ctxt, obj, lmmp, lmm_size, MDS_LOV_MD_NAME, 0,
+ rc = mdd_xattr_set_txn(ctxt, obj, lmmp, lmm_size, MDS_LOV_MD_NAME, 0,
handle);
-
+
CDEBUG(D_INFO, "set lov ea of "DFID" rc %d \n", PFID(mdo2fid(obj)), rc);
RETURN(rc);
}
-
-static int mdd_lov_set_dir_md(const struct lu_context *ctxt,
+
+static int mdd_lov_set_dir_md(const struct lu_context *ctxt,
struct mdd_object *obj, struct lov_mds_md *lmmp,
int lmm_size, struct thandle *handle)
{
ENTRY;
/*TODO check permission*/
- LASSERT(S_ISDIR(mdd_object_type(obj)));
+ LASSERT(S_ISDIR(mdd_object_type(ctxt, obj)));
lum = (struct lov_user_md*)lmmp;
/* if { size, offset, count } = { 0, -1, 0 } (i.e. all default
* values specified) then delete default striping from dir. */
- if ((lum->lmm_stripe_size == 0 && lum->lmm_stripe_count == 0 &&
+ if ((lum->lmm_stripe_size == 0 && lum->lmm_stripe_count == 0 &&
lum->lmm_stripe_offset == (typeof(lum->lmm_stripe_offset))(-1)) ||
/* lmm_stripe_size == -1 is deprecated in 1.4.6 */
lum->lmm_stripe_size == (typeof(lum->lmm_stripe_size))(-1)){
- rc = mdd_xattr_set_txn(ctxt, obj, NULL, 0, MDS_LOV_MD_NAME, 0,
+ rc = mdd_xattr_set_txn(ctxt, obj, NULL, 0, MDS_LOV_MD_NAME, 0,
handle);
if (rc == -ENODATA)
rc = 0;
CDEBUG(D_INFO, "delete lov ea of "DFID" rc %d \n",
PFID(mdo2fid(obj)), rc);
} else {
- rc = mdd_lov_set_stripe_md(ctxt, obj, lmmp, lmm_size, handle);
+ rc = mdd_lov_set_stripe_md(ctxt, obj, lmmp, lmm_size, handle);
}
RETURN(rc);
}
-
+
int mdd_lov_set_md(const struct lu_context *ctxt, struct mdd_object *pobj,
struct mdd_object *child, struct lov_mds_md *lmmp,
int lmm_size, struct thandle *handle, int set_stripe)
{
int rc = 0;
+ umode_t mode;
ENTRY;
- if (S_ISREG(mdd_object_type(child)) && lmm_size > 0) {
+ mode = mdd_object_type(ctxt, child);
+ if (S_ISREG(mode) && lmm_size > 0) {
if (set_stripe) {
rc = mdd_lov_set_stripe_md(ctxt, child, lmmp, lmm_size,
handle);
rc = mdd_xattr_set_txn(ctxt, child, lmmp, lmm_size,
MDS_LOV_MD_NAME, 0, handle);
}
- } else if (S_ISDIR(mdd_object_type(child))) {
+ } else if (S_ISDIR(mode)) {
if (lmmp == NULL && lmm_size == 0) {
struct lov_mds_md *lmm = &mdd_ctx_info(ctxt)->mti_lmm;
int size = sizeof(lmm);
return ((fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid));
}
-/*FIXME: it is just the helper function used by mdd lov obd to
+/*FIXME: it is just the helper function used by mdd lov obd to
* get attr from obdo, copied from obdo_from_inode*/
static void obdo_from_la(struct obdo *dst, struct lu_attr *la, obd_flag valid)
{
LASSERT(eadata != NULL);
rc = obd_iocontrol(OBD_IOC_LOV_SETEA, lov_exp, 0, &lsm,
(void*)eadata);
- if (rc)
+ if (rc)
GOTO(out_oa, rc);
lsm->lsm_object_id = oa->o_id;
}
- /*Sometimes, we may truncate some object(without lsm)
- *then open (with write flags)it, so creating lsm above.
- *The Nonzero(truncated) size should tell ost. since size
+ /*Sometimes, we may truncate some object(without lsm)
+ *then open (with write flags)it, so creating lsm above.
+ *The Nonzero(truncated) size should tell ost. since size
*attr is in charged by OST.
*/
if (la->la_size && la->la_valid & LA_SIZE) {
obdo_from_la(oa, la, OBD_MD_FLTYPE | OBD_MD_FLATIME |
OBD_MD_FLMTIME | OBD_MD_FLCTIME | OBD_MD_FLSIZE);
- /* FIXME:pack lustre id to OST, in OST, it will be packed
- * by filter_fid, but can not see what is the usages. So just
+ /* FIXME:pack lustre id to OST, in OST, it will be packed
+ * by filter_fid, but can not see what is the usages. So just
* pack o_seq o_ver here, maybe fix it after this cycle*/
oa->o_fid = lu_object_fid(mdd2lu_obj(child))->f_seq;
oa->o_generation = lu_object_fid(mdd2lu_obj(child))->f_oid;
CERROR("error setting attrs for "DFID": rc %d\n",
PFID(mdo2fid(child)), rc);
if (rc > 0) {
- CERROR("obd_setattr for "DFID" rc %d\n",
+ CERROR("obd_setattr for "DFID" rc %d\n",
PFID(mdo2fid(child)), rc);
rc = -EIO;
}
{
struct lov_ost_data_v1 *lod;
int i;
- __s16 stripe_count =
+ __s16 stripe_count =
le16_to_cpu(((struct lov_user_md*)lmm)->lmm_stripe_count);
CDEBUG_EX(level, "objid "LPX64", magic 0x%08X, pattern %#X\n",
ENTRY;
repbody = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY);
-
+
if (ma->ma_valid & MA_INODE)
mdt_pack_attr2body(repbody, la, mdt_object_fid(mo));
if (ma->ma_valid & MA_LOV) {
+ __u32 mode;
+
+ mode = lu_object_attr(info->mti_ctxt, &mo->mot_obj.mo_lu);
LASSERT(ma->ma_lmm_size);
mdt_dump_lmm(D_INFO, ma->ma_lmm);
repbody->eadatasize = ma->ma_lmm_size;
- if (S_ISREG(lu_object_attr(&mo->mot_obj.mo_lu)))
+ if (S_ISREG(mode))
repbody->valid |= OBD_MD_FLEASIZE;
- else if (S_ISDIR(lu_object_attr(&mo->mot_obj.mo_lu)))
+ else if (S_ISDIR(mode))
repbody->valid |= OBD_MD_FLDIREA;
- else
+ else
LBUG();
}
-
+
if (ma->ma_cookie_size && (ma->ma_valid & MA_COOKIE))
repbody->valid |= OBD_MD_FLCOOKIE;
-
+
RETURN(0);
}
in &= ~(ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|
ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_FROM_OPEN|
ATTR_ATIME_SET|ATTR_CTIME_SET|ATTR_MTIME_SET|
- ATTR_ATTR_FLAG|ATTR_RAW);
+ ATTR_ATTR_FLAG|ATTR_RAW);
if (in != 0)
CERROR("Unknown attr bits: %#llx\n", in);
return out;
RETURN(-EFAULT);
rr->rr_fid1 = &rec->sa_fid;
- la->la_valid = mdt_attr_valid_xlate(rec->sa_valid, rr, ma,
+ la->la_valid = mdt_attr_valid_xlate(rec->sa_valid, rr, ma,
rec->sa_attr_flags);
la->la_mode = rec->sa_mode;
la->la_uid = rec->sa_uid;
attr->la_mtime = rec->cr_time;
attr->la_atime = rec->cr_time;
attr->la_valid = LA_MODE | LA_RDEV | LA_UID | LA_GID |
- LA_CTIME | LA_MTIME | LA_ATIME;
+ LA_CTIME | LA_MTIME | LA_ATIME;
info->mti_spec.sp_cr_flags = rec->cr_flags;
rr->rr_name = req_capsule_client_get(pill, &RMF_NAME);