Whamcloud - gitweb
Macros useful for debugging the file offset/page index corruption, allowing
authoradilger <adilger>
Thu, 9 May 2002 20:11:41 +0000 (20:11 +0000)
committeradilger <adilger>
Thu, 9 May 2002 20:11:41 +0000 (20:11 +0000)
you to set the maximum file size in a single place (maybe a /proc/sys/lustre
value which could be set at runtime would be more useful at a later date).

lustre/include/linux/lustre_lib.h

index fcf3998..da941fa 100644 (file)
@@ -47,13 +47,29 @@ int lustre_fread(struct file *file, char *str, int len, loff_t *off);
 int lustre_fwrite(struct file *file, const char *str, int len, loff_t *off);
 int lustre_fsync(struct file *file);
 
+#define ASSERT_MAX_SIZE_MB 50000ULL
+#define ASSERT_PAGE_INDEX(index, OP)                                    \
+do { if (index > ASSERT_MAX_SIZE_MB << (20 - PAGE_SHIFT)) {             \
+        CERROR("bad page index %lu > %Lu\n", index,                     \
+               ASSERT_MAX_SIZE_MB << (20 - PAGE_SHIFT));                \
+        portal_debug = ~0UL;                                            \
+        OP;                                                             \
+}} while(0)
+
+#define ASSERT_FILE_OFFSET(offset, OP)                                  \
+do { if (offset > ASSERT_MAX_SIZE_MB << 20) {                           \
+        CERROR("bad file offset %Lu > %Lu\n", offset,                   \
+               ASSERT_MAX_SIZE_MB << 20);                               \
+        portal_debug = ~0UL;                                            \
+        OP;                                                             \
+}} while(0)
+
 static inline void ll_sleep(int t)
 {
         set_current_state(TASK_INTERRUPTIBLE);
         schedule_timeout(t * HZ);
         set_current_state(TASK_RUNNING);
 }
-
 #endif
 
 #include <linux/portals_lib.h>