Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/ext2_fs_sb.h |
| 3 | * |
| 4 | * Copyright (C) 1992, 1993, 1994, 1995 |
| 5 | * Remy Card (card@masi.ibp.fr) |
| 6 | * Laboratoire MASI - Institut Blaise Pascal |
| 7 | * Universite Pierre et Marie Curie (Paris VI) |
| 8 | * |
| 9 | * from |
| 10 | * |
| 11 | * linux/include/linux/minix_fs_sb.h |
| 12 | * |
| 13 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 14 | */ |
| 15 | |
| 16 | #ifndef _LINUX_EXT2_FS_SB |
| 17 | #define _LINUX_EXT2_FS_SB |
| 18 | |
| 19 | #include <linux/blockgroup_lock.h> |
| 20 | #include <linux/percpu_counter.h> |
Martin J. Bligh | a686cd8 | 2007-10-16 23:30:46 -0700 | [diff] [blame] | 21 | #include <linux/rbtree.h> |
| 22 | |
| 23 | /* XXX Here for now... not interested in restructing headers JUST now */ |
| 24 | |
| 25 | /* data type for block offset of block group */ |
| 26 | typedef int ext2_grpblk_t; |
| 27 | |
| 28 | /* data type for filesystem-wide blocks number */ |
| 29 | typedef unsigned long ext2_fsblk_t; |
| 30 | |
| 31 | #define E2FSBLK "%lu" |
| 32 | |
| 33 | struct ext2_reserve_window { |
| 34 | ext2_fsblk_t _rsv_start; /* First byte reserved */ |
| 35 | ext2_fsblk_t _rsv_end; /* Last byte reserved or 0 */ |
| 36 | }; |
| 37 | |
| 38 | struct ext2_reserve_window_node { |
| 39 | struct rb_node rsv_node; |
| 40 | __u32 rsv_goal_size; |
| 41 | __u32 rsv_alloc_hit; |
| 42 | struct ext2_reserve_window rsv_window; |
| 43 | }; |
| 44 | |
| 45 | struct ext2_block_alloc_info { |
| 46 | /* information about reservation window */ |
| 47 | struct ext2_reserve_window_node rsv_window_node; |
| 48 | /* |
| 49 | * was i_next_alloc_block in ext2_inode_info |
| 50 | * is the logical (file-relative) number of the |
| 51 | * most-recently-allocated block in this file. |
| 52 | * We use this for detecting linearly ascending allocation requests. |
| 53 | */ |
| 54 | __u32 last_alloc_logical_block; |
| 55 | /* |
| 56 | * Was i_next_alloc_goal in ext2_inode_info |
| 57 | * is the *physical* companion to i_next_alloc_block. |
| 58 | * it the the physical block number of the block which was most-recentl |
| 59 | * allocated to this file. This give us the goal (target) for the next |
| 60 | * allocation when we detect linearly ascending requests. |
| 61 | */ |
| 62 | ext2_fsblk_t last_alloc_physical_block; |
| 63 | }; |
| 64 | |
| 65 | #define rsv_start rsv_window._rsv_start |
| 66 | #define rsv_end rsv_window._rsv_end |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | /* |
| 69 | * second extended-fs super-block data in memory |
| 70 | */ |
| 71 | struct ext2_sb_info { |
| 72 | unsigned long s_frag_size; /* Size of a fragment in bytes */ |
| 73 | unsigned long s_frags_per_block;/* Number of fragments per block */ |
| 74 | unsigned long s_inodes_per_block;/* Number of inodes per block */ |
| 75 | unsigned long s_frags_per_group;/* Number of fragments in a group */ |
| 76 | unsigned long s_blocks_per_group;/* Number of blocks in a group */ |
| 77 | unsigned long s_inodes_per_group;/* Number of inodes in a group */ |
| 78 | unsigned long s_itb_per_group; /* Number of inode table blocks per group */ |
| 79 | unsigned long s_gdb_count; /* Number of group descriptor blocks */ |
| 80 | unsigned long s_desc_per_block; /* Number of group descriptors per block */ |
| 81 | unsigned long s_groups_count; /* Number of groups in the fs */ |
Badari Pulavarty | 2235219 | 2007-07-15 23:41:58 -0700 | [diff] [blame] | 82 | unsigned long s_overhead_last; /* Last calculated overhead */ |
| 83 | unsigned long s_blocks_last; /* Last seen block count */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | struct buffer_head * s_sbh; /* Buffer containing the super block */ |
| 85 | struct ext2_super_block * s_es; /* Pointer to the super block in the buffer */ |
| 86 | struct buffer_head ** s_group_desc; |
| 87 | unsigned long s_mount_opt; |
Miklos Szeredi | 93d44cb | 2007-10-16 23:26:26 -0700 | [diff] [blame] | 88 | unsigned long s_sb_block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | uid_t s_resuid; |
| 90 | gid_t s_resgid; |
| 91 | unsigned short s_mount_state; |
| 92 | unsigned short s_pad; |
| 93 | int s_addr_per_block_bits; |
| 94 | int s_desc_per_block_bits; |
| 95 | int s_inode_size; |
| 96 | int s_first_ino; |
| 97 | spinlock_t s_next_gen_lock; |
| 98 | u32 s_next_generation; |
| 99 | unsigned long s_dir_count; |
| 100 | u8 *s_debts; |
| 101 | struct percpu_counter s_freeblocks_counter; |
| 102 | struct percpu_counter s_freeinodes_counter; |
| 103 | struct percpu_counter s_dirs_counter; |
| 104 | struct blockgroup_lock s_blockgroup_lock; |
Martin J. Bligh | a686cd8 | 2007-10-16 23:30:46 -0700 | [diff] [blame] | 105 | /* root of the per fs reservation window tree */ |
| 106 | spinlock_t s_rsv_window_lock; |
| 107 | struct rb_root s_rsv_window_root; |
| 108 | struct ext2_reserve_window_node s_rsv_window_head; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
Pekka Enberg | c644f0e | 2009-01-04 12:00:48 -0800 | [diff] [blame^] | 111 | static inline spinlock_t * |
| 112 | sb_bgl_lock(struct ext2_sb_info *sbi, unsigned int block_group) |
| 113 | { |
| 114 | return bgl_lock_ptr(&sbi->s_blockgroup_lock, block_group); |
| 115 | } |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | #endif /* _LINUX_EXT2_FS_SB */ |