Whamcloud - gitweb
- give inodes more metadata for objects. Per stripe we now maintain:
authorbraam <braam>
Wed, 21 Aug 2002 17:05:43 +0000 (17:05 +0000)
committerbraam <braam>
Wed, 21 Aug 2002 17:05:43 +0000 (17:05 +0000)
  - id
  - size
  - soon: also flags indicating if we have a "size" lock on the object
- fix two lov bugs (open/close) - both used the wrong oa.

14 files changed:
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_lite.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/obd.h
lustre/include/linux/obd_lov.h
lustre/lib/l_net.c
lustre/lib/lov_pack.c
lustre/llite/file.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/mds_extN.c
lustre/mds/mds_reint.c
lustre/obdfilter/filter.c

index 488ccf7..2bb996f 100644 (file)
@@ -197,7 +197,7 @@ struct lov_object_id { /* per-child structure */
 
 #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 */
index 04daae4..b89d829 100644 (file)
@@ -29,6 +29,7 @@ struct ll_file_data {
         __u32 fd_flags;
 };
 
+
 struct ll_inode_md {
         struct mds_body *body;
         struct lov_stripe_md *md;
index 45ec453..6fecf23 100644 (file)
@@ -193,9 +193,9 @@ struct mds_fs_operations {
         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);
@@ -236,13 +236,13 @@ static inline int mds_fs_setattr(struct mds_obd *mds, struct dentry *dentry,
 }
 
 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);
 }
index 8474b78..73d0045 100644 (file)
@@ -31,6 +31,33 @@ struct brw_page {
         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 {
index 4d50153..11f3a48 100644 (file)
@@ -11,7 +11,7 @@
 
 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
index 239f8c0..10041bb 100644 (file)
@@ -105,7 +105,7 @@ int client_obd_setup(struct obd_device *obddev, obd_count len, void *buf)
                            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);
index d8b9b3e..b957eeb 100644 (file)
@@ -42,3 +42,18 @@ void lov_unpackdesc(struct lov_desc *ld)
         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;
+}
index 9ac392c..37dccc6 100644 (file)
@@ -100,7 +100,7 @@ static int ll_file_open(struct inode *inode, struct file *file)
 
         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;
index 005ec64..c804bd8 100644 (file)
@@ -184,6 +184,16 @@ static inline int lov_stripe_md_size(struct obd_device *obd)
         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;
 }
@@ -214,7 +224,7 @@ static int lov_create(struct lustre_handle *conn, struct obdo *oa, struct lov_st
         }
 
         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;
@@ -234,7 +244,8 @@ static int lov_create(struct lustre_handle *conn, struct obdo *oa, struct lov_st
                 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: 
@@ -242,7 +253,7 @@ static int lov_create(struct lustre_handle *conn, struct obdo *oa, struct lov_st
                 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", 
@@ -274,7 +285,7 @@ static int lov_destroy(struct lustre_handle *conn, struct obdo *oa,
         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",
@@ -305,7 +316,7 @@ static int lov_getattr(struct lustre_handle *conn, struct obdo *oa,
         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) { 
@@ -346,7 +357,7 @@ static int lov_setattr(struct lustre_handle *conn, struct obdo *oa,
         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) { 
@@ -378,7 +389,7 @@ static int lov_open(struct lustre_handle *conn, struct obdo *oa,
         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) { 
@@ -412,7 +423,7 @@ static int lov_close(struct lustre_handle *conn, struct obdo *oa,
         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) { 
@@ -502,7 +513,7 @@ static int lov_punch(struct lustre_handle *conn, struct obdo *oa,
                         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);
@@ -577,7 +588,7 @@ static inline int lov_brw(int cmd, struct lustre_handle *conn,
                         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++ ) { 
@@ -614,6 +625,7 @@ static int lov_enqueue(struct lustre_handle *conn, struct lov_stripe_md *md,
         int rc = 0, i;
         struct obd_export *export = class_conn2export(conn);
         struct lov_obd *lov;
+        struct lov_stripe_md submd;
         ENTRY;
 
         if (!md) { 
@@ -628,14 +640,13 @@ static int lov_enqueue(struct lustre_handle *conn, struct lov_stripe_md *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 */
@@ -644,7 +655,7 @@ static int lov_enqueue(struct lustre_handle *conn, struct lov_stripe_md *md,
                 // 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);
@@ -673,12 +684,12 @@ static int lov_cancel(struct lustre_handle *conn, struct lov_stripe_md *md, __u3
                 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);
index b0508bd..bd5badd 100644 (file)
@@ -128,7 +128,7 @@ int mdc_getlovinfo(struct obd_device *obd, struct lustre_handle *mdc_connh,
                 *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;
@@ -386,7 +386,7 @@ int mdc_open(struct lustre_handle *conn, obd_id ino, int type, int flags,
         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);
 
index 8d1d3c7..aac4edb 100644 (file)
@@ -406,7 +406,7 @@ static int mds_getlovinfo(struct ptlrpc_request *req)
                 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));
@@ -475,7 +475,7 @@ static int mds_getattr_internal(struct mds_obd *mds, struct dentry *dentry,
         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;
@@ -697,7 +697,7 @@ static int mds_open(struct ptlrpc_request *req)
         /* 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;
 
@@ -1089,7 +1089,7 @@ static int mds_setup(struct obd_device *obddev, obd_count len, void *buf)
         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);
@@ -1311,7 +1311,7 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
                 /* 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"
index db2d86d..b3a6888 100644 (file)
@@ -108,7 +108,7 @@ static int mds_extN_setattr(struct dentry *dentry, void *handle,
 }
 
 static int mds_extN_set_md(struct inode *inode, void *handle,
-                           struct lov_stripe_md *md)
+                           struct lov_mds_md *md)
 {
         int rc;
 
@@ -134,7 +134,7 @@ static int mds_extN_set_md(struct inode *inode, void *handle,
         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;
index e28066a..ab2409f 100644 (file)
@@ -235,7 +235,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         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);
 
@@ -316,7 +316,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
 
                 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) {
@@ -447,7 +447,7 @@ static int mds_reint_unlink(struct mds_update_record *rec, int offset,
                 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;
index 26a1b11..310f4de 100644 (file)
@@ -582,6 +582,7 @@ static int filter_open(struct lustre_handle *conn, struct obdo *oa,
         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));