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:
ext4: fix data corruption regression by reverting commit 6de9843dab
ext4: Allow indirect-block file to grow the file size to max file size
ext4: allow an active handle to be started when freezing
ext4: sync the directory inode in ext4_sync_parent()
ext4: init timer earlier to avoid a kernel panic in __save_error_info
jbd2: fix potential memory leak on transaction commit
ext4: fix a double free in ext4_register_li_request
ext4: fix credits computing for indirect mapped files
ext4: remove unnecessary [cm]time update of quota file
jbd2: move bdget out of critical section
This commit is contained in:
@@ -2502,6 +2502,7 @@ static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
|
||||
* for partial write.
|
||||
*/
|
||||
set_buffer_new(bh);
|
||||
set_buffer_mapped(bh);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -4429,8 +4430,8 @@ void ext4_truncate(struct inode *inode)
|
||||
Indirect chain[4];
|
||||
Indirect *partial;
|
||||
__le32 nr = 0;
|
||||
int n;
|
||||
ext4_lblk_t last_block;
|
||||
int n = 0;
|
||||
ext4_lblk_t last_block, max_block;
|
||||
unsigned blocksize = inode->i_sb->s_blocksize;
|
||||
|
||||
trace_ext4_truncate_enter(inode);
|
||||
@@ -4455,14 +4456,18 @@ void ext4_truncate(struct inode *inode)
|
||||
|
||||
last_block = (inode->i_size + blocksize-1)
|
||||
>> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
|
||||
max_block = (EXT4_SB(inode->i_sb)->s_bitmap_maxbytes + blocksize-1)
|
||||
>> EXT4_BLOCK_SIZE_BITS(inode->i_sb);
|
||||
|
||||
if (inode->i_size & (blocksize - 1))
|
||||
if (ext4_block_truncate_page(handle, mapping, inode->i_size))
|
||||
goto out_stop;
|
||||
|
||||
n = ext4_block_to_path(inode, last_block, offsets, NULL);
|
||||
if (n == 0)
|
||||
goto out_stop; /* error */
|
||||
if (last_block != max_block) {
|
||||
n = ext4_block_to_path(inode, last_block, offsets, NULL);
|
||||
if (n == 0)
|
||||
goto out_stop; /* error */
|
||||
}
|
||||
|
||||
/*
|
||||
* OK. This truncate is going to happen. We add the inode to the
|
||||
@@ -4493,7 +4498,13 @@ void ext4_truncate(struct inode *inode)
|
||||
*/
|
||||
ei->i_disksize = inode->i_size;
|
||||
|
||||
if (n == 1) { /* direct blocks */
|
||||
if (last_block == max_block) {
|
||||
/*
|
||||
* It is unnecessary to free any data blocks if last_block is
|
||||
* equal to the indirect block limit.
|
||||
*/
|
||||
goto out_unlock;
|
||||
} else if (n == 1) { /* direct blocks */
|
||||
ext4_free_data(handle, inode, NULL, i_data+offsets[0],
|
||||
i_data + EXT4_NDIR_BLOCKS);
|
||||
goto do_indirects;
|
||||
@@ -4553,6 +4564,7 @@ do_indirects:
|
||||
;
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
up_write(&ei->i_data_sem);
|
||||
inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
|
||||
ext4_mark_inode_dirty(handle, inode);
|
||||
@@ -5398,13 +5410,12 @@ static int ext4_indirect_trans_blocks(struct inode *inode, int nrblocks,
|
||||
/* if nrblocks are contiguous */
|
||||
if (chunk) {
|
||||
/*
|
||||
* With N contiguous data blocks, it need at most
|
||||
* N/EXT4_ADDR_PER_BLOCK(inode->i_sb) indirect blocks
|
||||
* 2 dindirect blocks
|
||||
* 1 tindirect block
|
||||
* With N contiguous data blocks, we need at most
|
||||
* N/EXT4_ADDR_PER_BLOCK(inode->i_sb) + 1 indirect blocks,
|
||||
* 2 dindirect blocks, and 1 tindirect block
|
||||
*/
|
||||
indirects = nrblocks / EXT4_ADDR_PER_BLOCK(inode->i_sb);
|
||||
return indirects + 3;
|
||||
return DIV_ROUND_UP(nrblocks,
|
||||
EXT4_ADDR_PER_BLOCK(inode->i_sb)) + 4;
|
||||
}
|
||||
/*
|
||||
* if nrblocks are not contiguous, worse case, each block touch
|
||||
|
||||
Reference in New Issue
Block a user