Skip to content

Commit a107e5a

Browse files
committed
Merge branch 'next' into upstream-merge
Conflicts: fs/ext4/inode.c fs/ext4/mballoc.c include/trace/events/ext4.h
2 parents e3e1288 + a269029 commit a107e5a

33 files changed

Lines changed: 2510 additions & 1131 deletions

‎Documentation/filesystems/ext4.txt‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,20 @@ noauto_da_alloc replacing existing files via patterns such as
353353
system crashes before the delayed allocation
354354
blocks are forced to disk.
355355

356+
noinit_itable Do not initialize any uninitialized inode table
357+
blocks in the background. This feature may be
358+
used by installation CD's so that the install
359+
process can complete as quickly as possible; the
360+
inode table initialization process would then be
361+
deferred until the next time the file system
362+
is unmounted.
363+
364+
init_itable=n The lazy itable init code will wait n times the
365+
number of milliseconds it took to zero out the
366+
previous block group's inode table. This
367+
minimizes the impact on the systme performance
368+
while file system's inode table is being initialized.
369+
356370
discard Controls whether ext4 should issue discard/TRIM
357371
nodiscard(*) commands to the underlying block device when
358372
blocks are freed. This is useful for SSD devices

‎fs/ext4/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
obj-$(CONFIG_EXT4_FS) += ext4.o
66

7-
ext4-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
7+
ext4-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \
88
ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
99
ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o
1010

‎fs/ext4/balloc.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
171171
* less than the blocksize * 8 ( which is the size
172172
* of bitmap ), set rest of the block bitmap to 1
173173
*/
174-
mark_bitmap_end(group_blocks, sb->s_blocksize * 8, bh->b_data);
174+
ext4_mark_bitmap_end(group_blocks, sb->s_blocksize * 8,
175+
bh->b_data);
175176
}
176177
return free_blocks - ext4_group_used_meta_blocks(sb, block_group, gdp);
177178
}
@@ -489,7 +490,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
489490
* Check if filesystem has nblocks free & available for allocation.
490491
* On success return 1, return 0 on failure.
491492
*/
492-
int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks)
493+
static int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks)
493494
{
494495
s64 free_blocks, dirty_blocks, root_blocks;
495496
struct percpu_counter *fbc = &sbi->s_freeblocks_counter;

‎fs/ext4/block_validity.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ struct ext4_system_zone {
2929

3030
static struct kmem_cache *ext4_system_zone_cachep;
3131

32-
int __init init_ext4_system_zone(void)
32+
int __init ext4_init_system_zone(void)
3333
{
34-
ext4_system_zone_cachep = KMEM_CACHE(ext4_system_zone,
35-
SLAB_RECLAIM_ACCOUNT);
34+
ext4_system_zone_cachep = KMEM_CACHE(ext4_system_zone, 0);
3635
if (ext4_system_zone_cachep == NULL)
3736
return -ENOMEM;
3837
return 0;
3938
}
4039

41-
void exit_ext4_system_zone(void)
40+
void ext4_exit_system_zone(void)
4241
{
4342
kmem_cache_destroy(ext4_system_zone_cachep);
4443
}

‎fs/ext4/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int ext4_release_dir(struct inode *inode,
3939
struct file *filp);
4040

4141
const struct file_operations ext4_dir_operations = {
42-
.llseek = generic_file_llseek,
42+
.llseek = ext4_llseek,
4343
.read = generic_read_dir,
4444
.readdir = ext4_readdir, /* we take BKL. needed?*/
4545
.unlocked_ioctl = ext4_ioctl,

‎fs/ext4/ext4.h‎

Lines changed: 88 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,20 @@ struct mpage_da_data {
168168
int pages_written;
169169
int retval;
170170
};
171-
#define EXT4_IO_UNWRITTEN 0x1
171+
172+
/*
173+
* Flags for ext4_io_end->flags
174+
*/
175+
#define EXT4_IO_END_UNWRITTEN 0x0001
176+
#define EXT4_IO_END_ERROR 0x0002
177+
178+
struct ext4_io_page {
179+
struct page *p_page;
180+
int p_count;
181+
};
182+
183+
#define MAX_IO_PAGES 128
184+
172185
typedef struct ext4_io_end {
173186
struct list_head list; /* per-file finished IO list */
174187
struct inode *inode; /* file being written to */
@@ -179,8 +192,18 @@ typedef struct ext4_io_end {
179192
struct work_struct work; /* data work queue */
180193
struct kiocb *iocb; /* iocb struct for AIO */
181194
int result; /* error value for AIO */
195+
int num_io_pages;
196+
struct ext4_io_page *pages[MAX_IO_PAGES];
182197
} ext4_io_end_t;
183198

199+
struct ext4_io_submit {
200+
int io_op;
201+
struct bio *io_bio;
202+
ext4_io_end_t *io_end;
203+
struct ext4_io_page *io_page;
204+
sector_t io_next_block;
205+
};
206+
184207
/*
185208
* Special inodes numbers
186209
*/
@@ -205,6 +228,7 @@ typedef struct ext4_io_end {
205228
#define EXT4_MIN_BLOCK_SIZE 1024
206229
#define EXT4_MAX_BLOCK_SIZE 65536
207230
#define EXT4_MIN_BLOCK_LOG_SIZE 10
231+
#define EXT4_MAX_BLOCK_LOG_SIZE 16
208232
#ifdef __KERNEL__
209233
# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
210234
#else
@@ -889,6 +913,7 @@ struct ext4_inode_info {
889913
#define EXT4_MOUNT_DATA_ERR_ABORT 0x10000000 /* Abort on file data write */
890914
#define EXT4_MOUNT_BLOCK_VALIDITY 0x20000000 /* Block validity checking */
891915
#define EXT4_MOUNT_DISCARD 0x40000000 /* Issue DISCARD requests */
916+
#define EXT4_MOUNT_INIT_INODE_TABLE 0x80000000 /* Initialize uninitialized itables */
892917

893918
#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
894919
#define set_opt(o, opt) o |= EXT4_MOUNT_##opt
@@ -1087,7 +1112,6 @@ struct ext4_sb_info {
10871112
struct completion s_kobj_unregister;
10881113

10891114
/* Journaling */
1090-
struct inode *s_journal_inode;
10911115
struct journal_s *s_journal;
10921116
struct list_head s_orphan;
10931117
struct mutex s_orphan_lock;
@@ -1120,10 +1144,7 @@ struct ext4_sb_info {
11201144
/* for buddy allocator */
11211145
struct ext4_group_info ***s_group_info;
11221146
struct inode *s_buddy_cache;
1123-
long s_blocks_reserved;
1124-
spinlock_t s_reserve_lock;
11251147
spinlock_t s_md_lock;
1126-
tid_t s_last_transaction;
11271148
unsigned short *s_mb_offsets;
11281149
unsigned int *s_mb_maxs;
11291150

@@ -1141,7 +1162,6 @@ struct ext4_sb_info {
11411162
unsigned long s_mb_last_start;
11421163

11431164
/* stats for buddy allocator */
1144-
spinlock_t s_mb_pa_lock;
11451165
atomic_t s_bal_reqs; /* number of reqs with len > 1 */
11461166
atomic_t s_bal_success; /* we found long enough chunks */
11471167
atomic_t s_bal_allocated; /* in blocks */
@@ -1172,6 +1192,11 @@ struct ext4_sb_info {
11721192

11731193
/* timer for periodic error stats printing */
11741194
struct timer_list s_err_report;
1195+
1196+
/* Lazy inode table initialization info */
1197+
struct ext4_li_request *s_li_request;
1198+
/* Wait multiplier for lazy initialization thread */
1199+
unsigned int s_li_wait_mult;
11751200
};
11761201

11771202
static inline struct ext4_sb_info *EXT4_SB(struct super_block *sb)
@@ -1533,7 +1558,42 @@ ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
15331558
void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
15341559
ext4_group_t *blockgrpp, ext4_grpblk_t *offsetp);
15351560

1536-
extern struct proc_dir_entry *ext4_proc_root;
1561+
/*
1562+
* Timeout and state flag for lazy initialization inode thread.
1563+
*/
1564+
#define EXT4_DEF_LI_WAIT_MULT 10
1565+
#define EXT4_DEF_LI_MAX_START_DELAY 5
1566+
#define EXT4_LAZYINIT_QUIT 0x0001
1567+
#define EXT4_LAZYINIT_RUNNING 0x0002
1568+
1569+
/*
1570+
* Lazy inode table initialization info
1571+
*/
1572+
struct ext4_lazy_init {
1573+
unsigned long li_state;
1574+
1575+
wait_queue_head_t li_wait_daemon;
1576+
wait_queue_head_t li_wait_task;
1577+
struct timer_list li_timer;
1578+
struct task_struct *li_task;
1579+
1580+
struct list_head li_request_list;
1581+
struct mutex li_list_mtx;
1582+
};
1583+
1584+
struct ext4_li_request {
1585+
struct super_block *lr_super;
1586+
struct ext4_sb_info *lr_sbi;
1587+
ext4_group_t lr_next_group;
1588+
struct list_head lr_request;
1589+
unsigned long lr_next_sched;
1590+
unsigned long lr_timeout;
1591+
};
1592+
1593+
struct ext4_features {
1594+
struct kobject f_kobj;
1595+
struct completion f_kobj_unregister;
1596+
};
15371597

15381598
/*
15391599
* Function prototypes
@@ -1561,7 +1621,6 @@ extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
15611621
extern ext4_fsblk_t ext4_new_meta_blocks(handle_t *handle, struct inode *inode,
15621622
ext4_fsblk_t goal, unsigned long *count, int *errp);
15631623
extern int ext4_claim_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
1564-
extern int ext4_has_free_blocks(struct ext4_sb_info *sbi, s64 nblocks);
15651624
extern void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
15661625
ext4_fsblk_t block, unsigned long count);
15671626
extern ext4_fsblk_t ext4_count_free_blocks(struct super_block *);
@@ -1605,11 +1664,9 @@ extern struct inode * ext4_orphan_get(struct super_block *, unsigned long);
16051664
extern unsigned long ext4_count_free_inodes(struct super_block *);
16061665
extern unsigned long ext4_count_dirs(struct super_block *);
16071666
extern void ext4_check_inodes_bitmap(struct super_block *);
1608-
extern unsigned ext4_init_inode_bitmap(struct super_block *sb,
1609-
struct buffer_head *bh,
1610-
ext4_group_t group,
1611-
struct ext4_group_desc *desc);
1612-
extern void mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
1667+
extern void ext4_mark_bitmap_end(int start_bit, int end_bit, char *bitmap);
1668+
extern int ext4_init_inode_table(struct super_block *sb,
1669+
ext4_group_t group, int barrier);
16131670

16141671
/* mballoc.c */
16151672
extern long ext4_mb_stats;
@@ -1620,16 +1677,15 @@ extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
16201677
struct ext4_allocation_request *, int *);
16211678
extern int ext4_mb_reserve_blocks(struct super_block *, int);
16221679
extern void ext4_discard_preallocations(struct inode *);
1623-
extern int __init init_ext4_mballoc(void);
1624-
extern void exit_ext4_mballoc(void);
1680+
extern int __init ext4_init_mballoc(void);
1681+
extern void ext4_exit_mballoc(void);
16251682
extern void ext4_free_blocks(handle_t *handle, struct inode *inode,
16261683
struct buffer_head *bh, ext4_fsblk_t block,
16271684
unsigned long count, int flags);
16281685
extern int ext4_mb_add_groupinfo(struct super_block *sb,
16291686
ext4_group_t i, struct ext4_group_desc *desc);
1630-
extern int ext4_mb_get_buddy_cache_lock(struct super_block *, ext4_group_t);
1631-
extern void ext4_mb_put_buddy_cache_lock(struct super_block *,
1632-
ext4_group_t, int);
1687+
extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
1688+
16331689
/* inode.c */
16341690
struct buffer_head *ext4_getblk(handle_t *, struct inode *,
16351691
ext4_lblk_t, int, int *);
@@ -1657,13 +1713,11 @@ extern void ext4_get_inode_flags(struct ext4_inode_info *);
16571713
extern int ext4_alloc_da_blocks(struct inode *inode);
16581714
extern void ext4_set_aops(struct inode *inode);
16591715
extern int ext4_writepage_trans_blocks(struct inode *);
1660-
extern int ext4_meta_trans_blocks(struct inode *, int nrblocks, int idxblocks);
16611716
extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
16621717
extern int ext4_block_truncate_page(handle_t *handle,
16631718
struct address_space *mapping, loff_t from);
16641719
extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
16651720
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
1666-
extern int flush_completed_IO(struct inode *inode);
16671721
extern void ext4_da_update_reserve_space(struct inode *inode,
16681722
int used, int quota_claim);
16691723
/* ioctl.c */
@@ -1960,6 +2014,7 @@ extern const struct file_operations ext4_dir_operations;
19602014
/* file.c */
19612015
extern const struct inode_operations ext4_file_inode_operations;
19622016
extern const struct file_operations ext4_file_operations;
2017+
extern loff_t ext4_llseek(struct file *file, loff_t offset, int origin);
19632018

19642019
/* namei.c */
19652020
extern const struct inode_operations ext4_dir_inode_operations;
@@ -1973,8 +2028,8 @@ extern const struct inode_operations ext4_fast_symlink_inode_operations;
19732028
/* block_validity */
19742029
extern void ext4_release_system_zone(struct super_block *sb);
19752030
extern int ext4_setup_system_zone(struct super_block *sb);
1976-
extern int __init init_ext4_system_zone(void);
1977-
extern void exit_ext4_system_zone(void);
2031+
extern int __init ext4_init_system_zone(void);
2032+
extern void ext4_exit_system_zone(void);
19782033
extern int ext4_data_block_valid(struct ext4_sb_info *sbi,
19792034
ext4_fsblk_t start_blk,
19802035
unsigned int count);
@@ -2002,6 +2057,17 @@ extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
20022057
__u64 start_orig, __u64 start_donor,
20032058
__u64 len, __u64 *moved_len);
20042059

2060+
/* page-io.c */
2061+
extern int __init ext4_init_pageio(void);
2062+
extern void ext4_exit_pageio(void);
2063+
extern void ext4_free_io_end(ext4_io_end_t *io);
2064+
extern ext4_io_end_t *ext4_init_io_end(struct inode *inode, gfp_t flags);
2065+
extern int ext4_end_io_nolock(ext4_io_end_t *io);
2066+
extern void ext4_io_submit(struct ext4_io_submit *io);
2067+
extern int ext4_bio_write_page(struct ext4_io_submit *io,
2068+
struct page *page,
2069+
int len,
2070+
struct writeback_control *wbc);
20052071

20062072
/* BH_Uninit flag: blocks are allocated but uninitialized on disk */
20072073
enum ext4_state_bits {

‎fs/ext4/ext4_extents.h‎

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,31 +225,70 @@ static inline void ext4_ext_mark_initialized(struct ext4_extent *ext)
225225
ext->ee_len = cpu_to_le16(ext4_ext_get_actual_len(ext));
226226
}
227227

228+
/*
229+
* ext4_ext_pblock:
230+
* combine low and high parts of physical block number into ext4_fsblk_t
231+
*/
232+
static inline ext4_fsblk_t ext4_ext_pblock(struct ext4_extent *ex)
233+
{
234+
ext4_fsblk_t block;
235+
236+
block = le32_to_cpu(ex->ee_start_lo);
237+
block |= ((ext4_fsblk_t) le16_to_cpu(ex->ee_start_hi) << 31) << 1;
238+
return block;
239+
}
240+
241+
/*
242+
* ext4_idx_pblock:
243+
* combine low and high parts of a leaf physical block number into ext4_fsblk_t
244+
*/
245+
static inline ext4_fsblk_t ext4_idx_pblock(struct ext4_extent_idx *ix)
246+
{
247+
ext4_fsblk_t block;
248+
249+
block = le32_to_cpu(ix->ei_leaf_lo);
250+
block |= ((ext4_fsblk_t) le16_to_cpu(ix->ei_leaf_hi) << 31) << 1;
251+
return block;
252+
}
253+
254+
/*
255+
* ext4_ext_store_pblock:
256+
* stores a large physical block number into an extent struct,
257+
* breaking it into parts
258+
*/
259+
static inline void ext4_ext_store_pblock(struct ext4_extent *ex,
260+
ext4_fsblk_t pb)
261+
{
262+
ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
263+
ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) &
264+
0xffff);
265+
}
266+
267+
/*
268+
* ext4_idx_store_pblock:
269+
* stores a large physical block number into an index struct,
270+
* breaking it into parts
271+
*/
272+
static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix,
273+
ext4_fsblk_t pb)
274+
{
275+
ix->ei_leaf_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
276+
ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) &
277+
0xffff);
278+
}
279+
228280
extern int ext4_ext_calc_metadata_amount(struct inode *inode,
229281
sector_t lblocks);
230-
extern ext4_fsblk_t ext_pblock(struct ext4_extent *ex);
231-
extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
232-
extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
233282
extern int ext4_extent_tree_init(handle_t *, struct inode *);
234283
extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
235284
int num,
236285
struct ext4_ext_path *path);
237286
extern int ext4_can_extents_be_merged(struct inode *inode,
238287
struct ext4_extent *ex1,
239288
struct ext4_extent *ex2);
240-
extern int ext4_ext_try_to_merge(struct inode *inode,
241-
struct ext4_ext_path *path,
242-
struct ext4_extent *);
243-
extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *);
244289
extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *, int);
245-
extern int ext4_ext_walk_space(struct inode *, ext4_lblk_t, ext4_lblk_t,
246-
ext_prepare_callback, void *);
247290
extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
248291
struct ext4_ext_path *);
249-
extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
250-
ext4_lblk_t *, ext4_fsblk_t *);
251-
extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *,
252-
ext4_lblk_t *, ext4_fsblk_t *);
253292
extern void ext4_ext_drop_refs(struct ext4_ext_path *);
254293
extern int ext4_ext_check_inode(struct inode *inode);
255294
#endif /* _EXT4_EXTENTS */

0 commit comments

Comments
 (0)