ocfs2: teach ocfs2_file_aio_write() about sparse files
[pandora-kernel.git] / fs / ocfs2 / ocfs2.h
index 553e702..2699f7c 100644 (file)
 #include "endian.h"
 #include "ocfs2_lockid.h"
 
-struct ocfs2_extent_map {
-       u32             em_clusters;
-       struct rb_root  em_extents;
-};
-
 /* Most user visible OCFS2 inodes will have very few pieces of
  * metadata, but larger files (including bitmaps, etc) must be taken
  * into account when designing an access scheme. We allow a small
@@ -180,6 +175,7 @@ enum ocfs2_mount_options
 #define OCFS2_OSB_SOFT_RO      0x0001
 #define OCFS2_OSB_HARD_RO      0x0002
 #define OCFS2_OSB_ERROR_FS     0x0004
+#define OCFS2_DEFAULT_ATIME_QUANTUM    60
 
 struct ocfs2_journal;
 struct ocfs2_super
@@ -218,6 +214,7 @@ struct ocfs2_super
        unsigned long osb_flags;
 
        unsigned long s_mount_opt;
+       unsigned int s_atime_quantum;
 
        u16 max_slots;
        s16 node_num;
@@ -283,7 +280,7 @@ struct ocfs2_super
        /* Truncate log info */
        struct inode                    *osb_tl_inode;
        struct buffer_head              *osb_tl_bh;
-       struct work_struct              osb_truncate_log_wq;
+       struct delayed_work             osb_truncate_log_wq;
 
        struct ocfs2_node_map           osb_recovering_orphan_dirs;
        unsigned int                    *osb_orphan_wipes;
@@ -301,6 +298,13 @@ static inline int ocfs2_should_order_data(struct inode *inode)
        return 1;
 }
 
+static inline int ocfs2_sparse_alloc(struct ocfs2_super *osb)
+{
+       if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC)
+               return 1;
+       return 0;
+}
+
 /* set / clear functions because cluster events can make these happen
  * in parallel so we want the transitions to be atomic. this also
  * means that any future flags osb_flags must be protected by spinlock
@@ -347,6 +351,11 @@ static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb)
        return ret;
 }
 
+static inline int ocfs2_mount_local(struct ocfs2_super *osb)
+{
+       return (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT);
+}
+
 #define OCFS2_IS_VALID_DINODE(ptr)                                     \
        (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE))
 
@@ -454,6 +463,38 @@ static inline unsigned long ocfs2_align_bytes_to_sectors(u64 bytes)
        return (unsigned long)((bytes + 511) >> 9);
 }
 
+static inline unsigned int ocfs2_page_index_to_clusters(struct super_block *sb,
+                                                       unsigned long pg_index)
+{
+       u32 clusters = pg_index;
+       unsigned int cbits = OCFS2_SB(sb)->s_clustersize_bits;
+
+       if (unlikely(PAGE_CACHE_SHIFT > cbits))
+               clusters = pg_index << (PAGE_CACHE_SHIFT - cbits);
+       else if (PAGE_CACHE_SHIFT < cbits)
+               clusters = pg_index >> (cbits - PAGE_CACHE_SHIFT);
+
+       return clusters;
+}
+
+/*
+ * Find the 1st page index which covers the given clusters.
+ */
+static inline unsigned long ocfs2_align_clusters_to_page_index(struct super_block *sb,
+                                                       u32 clusters)
+{
+       unsigned int cbits = OCFS2_SB(sb)->s_clustersize_bits;
+       unsigned long index = clusters;
+
+       if (PAGE_CACHE_SHIFT > cbits) {
+               index = clusters >> (PAGE_CACHE_SHIFT - cbits);
+       } else if (PAGE_CACHE_SHIFT < cbits) {
+               index = clusters << (cbits - PAGE_CACHE_SHIFT);
+       }
+
+       return index;
+}
+
 #define ocfs2_set_bit ext2_set_bit
 #define ocfs2_clear_bit ext2_clear_bit
 #define ocfs2_test_bit ext2_test_bit