ocfs2: Morph the haphazard OCFS2_IS_VALID_DINODE() checks.
[safe/jmp/linux-2.6] / fs / ocfs2 / ocfs2.h
index af929ec..467bdb6 100644 (file)
 #include <linux/workqueue.h>
 #include <linux/kref.h>
 #include <linux/mutex.h>
-#include <linux/jbd.h>
+#ifndef CONFIG_OCFS2_COMPAT_JBD
+# include <linux/jbd2.h>
+#else
+# include <linux/jbd.h>
+# include "ocfs2_jbd_compat.h"
+#endif
 
 /* For union ocfs2_dlm_lksb */
 #include "stackglue.h"
@@ -80,7 +85,7 @@ enum ocfs2_unlock_action {
 };
 
 /* ocfs2_lock_res->l_flags flags. */
-#define OCFS2_LOCK_ATTACHED      (0x00000001) /* have we initialized
+#define OCFS2_LOCK_ATTACHED      (0x00000001) /* we have initialized
                                               * the lvb */
 #define OCFS2_LOCK_BUSY          (0x00000002) /* we are currently in
                                               * dlm_lock */
@@ -132,6 +137,18 @@ struct ocfs2_lock_res {
        wait_queue_head_t        l_event;
 
        struct list_head         l_debug_list;
+
+#ifdef CONFIG_OCFS2_FS_STATS
+       unsigned long long       l_lock_num_prmode;        /* PR acquires */
+       unsigned long long       l_lock_num_exmode;        /* EX acquires */
+       unsigned int             l_lock_num_prmode_failed; /* Failed PR gets */
+       unsigned int             l_lock_num_exmode_failed; /* Failed EX gets */
+       unsigned long long       l_lock_total_prmode;      /* Tot wait for PR */
+       unsigned long long       l_lock_total_exmode;      /* Tot wait for EX */
+       unsigned int             l_lock_max_prmode;        /* Max wait for PR */
+       unsigned int             l_lock_max_exmode;        /* Max wait for EX */
+       unsigned int             l_lock_refresh;           /* Disk refreshes */
+#endif
 };
 
 struct ocfs2_dlm_debug {
@@ -159,9 +176,13 @@ struct ocfs2_alloc_stats
 
 enum ocfs2_local_alloc_state
 {
-       OCFS2_LA_UNUSED = 0,
-       OCFS2_LA_ENABLED,
-       OCFS2_LA_DISABLED
+       OCFS2_LA_UNUSED = 0,    /* Local alloc will never be used for
+                                * this mountpoint. */
+       OCFS2_LA_ENABLED,       /* Local alloc is in use. */
+       OCFS2_LA_THROTTLED,     /* Local alloc is in use, but number
+                                * of bits has been reduced. */
+       OCFS2_LA_DISABLED       /* Local alloc has temporarily been
+                                * disabled. */
 };
 
 enum ocfs2_mount_options
@@ -172,6 +193,9 @@ enum ocfs2_mount_options
        OCFS2_MOUNT_ERRORS_PANIC = 1 << 3, /* Panic on errors */
        OCFS2_MOUNT_DATA_WRITEBACK = 1 << 4, /* No data ordering */
        OCFS2_MOUNT_LOCALFLOCKS = 1 << 5, /* No cluster aware user file locks */
+       OCFS2_MOUNT_NOUSERXATTR = 1 << 6, /* No user xattr */
+       OCFS2_MOUNT_INODE64 = 1 << 7,   /* Allow inode numbers > 2^32 */
+       OCFS2_MOUNT_POSIX_ACL = 1 << 8, /* POSIX access control lists */
 };
 
 #define OCFS2_OSB_SOFT_RO      0x0001
@@ -192,6 +216,8 @@ struct ocfs2_super
 
        struct ocfs2_slot_info *slot_info;
 
+       u32 *slot_recovery_generations;
+
        spinlock_t node_map_lock;
 
        u64 root_blkno;
@@ -200,6 +226,7 @@ struct ocfs2_super
        u32 bitmap_cpg;
        u8 *uuid;
        char *uuid_str;
+       u32 uuid_hash;
        u8 *vol_label;
        u64 first_cluster_group_blkno;
        u32 fs_generation;
@@ -208,11 +235,14 @@ struct ocfs2_super
        u32 s_feature_incompat;
        u32 s_feature_ro_compat;
 
-       /* Protects s_next_generaion, osb_flags. Could protect more on
-        * osb as it's very short lived. */
+       /* Protects s_next_generation, osb_flags and s_inode_steal_slot.
+        * Could protect more on osb as it's very short lived.
+        */
        spinlock_t osb_lock;
        u32 s_next_generation;
        unsigned long osb_flags;
+       s16 s_inode_steal_slot;
+       atomic_t s_num_inodes_stolen;
 
        unsigned long s_mount_opt;
        unsigned int s_atime_quantum;
@@ -224,6 +254,7 @@ struct ocfs2_super
        int s_sectsize_bits;
        int s_clustersize;
        int s_clustersize_bits;
+       unsigned int s_xattr_inline_size;
 
        atomic_t vol_state;
        struct mutex recovery_lock;
@@ -235,11 +266,27 @@ struct ocfs2_super
        struct ocfs2_journal *journal;
        unsigned long osb_commit_interval;
 
-       int local_alloc_size;
-       enum ocfs2_local_alloc_state local_alloc_state;
+       struct delayed_work             la_enable_wq;
+
+       /*
+        * Must hold local alloc i_mutex and osb->osb_lock to change
+        * local_alloc_bits. Reads can be done under either lock.
+        */
+       unsigned int local_alloc_bits;
+       unsigned int local_alloc_default_bits;
+
+       enum ocfs2_local_alloc_state local_alloc_state; /* protected
+                                                        * by osb_lock */
+
        struct buffer_head *local_alloc_bh;
+
        u64 la_last_gd;
 
+#ifdef CONFIG_OCFS2_FS_STATS
+       struct dentry *local_alloc_debug;
+       char *local_alloc_debug_buf;
+#endif
+
        /* Next two fields are for local node slot recovery during
         * mount. */
        int dirty;
@@ -248,6 +295,7 @@ struct ocfs2_super
        struct ocfs2_alloc_stats alloc_stats;
        char dev_str[20];               /* "major,minor" of the device */
 
+       char osb_cluster_stack[OCFS2_STACK_LABEL_LEN + 1];
        struct ocfs2_cluster_connection *cconn;
        struct ocfs2_lock_res osb_super_lockres;
        struct ocfs2_lock_res osb_rename_lockres;
@@ -322,6 +370,13 @@ static inline int ocfs2_supports_inline_data(struct ocfs2_super *osb)
        return 0;
 }
 
+static inline int ocfs2_supports_xattr(struct ocfs2_super *osb)
+{
+       if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_XATTR)
+               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
@@ -368,6 +423,12 @@ static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb)
        return ret;
 }
 
+static inline int ocfs2_userspace_stack(struct ocfs2_super *osb)
+{
+       return (osb->s_feature_incompat &
+               OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK);
+}
+
 static inline int ocfs2_mount_local(struct ocfs2_super *osb)
 {
        return (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT);
@@ -383,14 +444,6 @@ static inline int ocfs2_uses_extended_slot_map(struct ocfs2_super *osb)
 #define OCFS2_IS_VALID_DINODE(ptr)                                     \
        (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE))
 
-#define OCFS2_RO_ON_INVALID_DINODE(__sb, __di) do {                    \
-       typeof(__di) ____di = (__di);                                   \
-       ocfs2_error((__sb),                                             \
-               "Dinode # %llu has bad signature %.*s",                 \
-               (unsigned long long)le64_to_cpu((____di)->i_blkno), 7,  \
-               (____di)->i_signature);                                 \
-} while (0)
-
 #define OCFS2_IS_VALID_EXTENT_BLOCK(ptr)                               \
        (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE))
 
@@ -413,6 +466,9 @@ static inline int ocfs2_uses_extended_slot_map(struct ocfs2_super *osb)
                (____gd)->bg_signature);                                \
 } while (0)
 
+#define OCFS2_IS_VALID_XATTR_BLOCK(ptr)                                        \
+       (!strcmp((ptr)->xb_signature, OCFS2_XATTR_BLOCK_SIGNATURE))
+
 static inline unsigned long ino_from_blkno(struct super_block *sb,
                                           u64 blkno)
 {
@@ -530,6 +586,41 @@ static inline unsigned int ocfs2_pages_per_cluster(struct super_block *sb)
        return pages_per_cluster;
 }
 
+static inline unsigned int ocfs2_megabytes_to_clusters(struct super_block *sb,
+                                                      unsigned int megs)
+{
+       BUILD_BUG_ON(OCFS2_MAX_CLUSTERSIZE > 1048576);
+
+       return megs << (20 - OCFS2_SB(sb)->s_clustersize_bits);
+}
+
+static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb)
+{
+       spin_lock(&osb->osb_lock);
+       osb->s_inode_steal_slot = OCFS2_INVALID_SLOT;
+       spin_unlock(&osb->osb_lock);
+       atomic_set(&osb->s_num_inodes_stolen, 0);
+}
+
+static inline void ocfs2_set_inode_steal_slot(struct ocfs2_super *osb,
+                                             s16 slot)
+{
+       spin_lock(&osb->osb_lock);
+       osb->s_inode_steal_slot = slot;
+       spin_unlock(&osb->osb_lock);
+}
+
+static inline s16 ocfs2_get_inode_steal_slot(struct ocfs2_super *osb)
+{
+       s16 slot;
+
+       spin_lock(&osb->osb_lock);
+       slot = osb->s_inode_steal_slot;
+       spin_unlock(&osb->osb_lock);
+
+       return slot;
+}
+
 #define ocfs2_set_bit ext2_set_bit
 #define ocfs2_clear_bit ext2_clear_bit
 #define ocfs2_test_bit ext2_test_bit