Whamcloud - gitweb
Write out MDS last_rcvd when first created, don't wait for a client connect.
authoradilger <adilger>
Fri, 12 Sep 2003 08:23:50 +0000 (08:23 +0000)
committeradilger <adilger>
Fri, 12 Sep 2003 08:23:50 +0000 (08:23 +0000)
b=1600

lustre/include/linux/lustre_fsfilt.h
lustre/mds/handler.c
lustre/mds/mds_fs.c
lustre/mds/mds_reint.c
lustre/obdclass/fsfilt_ext3.c
lustre/obdclass/fsfilt_extN.c
lustre/obdfilter/filter.c

index 37ffc4f..72b2292 100644 (file)
@@ -61,8 +61,8 @@ struct fsfilt_operations {
         int     (* fs_sync)(struct super_block *sb);
         int     (* fs_prep_san_write)(struct inode *inode, long *blocks,
                                       int nblocks, loff_t newsize);
-        int     (* fs_write_record)(struct file *, char *, int size, loff_t *);
-        int     (* fs_read_record)(struct file *, char *, int size, loff_t *);
+        int     (* fs_write_record)(struct file *, void *, int size, loff_t *);
+        int     (* fs_read_record)(struct file *, void *, int size, loff_t *);
 };
 
 extern int fsfilt_register_ops(struct fsfilt_operations *fs_ops);
@@ -206,13 +206,13 @@ static inline int fs_prep_san_write(struct obd_device *obd,
 }
 
 static inline int fsfilt_read_record(struct obd_device *obd, struct file *file,
-                                     char *buf, loff_t size, loff_t *offs)
+                                     void *buf, loff_t size, loff_t *offs)
 {
         return obd->obd_fsops->fs_read_record(file, buf, size, offs);
 }
 
 static inline int fsfilt_write_record(struct obd_device *obd, struct file *file,
-                                      char *buf, loff_t size, loff_t *offs)
+                                      void *buf, loff_t size, loff_t *offs)
 {
         return obd->obd_fsops->fs_write_record(file, buf, size, offs);
 }
index b90bdc1..8130ffe 100644 (file)
@@ -1539,7 +1539,7 @@ int mds_update_server_data(struct obd_device *obd)
 
         CDEBUG(D_SUPER, "MDS mount_count is "LPU64", last_transno is "LPU64"\n",
                mds->mds_mount_count, mds->mds_last_transno);
-        rc = fsfilt_write_record(obd, filp, (char *)msd, sizeof(*msd), &off);
+        rc = fsfilt_write_record(obd, filp, msd, sizeof(*msd), &off);
         if (rc != sizeof(*msd)) {
                 CERROR("error writing MDS server data: rc = %d\n", rc);
                 if (rc > 0)
index 56346ca..224591a 100644 (file)
@@ -125,7 +125,7 @@ int mds_client_add(struct obd_device *obd, struct mds_obd *mds,
                                (int)written);
                 } else {
                         written = fsfilt_write_record(obd, mds->mds_rcvd_filp,
-                                                      (char *)med->med_mcd,
+                                                      med->med_mcd,
                                                       sizeof(*med->med_mcd),
                                                       &off);
                         fsfilt_commit(obd,mds->mds_rcvd_filp->f_dentry->d_inode,
@@ -174,9 +174,8 @@ int mds_client_free(struct obd_export *exp)
 
         memset(&zero_mcd, 0, sizeof zero_mcd);
         push_ctxt(&saved, &mds->mds_ctxt, NULL);
-        written = fsfilt_write_record(obd, mds->mds_rcvd_filp,
-                                      (char *)&zero_mcd, sizeof(zero_mcd),
-                                      &med->med_off);
+        written = fsfilt_write_record(obd, mds->mds_rcvd_filp, &zero_mcd,
+                                      sizeof(zero_mcd), &med->med_off);
         pop_ctxt(&saved, &mds->mds_ctxt, NULL);
 
         if (written != sizeof(zero_mcd)) {
@@ -233,16 +232,23 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file)
         mds->mds_server_data = msd;
 
         if (last_rcvd_size == 0) {
+                int written;
                 CWARN("%s: initializing new %s\n", obd->obd_name, LAST_RCVD);
                 memcpy(msd->msd_uuid, obd->obd_uuid.uuid,sizeof(msd->msd_uuid));
                 msd->msd_server_size = cpu_to_le32(MDS_LR_SERVER_SIZE);
                 msd->msd_client_start = cpu_to_le32(MDS_LR_CLIENT_START);
                 msd->msd_client_size = cpu_to_le16(MDS_LR_CLIENT_SIZE);
+                written = fsfilt_write_record(obd, file, msd, sizeof(*msd),
+                                              &off);
 
-                RETURN(0);
+                if (written == sizeof(*msd))
+                        RETURN(0);
+                CERROR("%s: error writing new MSD: %d\n", obd->obd_name,
+                       written);
+                GOTO(err_msd, rc = (written < 0 ? written : -EIO));
         }
 
-        rc = fsfilt_read_record(obd, file, (char *)msd, sizeof(*msd), &off);
+        rc = fsfilt_read_record(obd, file, msd, sizeof(*msd), &off);
 
         if (rc != sizeof(*msd)) {
                 CERROR("error reading MDS %s: rc = %d\n", LAST_RCVD,rc);
@@ -308,8 +314,7 @@ static int mds_read_last_rcvd(struct obd_device *obd, struct file *file)
                  */
                 off = le32_to_cpu(msd->msd_client_start) +
                         cl_idx * le16_to_cpu(msd->msd_client_size);
-                rc = fsfilt_read_record(obd, file, (char *)mcd,
-                                        sizeof(*mcd), &off);
+                rc = fsfilt_read_record(obd, file, mcd, sizeof(*mcd), &off);
                 if (rc != sizeof(*mcd)) {
                         CERROR("error reading MDS %s offset %d: rc = %d\n",
                                LAST_RCVD, cl_idx, rc);
index 61871d7..7255bf7 100644 (file)
@@ -170,7 +170,7 @@ int mds_finish_transno(struct mds_obd *mds, struct inode *inode, void *handle,
         fsfilt_set_last_rcvd(req->rq_export->exp_obd, transno, handle,
                              mds_commit_cb, NULL);
         written = fsfilt_write_record(obd, mds->mds_rcvd_filp,
-                                      (char *)mcd, sizeof(*mcd), &off);
+                                      mcd, sizeof(*mcd), &off);
         CDEBUG(D_INODE, "wrote trans "LPU64" client %s at idx %u: written = "
                LPSZ"\n", transno, mcd->mcd_uuid, med->med_idx, written);
 
index 24844ff..c0c839a 100644 (file)
@@ -523,7 +523,7 @@ static int fsfilt_ext3_prep_san_write(struct inode *inode, long *blocks,
         return ext3_prep_san_write(inode, blocks, nblocks, newsize);
 }
 
-static int fsfilt_ext3_read_record(struct file * file, char *buf,
+static int fsfilt_ext3_read_record(struct file * file, void *buf,
                                    int size, loff_t *offs)
 {
         struct buffer_head *bh;
@@ -558,7 +558,7 @@ static int fsfilt_ext3_read_record(struct file * file, char *buf,
         return size;
 }
 
-static int fsfilt_ext3_write_record(struct file * file, char *buf,
+static int fsfilt_ext3_write_record(struct file * file, void *buf,
                                     int size, loff_t *offs)
 {
         struct buffer_head *bh;
index d167ce9..ac97d5a 100644 (file)
@@ -509,7 +509,7 @@ static int fsfilt_extN_prep_san_write(struct inode *inode, long *blocks,
         return extN_prep_san_write(inode, blocks, nblocks, newsize);
 }
 
-static int fsfilt_extN_read_record(struct file * file, char *buf,
+static int fsfilt_extN_read_record(struct file * file, void *buf,
                                    int size, loff_t *offs)
 {
         struct buffer_head *bh;
@@ -544,7 +544,7 @@ static int fsfilt_extN_read_record(struct file * file, char *buf,
         return size;
 }
 
-static int fsfilt_extN_write_record(struct file * file, char *buf,
+static int fsfilt_extN_write_record(struct file * file, void *buf,
                                     int size, loff_t *offs)
 {
         struct buffer_head *bh;
index 41eb140..e2b1d30 100644 (file)
@@ -228,7 +228,7 @@ int filter_finish_transno(struct obd_export *exp, struct obd_trans_info *oti,
                 fsfilt_set_last_rcvd(exp->exp_obd, last_rcvd, oti->oti_handle,
                                      filter_commit_cb, NULL);
                 written = fsfilt_write_record(exp->exp_obd,
-                                              filter->fo_rcvd_filp, (char *)fcd,
+                                              filter->fo_rcvd_filp, fcd,
                                               sizeof(*fcd), &off);
                 CDEBUG(D_HA, "wrote trans #"LPD64" for client %s at #%d: "
                        "written = "LPSZ"\n", last_rcvd, fcd->fcd_uuid,
@@ -337,8 +337,9 @@ static int filter_client_add(struct obd_device *obd, struct filter_obd *filter,
                                (int)written);
                 } else {
                         written = fsfilt_write_record(obd, filter->fo_rcvd_filp,
-                                                (char *)fed->fed_fcd,
-                                                sizeof(*fed->fed_fcd), &off);
+                                                      fed->fed_fcd,
+                                                      sizeof(*fed->fed_fcd),
+                                                      &off);
                         fsfilt_commit(obd,
                                       filter->fo_rcvd_filp->f_dentry->d_inode,
                                       handle, 0);
@@ -393,8 +394,7 @@ static int filter_client_free(struct obd_export *exp, int flags)
         memset(&zero_fcd, 0, sizeof zero_fcd);
         push_ctxt(&saved, &filter->fo_ctxt, NULL);
         written = fsfilt_write_record(obd, filter->fo_rcvd_filp,
-                                      (char *)&zero_fcd, sizeof(zero_fcd),
-                                      &off);
+                                      &zero_fcd, sizeof(zero_fcd), &off);
 
         /* XXX: this write gets lost sometimes, unless this sync is here. */
         if (written > 0)
@@ -444,7 +444,7 @@ int filter_update_server_data(struct obd_device *obd,
         CDEBUG(D_INODE, "server last_mount: "LPU64"\n",
                le64_to_cpu(fsd->fsd_mount_count));
 
-        rc = fsfilt_write_record(obd, filp, (char *)fsd, sizeof(*fsd), &off);
+        rc = fsfilt_write_record(obd, filp, fsd, sizeof(*fsd), &off);
         if (rc == sizeof(*fsd))
                 RETURN(0);
 
@@ -499,7 +499,7 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp,
                 fsd->fsd_subdir_count = cpu_to_le16(FILTER_SUBDIR_COUNT);
                 filter->fo_subdir_count = FILTER_SUBDIR_COUNT;
         } else {
-                int retval = fsfilt_read_record(obd, filp, (char *)fsd,
+                int retval = fsfilt_read_record(obd, filp, fsd,
                                                 sizeof(*fsd), &off);
                 if (retval != sizeof(*fsd)) {
                         CDEBUG(D_INODE,"OBD filter: error reading %s: rc %d\n",
@@ -560,8 +560,7 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp,
                  */
                 off = le32_to_cpu(fsd->fsd_client_start) +
                         cl_idx * le16_to_cpu(fsd->fsd_client_size);
-                rc = fsfilt_read_record(obd, filp, (char *)fcd, sizeof(*fcd),
-                                        &off);
+                rc = fsfilt_read_record(obd, filp, fcd, sizeof(*fcd), &off);
                 if (rc != sizeof(*fcd)) {
                         CERROR("error reading FILTER %s offset %d: rc = %d\n",
                                LAST_RCVD, cl_idx, rc);