Fix up possibly racy module refcounting
[safe/jmp/linux-2.6] / include / linux / ext2_fs_sb.h
index 4eda0ed..1cdb663 100644 (file)
 
 #include <linux/blockgroup_lock.h>
 #include <linux/percpu_counter.h>
+#include <linux/rbtree.h>
+
+/* XXX Here for now... not interested in restructing headers JUST now */
+
+/* data type for block offset of block group */
+typedef int ext2_grpblk_t;
+
+/* data type for filesystem-wide blocks number */
+typedef unsigned long ext2_fsblk_t;
+
+#define E2FSBLK "%lu"
+
+struct ext2_reserve_window {
+       ext2_fsblk_t            _rsv_start;     /* First byte reserved */
+       ext2_fsblk_t            _rsv_end;       /* Last byte reserved or 0 */
+};
+
+struct ext2_reserve_window_node {
+       struct rb_node          rsv_node;
+       __u32                   rsv_goal_size;
+       __u32                   rsv_alloc_hit;
+       struct ext2_reserve_window      rsv_window;
+};
+
+struct ext2_block_alloc_info {
+       /* information about reservation window */
+       struct ext2_reserve_window_node rsv_window_node;
+       /*
+        * was i_next_alloc_block in ext2_inode_info
+        * is the logical (file-relative) number of the
+        * most-recently-allocated block in this file.
+        * We use this for detecting linearly ascending allocation requests.
+        */
+       __u32                   last_alloc_logical_block;
+       /*
+        * Was i_next_alloc_goal in ext2_inode_info
+        * is the *physical* companion to i_next_alloc_block.
+        * it the the physical block number of the block which was most-recentl
+        * allocated to this file.  This give us the goal (target) for the next
+        * allocation when we detect linearly ascending requests.
+        */
+       ext2_fsblk_t            last_alloc_physical_block;
+};
+
+#define rsv_start rsv_window._rsv_start
+#define rsv_end rsv_window._rsv_end
 
 /*
  * second extended-fs super-block data in memory
@@ -33,10 +79,13 @@ struct ext2_sb_info {
        unsigned long s_gdb_count;      /* Number of group descriptor blocks */
        unsigned long s_desc_per_block; /* Number of group descriptors per block */
        unsigned long s_groups_count;   /* Number of groups in the fs */
+       unsigned long s_overhead_last;  /* Last calculated overhead */
+       unsigned long s_blocks_last;    /* Last seen block count */
        struct buffer_head * s_sbh;     /* Buffer containing the super block */
        struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */
        struct buffer_head ** s_group_desc;
        unsigned long  s_mount_opt;
+       unsigned long s_sb_block;
        uid_t s_resuid;
        gid_t s_resgid;
        unsigned short s_mount_state;
@@ -52,7 +101,17 @@ struct ext2_sb_info {
        struct percpu_counter s_freeblocks_counter;
        struct percpu_counter s_freeinodes_counter;
        struct percpu_counter s_dirs_counter;
-       struct blockgroup_lock s_blockgroup_lock;
+       struct blockgroup_lock *s_blockgroup_lock;
+       /* root of the per fs reservation window tree */
+       spinlock_t s_rsv_window_lock;
+       struct rb_root s_rsv_window_root;
+       struct ext2_reserve_window_node s_rsv_window_head;
 };
 
+static inline spinlock_t *
+sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group)
+{
+       return bgl_lock_ptr(sbi->s_blockgroup_lock, block_group);
+}
+
 #endif /* _LINUX_EXT2_FS_SB */