Skip to content

Commit 890879c

Browse files
committed
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: jbd2: Fix oops in jbd2_journal_remove_journal_head() jbd2: Remove obsolete parameters in the comments for some jbd2 functions ext4: fixed tracepoints cleanup ext4: use FIEMAP_EXTENT_LAST flag for last extent in fiemap ext4: Fix max file size and logical block counting of extent format file ext4: correct comments for ext4_free_blocks()
2 parents 5629937 + de1b794 commit 890879c

File tree

12 files changed

+223
-265
lines changed

12 files changed

+223
-265
lines changed

fs/ext4/ext4_extents.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,19 @@ struct ext4_ext_path {
125125
* positive retcode - signal for ext4_ext_walk_space(), see below
126126
* callback must return valid extent (passed or newly created)
127127
*/
128-
typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
128+
typedef int (*ext_prepare_callback)(struct inode *, ext4_lblk_t,
129129
struct ext4_ext_cache *,
130130
struct ext4_extent *, void *);
131131

132132
#define EXT_CONTINUE 0
133133
#define EXT_BREAK 1
134134
#define EXT_REPEAT 2
135135

136-
/* Maximum logical block in a file; ext4_extent's ee_block is __le32 */
137-
#define EXT_MAX_BLOCK 0xffffffff
136+
/*
137+
* Maximum number of logical blocks in a file; ext4_extent's ee_block is
138+
* __le32.
139+
*/
140+
#define EXT_MAX_BLOCKS 0xffffffff
138141

139142
/*
140143
* EXT_INIT_MAX_LEN is the maximum number of blocks we can have in an

fs/ext4/extents.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,7 +1408,7 @@ static int ext4_ext_search_right(struct inode *inode,
14081408

14091409
/*
14101410
* ext4_ext_next_allocated_block:
1411-
* returns allocated block in subsequent extent or EXT_MAX_BLOCK.
1411+
* returns allocated block in subsequent extent or EXT_MAX_BLOCKS.
14121412
* NOTE: it considers block number from index entry as
14131413
* allocated block. Thus, index entries have to be consistent
14141414
* with leaves.
@@ -1422,7 +1422,7 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path)
14221422
depth = path->p_depth;
14231423

14241424
if (depth == 0 && path->p_ext == NULL)
1425-
return EXT_MAX_BLOCK;
1425+
return EXT_MAX_BLOCKS;
14261426

14271427
while (depth >= 0) {
14281428
if (depth == path->p_depth) {
@@ -1439,12 +1439,12 @@ ext4_ext_next_allocated_block(struct ext4_ext_path *path)
14391439
depth--;
14401440
}
14411441

1442-
return EXT_MAX_BLOCK;
1442+
return EXT_MAX_BLOCKS;
14431443
}
14441444

14451445
/*
14461446
* ext4_ext_next_leaf_block:
1447-
* returns first allocated block from next leaf or EXT_MAX_BLOCK
1447+
* returns first allocated block from next leaf or EXT_MAX_BLOCKS
14481448
*/
14491449
static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
14501450
struct ext4_ext_path *path)
@@ -1456,7 +1456,7 @@ static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
14561456

14571457
/* zero-tree has no leaf blocks at all */
14581458
if (depth == 0)
1459-
return EXT_MAX_BLOCK;
1459+
return EXT_MAX_BLOCKS;
14601460

14611461
/* go to index block */
14621462
depth--;
@@ -1469,7 +1469,7 @@ static ext4_lblk_t ext4_ext_next_leaf_block(struct inode *inode,
14691469
depth--;
14701470
}
14711471

1472-
return EXT_MAX_BLOCK;
1472+
return EXT_MAX_BLOCKS;
14731473
}
14741474

14751475
/*
@@ -1677,13 +1677,13 @@ static unsigned int ext4_ext_check_overlap(struct inode *inode,
16771677
*/
16781678
if (b2 < b1) {
16791679
b2 = ext4_ext_next_allocated_block(path);
1680-
if (b2 == EXT_MAX_BLOCK)
1680+
if (b2 == EXT_MAX_BLOCKS)
16811681
goto out;
16821682
}
16831683

16841684
/* check for wrap through zero on extent logical start block*/
16851685
if (b1 + len1 < b1) {
1686-
len1 = EXT_MAX_BLOCK - b1;
1686+
len1 = EXT_MAX_BLOCKS - b1;
16871687
newext->ee_len = cpu_to_le16(len1);
16881688
ret = 1;
16891689
}
@@ -1767,7 +1767,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
17671767
fex = EXT_LAST_EXTENT(eh);
17681768
next = ext4_ext_next_leaf_block(inode, path);
17691769
if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
1770-
&& next != EXT_MAX_BLOCK) {
1770+
&& next != EXT_MAX_BLOCKS) {
17711771
ext_debug("next leaf block - %d\n", next);
17721772
BUG_ON(npath != NULL);
17731773
npath = ext4_ext_find_extent(inode, next, NULL);
@@ -1887,7 +1887,7 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block,
18871887
BUG_ON(func == NULL);
18881888
BUG_ON(inode == NULL);
18891889

1890-
while (block < last && block != EXT_MAX_BLOCK) {
1890+
while (block < last && block != EXT_MAX_BLOCKS) {
18911891
num = last - block;
18921892
/* find extent for this block */
18931893
down_read(&EXT4_I(inode)->i_data_sem);
@@ -1958,7 +1958,7 @@ static int ext4_ext_walk_space(struct inode *inode, ext4_lblk_t block,
19581958
err = -EIO;
19591959
break;
19601960
}
1961-
err = func(inode, path, &cbex, ex, cbdata);
1961+
err = func(inode, next, &cbex, ex, cbdata);
19621962
ext4_ext_drop_refs(path);
19631963

19641964
if (err < 0)
@@ -2020,7 +2020,7 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
20202020
if (ex == NULL) {
20212021
/* there is no extent yet, so gap is [0;-] */
20222022
lblock = 0;
2023-
len = EXT_MAX_BLOCK;
2023+
len = EXT_MAX_BLOCKS;
20242024
ext_debug("cache gap(whole file):");
20252025
} else if (block < le32_to_cpu(ex->ee_block)) {
20262026
lblock = block;
@@ -2350,7 +2350,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
23502350
* never happen because at least one of the end points
23512351
* needs to be on the edge of the extent.
23522352
*/
2353-
if (end == EXT_MAX_BLOCK) {
2353+
if (end == EXT_MAX_BLOCKS - 1) {
23542354
ext_debug(" bad truncate %u:%u\n",
23552355
start, end);
23562356
block = 0;
@@ -2398,7 +2398,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
23982398
* If this is a truncate, this condition
23992399
* should never happen
24002400
*/
2401-
if (end == EXT_MAX_BLOCK) {
2401+
if (end == EXT_MAX_BLOCKS - 1) {
24022402
ext_debug(" bad truncate %u:%u\n",
24032403
start, end);
24042404
err = -EIO;
@@ -2478,7 +2478,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
24782478
* we need to remove it from the leaf
24792479
*/
24802480
if (num == 0) {
2481-
if (end != EXT_MAX_BLOCK) {
2481+
if (end != EXT_MAX_BLOCKS - 1) {
24822482
/*
24832483
* For hole punching, we need to scoot all the
24842484
* extents up when an extent is removed so that
@@ -3699,7 +3699,7 @@ void ext4_ext_truncate(struct inode *inode)
36993699

37003700
last_block = (inode->i_size + sb->s_blocksize - 1)
37013701
>> EXT4_BLOCK_SIZE_BITS(sb);
3702-
err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCK);
3702+
err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
37033703

37043704
/* In a multi-transaction truncate, we only make the final
37053705
* transaction synchronous.
@@ -3914,14 +3914,13 @@ int ext4_convert_unwritten_extents(struct inode *inode, loff_t offset,
39143914
/*
39153915
* Callback function called for each extent to gather FIEMAP information.
39163916
*/
3917-
static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
3917+
static int ext4_ext_fiemap_cb(struct inode *inode, ext4_lblk_t next,
39183918
struct ext4_ext_cache *newex, struct ext4_extent *ex,
39193919
void *data)
39203920
{
39213921
__u64 logical;
39223922
__u64 physical;
39233923
__u64 length;
3924-
loff_t size;
39253924
__u32 flags = 0;
39263925
int ret = 0;
39273926
struct fiemap_extent_info *fieinfo = data;
@@ -4103,8 +4102,7 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
41034102
if (ex && ext4_ext_is_uninitialized(ex))
41044103
flags |= FIEMAP_EXTENT_UNWRITTEN;
41054104

4106-
size = i_size_read(inode);
4107-
if (logical + length >= size)
4105+
if (next == EXT_MAX_BLOCKS)
41084106
flags |= FIEMAP_EXTENT_LAST;
41094107

41104108
ret = fiemap_fill_next_extent(fieinfo, logical, physical,
@@ -4347,8 +4345,8 @@ int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
43474345

43484346
start_blk = start >> inode->i_sb->s_blocksize_bits;
43494347
last_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits;
4350-
if (last_blk >= EXT_MAX_BLOCK)
4351-
last_blk = EXT_MAX_BLOCK-1;
4348+
if (last_blk >= EXT_MAX_BLOCKS)
4349+
last_blk = EXT_MAX_BLOCKS-1;
43524350
len_blks = ((ext4_lblk_t) last_blk) - start_blk + 1;
43534351

43544352
/*

fs/ext4/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,7 @@ static int ext4_writepage(struct page *page,
26342634
struct buffer_head *page_bufs = NULL;
26352635
struct inode *inode = page->mapping->host;
26362636

2637-
trace_ext4_writepage(inode, page);
2637+
trace_ext4_writepage(page);
26382638
size = i_size_read(inode);
26392639
if (page->index == size >> PAGE_CACHE_SHIFT)
26402640
len = size & ~PAGE_CACHE_MASK;

fs/ext4/mballoc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3578,8 +3578,8 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
35783578
free += next - bit;
35793579

35803580
trace_ext4_mballoc_discard(sb, NULL, group, bit, next - bit);
3581-
trace_ext4_mb_release_inode_pa(sb, pa->pa_inode, pa,
3582-
grp_blk_start + bit, next - bit);
3581+
trace_ext4_mb_release_inode_pa(pa, grp_blk_start + bit,
3582+
next - bit);
35833583
mb_free_blocks(pa->pa_inode, e4b, bit, next - bit);
35843584
bit = next + 1;
35853585
}
@@ -3608,7 +3608,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
36083608
ext4_group_t group;
36093609
ext4_grpblk_t bit;
36103610

3611-
trace_ext4_mb_release_group_pa(sb, pa);
3611+
trace_ext4_mb_release_group_pa(pa);
36123612
BUG_ON(pa->pa_deleted == 0);
36133613
ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
36143614
BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
@@ -4448,7 +4448,7 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b,
44484448
* @inode: inode
44494449
* @block: start physical block to free
44504450
* @count: number of blocks to count
4451-
* @metadata: Are these metadata blocks
4451+
* @flags: flags used by ext4_free_blocks
44524452
*/
44534453
void ext4_free_blocks(handle_t *handle, struct inode *inode,
44544454
struct buffer_head *bh, ext4_fsblk_t block,

fs/ext4/move_extent.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,12 +1002,12 @@ mext_check_arguments(struct inode *orig_inode,
10021002
return -EINVAL;
10031003
}
10041004

1005-
if ((orig_start > EXT_MAX_BLOCK) ||
1006-
(donor_start > EXT_MAX_BLOCK) ||
1007-
(*len > EXT_MAX_BLOCK) ||
1008-
(orig_start + *len > EXT_MAX_BLOCK)) {
1005+
if ((orig_start >= EXT_MAX_BLOCKS) ||
1006+
(donor_start >= EXT_MAX_BLOCKS) ||
1007+
(*len > EXT_MAX_BLOCKS) ||
1008+
(orig_start + *len >= EXT_MAX_BLOCKS)) {
10091009
ext4_debug("ext4 move extent: Can't handle over [%u] blocks "
1010-
"[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCK,
1010+
"[ino:orig %lu, donor %lu]\n", EXT_MAX_BLOCKS,
10111011
orig_inode->i_ino, donor_inode->i_ino);
10121012
return -EINVAL;
10131013
}

fs/ext4/super.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,6 +2243,12 @@ static void ext4_orphan_cleanup(struct super_block *sb,
22432243
* in the vfs. ext4 inode has 48 bits of i_block in fsblock units,
22442244
* so that won't be a limiting factor.
22452245
*
2246+
* However there is other limiting factor. We do store extents in the form
2247+
* of starting block and length, hence the resulting length of the extent
2248+
* covering maximum file size must fit into on-disk format containers as
2249+
* well. Given that length is always by 1 unit bigger than max unit (because
2250+
* we count 0 as well) we have to lower the s_maxbytes by one fs block.
2251+
*
22462252
* Note, this does *not* consider any metadata overhead for vfs i_blocks.
22472253
*/
22482254
static loff_t ext4_max_size(int blkbits, int has_huge_files)
@@ -2264,10 +2270,13 @@ static loff_t ext4_max_size(int blkbits, int has_huge_files)
22642270
upper_limit <<= blkbits;
22652271
}
22662272

2267-
/* 32-bit extent-start container, ee_block */
2268-
res = 1LL << 32;
2273+
/*
2274+
* 32-bit extent-start container, ee_block. We lower the maxbytes
2275+
* by one fs block, so ee_len can cover the extent of maximum file
2276+
* size
2277+
*/
2278+
res = (1LL << 32) - 1;
22692279
res <<= blkbits;
2270-
res -= 1;
22712280

22722281
/* Sanity check against vm- & vfs- imposed limits */
22732282
if (res > upper_limit)

0 commit comments

Comments
 (0)