diff options
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 145 |
1 files changed, 111 insertions, 34 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 9714db393efe..984ca0cb38c3 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -65,29 +65,37 @@ typedef __u32 ext4_lblk_t; | |||
65 | /* data type for block group number */ | 65 | /* data type for block group number */ |
66 | typedef unsigned int ext4_group_t; | 66 | typedef unsigned int ext4_group_t; |
67 | 67 | ||
68 | /* | ||
69 | * Flags used in mballoc's allocation_context flags field. | ||
70 | * | ||
71 | * Also used to show what's going on for debugging purposes when the | ||
72 | * flag field is exported via the traceport interface | ||
73 | */ | ||
68 | 74 | ||
69 | /* prefer goal again. length */ | 75 | /* prefer goal again. length */ |
70 | #define EXT4_MB_HINT_MERGE 1 | 76 | #define EXT4_MB_HINT_MERGE 0x0001 |
71 | /* blocks already reserved */ | 77 | /* blocks already reserved */ |
72 | #define EXT4_MB_HINT_RESERVED 2 | 78 | #define EXT4_MB_HINT_RESERVED 0x0002 |
73 | /* metadata is being allocated */ | 79 | /* metadata is being allocated */ |
74 | #define EXT4_MB_HINT_METADATA 4 | 80 | #define EXT4_MB_HINT_METADATA 0x0004 |
75 | /* first blocks in the file */ | 81 | /* first blocks in the file */ |
76 | #define EXT4_MB_HINT_FIRST 8 | 82 | #define EXT4_MB_HINT_FIRST 0x0008 |
77 | /* search for the best chunk */ | 83 | /* search for the best chunk */ |
78 | #define EXT4_MB_HINT_BEST 16 | 84 | #define EXT4_MB_HINT_BEST 0x0010 |
79 | /* data is being allocated */ | 85 | /* data is being allocated */ |
80 | #define EXT4_MB_HINT_DATA 32 | 86 | #define EXT4_MB_HINT_DATA 0x0020 |
81 | /* don't preallocate (for tails) */ | 87 | /* don't preallocate (for tails) */ |
82 | #define EXT4_MB_HINT_NOPREALLOC 64 | 88 | #define EXT4_MB_HINT_NOPREALLOC 0x0040 |
83 | /* allocate for locality group */ | 89 | /* allocate for locality group */ |
84 | #define EXT4_MB_HINT_GROUP_ALLOC 128 | 90 | #define EXT4_MB_HINT_GROUP_ALLOC 0x0080 |
85 | /* allocate goal blocks or none */ | 91 | /* allocate goal blocks or none */ |
86 | #define EXT4_MB_HINT_GOAL_ONLY 256 | 92 | #define EXT4_MB_HINT_GOAL_ONLY 0x0100 |
87 | /* goal is meaningful */ | 93 | /* goal is meaningful */ |
88 | #define EXT4_MB_HINT_TRY_GOAL 512 | 94 | #define EXT4_MB_HINT_TRY_GOAL 0x0200 |
89 | /* blocks already pre-reserved by delayed allocation */ | 95 | /* blocks already pre-reserved by delayed allocation */ |
90 | #define EXT4_MB_DELALLOC_RESERVED 1024 | 96 | #define EXT4_MB_DELALLOC_RESERVED 0x0400 |
97 | /* We are doing stream allocation */ | ||
98 | #define EXT4_MB_STREAM_ALLOC 0x0800 | ||
91 | 99 | ||
92 | 100 | ||
93 | struct ext4_allocation_request { | 101 | struct ext4_allocation_request { |
@@ -112,6 +120,31 @@ struct ext4_allocation_request { | |||
112 | }; | 120 | }; |
113 | 121 | ||
114 | /* | 122 | /* |
123 | * For delayed allocation tracking | ||
124 | */ | ||
125 | struct mpage_da_data { | ||
126 | struct inode *inode; | ||
127 | sector_t b_blocknr; /* start block number of extent */ | ||
128 | size_t b_size; /* size of extent */ | ||
129 | unsigned long b_state; /* state of the extent */ | ||
130 | unsigned long first_page, next_page; /* extent of pages */ | ||
131 | struct writeback_control *wbc; | ||
132 | int io_done; | ||
133 | int pages_written; | ||
134 | int retval; | ||
135 | }; | ||
136 | #define DIO_AIO_UNWRITTEN 0x1 | ||
137 | typedef struct ext4_io_end { | ||
138 | struct list_head list; /* per-file finished AIO list */ | ||
139 | struct inode *inode; /* file being written to */ | ||
140 | unsigned int flag; /* unwritten or not */ | ||
141 | int error; /* I/O error code */ | ||
142 | ext4_lblk_t offset; /* offset in the file */ | ||
143 | size_t size; /* size of the extent */ | ||
144 | struct work_struct work; /* data work queue */ | ||
145 | } ext4_io_end_t; | ||
146 | |||
147 | /* | ||
115 | * Special inodes numbers | 148 | * Special inodes numbers |
116 | */ | 149 | */ |
117 | #define EXT4_BAD_INO 1 /* Bad blocks inode */ | 150 | #define EXT4_BAD_INO 1 /* Bad blocks inode */ |
@@ -251,7 +284,6 @@ struct flex_groups { | |||
251 | #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ | 284 | #define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ |
252 | #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */ | 285 | #define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */ |
253 | #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ | 286 | #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ |
254 | #define EXT4_EXT_MIGRATE 0x00100000 /* Inode is migrating */ | ||
255 | #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */ | 287 | #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */ |
256 | 288 | ||
257 | #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */ | 289 | #define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */ |
@@ -289,6 +321,7 @@ static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags) | |||
289 | #define EXT4_STATE_XATTR 0x00000004 /* has in-inode xattrs */ | 321 | #define EXT4_STATE_XATTR 0x00000004 /* has in-inode xattrs */ |
290 | #define EXT4_STATE_NO_EXPAND 0x00000008 /* No space for expansion */ | 322 | #define EXT4_STATE_NO_EXPAND 0x00000008 /* No space for expansion */ |
291 | #define EXT4_STATE_DA_ALLOC_CLOSE 0x00000010 /* Alloc DA blks on close */ | 323 | #define EXT4_STATE_DA_ALLOC_CLOSE 0x00000010 /* Alloc DA blks on close */ |
324 | #define EXT4_STATE_EXT_MIGRATE 0x00000020 /* Inode is migrating */ | ||
292 | 325 | ||
293 | /* Used to pass group descriptor data when online resize is done */ | 326 | /* Used to pass group descriptor data when online resize is done */ |
294 | struct ext4_new_group_input { | 327 | struct ext4_new_group_input { |
@@ -330,7 +363,16 @@ struct ext4_new_group_data { | |||
330 | /* Call ext4_da_update_reserve_space() after successfully | 363 | /* Call ext4_da_update_reserve_space() after successfully |
331 | allocating the blocks */ | 364 | allocating the blocks */ |
332 | #define EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE 0x0008 | 365 | #define EXT4_GET_BLOCKS_UPDATE_RESERVE_SPACE 0x0008 |
333 | 366 | /* caller is from the direct IO path, request to creation of an | |
367 | unitialized extents if not allocated, split the uninitialized | ||
368 | extent if blocks has been preallocated already*/ | ||
369 | #define EXT4_GET_BLOCKS_DIO 0x0010 | ||
370 | #define EXT4_GET_BLOCKS_CONVERT 0x0020 | ||
371 | #define EXT4_GET_BLOCKS_DIO_CREATE_EXT (EXT4_GET_BLOCKS_DIO|\ | ||
372 | EXT4_GET_BLOCKS_CREATE_UNINIT_EXT) | ||
373 | /* Convert extent to initialized after direct IO complete */ | ||
374 | #define EXT4_GET_BLOCKS_DIO_CONVERT_EXT (EXT4_GET_BLOCKS_CONVERT|\ | ||
375 | EXT4_GET_BLOCKS_DIO_CREATE_EXT) | ||
334 | 376 | ||
335 | /* | 377 | /* |
336 | * ioctl commands | 378 | * ioctl commands |
@@ -386,6 +428,9 @@ struct ext4_mount_options { | |||
386 | #endif | 428 | #endif |
387 | }; | 429 | }; |
388 | 430 | ||
431 | /* Max physical block we can addres w/o extents */ | ||
432 | #define EXT4_MAX_BLOCK_FILE_PHYS 0xFFFFFFFF | ||
433 | |||
389 | /* | 434 | /* |
390 | * Structure of an inode on the disk | 435 | * Structure of an inode on the disk |
391 | */ | 436 | */ |
@@ -456,7 +501,6 @@ struct move_extent { | |||
456 | __u64 len; /* block length to be moved */ | 501 | __u64 len; /* block length to be moved */ |
457 | __u64 moved_len; /* moved block length */ | 502 | __u64 moved_len; /* moved block length */ |
458 | }; | 503 | }; |
459 | #define MAX_DEFRAG_SIZE ((1UL<<31) - 1) | ||
460 | 504 | ||
461 | #define EXT4_EPOCH_BITS 2 | 505 | #define EXT4_EPOCH_BITS 2 |
462 | #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1) | 506 | #define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1) |
@@ -481,8 +525,8 @@ struct move_extent { | |||
481 | static inline __le32 ext4_encode_extra_time(struct timespec *time) | 525 | static inline __le32 ext4_encode_extra_time(struct timespec *time) |
482 | { | 526 | { |
483 | return cpu_to_le32((sizeof(time->tv_sec) > 4 ? | 527 | return cpu_to_le32((sizeof(time->tv_sec) > 4 ? |
484 | time->tv_sec >> 32 : 0) | | 528 | (time->tv_sec >> 32) & EXT4_EPOCH_MASK : 0) | |
485 | ((time->tv_nsec << 2) & EXT4_NSEC_MASK)); | 529 | ((time->tv_nsec << EXT4_EPOCH_BITS) & EXT4_NSEC_MASK)); |
486 | } | 530 | } |
487 | 531 | ||
488 | static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) | 532 | static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) |
@@ -490,7 +534,7 @@ static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) | |||
490 | if (sizeof(time->tv_sec) > 4) | 534 | if (sizeof(time->tv_sec) > 4) |
491 | time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) | 535 | time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) |
492 | << 32; | 536 | << 32; |
493 | time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> 2; | 537 | time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; |
494 | } | 538 | } |
495 | 539 | ||
496 | #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \ | 540 | #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \ |
@@ -653,6 +697,11 @@ struct ext4_inode_info { | |||
653 | __u16 i_extra_isize; | 697 | __u16 i_extra_isize; |
654 | 698 | ||
655 | spinlock_t i_block_reservation_lock; | 699 | spinlock_t i_block_reservation_lock; |
700 | |||
701 | /* completed async DIOs that might need unwritten extents handling */ | ||
702 | struct list_head i_aio_dio_complete_list; | ||
703 | /* current io_end structure for async DIO write*/ | ||
704 | ext4_io_end_t *cur_aio_dio; | ||
656 | }; | 705 | }; |
657 | 706 | ||
658 | /* | 707 | /* |
@@ -694,7 +743,6 @@ struct ext4_inode_info { | |||
694 | #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */ | 743 | #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */ |
695 | #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ | 744 | #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ |
696 | #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ | 745 | #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ |
697 | #define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */ | ||
698 | #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */ | 746 | #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */ |
699 | #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */ | 747 | #define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */ |
700 | #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */ | 748 | #define EXT4_MOUNT_DELALLOC 0x8000000 /* Delalloc support */ |
@@ -841,6 +889,7 @@ struct ext4_sb_info { | |||
841 | unsigned long s_gdb_count; /* Number of group descriptor blocks */ | 889 | unsigned long s_gdb_count; /* Number of group descriptor blocks */ |
842 | unsigned long s_desc_per_block; /* Number of group descriptors per block */ | 890 | unsigned long s_desc_per_block; /* Number of group descriptors per block */ |
843 | ext4_group_t s_groups_count; /* Number of groups in the fs */ | 891 | ext4_group_t s_groups_count; /* Number of groups in the fs */ |
892 | ext4_group_t s_blockfile_groups;/* Groups acceptable for non-extent files */ | ||
844 | unsigned long s_overhead_last; /* Last calculated overhead */ | 893 | unsigned long s_overhead_last; /* Last calculated overhead */ |
845 | unsigned long s_blocks_last; /* Last seen block count */ | 894 | unsigned long s_blocks_last; /* Last seen block count */ |
846 | loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */ | 895 | loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */ |
@@ -923,18 +972,11 @@ struct ext4_sb_info { | |||
923 | unsigned int s_mb_stats; | 972 | unsigned int s_mb_stats; |
924 | unsigned int s_mb_order2_reqs; | 973 | unsigned int s_mb_order2_reqs; |
925 | unsigned int s_mb_group_prealloc; | 974 | unsigned int s_mb_group_prealloc; |
975 | unsigned int s_max_writeback_mb_bump; | ||
926 | /* where last allocation was done - for stream allocation */ | 976 | /* where last allocation was done - for stream allocation */ |
927 | unsigned long s_mb_last_group; | 977 | unsigned long s_mb_last_group; |
928 | unsigned long s_mb_last_start; | 978 | unsigned long s_mb_last_start; |
929 | 979 | ||
930 | /* history to debug policy */ | ||
931 | struct ext4_mb_history *s_mb_history; | ||
932 | int s_mb_history_cur; | ||
933 | int s_mb_history_max; | ||
934 | int s_mb_history_num; | ||
935 | spinlock_t s_mb_history_lock; | ||
936 | int s_mb_history_filter; | ||
937 | |||
938 | /* stats for buddy allocator */ | 980 | /* stats for buddy allocator */ |
939 | spinlock_t s_mb_pa_lock; | 981 | spinlock_t s_mb_pa_lock; |
940 | atomic_t s_bal_reqs; /* number of reqs with len > 1 */ | 982 | atomic_t s_bal_reqs; /* number of reqs with len > 1 */ |
@@ -950,6 +992,7 @@ struct ext4_sb_info { | |||
950 | atomic_t s_mb_lost_chunks; | 992 | atomic_t s_mb_lost_chunks; |
951 | atomic_t s_mb_preallocated; | 993 | atomic_t s_mb_preallocated; |
952 | atomic_t s_mb_discarded; | 994 | atomic_t s_mb_discarded; |
995 | atomic_t s_lock_busy; | ||
953 | 996 | ||
954 | /* locality groups */ | 997 | /* locality groups */ |
955 | struct ext4_locality_group *s_locality_groups; | 998 | struct ext4_locality_group *s_locality_groups; |
@@ -960,6 +1003,9 @@ struct ext4_sb_info { | |||
960 | 1003 | ||
961 | unsigned int s_log_groups_per_flex; | 1004 | unsigned int s_log_groups_per_flex; |
962 | struct flex_groups *s_flex_groups; | 1005 | struct flex_groups *s_flex_groups; |
1006 | |||
1007 | /* workqueue for dio unwritten */ | ||
1008 | struct workqueue_struct *dio_unwritten_wq; | ||
963 | }; | 1009 | }; |
964 | 1010 | ||
965 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) | 1011 | static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb) |
@@ -1340,8 +1386,6 @@ extern void ext4_mb_free_blocks(handle_t *, struct inode *, | |||
1340 | ext4_fsblk_t, unsigned long, int, unsigned long *); | 1386 | ext4_fsblk_t, unsigned long, int, unsigned long *); |
1341 | extern int ext4_mb_add_groupinfo(struct super_block *sb, | 1387 | extern int ext4_mb_add_groupinfo(struct super_block *sb, |
1342 | ext4_group_t i, struct ext4_group_desc *desc); | 1388 | ext4_group_t i, struct ext4_group_desc *desc); |
1343 | extern void ext4_mb_update_group_info(struct ext4_group_info *grp, | ||
1344 | ext4_grpblk_t add); | ||
1345 | extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t); | 1389 | extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t); |
1346 | extern void ext4_mb_put_buddy_cache_lock(struct super_block *, | 1390 | extern void ext4_mb_put_buddy_cache_lock(struct super_block *, |
1347 | ext4_group_t, int); | 1391 | ext4_group_t, int); |
@@ -1367,6 +1411,7 @@ extern int ext4_change_inode_journal_flag(struct inode *, int); | |||
1367 | extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); | 1411 | extern int ext4_get_inode_loc(struct inode *, struct ext4_iloc *); |
1368 | extern int ext4_can_truncate(struct inode *inode); | 1412 | extern int ext4_can_truncate(struct inode *inode); |
1369 | extern void ext4_truncate(struct inode *); | 1413 | extern void ext4_truncate(struct inode *); |
1414 | extern int ext4_truncate_restart_trans(handle_t *, struct inode *, int nblocks); | ||
1370 | extern void ext4_set_inode_flags(struct inode *); | 1415 | extern void ext4_set_inode_flags(struct inode *); |
1371 | extern void ext4_get_inode_flags(struct ext4_inode_info *); | 1416 | extern void ext4_get_inode_flags(struct ext4_inode_info *); |
1372 | extern int ext4_alloc_da_blocks(struct inode *inode); | 1417 | extern int ext4_alloc_da_blocks(struct inode *inode); |
@@ -1378,7 +1423,7 @@ extern int ext4_block_truncate_page(handle_t *handle, | |||
1378 | struct address_space *mapping, loff_t from); | 1423 | struct address_space *mapping, loff_t from); |
1379 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); | 1424 | extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf); |
1380 | extern qsize_t ext4_get_reserved_space(struct inode *inode); | 1425 | extern qsize_t ext4_get_reserved_space(struct inode *inode); |
1381 | 1426 | extern int flush_aio_dio_completed_IO(struct inode *inode); | |
1382 | /* ioctl.c */ | 1427 | /* ioctl.c */ |
1383 | extern long ext4_ioctl(struct file *, unsigned int, unsigned long); | 1428 | extern long ext4_ioctl(struct file *, unsigned int, unsigned long); |
1384 | extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long); | 1429 | extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long); |
@@ -1575,15 +1620,18 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize) | |||
1575 | struct ext4_group_info { | 1620 | struct ext4_group_info { |
1576 | unsigned long bb_state; | 1621 | unsigned long bb_state; |
1577 | struct rb_root bb_free_root; | 1622 | struct rb_root bb_free_root; |
1578 | unsigned short bb_first_free; | 1623 | ext4_grpblk_t bb_first_free; /* first free block */ |
1579 | unsigned short bb_free; | 1624 | ext4_grpblk_t bb_free; /* total free blocks */ |
1580 | unsigned short bb_fragments; | 1625 | ext4_grpblk_t bb_fragments; /* nr of freespace fragments */ |
1581 | struct list_head bb_prealloc_list; | 1626 | struct list_head bb_prealloc_list; |
1582 | #ifdef DOUBLE_CHECK | 1627 | #ifdef DOUBLE_CHECK |
1583 | void *bb_bitmap; | 1628 | void *bb_bitmap; |
1584 | #endif | 1629 | #endif |
1585 | struct rw_semaphore alloc_sem; | 1630 | struct rw_semaphore alloc_sem; |
1586 | unsigned short bb_counters[]; | 1631 | ext4_grpblk_t bb_counters[]; /* Nr of free power-of-two-block |
1632 | * regions, index is order. | ||
1633 | * bb_counters[3] = 5 means | ||
1634 | * 5 free 8-block regions. */ | ||
1587 | }; | 1635 | }; |
1588 | 1636 | ||
1589 | #define EXT4_GROUP_INFO_NEED_INIT_BIT 0 | 1637 | #define EXT4_GROUP_INFO_NEED_INIT_BIT 0 |
@@ -1591,15 +1639,42 @@ struct ext4_group_info { | |||
1591 | #define EXT4_MB_GRP_NEED_INIT(grp) \ | 1639 | #define EXT4_MB_GRP_NEED_INIT(grp) \ |
1592 | (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state))) | 1640 | (test_bit(EXT4_GROUP_INFO_NEED_INIT_BIT, &((grp)->bb_state))) |
1593 | 1641 | ||
1642 | #define EXT4_MAX_CONTENTION 8 | ||
1643 | #define EXT4_CONTENTION_THRESHOLD 2 | ||
1644 | |||
1594 | static inline spinlock_t *ext4_group_lock_ptr(struct super_block *sb, | 1645 | static inline spinlock_t *ext4_group_lock_ptr(struct super_block *sb, |
1595 | ext4_group_t group) | 1646 | ext4_group_t group) |
1596 | { | 1647 | { |
1597 | return bgl_lock_ptr(EXT4_SB(sb)->s_blockgroup_lock, group); | 1648 | return bgl_lock_ptr(EXT4_SB(sb)->s_blockgroup_lock, group); |
1598 | } | 1649 | } |
1599 | 1650 | ||
1651 | /* | ||
1652 | * Returns true if the filesystem is busy enough that attempts to | ||
1653 | * access the block group locks has run into contention. | ||
1654 | */ | ||
1655 | static inline int ext4_fs_is_busy(struct ext4_sb_info *sbi) | ||
1656 | { | ||
1657 | return (atomic_read(&sbi->s_lock_busy) > EXT4_CONTENTION_THRESHOLD); | ||
1658 | } | ||
1659 | |||
1600 | static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group) | 1660 | static inline void ext4_lock_group(struct super_block *sb, ext4_group_t group) |
1601 | { | 1661 | { |
1602 | spin_lock(ext4_group_lock_ptr(sb, group)); | 1662 | spinlock_t *lock = ext4_group_lock_ptr(sb, group); |
1663 | if (spin_trylock(lock)) | ||
1664 | /* | ||
1665 | * We're able to grab the lock right away, so drop the | ||
1666 | * lock contention counter. | ||
1667 | */ | ||
1668 | atomic_add_unless(&EXT4_SB(sb)->s_lock_busy, -1, 0); | ||
1669 | else { | ||
1670 | /* | ||
1671 | * The lock is busy, so bump the contention counter, | ||
1672 | * and then wait on the spin lock. | ||
1673 | */ | ||
1674 | atomic_add_unless(&EXT4_SB(sb)->s_lock_busy, 1, | ||
1675 | EXT4_MAX_CONTENTION); | ||
1676 | spin_lock(lock); | ||
1677 | } | ||
1603 | } | 1678 | } |
1604 | 1679 | ||
1605 | static inline void ext4_unlock_group(struct super_block *sb, | 1680 | static inline void ext4_unlock_group(struct super_block *sb, |
@@ -1650,6 +1725,8 @@ extern void ext4_ext_init(struct super_block *); | |||
1650 | extern void ext4_ext_release(struct super_block *); | 1725 | extern void ext4_ext_release(struct super_block *); |
1651 | extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, | 1726 | extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, |
1652 | loff_t len); | 1727 | loff_t len); |
1728 | extern int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset, | ||
1729 | loff_t len); | ||
1653 | extern int ext4_get_blocks(handle_t *handle, struct inode *inode, | 1730 | extern int ext4_get_blocks(handle_t *handle, struct inode *inode, |
1654 | sector_t block, unsigned int max_blocks, | 1731 | sector_t block, unsigned int max_blocks, |
1655 | struct buffer_head *bh, int flags); | 1732 | struct buffer_head *bh, int flags); |