#define LOV_PATTERN_FIRST 0x100 /* first stripe is not in round-robin */
#define LOV_PATTERN_CMOBD 0x200
+#define LOV_OBJECT_GROUP_DEFAULT ~0ULL
+#define LOV_OBJECT_GROUP_CLEAR 0ULL
+
#define lov_ost_data lov_ost_data_v1
struct lov_ost_data_v1 { /* per-stripe data structure (little-endian)*/
__u64 l_object_id; /* OST object ID */
mfd->mfd_dentry->d_name.len,mfd->mfd_dentry->d_name.name,
mfd->mfd_dentry->d_inode->i_ino);
- rc = mds_get_md(obd, mfd->mfd_dentry->d_inode, lmm,&lmm_size,1);
+ rc = mds_get_md(obd, mfd->mfd_dentry->d_inode, lmm,
+ &lmm_size, 1, 0);
if (rc < 0)
CWARN("mds_get_md failure, rc=%d\n", rc);
else
* The EA size is also returned on success, and -ve errno on failure.
* If there is no EA then 0 is returned. */
int mds_get_md(struct obd_device *obd, struct inode *inode, void *md,
- int *size, int lock)
+ int *size, int lock, int flags)
{
int rc = 0;
- int lmm_size;
+ int lmm_size = 0;
if (lock)
LOCK_INODE_MUTEX(inode);
rc = fsfilt_get_md(obd, inode, md, *size, "lov");
+ if (rc == 0 && flags == MDS_GETATTR)
+ rc = mds_get_default_md(obd, md, &lmm_size);
+
if (rc < 0) {
CERROR("Error %d reading eadata for ino %lu\n",
rc, inode->i_ino);
/* Call with lock=1 if you want mds_pack_md to take the i_mutex.
* Call with lock=0 if the caller has already taken the i_mutex. */
int mds_pack_md(struct obd_device *obd, struct lustre_msg *msg, int offset,
- struct mds_body *body, struct inode *inode, int lock)
+ struct mds_body *body, struct inode *inode, int lock, int flags)
{
struct mds_obd *mds = &obd->u.mds;
void *lmm;
// RETURN(-EINVAL);
}
- rc = mds_get_md(obd, inode, lmm, &lmm_size, lock);
+ rc = mds_get_md(obd, inode, lmm, &lmm_size, lock, flags);
if (rc > 0) {
if (S_ISDIR(inode->i_mode))
body->valid |= OBD_MD_FLDIREA;
struct mds_body *body;
struct inode *inode = dentry->d_inode;
int rc = 0;
+ int flags = 0;
ENTRY;
if (inode == NULL)
if ((S_ISREG(inode->i_mode) && (reqbody->valid & OBD_MD_FLEASIZE)) ||
(S_ISDIR(inode->i_mode) && (reqbody->valid & OBD_MD_FLDIREA))) {
+ if (lustre_msg_get_opc(req->rq_reqmsg) == MDS_GETATTR &&
+ ((S_ISDIR(inode->i_mode) && (reqbody->valid & OBD_MD_FLDIREA))))
+ flags = MDS_GETATTR;
+
rc = mds_pack_md(obd, req->rq_repmsg, reply_off, body,
- inode, 1);
+ inode, 1, flags);
/* If we have LOV EA data, the OST holds size, atime, mtime */
if (!(body->valid & OBD_MD_FLEASIZE) &&
UNLOCK_INODE_MUTEX(inode);
CDEBUG(D_INODE, "got %d bytes MD data for inode %lu\n",
rc, inode->i_ino);
+ if ((rc == 0) && (lustre_msg_get_opc(req->rq_reqmsg) == MDS_GETATTR) &&
+ ((S_ISDIR(inode->i_mode) && (body->valid & OBD_MD_FLDIREA))))
+ rc = sizeof(struct lov_mds_md);
if (rc < 0) {
if (rc != -ENODATA) {
CERROR("error getting inode %lu MD: rc = %d\n",
int mds_post_mds_lovconf(struct obd_device *obd);
int mds_notify(struct obd_device *obd, struct obd_device *watched,
enum obd_notify_event ev, void *data);
+int mds_get_default_md(struct obd_device *obd, struct lov_mds_md *lmm,
+ int *lmmsize);
int mds_convert_lov_ea(struct obd_device *obd, struct inode *inode,
struct lov_mds_md *lmm, int lmm_size);
void mds_objids_from_lmm(obd_id *ids, struct lov_mds_md *lmm,
int mds_init_export(struct obd_export *exp);
#ifdef __KERNEL__
int mds_get_md(struct obd_device *, struct inode *, void *md, int *size,
- int lock);
+ int lock, int flags);
int mds_pack_md(struct obd_device *, struct lustre_msg *, int offset,
- struct mds_body *, struct inode *, int lock);
+ struct mds_body *, struct inode *, int lock, int flags);
void mds_pack_inode2fid(struct ll_fid *fid, struct inode *inode);
void mds_pack_inode2body(struct mds_body *body, struct inode *inode);
#endif
GOTO(cleanup, rc);
}
- rc = mds_get_md(obd, tail_inode, tail_lmm, &lmm_size, 1);
+ rc = mds_get_md(obd, tail_inode, tail_lmm, &lmm_size, 1, 0);
if (rc < 0) /* get md fails */
GOTO(cleanup, rc);
LOCK_INODE_MUTEX(head_inode);
cleanup_phase = 1;
- rc = mds_get_md(obd, head_inode, head_lmm, &size, 0);
+ rc = mds_get_md(obd, head_inode, head_lmm, &size, 0, 0);
if (rc < 0)
GOTO(cleanup, rc);
RETURN(rc);
}
+int mds_get_default_md(struct obd_device *obd, struct lov_mds_md *lmm,
+ int *size)
+{
+ struct lov_desc *ldesc;
+ ENTRY;
+
+ ldesc = &obd->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));
+}
+
/* Convert the on-disk LOV EA structre.
* We always try to convert from an old LOV EA format to the common in-memory
* (lsm) format (obd_unpackmd() understands the old on-disk (lmm) format) and
lmm_size = mds->mds_max_mdsize;
rc = mds_get_md(obd, dchild->d_parent->d_inode,
- lmm, &lmm_size, 1);
+ lmm, &lmm_size, 1, 0);
if (rc > 0)
rc = obd_iocontrol(OBD_IOC_LOV_SETSTRIPE,
mds->mds_osc_exp,
mds_pack_inode2body(body, dchild->d_inode);
if (S_ISREG(dchild->d_inode->i_mode)) {
rc = mds_pack_md(obd, req->rq_repmsg, DLM_REPLY_REC_OFF + 1,
- body, dchild->d_inode, 1);
+ body, dchild->d_inode, 1, 0);
if (rc)
LASSERT(rc == req->rq_status);
if (S_ISREG(dchild->d_inode->i_mode) &&
!(body->valid & OBD_MD_FLEASIZE)) {
rc = mds_pack_md(obd, req->rq_repmsg, DLM_REPLY_REC_OFF + 1,
- body, dchild->d_inode, 0);
+ body, dchild->d_inode, 0, 0);
if (rc) {
UNLOCK_INODE_MUTEX(dchild->d_inode);
RETURN(rc);
mds_pack_inode2fid(&body->fid1, inode);
mds_pack_inode2body(body, inode);
mds_pack_md(obd, req->rq_repmsg, REPLY_REC_OFF + 1, body, inode,
- MDS_PACK_MD_LOCK);
+ MDS_PACK_MD_LOCK, 0);
}
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
GOTO(cleanup, rc = -ENOMEM);
cleanup_phase = 2;
- rc = mds_get_md(obd, inode, lmm, &lmm_size, need_lock);
+ rc = mds_get_md(obd, inode, lmm, &lmm_size, need_lock, 0);
if (rc < 0)
GOTO(cleanup, rc);
rc = 0;
if (S_ISDIR(inode->i_mode)) {
struct lov_mds_md lmm;
int lmm_size = sizeof(lmm);
- rc = mds_get_md(obd, dir, &lmm, &lmm_size, 1);
+ rc = mds_get_md(obd, dir, &lmm, &lmm_size, 1, 0);
if (rc > 0) {
LOCK_INODE_MUTEX(inode);
rc = fsfilt_set_md(obd, inode, handle,
mds_pack_inode2fid(&body->fid1, child_inode);
mds_pack_inode2body(body, child_inode);
mds_pack_md(obd, req->rq_repmsg, offset + 1, body,
- child_inode, MDS_PACK_MD_LOCK);
+ child_inode, MDS_PACK_MD_LOCK, 0);
}
}
mds_pack_inode2fid(&body->fid1, new_inode);
mds_pack_inode2body(body, new_inode);
mds_pack_md(obd, req->rq_repmsg, offset + 1, body,
- new_inode, MDS_PACK_MD_LOCK);
+ new_inode, MDS_PACK_MD_LOCK, 0);
}
}
if (lmm == NULL)
RETURN(-ENOMEM);
- rc = mds_get_md(obd, inode, lmm, &lmm_size, 1);
+ rc = mds_get_md(obd, inode, lmm, &lmm_size, 1, 0);
if (rc < 0)
GOTO(out_free_lmm, rc);
/* if it's a directory */
if (is_dir) {
if (obdstripe == 1) {
- printf("default stripe_count: %d stripe_size: %u "
+ if (lum->lmm_object_gr == LOV_OBJECT_GROUP_DEFAULT) {
+ printf("(Default) ");
+ lum->lmm_object_gr = LOV_OBJECT_GROUP_CLEAR;
+ }
+ printf("stripe_count: %d stripe_size: %u "
"stripe_offset: %d\n",
lum->lmm_stripe_count == (__u16)-1 ? -1 :
lum->lmm_stripe_count,