Unionfs: m/c/atime invariant checking debugging code
authorErez_Zadok <ezk@cs.sunysb.edu>
Mon, 18 Jun 2007 02:33:56 +0000 (22:33 -0400)
committerErez_Zadok <ezk@cs.sunysb.edu>
Mon, 23 Jul 2007 00:50:51 +0000 (20:50 -0400)
Add checks to verify that lower inode times are not newer than our own inode
times.  Introduce two useful utility debugging functions to print inode
times.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/debug.c
fs/unionfs/union.h

index 34ef190e7f847b3b5bdde067c83f92119b28de93..b4d35d62e7ad15355bc5667621b4f2a7b97377a6 100644 (file)
@@ -299,6 +299,26 @@ void __unionfs_check_dentry(const struct dentry *dentry,
                                       bindex, dstart, dend);
                        }
                }
+       /* check if lower inode is newer than upper one (it shouldn't) */
+       if (is_newer_lower(dentry)) {
+               PRINT_CALLER();
+               for (bindex=ibstart(inode); bindex <= ibend(inode); bindex++) {
+                       lower_inode = unionfs_lower_inode_idx(inode, bindex);
+                       if (!lower_inode)
+                               continue;
+                       printk(" CI8: bindex=%d mtime/lmtime=%lu.%lu/%lu.%lu "
+                              "ctime/lctime=%lu.%lu/%lu.%lu\n",
+                              bindex,
+                              inode->i_mtime.tv_sec,
+                              inode->i_mtime.tv_nsec,
+                              lower_inode->i_mtime.tv_sec,
+                              lower_inode->i_mtime.tv_nsec,
+                              inode->i_ctime.tv_sec,
+                              inode->i_ctime.tv_nsec,
+                              lower_inode->i_ctime.tv_sec,
+                              lower_inode->i_ctime.tv_nsec);
+               }
+       }
 }
 
 void __unionfs_check_file(const struct file *file,
@@ -401,3 +421,50 @@ void __show_branch_counts(const struct super_block *sb,
        }
        printk("%s:%s:%d\n",file,fxn,line);
 }
+
+void __show_inode_times(const struct inode *inode,
+                       const char *file, const char *fxn, int line)
+{
+       struct inode *lower_inode;
+       int bindex;
+
+       for (bindex=ibstart(inode); bindex <= ibend(inode); bindex++) {
+               lower_inode = unionfs_lower_inode_idx(inode, bindex);
+               if (!lower_inode)
+                       continue;
+               printk("IT(%lu:%d): ", inode->i_ino, bindex);
+               printk("%s:%s:%d ",file,fxn,line);
+               printk("um=%lu/%lu lm=%lu/%lu ",
+                      inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+                      lower_inode->i_mtime.tv_sec,
+                      lower_inode->i_mtime.tv_nsec);
+               printk("uc=%lu/%lu lc=%lu/%lu\n",
+                      inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+                      lower_inode->i_ctime.tv_sec,
+                      lower_inode->i_ctime.tv_nsec);
+       }
+}
+
+void __show_dinode_times(const struct dentry *dentry,
+                       const char *file, const char *fxn, int line)
+{
+       struct inode *inode = dentry->d_inode;
+       struct inode *lower_inode;
+       int bindex;
+
+       for (bindex=ibstart(inode); bindex <= ibend(inode); bindex++) {
+               lower_inode = unionfs_lower_inode_idx(inode, bindex);
+               if (!lower_inode)
+                       continue;
+               printk("DT(%s:%lu:%d): ", dentry->d_name.name, inode->i_ino, bindex);
+               printk("%s:%s:%d ",file,fxn,line);
+               printk("um=%lu/%lu lm=%lu/%lu ",
+                      inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+                      lower_inode->i_mtime.tv_sec,
+                      lower_inode->i_mtime.tv_nsec);
+               printk("uc=%lu/%lu lc=%lu/%lu\n",
+                      inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+                      lower_inode->i_ctime.tv_sec,
+                      lower_inode->i_ctime.tv_nsec);
+       }
+}
index 6cd3207022f8667d2bcc17765946289fdbe7781b..f7c65e8ae487b7bf1355c040c17fa0e984de7d53 100644 (file)
@@ -533,6 +533,11 @@ static inline void unionfs_mntput(struct dentry *dentry, int bindex)
        __FILE__,__FUNCTION__,__LINE__)
 #define show_branch_counts(sb) __show_branch_counts((sb),      \
        __FILE__,__FUNCTION__,__LINE__)
+#define show_inode_times(i)    __show_inode_times((i),         \
+       __FILE__,__FUNCTION__,__LINE__)
+#define show_dinode_times(d)   __show_dinode_times((d),        \
+       __FILE__,__FUNCTION__,__LINE__)
+
 extern void __unionfs_check_inode(const struct inode *inode, const char *fname,
                                  const char *fxn, int line);
 extern void __unionfs_check_dentry(const struct dentry *dentry,
@@ -542,6 +547,10 @@ extern void __unionfs_check_file(const struct file *file,
                                 const char *fname, const char *fxn, int line);
 extern void __show_branch_counts(const struct super_block *sb,
                                 const char *file, const char *fxn, int line);
+extern void __show_inode_times(const struct inode *inode,
+                              const char *file, const char *fxn, int line);
+extern void __show_dinode_times(const struct dentry *dentry,
+                               const char *file, const char *fxn, int line);
 
 #else /* not UNIONFS_DEBUG */
 
@@ -550,6 +559,8 @@ extern void __show_branch_counts(const struct super_block *sb,
 #define unionfs_check_dentry(d)
 #define unionfs_check_file(f)
 #define show_branch_counts(sb)
+#define show_inode_times(i)
+#define show_dinode_times(d)
 
 #endif /* not UNIONFS_DEBUG */