-#define ll_set_dflags(dentry, flags) do { \
- cfs_spin_lock(&dentry->d_lock); \
- dentry->d_flags |= flags; \
- cfs_spin_unlock(&dentry->d_lock); \
- } while(0)
-#endif
-
-#ifndef container_of
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-#endif
-
-#define UP_WRITE_I_ALLOC_SEM(i) up_write(&(i)->i_alloc_sem)
-#define DOWN_WRITE_I_ALLOC_SEM(i) down_write(&(i)->i_alloc_sem)
-#define LASSERT_I_ALLOC_SEM_WRITE_LOCKED(i) LASSERT(down_read_trylock(&(i)->i_alloc_sem) == 0)
-
-#define UP_READ_I_ALLOC_SEM(i) up_read(&(i)->i_alloc_sem)
-#define DOWN_READ_I_ALLOC_SEM(i) down_read(&(i)->i_alloc_sem)
-#define LASSERT_I_ALLOC_SEM_READ_LOCKED(i) LASSERT(down_write_trylock(&(i)->i_alloc_sem) == 0)
-
-#ifndef HAVE_GRAB_CACHE_PAGE_NOWAIT_GFP
-#define grab_cache_page_nowait_gfp(x, y, z) grab_cache_page_nowait((x), (y))
-#endif
-
-#include <linux/mpage.h> /* for generic_writepages */
-#ifndef HAVE_FILEMAP_FDATAWRITE_RANGE
-#include <linux/backing-dev.h> /* for mapping->backing_dev_info */
-static inline int filemap_fdatawrite_range(struct address_space *mapping,
- loff_t start, loff_t end)
-{
- int rc;
- struct writeback_control wbc = {
- .sync_mode = WB_SYNC_ALL,
- .nr_to_write = (end - start + PAGE_SIZE - 1) >> PAGE_SHIFT,
- };
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18)
- wbc.range_start = start;
- wbc.range_end = end;
-#else
- wbc.start = start;
- wbc.end = end;
-#endif
-
-#ifdef HAVE_MAPPING_CAP_WRITEBACK_DIRTY
- if (!mapping_cap_writeback_dirty(mapping))
- rc = 0;
-#else
- if (mapping->backing_dev_info->memory_backed)
- rc = 0;
-#endif
- /* do_writepages() */
- else if (mapping->a_ops->writepages)
- rc = mapping->a_ops->writepages(mapping, &wbc);
- else
- rc = generic_writepages(mapping, &wbc);
- return rc;
-}
-#else
-int filemap_fdatawrite_range(struct address_space *mapping,
- loff_t start, loff_t end);
-#endif /* HAVE_FILEMAP_FDATAWRITE_RANGE */
-
-#ifdef HAVE_VFS_KERN_MOUNT
-static inline struct vfsmount *
-ll_kern_mount(const char *fstype, int flags, const char *name, void *data)
-{
- struct file_system_type *type = get_fs_type(fstype);
- struct vfsmount *mnt;
- if (!type)
- return ERR_PTR(-ENODEV);
- mnt = vfs_kern_mount(type, flags, name, data);
- cfs_module_put(type->owner);
- return mnt;
-}
-#else
-#define ll_kern_mount(fstype, flags, name, data) do_kern_mount((fstype), (flags), (name), (data))
-#endif
-
-#ifdef HAVE_STATFS_DENTRY_PARAM
-#define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb)->s_root, (sfs))
-#else
-#define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb), (sfs))
-#endif
-
-#ifndef HAVE_SB_TIME_GRAN
-#ifndef HAVE_S_TIME_GRAN
-#error Need s_time_gran patch!
-#endif
-static inline u32 get_sb_time_gran(struct super_block *sb)
-{
- return sb->s_time_gran;
-}
-#endif
-
-#ifdef HAVE_RW_TREE_LOCK
-#define TREE_READ_LOCK_IRQ(mapping) read_lock_irq(&(mapping)->tree_lock)
-#define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock)
-#else
-#define TREE_READ_LOCK_IRQ(mapping) cfs_spin_lock_irq(&(mapping)->tree_lock)
-#define TREE_READ_UNLOCK_IRQ(mapping) cfs_spin_unlock_irq(&(mapping)->tree_lock)
-#endif
-
-#ifdef HAVE_UNREGISTER_BLKDEV_RETURN_INT
-#define ll_unregister_blkdev(a,b) unregister_blkdev((a),(b))
-#else
-static inline
-int ll_unregister_blkdev(unsigned int dev, const char *name)
-{
- unregister_blkdev(dev, name);
- return 0;
-}
-#endif
-
-#ifdef HAVE_INVALIDATE_BDEV_2ARG
-#define ll_invalidate_bdev(a,b) invalidate_bdev((a),(b))