From 3987b8f1250f837091c20ae950bf376bebd239b0 Mon Sep 17 00:00:00 2001 From: adilger Date: Thu, 9 May 2002 20:11:41 +0000 Subject: [PATCH] Macros useful for debugging the file offset/page index corruption, allowing 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 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index fcf3998..da941fa 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -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 -- 1.8.3.1