aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-arm/bitops.h2
-rw-r--r--include/asm-generic/bitops/ext2-non-atomic.h2
-rw-r--r--include/asm-generic/bitops/le.h4
-rw-r--r--include/asm-m68k/bitops.h2
-rw-r--r--include/asm-m68knommu/bitops.h2
-rw-r--r--include/asm-powerpc/bitops.h4
-rw-r--r--include/asm-s390/bitops.h2
-rw-r--r--include/linux/buffer_head.h2
-rw-r--r--include/linux/ext4_fs.h198
-rw-r--r--include/linux/ext4_fs_extents.h25
-rw-r--r--include/linux/ext4_fs_i.h25
-rw-r--r--include/linux/ext4_fs_sb.h55
-rw-r--r--include/linux/fs.h19
-rw-r--r--include/linux/jbd2.h135
14 files changed, 395 insertions, 82 deletions
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 47a6b086eee2..5c60bfc1a84d 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -310,6 +310,8 @@ static inline int constant_fls(int x)
310 _find_first_zero_bit_le(p,sz) 310 _find_first_zero_bit_le(p,sz)
311#define ext2_find_next_zero_bit(p,sz,off) \ 311#define ext2_find_next_zero_bit(p,sz,off) \
312 _find_next_zero_bit_le(p,sz,off) 312 _find_next_zero_bit_le(p,sz,off)
313#define ext2_find_next_bit(p, sz, off) \
314 _find_next_bit_le(p, sz, off)
313 315
314/* 316/*
315 * Minix is defined to use little-endian byte ordering. 317 * Minix is defined to use little-endian byte ordering.
diff --git a/include/asm-generic/bitops/ext2-non-atomic.h b/include/asm-generic/bitops/ext2-non-atomic.h
index 1697404afa05..63cf822431a2 100644
--- a/include/asm-generic/bitops/ext2-non-atomic.h
+++ b/include/asm-generic/bitops/ext2-non-atomic.h
@@ -14,5 +14,7 @@
14 generic_find_first_zero_le_bit((unsigned long *)(addr), (size)) 14 generic_find_first_zero_le_bit((unsigned long *)(addr), (size))
15#define ext2_find_next_zero_bit(addr, size, off) \ 15#define ext2_find_next_zero_bit(addr, size, off) \
16 generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off)) 16 generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off))
17#define ext2_find_next_bit(addr, size, off) \
18 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
17 19
18#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */ 20#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index b9c7e5d2d2ad..80e3bf13b2b9 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -20,6 +20,8 @@
20#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr) 20#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr)
21 21
22#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset) 22#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset)
23#define generic_find_next_le_bit(addr, size, offset) \
24 find_next_bit(addr, size, offset)
23 25
24#elif defined(__BIG_ENDIAN) 26#elif defined(__BIG_ENDIAN)
25 27
@@ -42,6 +44,8 @@
42 44
43extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, 45extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
44 unsigned long size, unsigned long offset); 46 unsigned long size, unsigned long offset);
47extern unsigned long generic_find_next_le_bit(const unsigned long *addr,
48 unsigned long size, unsigned long offset);
45 49
46#else 50#else
47#error "Please fix <asm/byteorder.h>" 51#error "Please fix <asm/byteorder.h>"
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index 2976b5d68e96..83d1f286230b 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -410,6 +410,8 @@ static inline int ext2_find_next_zero_bit(const void *vaddr, unsigned size,
410 res = ext2_find_first_zero_bit (p, size - 32 * (p - addr)); 410 res = ext2_find_first_zero_bit (p, size - 32 * (p - addr));
411 return (p - addr) * 32 + res; 411 return (p - addr) * 32 + res;
412} 412}
413#define ext2_find_next_bit(addr, size, off) \
414 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
413 415
414#endif /* __KERNEL__ */ 416#endif /* __KERNEL__ */
415 417
diff --git a/include/asm-m68knommu/bitops.h b/include/asm-m68knommu/bitops.h
index f8dfb7ba2e25..f43afe1fc3b3 100644
--- a/include/asm-m68knommu/bitops.h
+++ b/include/asm-m68knommu/bitops.h
@@ -294,6 +294,8 @@ found_middle:
294 return result + ffz(__swab32(tmp)); 294 return result + ffz(__swab32(tmp));
295} 295}
296 296
297#define ext2_find_next_bit(addr, size, off) \
298 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
297#include <asm-generic/bitops/minix.h> 299#include <asm-generic/bitops/minix.h>
298 300
299#endif /* __KERNEL__ */ 301#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h
index 733b4af7f4f1..220d9a781ab9 100644
--- a/include/asm-powerpc/bitops.h
+++ b/include/asm-powerpc/bitops.h
@@ -359,6 +359,8 @@ static __inline__ int test_le_bit(unsigned long nr,
359unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, 359unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
360 unsigned long size, unsigned long offset); 360 unsigned long size, unsigned long offset);
361 361
362unsigned long generic_find_next_le_bit(const unsigned long *addr,
363 unsigned long size, unsigned long offset);
362/* Bitmap functions for the ext2 filesystem */ 364/* Bitmap functions for the ext2 filesystem */
363 365
364#define ext2_set_bit(nr,addr) \ 366#define ext2_set_bit(nr,addr) \
@@ -378,6 +380,8 @@ unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
378#define ext2_find_next_zero_bit(addr, size, off) \ 380#define ext2_find_next_zero_bit(addr, size, off) \
379 generic_find_next_zero_le_bit((unsigned long*)addr, size, off) 381 generic_find_next_zero_le_bit((unsigned long*)addr, size, off)
380 382
383#define ext2_find_next_bit(addr, size, off) \
384 generic_find_next_le_bit((unsigned long *)addr, size, off)
381/* Bitmap functions for the minix filesystem. */ 385/* Bitmap functions for the minix filesystem. */
382 386
383#define minix_test_and_set_bit(nr,addr) \ 387#define minix_test_and_set_bit(nr,addr) \
diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h
index 34d9a6357c38..dba6fecad0be 100644
--- a/include/asm-s390/bitops.h
+++ b/include/asm-s390/bitops.h
@@ -772,6 +772,8 @@ static inline int sched_find_first_bit(unsigned long *b)
772 test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) 772 test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
773#define ext2_test_bit(nr, addr) \ 773#define ext2_test_bit(nr, addr) \
774 test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) 774 test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
775#define ext2_find_next_bit(addr, size, off) \
776 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
775 777
776#ifndef __s390x__ 778#ifndef __s390x__
777 779
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index da0d83fbadc0..e98801f06dcc 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -192,6 +192,8 @@ int sync_dirty_buffer(struct buffer_head *bh);
192int submit_bh(int, struct buffer_head *); 192int submit_bh(int, struct buffer_head *);
193void write_boundary_block(struct block_device *bdev, 193void write_boundary_block(struct block_device *bdev,
194 sector_t bblock, unsigned blocksize); 194 sector_t bblock, unsigned blocksize);
195int bh_uptodate_or_lock(struct buffer_head *bh);
196int bh_submit_read(struct buffer_head *bh);
195 197
196extern int buffer_heads_over_limit; 198extern int buffer_heads_over_limit;
197 199
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
index 97dd409d5f4a..1852313fc7c7 100644
--- a/include/linux/ext4_fs.h
+++ b/include/linux/ext4_fs.h
@@ -20,6 +20,8 @@
20#include <linux/blkdev.h> 20#include <linux/blkdev.h>
21#include <linux/magic.h> 21#include <linux/magic.h>
22 22
23#include <linux/ext4_fs_i.h>
24
23/* 25/*
24 * The second extended filesystem constants/structures 26 * The second extended filesystem constants/structures
25 */ 27 */
@@ -51,6 +53,50 @@
51#define ext4_debug(f, a...) do {} while (0) 53#define ext4_debug(f, a...) do {} while (0)
52#endif 54#endif
53 55
56#define EXT4_MULTIBLOCK_ALLOCATOR 1
57
58/* prefer goal again. length */
59#define EXT4_MB_HINT_MERGE 1
60/* blocks already reserved */
61#define EXT4_MB_HINT_RESERVED 2
62/* metadata is being allocated */
63#define EXT4_MB_HINT_METADATA 4
64/* first blocks in the file */
65#define EXT4_MB_HINT_FIRST 8
66/* search for the best chunk */
67#define EXT4_MB_HINT_BEST 16
68/* data is being allocated */
69#define EXT4_MB_HINT_DATA 32
70/* don't preallocate (for tails) */
71#define EXT4_MB_HINT_NOPREALLOC 64
72/* allocate for locality group */
73#define EXT4_MB_HINT_GROUP_ALLOC 128
74/* allocate goal blocks or none */
75#define EXT4_MB_HINT_GOAL_ONLY 256
76/* goal is meaningful */
77#define EXT4_MB_HINT_TRY_GOAL 512
78
79struct ext4_allocation_request {
80 /* target inode for block we're allocating */
81 struct inode *inode;
82 /* logical block in target inode */
83 ext4_lblk_t logical;
84 /* phys. target (a hint) */
85 ext4_fsblk_t goal;
86 /* the closest logical allocated block to the left */
87 ext4_lblk_t lleft;
88 /* phys. block for ^^^ */
89 ext4_fsblk_t pleft;
90 /* the closest logical allocated block to the right */
91 ext4_lblk_t lright;
92 /* phys. block for ^^^ */
93 ext4_fsblk_t pright;
94 /* how many blocks we want to allocate */
95 unsigned long len;
96 /* flags. see above EXT4_MB_HINT_* */
97 unsigned long flags;
98};
99
54/* 100/*
55 * Special inodes numbers 101 * Special inodes numbers
56 */ 102 */
@@ -73,8 +119,8 @@
73 * Macro-instructions used to manage several block sizes 119 * Macro-instructions used to manage several block sizes
74 */ 120 */
75#define EXT4_MIN_BLOCK_SIZE 1024 121#define EXT4_MIN_BLOCK_SIZE 1024
76#define EXT4_MAX_BLOCK_SIZE 4096 122#define EXT4_MAX_BLOCK_SIZE 65536
77#define EXT4_MIN_BLOCK_LOG_SIZE 10 123#define EXT4_MIN_BLOCK_LOG_SIZE 10
78#ifdef __KERNEL__ 124#ifdef __KERNEL__
79# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize) 125# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
80#else 126#else
@@ -118,6 +164,11 @@ struct ext4_group_desc
118 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */ 164 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
119 __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */ 165 __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
120 __le32 bg_inode_table_hi; /* Inodes table block MSB */ 166 __le32 bg_inode_table_hi; /* Inodes table block MSB */
167 __le16 bg_free_blocks_count_hi;/* Free blocks count MSB */
168 __le16 bg_free_inodes_count_hi;/* Free inodes count MSB */
169 __le16 bg_used_dirs_count_hi; /* Directories count MSB */
170 __le16 bg_itable_unused_hi; /* Unused inodes count MSB */
171 __u32 bg_reserved2[3];
121}; 172};
122 173
123#define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */ 174#define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */
@@ -178,8 +229,9 @@ struct ext4_group_desc
178#define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */ 229#define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
179#define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */ 230#define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
180#define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ 231#define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
181#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */ 232#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
182#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ 233#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
234#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
183 235
184#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */ 236#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
185#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */ 237#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
@@ -237,6 +289,7 @@ struct ext4_new_group_data {
237#endif 289#endif
238#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long) 290#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
239#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long) 291#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
292#define EXT4_IOC_MIGRATE _IO('f', 7)
240 293
241/* 294/*
242 * ioctl commands in 32 bit emulation 295 * ioctl commands in 32 bit emulation
@@ -275,18 +328,18 @@ struct ext4_mount_options {
275struct ext4_inode { 328struct ext4_inode {
276 __le16 i_mode; /* File mode */ 329 __le16 i_mode; /* File mode */
277 __le16 i_uid; /* Low 16 bits of Owner Uid */ 330 __le16 i_uid; /* Low 16 bits of Owner Uid */
278 __le32 i_size; /* Size in bytes */ 331 __le32 i_size_lo; /* Size in bytes */
279 __le32 i_atime; /* Access time */ 332 __le32 i_atime; /* Access time */
280 __le32 i_ctime; /* Inode Change time */ 333 __le32 i_ctime; /* Inode Change time */
281 __le32 i_mtime; /* Modification time */ 334 __le32 i_mtime; /* Modification time */
282 __le32 i_dtime; /* Deletion Time */ 335 __le32 i_dtime; /* Deletion Time */
283 __le16 i_gid; /* Low 16 bits of Group Id */ 336 __le16 i_gid; /* Low 16 bits of Group Id */
284 __le16 i_links_count; /* Links count */ 337 __le16 i_links_count; /* Links count */
285 __le32 i_blocks; /* Blocks count */ 338 __le32 i_blocks_lo; /* Blocks count */
286 __le32 i_flags; /* File flags */ 339 __le32 i_flags; /* File flags */
287 union { 340 union {
288 struct { 341 struct {
289 __u32 l_i_reserved1; 342 __le32 l_i_version;
290 } linux1; 343 } linux1;
291 struct { 344 struct {
292 __u32 h_i_translator; 345 __u32 h_i_translator;
@@ -297,12 +350,12 @@ struct ext4_inode {
297 } osd1; /* OS dependent 1 */ 350 } osd1; /* OS dependent 1 */
298 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */ 351 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
299 __le32 i_generation; /* File version (for NFS) */ 352 __le32 i_generation; /* File version (for NFS) */
300 __le32 i_file_acl; /* File ACL */ 353 __le32 i_file_acl_lo; /* File ACL */
301 __le32 i_dir_acl; /* Directory ACL */ 354 __le32 i_size_high;
302 __le32 i_obso_faddr; /* Obsoleted fragment address */ 355 __le32 i_obso_faddr; /* Obsoleted fragment address */
303 union { 356 union {
304 struct { 357 struct {
305 __le16 l_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ 358 __le16 l_i_blocks_high; /* were l_i_reserved1 */
306 __le16 l_i_file_acl_high; 359 __le16 l_i_file_acl_high;
307 __le16 l_i_uid_high; /* these 2 fields */ 360 __le16 l_i_uid_high; /* these 2 fields */
308 __le16 l_i_gid_high; /* were reserved2[0] */ 361 __le16 l_i_gid_high; /* were reserved2[0] */
@@ -328,9 +381,9 @@ struct ext4_inode {
328 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ 381 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
329 __le32 i_crtime; /* File Creation time */ 382 __le32 i_crtime; /* File Creation time */
330 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ 383 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
384 __le32 i_version_hi; /* high 32 bits for 64-bit version */
331}; 385};
332 386
333#define i_size_high i_dir_acl
334 387
335#define EXT4_EPOCH_BITS 2 388#define EXT4_EPOCH_BITS 2
336#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1) 389#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
@@ -402,9 +455,12 @@ do { \
402 raw_inode->xtime ## _extra); \ 455 raw_inode->xtime ## _extra); \
403} while (0) 456} while (0)
404 457
458#define i_disk_version osd1.linux1.l_i_version
459
405#if defined(__KERNEL__) || defined(__linux__) 460#if defined(__KERNEL__) || defined(__linux__)
406#define i_reserved1 osd1.linux1.l_i_reserved1 461#define i_reserved1 osd1.linux1.l_i_reserved1
407#define i_file_acl_high osd2.linux2.l_i_file_acl_high 462#define i_file_acl_high osd2.linux2.l_i_file_acl_high
463#define i_blocks_high osd2.linux2.l_i_blocks_high
408#define i_uid_low i_uid 464#define i_uid_low i_uid
409#define i_gid_low i_gid 465#define i_gid_low i_gid
410#define i_uid_high osd2.linux2.l_i_uid_high 466#define i_uid_high osd2.linux2.l_i_uid_high
@@ -461,7 +517,10 @@ do { \
461#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ 517#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
462#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ 518#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
463#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */ 519#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
464 520#define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
521#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
522#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
523#define EXT4_MOUNT_MBALLOC 0x4000000 /* Buddy allocation support */
465/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */ 524/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
466#ifndef _LINUX_EXT2_FS_H 525#ifndef _LINUX_EXT2_FS_H
467#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt 526#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
@@ -481,6 +540,7 @@ do { \
481#define ext4_test_bit ext2_test_bit 540#define ext4_test_bit ext2_test_bit
482#define ext4_find_first_zero_bit ext2_find_first_zero_bit 541#define ext4_find_first_zero_bit ext2_find_first_zero_bit
483#define ext4_find_next_zero_bit ext2_find_next_zero_bit 542#define ext4_find_next_zero_bit ext2_find_next_zero_bit
543#define ext4_find_next_bit ext2_find_next_bit
484 544
485/* 545/*
486 * Maximal mount counts between two filesystem checks 546 * Maximal mount counts between two filesystem checks
@@ -671,6 +731,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
671#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 731#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
672#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 732#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
673#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 733#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
734#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
674#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 735#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
675#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 736#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
676#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 737#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
@@ -682,6 +743,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
682#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010 743#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
683#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */ 744#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
684#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 745#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
746#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
685#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 747#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
686 748
687#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR 749#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
@@ -696,7 +758,8 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
696 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ 758 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
697 EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \ 759 EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
698 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \ 760 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
699 EXT4_FEATURE_RO_COMPAT_BTREE_DIR) 761 EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
762 EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
700 763
701/* 764/*
702 * Default values for user and/or group using reserved blocks 765 * Default values for user and/or group using reserved blocks
@@ -767,6 +830,26 @@ struct ext4_dir_entry_2 {
767#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1) 830#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
768#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ 831#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
769 ~EXT4_DIR_ROUND) 832 ~EXT4_DIR_ROUND)
833#define EXT4_MAX_REC_LEN ((1<<16)-1)
834
835static inline unsigned ext4_rec_len_from_disk(__le16 dlen)
836{
837 unsigned len = le16_to_cpu(dlen);
838
839 if (len == EXT4_MAX_REC_LEN)
840 return 1 << 16;
841 return len;
842}
843
844static inline __le16 ext4_rec_len_to_disk(unsigned len)
845{
846 if (len == (1 << 16))
847 return cpu_to_le16(EXT4_MAX_REC_LEN);
848 else if (len > (1 << 16))
849 BUG();
850 return cpu_to_le16(len);
851}
852
770/* 853/*
771 * Hash Tree Directory indexing 854 * Hash Tree Directory indexing
772 * (c) Daniel Phillips, 2001 855 * (c) Daniel Phillips, 2001
@@ -810,7 +893,7 @@ struct ext4_iloc
810{ 893{
811 struct buffer_head *bh; 894 struct buffer_head *bh;
812 unsigned long offset; 895 unsigned long offset;
813 unsigned long block_group; 896 ext4_group_t block_group;
814}; 897};
815 898
816static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc) 899static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
@@ -835,7 +918,7 @@ struct dir_private_info {
835 918
836/* calculate the first block number of the group */ 919/* calculate the first block number of the group */
837static inline ext4_fsblk_t 920static inline ext4_fsblk_t
838ext4_group_first_block_no(struct super_block *sb, unsigned long group_no) 921ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
839{ 922{
840 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) + 923 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
841 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); 924 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
@@ -866,21 +949,24 @@ extern unsigned int ext4_block_group(struct super_block *sb,
866 ext4_fsblk_t blocknr); 949 ext4_fsblk_t blocknr);
867extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb, 950extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
868 ext4_fsblk_t blocknr); 951 ext4_fsblk_t blocknr);
869extern int ext4_bg_has_super(struct super_block *sb, int group); 952extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group);
870extern unsigned long ext4_bg_num_gdb(struct super_block *sb, int group); 953extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
954 ext4_group_t group);
871extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode, 955extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode,
872 ext4_fsblk_t goal, int *errp); 956 ext4_fsblk_t goal, int *errp);
873extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode, 957extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode,
874 ext4_fsblk_t goal, unsigned long *count, int *errp); 958 ext4_fsblk_t goal, unsigned long *count, int *errp);
959extern ext4_fsblk_t ext4_new_blocks_old(handle_t *handle, struct inode *inode,
960 ext4_fsblk_t goal, unsigned long *count, int *errp);
875extern void ext4_free_blocks (handle_t *handle, struct inode *inode, 961extern void ext4_free_blocks (handle_t *handle, struct inode *inode,
876 ext4_fsblk_t block, unsigned long count); 962 ext4_fsblk_t block, unsigned long count, int metadata);
877extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb, 963extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
878 ext4_fsblk_t block, unsigned long count, 964 ext4_fsblk_t block, unsigned long count,
879 unsigned long *pdquot_freed_blocks); 965 unsigned long *pdquot_freed_blocks);
880extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *); 966extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *);
881extern void ext4_check_blocks_bitmap (struct super_block *); 967extern void ext4_check_blocks_bitmap (struct super_block *);
882extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb, 968extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
883 unsigned int block_group, 969 ext4_group_t block_group,
884 struct buffer_head ** bh); 970 struct buffer_head ** bh);
885extern int ext4_should_retry_alloc(struct super_block *sb, int *retries); 971extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
886extern void ext4_init_block_alloc_info(struct inode *); 972extern void ext4_init_block_alloc_info(struct inode *);
@@ -911,15 +997,32 @@ extern unsigned long ext4_count_dirs (struct super_block *);
911extern void ext4_check_inodes_bitmap (struct super_block *); 997extern void ext4_check_inodes_bitmap (struct super_block *);
912extern unsigned long ext4_count_free (struct buffer_head *, unsigned); 998extern unsigned long ext4_count_free (struct buffer_head *, unsigned);
913 999
1000/* mballoc.c */
1001extern long ext4_mb_stats;
1002extern long ext4_mb_max_to_scan;
1003extern int ext4_mb_init(struct super_block *, int);
1004extern int ext4_mb_release(struct super_block *);
1005extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
1006 struct ext4_allocation_request *, int *);
1007extern int ext4_mb_reserve_blocks(struct super_block *, int);
1008extern void ext4_mb_discard_inode_preallocations(struct inode *);
1009extern int __init init_ext4_mballoc(void);
1010extern void exit_ext4_mballoc(void);
1011extern void ext4_mb_free_blocks(handle_t *, struct inode *,
1012 unsigned long, unsigned long, int, unsigned long *);
1013
914 1014
915/* inode.c */ 1015/* inode.c */
916int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, 1016int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
917 struct buffer_head *bh, ext4_fsblk_t blocknr); 1017 struct buffer_head *bh, ext4_fsblk_t blocknr);
918struct buffer_head * ext4_getblk (handle_t *, struct inode *, long, int, int *); 1018struct buffer_head *ext4_getblk(handle_t *, struct inode *,
919struct buffer_head * ext4_bread (handle_t *, struct inode *, int, int, int *); 1019 ext4_lblk_t, int, int *);
1020struct buffer_head *ext4_bread(handle_t *, struct inode *,
1021 ext4_lblk_t, int, int *);
920int ext4_get_blocks_handle(handle_t *handle, struct inode *inode, 1022int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
921 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result, 1023 ext4_lblk_t iblock, unsigned long maxblocks,
922 int create, int extend_disksize); 1024 struct buffer_head *bh_result,
1025 int create, int extend_disksize);
923 1026
924extern void ext4_read_inode (struct inode *); 1027extern void ext4_read_inode (struct inode *);
925extern int ext4_write_inode (struct inode *, int); 1028extern int ext4_write_inode (struct inode *, int);
@@ -943,6 +1046,9 @@ extern int ext4_ioctl (struct inode *, struct file *, unsigned int,
943 unsigned long); 1046 unsigned long);
944extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long); 1047extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
945 1048
1049/* migrate.c */
1050extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
1051 unsigned long);
946/* namei.c */ 1052/* namei.c */
947extern int ext4_orphan_add(handle_t *, struct inode *); 1053extern int ext4_orphan_add(handle_t *, struct inode *);
948extern int ext4_orphan_del(handle_t *, struct inode *); 1054extern int ext4_orphan_del(handle_t *, struct inode *);
@@ -965,6 +1071,12 @@ extern void ext4_abort (struct super_block *, const char *, const char *, ...)
965extern void ext4_warning (struct super_block *, const char *, const char *, ...) 1071extern void ext4_warning (struct super_block *, const char *, const char *, ...)
966 __attribute__ ((format (printf, 3, 4))); 1072 __attribute__ ((format (printf, 3, 4)));
967extern void ext4_update_dynamic_rev (struct super_block *sb); 1073extern void ext4_update_dynamic_rev (struct super_block *sb);
1074extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
1075 __u32 compat);
1076extern int ext4_update_rocompat_feature(handle_t *handle,
1077 struct super_block *sb, __u32 rocompat);
1078extern int ext4_update_incompat_feature(handle_t *handle,
1079 struct super_block *sb, __u32 incompat);
968extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, 1080extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
969 struct ext4_group_desc *bg); 1081 struct ext4_group_desc *bg);
970extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, 1082extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
@@ -1017,6 +1129,29 @@ static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
1017 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32); 1129 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
1018} 1130}
1019 1131
1132static inline loff_t ext4_isize(struct ext4_inode *raw_inode)
1133{
1134 return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) |
1135 le32_to_cpu(raw_inode->i_size_lo);
1136}
1137
1138static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size)
1139{
1140 raw_inode->i_size_lo = cpu_to_le32(i_size);
1141 raw_inode->i_size_high = cpu_to_le32(i_size >> 32);
1142}
1143
1144static inline
1145struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
1146 ext4_group_t group)
1147{
1148 struct ext4_group_info ***grp_info;
1149 long indexv, indexh;
1150 grp_info = EXT4_SB(sb)->s_group_info;
1151 indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
1152 indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);
1153 return grp_info[indexv][indexh];
1154}
1020 1155
1021 1156
1022#define ext4_std_error(sb, errno) \ 1157#define ext4_std_error(sb, errno) \
@@ -1048,7 +1183,7 @@ extern const struct inode_operations ext4_fast_symlink_inode_operations;
1048extern int ext4_ext_tree_init(handle_t *handle, struct inode *); 1183extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
1049extern int ext4_ext_writepage_trans_blocks(struct inode *, int); 1184extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
1050extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, 1185extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1051 ext4_fsblk_t iblock, 1186 ext4_lblk_t iblock,
1052 unsigned long max_blocks, struct buffer_head *bh_result, 1187 unsigned long max_blocks, struct buffer_head *bh_result,
1053 int create, int extend_disksize); 1188 int create, int extend_disksize);
1054extern void ext4_ext_truncate(struct inode *, struct page *); 1189extern void ext4_ext_truncate(struct inode *, struct page *);
@@ -1056,19 +1191,10 @@ extern void ext4_ext_init(struct super_block *);
1056extern void ext4_ext_release(struct super_block *); 1191extern void ext4_ext_release(struct super_block *);
1057extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, 1192extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
1058 loff_t len); 1193 loff_t len);
1059static inline int 1194extern int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode,
1060ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, 1195 sector_t block, unsigned long max_blocks,
1061 unsigned long max_blocks, struct buffer_head *bh, 1196 struct buffer_head *bh, int create,
1062 int create, int extend_disksize) 1197 int extend_disksize);
1063{
1064 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
1065 return ext4_ext_get_blocks(handle, inode, block, max_blocks,
1066 bh, create, extend_disksize);
1067 return ext4_get_blocks_handle(handle, inode, block, max_blocks, bh,
1068 create, extend_disksize);
1069}
1070
1071
1072#endif /* __KERNEL__ */ 1198#endif /* __KERNEL__ */
1073 1199
1074#endif /* _LINUX_EXT4_FS_H */ 1200#endif /* _LINUX_EXT4_FS_H */
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
index d2045a26195d..697da4bce6c5 100644
--- a/include/linux/ext4_fs_extents.h
+++ b/include/linux/ext4_fs_extents.h
@@ -124,20 +124,6 @@ struct ext4_ext_path {
124#define EXT4_EXT_CACHE_GAP 1 124#define EXT4_EXT_CACHE_GAP 1
125#define EXT4_EXT_CACHE_EXTENT 2 125#define EXT4_EXT_CACHE_EXTENT 2
126 126
127/*
128 * to be called by ext4_ext_walk_space()
129 * negative retcode - error
130 * positive retcode - signal for ext4_ext_walk_space(), see below
131 * callback must return valid extent (passed or newly created)
132 */
133typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
134 struct ext4_ext_cache *,
135 void *);
136
137#define EXT_CONTINUE 0
138#define EXT_BREAK 1
139#define EXT_REPEAT 2
140
141 127
142#define EXT_MAX_BLOCK 0xffffffff 128#define EXT_MAX_BLOCK 0xffffffff
143 129
@@ -226,6 +212,8 @@ static inline int ext4_ext_get_actual_len(struct ext4_extent *ext)
226 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN)); 212 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
227} 213}
228 214
215extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
216extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
229extern int ext4_extent_tree_init(handle_t *, struct inode *); 217extern int ext4_extent_tree_init(handle_t *, struct inode *);
230extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *); 218extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *);
231extern int ext4_ext_try_to_merge(struct inode *inode, 219extern int ext4_ext_try_to_merge(struct inode *inode,
@@ -233,8 +221,11 @@ extern int ext4_ext_try_to_merge(struct inode *inode,
233 struct ext4_extent *); 221 struct ext4_extent *);
234extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *); 222extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *);
235extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *); 223extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
236extern int ext4_ext_walk_space(struct inode *, unsigned long, unsigned long, ext_prepare_callback, void *); 224extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
237extern struct ext4_ext_path * ext4_ext_find_extent(struct inode *, int, struct ext4_ext_path *); 225 struct ext4_ext_path *);
238 226extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
227 ext4_lblk_t *, ext4_fsblk_t *);
228extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *,
229 ext4_lblk_t *, ext4_fsblk_t *);
239#endif /* _LINUX_EXT4_EXTENTS */ 230#endif /* _LINUX_EXT4_EXTENTS */
240 231
diff --git a/include/linux/ext4_fs_i.h b/include/linux/ext4_fs_i.h
index 86ddfe2089f3..d5508d3cf290 100644
--- a/include/linux/ext4_fs_i.h
+++ b/include/linux/ext4_fs_i.h
@@ -27,6 +27,12 @@ typedef int ext4_grpblk_t;
27/* data type for filesystem-wide blocks number */ 27/* data type for filesystem-wide blocks number */
28typedef unsigned long long ext4_fsblk_t; 28typedef unsigned long long ext4_fsblk_t;
29 29
30/* data type for file logical block number */
31typedef __u32 ext4_lblk_t;
32
33/* data type for block group number */
34typedef unsigned long ext4_group_t;
35
30struct ext4_reserve_window { 36struct ext4_reserve_window {
31 ext4_fsblk_t _rsv_start; /* First byte reserved */ 37 ext4_fsblk_t _rsv_start; /* First byte reserved */
32 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */ 38 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */
@@ -48,7 +54,7 @@ struct ext4_block_alloc_info {
48 * most-recently-allocated block in this file. 54 * most-recently-allocated block in this file.
49 * We use this for detecting linearly ascending allocation requests. 55 * We use this for detecting linearly ascending allocation requests.
50 */ 56 */
51 __u32 last_alloc_logical_block; 57 ext4_lblk_t last_alloc_logical_block;
52 /* 58 /*
53 * Was i_next_alloc_goal in ext4_inode_info 59 * Was i_next_alloc_goal in ext4_inode_info
54 * is the *physical* companion to i_next_alloc_block. 60 * is the *physical* companion to i_next_alloc_block.
@@ -67,7 +73,7 @@ struct ext4_block_alloc_info {
67 */ 73 */
68struct ext4_ext_cache { 74struct ext4_ext_cache {
69 ext4_fsblk_t ec_start; 75 ext4_fsblk_t ec_start;
70 __u32 ec_block; 76 ext4_lblk_t ec_block;
71 __u32 ec_len; /* must be 32bit to return holes */ 77 __u32 ec_len; /* must be 32bit to return holes */
72 __u32 ec_type; 78 __u32 ec_type;
73}; 79};
@@ -79,7 +85,6 @@ struct ext4_inode_info {
79 __le32 i_data[15]; /* unconverted */ 85 __le32 i_data[15]; /* unconverted */
80 __u32 i_flags; 86 __u32 i_flags;
81 ext4_fsblk_t i_file_acl; 87 ext4_fsblk_t i_file_acl;
82 __u32 i_dir_acl;
83 __u32 i_dtime; 88 __u32 i_dtime;
84 89
85 /* 90 /*
@@ -89,13 +94,13 @@ struct ext4_inode_info {
89 * place a file's data blocks near its inode block, and new inodes 94 * place a file's data blocks near its inode block, and new inodes
90 * near to their parent directory's inode. 95 * near to their parent directory's inode.
91 */ 96 */
92 __u32 i_block_group; 97 ext4_group_t i_block_group;
93 __u32 i_state; /* Dynamic state flags for ext4 */ 98 __u32 i_state; /* Dynamic state flags for ext4 */
94 99
95 /* block reservation info */ 100 /* block reservation info */
96 struct ext4_block_alloc_info *i_block_alloc_info; 101 struct ext4_block_alloc_info *i_block_alloc_info;
97 102
98 __u32 i_dir_start_lookup; 103 ext4_lblk_t i_dir_start_lookup;
99#ifdef CONFIG_EXT4DEV_FS_XATTR 104#ifdef CONFIG_EXT4DEV_FS_XATTR
100 /* 105 /*
101 * Extended attributes can be read independently of the main file 106 * Extended attributes can be read independently of the main file
@@ -134,16 +139,16 @@ struct ext4_inode_info {
134 __u16 i_extra_isize; 139 __u16 i_extra_isize;
135 140
136 /* 141 /*
137 * truncate_mutex is for serialising ext4_truncate() against 142 * i_data_sem is for serialising ext4_truncate() against
138 * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's 143 * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's
139 * data tree are chopped off during truncate. We can't do that in 144 * data tree are chopped off during truncate. We can't do that in
140 * ext4 because whenever we perform intermediate commits during 145 * ext4 because whenever we perform intermediate commits during
141 * truncate, the inode and all the metadata blocks *must* be in a 146 * truncate, the inode and all the metadata blocks *must* be in a
142 * consistent state which allows truncation of the orphans to restart 147 * consistent state which allows truncation of the orphans to restart
143 * during recovery. Hence we must fix the get_block-vs-truncate race 148 * during recovery. Hence we must fix the get_block-vs-truncate race
144 * by other means, so we have truncate_mutex. 149 * by other means, so we have i_data_sem.
145 */ 150 */
146 struct mutex truncate_mutex; 151 struct rw_semaphore i_data_sem;
147 struct inode vfs_inode; 152 struct inode vfs_inode;
148 153
149 unsigned long i_ext_generation; 154 unsigned long i_ext_generation;
@@ -153,6 +158,10 @@ struct ext4_inode_info {
153 * struct timespec i_{a,c,m}time in the generic inode. 158 * struct timespec i_{a,c,m}time in the generic inode.
154 */ 159 */
155 struct timespec i_crtime; 160 struct timespec i_crtime;
161
162 /* mballoc */
163 struct list_head i_prealloc_list;
164 spinlock_t i_prealloc_lock;
156}; 165};
157 166
158#endif /* _LINUX_EXT4_FS_I */ 167#endif /* _LINUX_EXT4_FS_I */
diff --git a/include/linux/ext4_fs_sb.h b/include/linux/ext4_fs_sb.h
index b40e827cd495..abaae2c8cccf 100644
--- a/include/linux/ext4_fs_sb.h
+++ b/include/linux/ext4_fs_sb.h
@@ -35,9 +35,10 @@ struct ext4_sb_info {
35 unsigned long s_itb_per_group; /* Number of inode table blocks per group */ 35 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
36 unsigned long s_gdb_count; /* Number of group descriptor blocks */ 36 unsigned long s_gdb_count; /* Number of group descriptor blocks */
37 unsigned long s_desc_per_block; /* Number of group descriptors per block */ 37 unsigned long s_desc_per_block; /* Number of group descriptors per block */
38 unsigned long s_groups_count; /* Number of groups in the fs */ 38 ext4_group_t s_groups_count; /* Number of groups in the fs */
39 unsigned long s_overhead_last; /* Last calculated overhead */ 39 unsigned long s_overhead_last; /* Last calculated overhead */
40 unsigned long s_blocks_last; /* Last seen block count */ 40 unsigned long s_blocks_last; /* Last seen block count */
41 loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */
41 struct buffer_head * s_sbh; /* Buffer containing the super block */ 42 struct buffer_head * s_sbh; /* Buffer containing the super block */
42 struct ext4_super_block * s_es; /* Pointer to the super block in the buffer */ 43 struct ext4_super_block * s_es; /* Pointer to the super block in the buffer */
43 struct buffer_head ** s_group_desc; 44 struct buffer_head ** s_group_desc;
@@ -90,6 +91,58 @@ struct ext4_sb_info {
90 unsigned long s_ext_blocks; 91 unsigned long s_ext_blocks;
91 unsigned long s_ext_extents; 92 unsigned long s_ext_extents;
92#endif 93#endif
94
95 /* for buddy allocator */
96 struct ext4_group_info ***s_group_info;
97 struct inode *s_buddy_cache;
98 long s_blocks_reserved;
99 spinlock_t s_reserve_lock;
100 struct list_head s_active_transaction;
101 struct list_head s_closed_transaction;
102 struct list_head s_committed_transaction;
103 spinlock_t s_md_lock;
104 tid_t s_last_transaction;
105 unsigned short *s_mb_offsets, *s_mb_maxs;
106
107 /* tunables */
108 unsigned long s_stripe;
109 unsigned long s_mb_stream_request;
110 unsigned long s_mb_max_to_scan;
111 unsigned long s_mb_min_to_scan;
112 unsigned long s_mb_stats;
113 unsigned long s_mb_order2_reqs;
114 unsigned long s_mb_group_prealloc;
115 /* where last allocation was done - for stream allocation */
116 unsigned long s_mb_last_group;
117 unsigned long s_mb_last_start;
118
119 /* history to debug policy */
120 struct ext4_mb_history *s_mb_history;
121 int s_mb_history_cur;
122 int s_mb_history_max;
123 int s_mb_history_num;
124 struct proc_dir_entry *s_mb_proc;
125 spinlock_t s_mb_history_lock;
126 int s_mb_history_filter;
127
128 /* stats for buddy allocator */
129 spinlock_t s_mb_pa_lock;
130 atomic_t s_bal_reqs; /* number of reqs with len > 1 */
131 atomic_t s_bal_success; /* we found long enough chunks */
132 atomic_t s_bal_allocated; /* in blocks */
133 atomic_t s_bal_ex_scanned; /* total extents scanned */
134 atomic_t s_bal_goals; /* goal hits */
135 atomic_t s_bal_breaks; /* too long searches */
136 atomic_t s_bal_2orders; /* 2^order hits */
137 spinlock_t s_bal_lock;
138 unsigned long s_mb_buddies_generated;
139 unsigned long long s_mb_generation_time;
140 atomic_t s_mb_lost_chunks;
141 atomic_t s_mb_preallocated;
142 atomic_t s_mb_discarded;
143
144 /* locality groups */
145 struct ext4_locality_group *s_locality_groups;
93}; 146};
94 147
95#endif /* _LINUX_EXT4_FS_SB */ 148#endif /* _LINUX_EXT4_FS_SB */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 21398a5d688d..a516b6716870 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -124,6 +124,7 @@ extern int dir_notify_enable;
124#define MS_SHARED (1<<20) /* change to shared */ 124#define MS_SHARED (1<<20) /* change to shared */
125#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ 125#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
126#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ 126#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
127#define MS_I_VERSION (1<<23) /* Update inode I_version field */
127#define MS_ACTIVE (1<<30) 128#define MS_ACTIVE (1<<30)
128#define MS_NOUSER (1<<31) 129#define MS_NOUSER (1<<31)
129 130
@@ -173,6 +174,7 @@ extern int dir_notify_enable;
173 ((inode)->i_flags & (S_SYNC|S_DIRSYNC))) 174 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
174#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK) 175#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
175#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME) 176#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
177#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
176 178
177#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA) 179#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
178#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) 180#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
@@ -599,7 +601,7 @@ struct inode {
599 uid_t i_uid; 601 uid_t i_uid;
600 gid_t i_gid; 602 gid_t i_gid;
601 dev_t i_rdev; 603 dev_t i_rdev;
602 unsigned long i_version; 604 u64 i_version;
603 loff_t i_size; 605 loff_t i_size;
604#ifdef __NEED_I_SIZE_ORDERED 606#ifdef __NEED_I_SIZE_ORDERED
605 seqcount_t i_size_seqcount; 607 seqcount_t i_size_seqcount;
@@ -1394,6 +1396,21 @@ static inline void inode_dec_link_count(struct inode *inode)
1394 mark_inode_dirty(inode); 1396 mark_inode_dirty(inode);
1395} 1397}
1396 1398
1399/**
1400 * inode_inc_iversion - increments i_version
1401 * @inode: inode that need to be updated
1402 *
1403 * Every time the inode is modified, the i_version field will be incremented.
1404 * The filesystem has to be mounted with i_version flag
1405 */
1406
1407static inline void inode_inc_iversion(struct inode *inode)
1408{
1409 spin_lock(&inode->i_lock);
1410 inode->i_version++;
1411 spin_unlock(&inode->i_lock);
1412}
1413
1397extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry); 1414extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry);
1398static inline void file_accessed(struct file *file) 1415static inline void file_accessed(struct file *file)
1399{ 1416{
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 06ef11457051..2cbf6fdb1799 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -149,6 +149,28 @@ typedef struct journal_header_s
149 __be32 h_sequence; 149 __be32 h_sequence;
150} journal_header_t; 150} journal_header_t;
151 151
152/*
153 * Checksum types.
154 */
155#define JBD2_CRC32_CHKSUM 1
156#define JBD2_MD5_CHKSUM 2
157#define JBD2_SHA1_CHKSUM 3
158
159#define JBD2_CRC32_CHKSUM_SIZE 4
160
161#define JBD2_CHECKSUM_BYTES (32 / sizeof(u32))
162/*
163 * Commit block header for storing transactional checksums:
164 */
165struct commit_header {
166 __be32 h_magic;
167 __be32 h_blocktype;
168 __be32 h_sequence;
169 unsigned char h_chksum_type;
170 unsigned char h_chksum_size;
171 unsigned char h_padding[2];
172 __be32 h_chksum[JBD2_CHECKSUM_BYTES];
173};
152 174
153/* 175/*
154 * The block tag: used to describe a single buffer in the journal. 176 * The block tag: used to describe a single buffer in the journal.
@@ -242,31 +264,25 @@ typedef struct journal_superblock_s
242 ((j)->j_format_version >= 2 && \ 264 ((j)->j_format_version >= 2 && \
243 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask)))) 265 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
244 266
245#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001 267#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
246#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 268
269#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
270#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
271#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
247 272
248/* Features known to this kernel version: */ 273/* Features known to this kernel version: */
249#define JBD2_KNOWN_COMPAT_FEATURES 0 274#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
250#define JBD2_KNOWN_ROCOMPAT_FEATURES 0 275#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
251#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ 276#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
252 JBD2_FEATURE_INCOMPAT_64BIT) 277 JBD2_FEATURE_INCOMPAT_64BIT | \
278 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)
253 279
254#ifdef __KERNEL__ 280#ifdef __KERNEL__
255 281
256#include <linux/fs.h> 282#include <linux/fs.h>
257#include <linux/sched.h> 283#include <linux/sched.h>
258 284
259#define JBD2_ASSERTIONS 285#define J_ASSERT(assert) BUG_ON(!(assert))
260#ifdef JBD2_ASSERTIONS
261#define J_ASSERT(assert) \
262do { \
263 if (!(assert)) { \
264 printk (KERN_EMERG \
265 "Assertion failure in %s() at %s:%d: \"%s\"\n", \
266 __FUNCTION__, __FILE__, __LINE__, # assert); \
267 BUG(); \
268 } \
269} while (0)
270 286
271#if defined(CONFIG_BUFFER_DEBUG) 287#if defined(CONFIG_BUFFER_DEBUG)
272void buffer_assertion_failure(struct buffer_head *bh); 288void buffer_assertion_failure(struct buffer_head *bh);
@@ -282,10 +298,6 @@ void buffer_assertion_failure(struct buffer_head *bh);
282#define J_ASSERT_JH(jh, expr) J_ASSERT(expr) 298#define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
283#endif 299#endif
284 300
285#else
286#define J_ASSERT(assert) do { } while (0)
287#endif /* JBD2_ASSERTIONS */
288
289#if defined(JBD2_PARANOID_IOFAIL) 301#if defined(JBD2_PARANOID_IOFAIL)
290#define J_EXPECT(expr, why...) J_ASSERT(expr) 302#define J_EXPECT(expr, why...) J_ASSERT(expr)
291#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr) 303#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
@@ -406,9 +418,23 @@ struct handle_s
406 unsigned int h_sync: 1; /* sync-on-close */ 418 unsigned int h_sync: 1; /* sync-on-close */
407 unsigned int h_jdata: 1; /* force data journaling */ 419 unsigned int h_jdata: 1; /* force data journaling */
408 unsigned int h_aborted: 1; /* fatal error on handle */ 420 unsigned int h_aborted: 1; /* fatal error on handle */
421
422#ifdef CONFIG_DEBUG_LOCK_ALLOC
423 struct lockdep_map h_lockdep_map;
424#endif
409}; 425};
410 426
411 427
428/*
429 * Some stats for checkpoint phase
430 */
431struct transaction_chp_stats_s {
432 unsigned long cs_chp_time;
433 unsigned long cs_forced_to_close;
434 unsigned long cs_written;
435 unsigned long cs_dropped;
436};
437
412/* The transaction_t type is the guts of the journaling mechanism. It 438/* The transaction_t type is the guts of the journaling mechanism. It
413 * tracks a compound transaction through its various states: 439 * tracks a compound transaction through its various states:
414 * 440 *
@@ -456,6 +482,8 @@ struct transaction_s
456 /* 482 /*
457 * Transaction's current state 483 * Transaction's current state
458 * [no locking - only kjournald2 alters this] 484 * [no locking - only kjournald2 alters this]
485 * [j_list_lock] guards transition of a transaction into T_FINISHED
486 * state and subsequent call of __jbd2_journal_drop_transaction()
459 * FIXME: needs barriers 487 * FIXME: needs barriers
460 * KLUDGE: [use j_state_lock] 488 * KLUDGE: [use j_state_lock]
461 */ 489 */
@@ -544,6 +572,21 @@ struct transaction_s
544 spinlock_t t_handle_lock; 572 spinlock_t t_handle_lock;
545 573
546 /* 574 /*
575 * Longest time some handle had to wait for running transaction
576 */
577 unsigned long t_max_wait;
578
579 /*
580 * When transaction started
581 */
582 unsigned long t_start;
583
584 /*
585 * Checkpointing stats [j_checkpoint_sem]
586 */
587 struct transaction_chp_stats_s t_chp_stats;
588
589 /*
547 * Number of outstanding updates running on this transaction 590 * Number of outstanding updates running on this transaction
548 * [t_handle_lock] 591 * [t_handle_lock]
549 */ 592 */
@@ -574,6 +617,39 @@ struct transaction_s
574 617
575}; 618};
576 619
620struct transaction_run_stats_s {
621 unsigned long rs_wait;
622 unsigned long rs_running;
623 unsigned long rs_locked;
624 unsigned long rs_flushing;
625 unsigned long rs_logging;
626
627 unsigned long rs_handle_count;
628 unsigned long rs_blocks;
629 unsigned long rs_blocks_logged;
630};
631
632struct transaction_stats_s {
633 int ts_type;
634 unsigned long ts_tid;
635 union {
636 struct transaction_run_stats_s run;
637 struct transaction_chp_stats_s chp;
638 } u;
639};
640
641#define JBD2_STATS_RUN 1
642#define JBD2_STATS_CHECKPOINT 2
643
644static inline unsigned long
645jbd2_time_diff(unsigned long start, unsigned long end)
646{
647 if (end >= start)
648 return end - start;
649
650 return end + (MAX_JIFFY_OFFSET - start);
651}
652
577/** 653/**
578 * struct journal_s - The journal_s type is the concrete type associated with 654 * struct journal_s - The journal_s type is the concrete type associated with
579 * journal_t. 655 * journal_t.
@@ -635,6 +711,12 @@ struct transaction_s
635 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the 711 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the
636 * number that will fit in j_blocksize 712 * number that will fit in j_blocksize
637 * @j_last_sync_writer: most recent pid which did a synchronous write 713 * @j_last_sync_writer: most recent pid which did a synchronous write
714 * @j_history: Buffer storing the transactions statistics history
715 * @j_history_max: Maximum number of transactions in the statistics history
716 * @j_history_cur: Current number of transactions in the statistics history
717 * @j_history_lock: Protect the transactions statistics history
718 * @j_proc_entry: procfs entry for the jbd statistics directory
719 * @j_stats: Overall statistics
638 * @j_private: An opaque pointer to fs-private information. 720 * @j_private: An opaque pointer to fs-private information.
639 */ 721 */
640 722
@@ -827,6 +909,19 @@ struct journal_s
827 pid_t j_last_sync_writer; 909 pid_t j_last_sync_writer;
828 910
829 /* 911 /*
912 * Journal statistics
913 */
914 struct transaction_stats_s *j_history;
915 int j_history_max;
916 int j_history_cur;
917 /*
918 * Protect the transactions statistics history
919 */
920 spinlock_t j_history_lock;
921 struct proc_dir_entry *j_proc_entry;
922 struct transaction_stats_s j_stats;
923
924 /*
830 * An opaque pointer to fs-private information. ext3 puts its 925 * An opaque pointer to fs-private information. ext3 puts its
831 * superblock pointer here 926 * superblock pointer here
832 */ 927 */
@@ -932,6 +1027,8 @@ extern int jbd2_journal_check_available_features
932 (journal_t *, unsigned long, unsigned long, unsigned long); 1027 (journal_t *, unsigned long, unsigned long, unsigned long);
933extern int jbd2_journal_set_features 1028extern int jbd2_journal_set_features
934 (journal_t *, unsigned long, unsigned long, unsigned long); 1029 (journal_t *, unsigned long, unsigned long, unsigned long);
1030extern void jbd2_journal_clear_features
1031 (journal_t *, unsigned long, unsigned long, unsigned long);
935extern int jbd2_journal_create (journal_t *); 1032extern int jbd2_journal_create (journal_t *);
936extern int jbd2_journal_load (journal_t *journal); 1033extern int jbd2_journal_load (journal_t *journal);
937extern void jbd2_journal_destroy (journal_t *); 1034extern void jbd2_journal_destroy (journal_t *);