Whamcloud - gitweb
New direcotory layout:
[fs/lustre-release.git] / lustre / include / linux / obd_support.h
index 2c6e664..db2081a 100644 (file)
@@ -1,3 +1,4 @@
+
 #ifndef _OBD_SUPPORT
 #define _OBD_SUPPORT
 #include <linux/malloc.h>
@@ -5,6 +6,10 @@
 
 #define SIM_OBD_DEBUG
 
+
+#define MIN(a,b) (((a)<(b)) ? (a): (b))
+#define MAX(a,b) (((a)>(b)) ? (a): (b))
+
 /*
  * Debug code
  */
@@ -25,6 +30,7 @@ extern int obd_print_entry;
 #define D_INFO      512 /* general information, especially from interface.c */
 #define D_IOCTL    1024 /* ioctl related information */
 #define D_BLOCKS   2048 /* ext2 block allocation */
+#define D_RPC      4096 /* ext2 block allocation */
  
 #ifdef SIM_OBD_DEBUG
 #define CDEBUG(mask, format, a...)                                     \
@@ -40,7 +46,7 @@ extern int obd_print_entry;
 
 #define EXIT                                                                 \
         if (obd_print_entry)                                                 \
-                printk("Process %d leaving %s\n", current->pid, __FUNCTION__)
+                printk("Process %d leaving %s [%d]\n", current->pid, __FUNCTION__, __LINE__)
 
 #else /* SIM_OBD_DEBUG */
 
@@ -50,17 +56,29 @@ extern int obd_print_entry;
 
 #endif /* SIM_OBD_DEBUG */
 
-#define PDEBUG(page,cmd)       {\
-               char *command = ( cmd == READ ) ? "read" : "write";\
+
+#define CMD(cmd) (( cmd == READ ) ? "read" : "write")
+
+#define IDEBUG(inode) { \
+       if ( !list_empty(&inode->i_data.pages) || inode->i_data.nrpages ) {\
+               struct page * page;\
+               printk("XXXXX: func %s line %d ino %ld list not empty, pages %ld\n", __FUNCTION__ , __LINE__,\
+                      inode->i_ino, inode->i_data.nrpages);\
+               page = list_entry(inode->i_data.pages.next, struct page , list);\
+               PDEBUG(page, "READ INODE");\
+       }}
+
+
+#define PDEBUG(page,cmd)       {if (page){\
                char *uptodate = (Page_Uptodate(page)) ? "yes" : "no";\
                char *locked = (PageLocked(page)) ? "yes" : "no";\
                int count = page->count.counter;\
-               long ino = (page->inode) ? page->inode->i_ino : -1;\
+                long offset = page->offset;\
                \
-               CDEBUG(D_IOCTL, " ** %s, cmd: %s, ino: %ld, uptodate: %s, "\
-                      "locked: %s, cnt %d ** \n", __FUNCTION__,\
-                      command, ino, uptodate, locked, count);\
-       }
+               CDEBUG(D_IOCTL, " ** %s, cmd: %s, off %ld, uptodate: %s, "\
+                      "locked: %s, cnt %d page %p pages %ld** \n", __FUNCTION__,\
+                      cmd, offset, uptodate, locked, count, page, page->mapping->nrpages);\
+       } else { CDEBUG(D_IOCTL, "** %s, no page\n", __FUNCTION__); }}
 
 
 #define OBD_ALLOC(ptr, cast, size)                                     \
@@ -94,4 +112,46 @@ do {                                                        \
        }                                               \
 } while (0)
 
+
+
+static inline void inode_to_iattr(struct inode *inode, struct iattr *tmp)
+{
+       tmp->ia_mode = inode->i_mode;
+       tmp->ia_uid = inode->i_uid;
+       tmp->ia_gid = inode->i_gid;
+       tmp->ia_size = inode->i_size;
+       tmp->ia_atime = inode->i_atime;
+       tmp->ia_mtime = inode->i_mtime;
+       tmp->ia_ctime = inode->i_ctime;
+       /*      tmp->ia_flags = inode->i_flags; */
+
+       tmp->ia_valid = ~0;
+}
+
+static inline void inode_cpy(struct inode *dest, struct inode *src)
+{
+       dest->i_mode = src->i_mode;
+       dest->i_uid = src->i_uid;
+       dest->i_gid = src->i_gid;
+       dest->i_size = src->i_size;
+       dest->i_atime = src->i_atime;
+       dest->i_mtime = src->i_mtime;
+       dest->i_ctime = src->i_ctime;
+       dest->i_flags = src->i_flags;
+       /* allocation of space */
+       dest->i_blocks = src->i_blocks;
+
+       if ( !dest->i_blocks) 
+               memcpy(&dest->u, &src->u, sizeof(src->u));
+}
+
+
+
+
+
+
+
+
+
+
 #endif