#define LOV_MAGIC 0x0BD00BD0
-struct lov_stripe_md {
+struct lov_mds_md {
__u32 lmd_magic;
__u32 lmd_easize; /* packed size of extended */
__u64 lmd_object_id; /* lov object id */
__u32 fd_flags;
};
+
struct ll_inode_md {
struct mds_body *body;
struct lov_stripe_md *md;
int (* fs_setattr)(struct dentry *dentry, void *handle,
struct iattr *iattr);
int (* fs_set_md)(struct inode *inode, void *handle,
- struct lov_stripe_md *md);
+ struct lov_mds_md *md);
int (* fs_get_md)(struct inode *inode,
- struct lov_stripe_md *md);
+ struct lov_mds_md *md);
ssize_t (* fs_readpage)(struct file *file, char *buf, size_t count,
loff_t *offset);
void (* fs_delete_inode)(struct inode *inode);
}
static inline int mds_fs_set_md(struct mds_obd *mds, struct inode *inode,
- void *handle, struct lov_stripe_md *md)
+ void *handle, struct lov_mds_md *md)
{
return mds->mds_fsops->fs_set_md(inode, handle, md);
}
static inline int mds_fs_get_md(struct mds_obd *mds, struct inode *inode,
- struct lov_stripe_md *md)
+ struct lov_mds_md *md)
{
return mds->mds_fsops->fs_get_md(inode, md);
}
obd_flag flag;
};
+struct lov_oinfo { /* per-child structure */
+ __u64 loi_id;
+ __u64 loi_size;
+};
+
+struct lov_stripe_md {
+ __u32 lmd_magic;
+ __u32 lmd_easize; /* packed size for MDS of ea */
+ __u64 lmd_object_id; /* lov object id */
+ __u64 lmd_stripe_offset; /* offset of the stripe */
+ __u64 lmd_stripe_size; /* size of the stripe */
+ __u32 lmd_stripe_count; /* how many objects are being striped */
+ __u32 lmd_stripe_pattern; /* per-lov object stripe pattern */
+ struct lov_oinfo lmd_oinfo[0];
+};
+
+struct lov_stripe_md_one {
+ __u32 lmd_magic;
+ __u32 lmd_easize; /* packed size for MDS of ea */
+ __u64 lmd_object_id; /* lov object id */
+ __u64 lmd_stripe_offset; /* offset of the stripe */
+ __u64 lmd_stripe_size; /* size of the stripe */
+ __u32 lmd_stripe_count; /* how many objects are being striped */
+ __u32 lmd_stripe_pattern; /* per-lov object stripe pattern */
+ struct lov_oinfo lmd_oinfo[1];
+};
+
/* Individual type definitions */
struct ext2_obd {
void lov_unpackdesc(struct lov_desc *ld);
void lov_packdesc(struct lov_desc *ld);
-
+void lov_packmd(struct lov_mds_md *mdsmd, struct lov_stripe_md *md);
#endif
#endif
LDLM_REPLY_PORTAL, mdc->cl_ldlm_client);
mdc->cl_client->cli_name = "mdc";
mdc->cl_ldlm_client->cli_name = "ldlm";
- mdc->cl_max_mdsize = sizeof(struct lov_stripe_md);
+ mdc->cl_max_mdsize = sizeof(struct lov_mds_md);
MOD_INC_USE_COUNT;
RETURN(0);
ld->ld_default_stripe_size = HTON__u32(ld->ld_default_stripe_size);
ld->ld_pattern = HTON__u32(ld->ld_pattern);
}
+
+void lov_packmd(struct lov_mds_md *mdsmd, struct lov_stripe_md *md)
+{
+ int i;
+ mdsmd->lmd_magic = md->lmd_magic;
+ mdsmd->lmd_easize = md->lmd_easize;
+ mdsmd->lmd_object_id = md->lmd_object_id;
+ mdsmd->lmd_stripe_offset = md->lmd_stripe_offset;
+ mdsmd->lmd_stripe_count = md->lmd_stripe_count;
+ mdsmd->lmd_stripe_size = md->lmd_stripe_size;
+ mdsmd->lmd_stripe_pattern = md->lmd_stripe_pattern;
+
+ for (i=0; i<md->lmd_stripe_count; i++)
+ mdsmd->lmd_objects[i].l_object_id = md->lmd_oinfo[i].loi_id;
+}
oa->o_id = lli->lli_smd->lmd_object_id;
oa->o_mode = S_IFREG | inode->i_mode;
- oa->o_valid = OBD_MD_FLMODE | OBD_MD_FLID;
+ oa->o_valid = OBD_MD_FLMODE | OBD_MD_FLID | OBD_MD_FLSIZE;
rc = obd_open(ll_i2obdconn(inode), oa, lli->lli_smd);
obdo_free(oa);
oa = NULL;
int size;
size = sizeof(struct lov_stripe_md) +
+ lov->desc.ld_tgt_count * sizeof(struct lov_oinfo);
+ return size;
+}
+
+static inline int lov_mds_md_size(struct obd_device *obd)
+{
+ struct lov_obd *lov = &obd->u.lov;
+ int size;
+
+ size = sizeof(struct lov_mds_md) +
lov->desc.ld_tgt_count * sizeof(struct lov_object_id);
return size;
}
}
md = *ea;
- md->lmd_easize = oa->o_easize;
+ md->lmd_easize = lov_mds_md_size(export->exp_obd);
md->lmd_object_id = oa->o_id;
if (!md->lmd_stripe_count) {
md->lmd_stripe_count = lov->desc.ld_default_stripe_count;
rc = obd_create(&lov->tgts[i].conn, &tmp, &obj_mdp);
if (rc)
GOTO(out_cleanup, rc);
- md->lmd_objects[i].l_object_id = tmp.o_id;
+ md->lmd_oinfo[i].loi_id = tmp.o_id;
+ md->lmd_oinfo[i].loi_size = tmp.o_size;
}
out_cleanup:
int i2, rc2;
for (i2 = 0 ; i2 < i ; i2++) {
/* destroy already created objects here */
- tmp.o_id = md->lmd_objects[i].l_object_id;
+ tmp.o_id = md->lmd_oinfo[i].loi_id;
rc2 = obd_destroy(&lov->tgts[i].conn, &tmp, NULL);
if (rc2) {
CERROR("Failed to remove object from target %d\n",
for (i = 0; i < md->lmd_stripe_count; i++) {
/* create data objects with "parent" OA */
memcpy(&tmp, oa, sizeof(tmp));
- tmp.o_id = md->lmd_objects[i].l_object_id;
+ tmp.o_id = md->lmd_oinfo[i].loi_id;
rc = obd_destroy(&lov->tgts[i].conn, &tmp, NULL);
if (!rc) {
CERROR("Error destroying object %Ld on %d\n",
for (i = 0; i < md->lmd_stripe_count; i++) {
/* create data objects with "parent" OA */
memcpy(&tmp, oa, sizeof(tmp));
- oa->o_id = md->lmd_objects[i].l_object_id;
+ oa->o_id = md->lmd_oinfo[i].loi_id;
rc = obd_getattr(&lov->tgts[i].conn, &tmp, NULL);
if (!rc) {
for (i = 0; i < md->lmd_stripe_count; i++) {
/* create data objects with "parent" OA */
memcpy(&tmp, oa, sizeof(tmp));
- oa->o_id = md->lmd_objects[i].l_object_id;
+ oa->o_id = md->lmd_oinfo[i].loi_id;
rc = obd_setattr(&lov->tgts[i].conn, &tmp, NULL);
if (!rc) {
for (i = 0; i < md->lmd_stripe_count; i++) {
/* create data objects with "parent" OA */
memcpy(&tmp, oa, sizeof(tmp));
- oa->o_id = md->lmd_objects[i].l_object_id;
+ tmp.o_id = md->lmd_oinfo[i].loi_id;
rc = obd_open(&lov->tgts[i].conn, &tmp, NULL);
if (rc) {
for (i = 0; i < md->lmd_stripe_count; i++) {
/* create data objects with "parent" OA */
memcpy(&tmp, oa, sizeof(tmp));
- oa->o_id = md->lmd_objects[i].l_object_id;
+ tmp.o_id = md->lmd_oinfo[i].loi_id;
rc = obd_close(&lov->tgts[i].conn, &tmp, NULL);
if (!rc) {
continue;
/* create data objects with "parent" OA */
memcpy(&tmp, oa, sizeof(tmp));
- oa->o_id = md->lmd_objects[i].l_object_id;
+ oa->o_id = md->lmd_oinfo[i].loi_id;
rc = obd_punch(&lov->tgts[i].conn, &tmp, NULL,
starti, endi);
stripeinfo[i].index =
stripeinfo[i-1].index + stripeinfo[i-1].bufct;
stripeinfo[i].md.lmd_object_id =
- md->lmd_objects[i].l_object_id;
+ md->lmd_oinfo[i].loi_id;
}
for (i=0 ; i < oa_bufs ; i++ ) {
int rc = 0, i;
struct obd_export *export = class_conn2export(conn);
struct lov_obd *lov;
+ struct lov_stripe_md submd;
ENTRY;
if (!md) {
for (i = 0; i < md->lmd_stripe_count; i++) {
struct ldlm_extent *extent = (struct ldlm_extent *)cookie;
struct ldlm_extent sub_ext;
- struct lov_stripe_md submd;
sub_ext.start = lov_offset(md, extent->start, i);
sub_ext.end = lov_offset(md, extent->end, i);
if ( sub_ext.start == sub_ext.end )
continue;
- submd.lmd_object_id = md->lmd_objects[i].l_object_id;
+ submd.lmd_object_id = md->lmd_oinfo[i].loi_id;
submd.lmd_easize = sizeof(submd);
submd.lmd_stripe_count = md->lmd_stripe_count;
/* XXX submd is not fully initialized here */
// XXX add a lock debug statement here
if (rc) {
CERROR("Error obd_enqueu object %Ld subobj %Ld\n", md->lmd_object_id,
- md->lmd_objects[i].l_object_id);
+ md->lmd_oinfo[i].loi_id);
}
}
RETURN(rc);
if ( lockhs[i].addr == 0 )
continue;
- submd.lmd_object_id = md->lmd_objects[i].l_object_id;
+ submd.lmd_object_id = md->lmd_oinfo[i].loi_id;
submd.lmd_easize = sizeof(submd);
rc = obd_cancel(&lov->tgts[i].conn, &submd, mode, &lockhs[i]);
if (!rc) {
CERROR("Error punch object %Ld subobj %Ld\n", md->lmd_object_id,
- md->lmd_objects[i].l_object_id);
+ md->lmd_oinfo[i].loi_id);
}
}
RETURN(rc);
*uuids = lustre_msg_buf(req->rq_repmsg, 1);
lov_unpackdesc(desc);
mdc->cl_max_mdsize = sizeof(struct lov_stripe_md) +
- desc->ld_tgt_count * sizeof(struct lov_object_id);
+ desc->ld_tgt_count * sizeof(struct lov_oinfo);
}
EXIT;
body->extra = cookie;
if (smd != NULL)
- memcpy(lustre_msg_buf(req->rq_reqmsg, 1), smd, smd->lmd_easize);
+ lov_packmd(lustre_msg_buf(req->rq_reqmsg, 1), smd);
req->rq_replen = lustre_msg_size(1, size);
RETURN(0);
}
- mds->mds_max_mdsize = sizeof(struct lov_stripe_md) +
+ mds->mds_max_mdsize = sizeof(struct lov_mds_md) +
tgt_count * sizeof(struct lov_object_id);
rc = mds_get_lovtgts(req->rq_obd, tgt_count,
lustre_msg_buf(req->rq_repmsg, 1));
mds_pack_inode2fid(&body->fid1, inode);
mds_pack_inode2body(body, inode);
if (S_ISREG(inode->i_mode)) {
- struct lov_stripe_md *md;
+ struct lov_mds_md *md;
md = lustre_msg_buf(req->rq_repmsg, reply_off + 1);
md->lmd_easize = mds->mds_max_mdsize;
/* check if this inode has seen a delayed object creation */
if (req->rq_reqmsg->bufcount > 1) {
void *handle;
- struct lov_stripe_md *md;
+ struct lov_mds_md *md;
struct inode *inode = de->d_inode;
int rc;
if (!mds->mds_sb)
GOTO(err_put, rc = -ENODEV);
- mds->mds_max_mdsize = sizeof(struct lov_stripe_md);
+ mds->mds_max_mdsize = sizeof(struct lov_mds_md);
rc = mds_fs_setup(obddev, mnt);
if (rc) {
CERROR("MDS filesystem method init failed: rc = %d\n", rc);
/* If the client is about to open a file that doesn't have an MD
* stripe record, it's going to need a write lock. */
if (it->opc & IT_OPEN) {
- struct lov_stripe_md *md =
+ struct lov_mds_md *md =
lustre_msg_buf(req->rq_repmsg, 2);
if (md->lmd_easize == 0) {
LDLM_DEBUG(lock, "open with no EA; returning PW"
}
static int mds_extN_set_md(struct inode *inode, void *handle,
- struct lov_stripe_md *md)
+ struct lov_mds_md *md)
{
int rc;
return rc;
}
-static int mds_extN_get_md(struct inode *inode, struct lov_stripe_md *md)
+static int mds_extN_get_md(struct inode *inode, struct lov_mds_md *md)
{
int rc;
int size = md->lmd_easize;
if (dchild->d_inode) {
struct mds_body *body;
struct inode *inode = dchild->d_inode;
- struct lov_stripe_md *md;
+ struct lov_mds_md *md;
CDEBUG(D_INODE, "child exists (dir %ld, name %s, ino %ld)\n",
dir->i_ino, rec->ur_name, dchild->d_inode->i_ino);
CDEBUG(D_INODE, "created ino %ld\n", dchild->d_inode->i_ino);
if (!offset && type == S_IFREG) {
- struct lov_stripe_md *md;
+ struct lov_mds_md *md;
md = lustre_msg_buf(req->rq_reqmsg, 2);
rc = mds_fs_set_md(mds, inode, handle, md);
if (rc) {
break;
case S_IFREG:
if ((inode->i_mode & S_IFMT) == S_IFREG && offset) {
- struct lov_stripe_md *md;
+ struct lov_mds_md *md;
md = lustre_msg_buf(req->rq_repmsg, 2);
md->lmd_easize = mds->mds_max_mdsize;
obd = class_conn2obd(conn);
dentry = filter_fid2dentry(obd, filter_parent(obd, oa->o_mode),
oa->o_id, oa->o_mode);
+ oa->o_size = dentry->d_inode->i_size;
if (IS_ERR(dentry))
RETURN(PTR_ERR(dentry));