Whamcloud - gitweb
b=15936 minor fixes noted in inspection
authorMikhail Pershin <tappro@sun.com>
Fri, 2 Jul 2010 13:14:30 +0000 (17:14 +0400)
committerRobert Read <robert.read@oracle.com>
Fri, 2 Jul 2010 20:44:16 +0000 (13:44 -0700)
i=adilger,zam

Use single place for mount count, unify mntdev getting, introduce
obt_magic to make sure obt is correct.

13 files changed:
lustre/include/lprocfs_status.h
lustre/include/lu_target.h
lustre/include/lustre_log.h
lustre/include/obd.h
lustre/mds/handler.c
lustre/mds/lproc_mds.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_recovery.c
lustre/obdclass/lprocfs_status.c
lustre/obdfilter/filter.c
lustre/obdfilter/lproc_obdfilter.c
lustre/ptlrpc/target.c

index 228ca9f..4555343 100644 (file)
@@ -659,7 +659,8 @@ int lprocfs_obd_rd_recovery_time_hard(char *page, char **start, off_t off,
                                       int count, int *eof, void *data);
 int lprocfs_obd_wr_recovery_time_hard(struct file *file, const char *buffer,
                                       unsigned long count, void *data);
-
+int lprocfs_obd_rd_mntdev(char *page, char **start, off_t off,
+                          int count, int *eof, void *data);
 /* all quota proc functions */
 extern int lprocfs_quota_rd_bunit(char *page, char **start, off_t off, int count,
                                   int *eof, void *data);
index 19bf8ff..1ec6e66 100644 (file)
@@ -57,8 +57,6 @@ struct lu_target {
         cfs_spinlock_t           lut_client_bitmap_lock;
         /** Bitmap of known clients */
         unsigned long           *lut_client_bitmap;
-        /** Number of mounts */
-        __u64                    lut_mount_count;
 };
 
 typedef void (*lut_cb_t)(struct lu_target *lut, __u64 transno,
index 8c0845d..634a19b 100644 (file)
@@ -389,6 +389,9 @@ static inline void llog_gen_init(struct llog_ctxt *ctxt)
 {
         struct obd_device *obd = ctxt->loc_exp->exp_obd;
 
+        LASSERTF(obd->u.obt.obt_magic == OBT_MAGIC,
+                 "%s: wrong obt magic %#x\n",
+                 obd->obd_name, obd->u.obt.obt_magic);
         ctxt->loc_gen.mnt_cnt = obd->u.obt.obt_mount_count;
         ctxt->loc_gen.conn_cnt++;
 }
index 1938cb1..79674c1 100644 (file)
@@ -228,8 +228,10 @@ struct brw_page {
 
 struct ost_server_data;
 
+#define OBT_MAGIC       0xBDDECEAE
 /* hold common fields for "target" device */
 struct obd_device_target {
+        __u32                     obt_magic;
         struct super_block       *obt_sb;
         /** last_rcvd file */
         struct file              *obt_rcvd_filp;
index 7fd6ec0..7430bb6 100644 (file)
@@ -318,7 +318,7 @@ static void mds_init_ctxt(struct obd_device *obd, struct vfsmount *mnt)
         mds->mds_obt.obt_vfsmnt = mnt;
         /* why not mnt->mnt_sb instead of mnt->mnt_root->d_inode->i_sb? */
         obd->u.obt.obt_sb = mnt->mnt_root->d_inode->i_sb;
-
+        obd->u.obt.obt_magic = OBT_MAGIC;
         fsfilt_setup(obd, obd->u.obt.obt_sb);
 
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
index 102e790..25ca6b6 100644 (file)
 #include "mds_internal.h"
 
 #ifdef LPROCFS
-static int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off, int count,
-                                 int *eof, void *data)
-{
-        struct obd_device* obd = (struct obd_device *)data;
-
-        LASSERT(obd != NULL);
-        LASSERT(obd->u.obt.obt_vfsmnt->mnt_devname);
-        *eof = 1;
-
-        return snprintf(page, count, "%s\n",obd->u.obt.obt_vfsmnt->mnt_devname);
-}
-
 static int lprocfs_mds_rd_evictostnids(char *page, char **start, off_t off,
                                        int count, int *eof, void *data)
 {
@@ -173,7 +161,7 @@ struct lprocfs_vars lprocfs_mds_obd_vars[] = {
         { "filestotal",      lprocfs_rd_filestotal,  0, 0 },
         { "filesfree",       lprocfs_rd_filesfree,   0, 0 },
         { "fstype",          lprocfs_rd_fstype,      0, 0 },
-        { "mntdev",          lprocfs_mds_rd_mntdev,  0, 0 },
+        { "mntdev",          lprocfs_obd_rd_mntdev,  0, 0 },
         { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
         { "hash_stats",      lprocfs_obd_rd_hash,    0, 0 },
         { "evict_client",    0,                lprocfs_mds_wr_evict_client, 0 },
index bf0f760..47502fc 100644 (file)
@@ -5245,7 +5245,8 @@ static int mdt_upcall(const struct lu_env *env, struct md_device *md,
                                      m->mdt_max_mdsize, m->mdt_max_cookiesize);
                         mdt_allow_cli(m, CONFIG_SYNC);
                         if (data)
-                                (*(__u64 *)data) = m->mdt_lut.lut_mount_count;
+                                (*(__u64 *)data) =
+                                      m->mdt_lut.lut_obd->u.obt.obt_mount_count;
                         break;
                 case MD_NO_TRANS:
                         mti = lu_context_key_get(&env->le_ctx, &mdt_thread_key);
index 2aef7e7..9de4773 100644 (file)
@@ -230,7 +230,7 @@ static int mdt_som_attr_set(struct mdt_thread_info *info,
                 ma->ma_som->msd_size = la->la_valid & LA_SIZE ? la->la_size : 0;
                 ma->ma_som->msd_blocks = la->la_valid & LA_BLOCKS ?
                                          la->la_blocks : 0;
-                ma->ma_som->msd_mountid = mdt->mdt_lut.lut_mount_count;
+                ma->ma_som->msd_mountid = mdt->mdt_lut.lut_obd->u.obt.obt_mount_count;
                 ma->ma_attr.la_valid &= LA_ATIME | LA_MTIME | LA_CTIME;
         } else {
                 ma->ma_som->msd_ioepoch = IOEPOCH_INVAL;
index bf658e0..61721c0 100644 (file)
@@ -472,8 +472,8 @@ static int mdt_server_data_init(const struct lu_env *env,
         obd->obd_last_committed = mdt->mdt_lut.lut_last_transno;
         cfs_spin_unlock(&mdt->mdt_lut.lut_translock);
 
-        mdt->mdt_lut.lut_mount_count = mount_count + 1;
-        lsd->lsd_mount_count = mdt->mdt_lut.lut_mount_count;
+        obd->u.obt.obt_mount_count = mount_count + 1;
+        lsd->lsd_mount_count = obd->u.obt.obt_mount_count;
 
         /* save it, so mount count and last_transno is current */
         rc = mdt_server_data_update(env, mdt);
@@ -503,7 +503,8 @@ static int mdt_server_data_update(const struct lu_env *env,
                 RETURN(PTR_ERR(th));
 
         CDEBUG(D_SUPER, "MDS mount_count is "LPU64", last_transno is "LPU64"\n",
-               mdt->mdt_lut.lut_mount_count, mdt->mdt_lut.lut_last_transno);
+               mdt->mdt_lut.lut_obd->u.obt.obt_mount_count,
+               mdt->mdt_lut.lut_last_transno);
 
         cfs_spin_lock(&mdt->mdt_lut.lut_translock);
         mdt->mdt_lut.lut_lsd.lsd_last_transno = mdt->mdt_lut.lut_last_transno;
index e134215..1a83697 100644 (file)
@@ -2305,6 +2305,19 @@ int lprocfs_obd_wr_recovery_time_hard(struct file *file, const char *buffer,
 }
 EXPORT_SYMBOL(lprocfs_obd_wr_recovery_time_hard);
 
+int lprocfs_obd_rd_mntdev(char *page, char **start, off_t off,
+                          int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+
+        LASSERT(obd != NULL);
+        LASSERT(obd->u.obt.obt_vfsmnt->mnt_devname);
+        *eof = 1;
+        return snprintf(page, count, "%s\n",
+                        obd->u.obt.obt_vfsmnt->mnt_devname);
+}
+EXPORT_SYMBOL(lprocfs_obd_rd_mntdev);
+
 EXPORT_SYMBOL(lprocfs_register);
 EXPORT_SYMBOL(lprocfs_srch);
 EXPORT_SYMBOL(lprocfs_remove);
index 56d7b83..82dfe24 100644 (file)
@@ -892,8 +892,8 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp)
 
         obd->obd_last_committed = le64_to_cpu(lsd->lsd_last_transno);
 out:
-        lut->lut_mount_count = mount_count + 1;
-        lsd->lsd_mount_count = cpu_to_le64(lut->lut_mount_count);
+        obd->u.obt.obt_mount_count = mount_count + 1;
+        lsd->lsd_mount_count = cpu_to_le64(obd->u.obt.obt_mount_count);
 
         /* save it, so mount count and last_transno is current */
         rc = filter_update_server_data(obd);
@@ -2019,6 +2019,7 @@ int filter_common_setup(struct obd_device *obd, struct lustre_cfg* lcfg,
 
         obd->u.obt.obt_vfsmnt = mnt;
         obd->u.obt.obt_sb = mnt->mnt_sb;
+        obd->u.obt.obt_magic = OBT_MAGIC;
         filter->fo_fstype = mnt->mnt_sb->s_type->name;
         CDEBUG(D_SUPER, "%s: mnt = %p\n", filter->fo_fstype, mnt);
 
index 01bc378..92effc9 100644 (file)
@@ -82,18 +82,6 @@ static int lprocfs_filter_rd_tot_pending(char *page, char **start, off_t off,
         return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_pending);
 }
 
-static int lprocfs_filter_rd_mntdev(char *page, char **start, off_t off,
-                                    int count, int *eof, void *data)
-{
-        struct obd_device *obd = (struct obd_device *)data;
-
-        LASSERT(obd != NULL);
-        LASSERT(obd->u.obt.obt_vfsmnt->mnt_devname);
-        *eof = 1;
-        return snprintf(page, count, "%s\n",
-                        obd->u.obt.obt_vfsmnt->mnt_devname);
-}
-
 static int lprocfs_filter_rd_last_id(char *page, char **start, off_t off,
                                      int count, int *eof, void *data)
 {
@@ -376,7 +364,7 @@ static struct lprocfs_vars lprocfs_filter_obd_vars[] = {
         { "filesfree",    lprocfs_rd_filesfree,     0, 0 },
         { "filegroups",   lprocfs_filter_rd_groups, 0, 0 },
         { "fstype",       lprocfs_rd_fstype,        0, 0 },
-        { "mntdev",       lprocfs_filter_rd_mntdev, 0, 0 },
+        { "mntdev",       lprocfs_obd_rd_mntdev,    0, 0 },
         { "last_id",      lprocfs_filter_rd_last_id,0, 0 },
         { "tot_dirty",    lprocfs_filter_rd_tot_dirty,   0, 0 },
         { "tot_pending",  lprocfs_filter_rd_tot_pending, 0, 0 },
index a1961b0..245c9dc 100644 (file)
@@ -248,7 +248,7 @@ static int lut_server_data_update(const struct lu_env *env,
 
         CDEBUG(D_SUPER,
                "%s: mount_count is "LPU64", last_transno is "LPU64"\n",
-               lut->lut_lsd.lsd_uuid, lut->lut_mount_count,
+               lut->lut_lsd.lsd_uuid, lut->lut_obd->u.obt.obt_mount_count,
                lut->lut_last_transno);
 
         cfs_spin_lock(&lut->lut_translock);