+#define EXT3_EA_TRANS_BLOCKS EXT3_DATA_TRANS_BLOCKS
+#define EXT3_SETMETA_TRANS_BLOCKS EXT3_DATA_TRANS_BLOCKS
+#define EXT3_NEWINODE_TRANS_BLOCKS 10
+
+#define SNAP_COPYBLOCK_TRANS_BLOCKS (EXT3_DATA_TRANS_BLOCKS)
+#define SNAP_INSERTLIST_TRANS_BLOCKS (2 * EXT3_EA_TRANS_BLOCKS + 1)
+#define SNAP_DELETELIST_TRANS_BLOCKS (2 * EXT3_EA_TRANS_BLOCKS + 2)
+#define SNAP_MIGRATEDATA_TRANS_BLOCKS 2
+#define SNAP_SETIND_TRANS_BLOCKS (SNAP_INSERTLIST_TRANS_BLOCKS + 1)
+#define SNAP_ADDORPHAN_TRANS_BLOCKS 2
+#define SNAP_REMOVEORPHAN_TRANS_BLOCKS 1
+#define SNAP_RESTOREORPHAN_TRANS_BLOCKS (EXT3_EA_TRANS_BLOCKS + \
+ SNAP_DELETELIST_TRANS_BLOCKS + \
+ EXT3_NEWINODE_TRANS_BLOCKS + \
+ 2 * SNAP_MIGRATEDATA_TRANS_BLOCKS)
+#define SNAP_BIGCOPY_TRANS_BLOCKS (2 * EXT3_DATA_TRANS_BLOCKS)
+#define SNAP_CREATEIND_TRANS_BLOCKS (EXT3_NEWINODE_TRANS_BLOCKS + \
+ SNAP_MIGRATEDATA_TRANS_BLOCKS + \
+ SNAP_SETIND_TRANS_BLOCKS + \
+ SNAP_BIGCOPY_TRANS_BLOCKS + 3)
+#define SNAP_MIGRATEBLK_TRANS_BLOCKS 2
+#define SNAP_DESTROY_TRANS_BLOCKS (SNAP_DELETELIST_TRANS_BLOCKS + \
+ EXT3_EA_TRANS_BLOCKS + 2)
+#define SNAP_RESTORE_TRANS_BLOCKS (EXT3_NEWINODE_TRANS_BLOCKS + \
+ 2 * SNAP_MIGRATEDATA_TRANS_BLOCKS + 1)
+
+#define EXT3_JOURNAL_START(sb, handle, blocks, rc) \
+do { \
+ journal_t *journal; \
+ journal = EXT3_SB(sb)->s_journal; \
+ lock_kernel(); \
+ handle = journal_start(journal, blocks); \
+ unlock_kernel(); \
+ if(IS_ERR(handle)) { \
+ CERROR("can't start transaction\n"); \
+ rc = PTR_ERR(handle); \
+ } else \
+ rc = 0; \
+} while(0)
+
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+static inline void double_lock_inode(struct inode *i1, struct inode *i2)
+{
+ if (i1 == i2)
+ down(&i1->i_sem);
+ else
+ double_down(&i1->i_sem, &i2->i_sem);
+}
+static inline void double_unlock_inode(struct inode *i1, struct inode *i2)
+{
+ if (i1 == i2)
+ up(&i1->i_sem);
+ else
+ double_up(&i1->i_sem, &i2->i_sem);
+}
+#else
+static inline void double_lock_inode(struct inode *i1, struct inode *i2)
+{
+ struct semaphore *s1 = &i1->i_sem;
+ struct semaphore *s2 = &i2->i_sem;
+
+ if (s1 != s2) {
+ if ((unsigned long) s1 < (unsigned long) s2) {
+ struct semaphore *tmp = s2;
+ s2 = s1; s1 = tmp;
+ }
+ down(s1);
+ }
+ down(s2);
+}
+
+static inline void double_unlock_inode(struct inode *i1, struct inode *i2)
+{
+ struct semaphore *s1 = &i1->i_sem;
+ struct semaphore *s2 = &i2->i_sem;
+
+ up(s1);
+ if (s1 != s2)
+ up(s2);
+}
+
+#endif
+