Skip to content

Commit a53b75b

Browse files
committed
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 update from Ted Ts'o: "Bug fixes and cleanups for ext4. We also enable the punch hole functionality for bigalloc file systems" * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: delete "set but not used" variables ext4: don't pass freed handle to ext4_walk_page_buffers ext4: avoid clearing beyond i_blocks when truncating an inline data file ext4: ext4_inode_is_fast_symlink should use EXT4_CLUSTER_SIZE ext4: fix a typo in extents.c ext4: use %pd printk specificer ext4: standardize error handling in ext4_da_write_inline_data_begin() ext4: retry allocation when inline->extent conversion failed ext4: enable punch hole for bigalloc
2 parents 2b2b15c + d7092ae commit a53b75b

5 files changed

Lines changed: 22 additions & 28 deletions

File tree

‎fs/ext4/extents.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3477,7 +3477,7 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
34773477
WARN_ON(map->m_lblk < ee_block);
34783478
/*
34793479
* It is safe to convert extent to initialized via explicit
3480-
* zeroout only if extent is fully insde i_size or new_size.
3480+
* zeroout only if extent is fully inside i_size or new_size.
34813481
*/
34823482
split_flag |= ee_block + ee_len <= eof_block ? EXT4_EXT_MAY_ZEROOUT : 0;
34833483

‎fs/ext4/inline.c‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -849,15 +849,16 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
849849
handle_t *handle;
850850
struct page *page;
851851
struct ext4_iloc iloc;
852+
int retries;
852853

853854
ret = ext4_get_inode_loc(inode, &iloc);
854855
if (ret)
855856
return ret;
856857

858+
retry_journal:
857859
handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
858860
if (IS_ERR(handle)) {
859861
ret = PTR_ERR(handle);
860-
handle = NULL;
861862
goto out;
862863
}
863864

@@ -867,14 +868,18 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
867868
if (inline_size >= pos + len) {
868869
ret = ext4_prepare_inline_data(handle, inode, pos + len);
869870
if (ret && ret != -ENOSPC)
870-
goto out;
871+
goto out_journal;
871872
}
872873

873874
if (ret == -ENOSPC) {
874875
ret = ext4_da_convert_inline_data_to_extent(mapping,
875876
inode,
876877
flags,
877878
fsdata);
879+
ext4_journal_stop(handle);
880+
if (ret == -ENOSPC &&
881+
ext4_should_retry_alloc(inode->i_sb, &retries))
882+
goto retry_journal;
878883
goto out;
879884
}
880885

@@ -887,7 +892,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
887892
page = grab_cache_page_write_begin(mapping, 0, flags);
888893
if (!page) {
889894
ret = -ENOMEM;
890-
goto out;
895+
goto out_journal;
891896
}
892897

893898
down_read(&EXT4_I(inode)->xattr_sem);
@@ -904,16 +909,15 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
904909

905910
up_read(&EXT4_I(inode)->xattr_sem);
906911
*pagep = page;
907-
handle = NULL;
908912
brelse(iloc.bh);
909913
return 1;
910914
out_release_page:
911915
up_read(&EXT4_I(inode)->xattr_sem);
912916
unlock_page(page);
913917
page_cache_release(page);
918+
out_journal:
919+
ext4_journal_stop(handle);
914920
out:
915-
if (handle)
916-
ext4_journal_stop(handle);
917921
brelse(iloc.bh);
918922
return ret;
919923
}
@@ -1837,7 +1841,6 @@ int ext4_try_to_evict_inline_data(handle_t *handle,
18371841
{
18381842
int error;
18391843
struct ext4_xattr_entry *entry;
1840-
struct ext4_xattr_ibody_header *header;
18411844
struct ext4_inode *raw_inode;
18421845
struct ext4_iloc iloc;
18431846

@@ -1846,7 +1849,6 @@ int ext4_try_to_evict_inline_data(handle_t *handle,
18461849
return error;
18471850

18481851
raw_inode = ext4_raw_inode(&iloc);
1849-
header = IHDR(inode, raw_inode);
18501852
entry = (struct ext4_xattr_entry *)((void *)raw_inode +
18511853
EXT4_I(inode)->i_inline_off);
18521854
if (EXT4_XATTR_LEN(entry->e_name_len) +
@@ -1924,9 +1926,11 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
19241926
}
19251927

19261928
/* Clear the content within i_blocks. */
1927-
if (i_size < EXT4_MIN_INLINE_DATA_SIZE)
1928-
memset(ext4_raw_inode(&is.iloc)->i_block + i_size, 0,
1929-
EXT4_MIN_INLINE_DATA_SIZE - i_size);
1929+
if (i_size < EXT4_MIN_INLINE_DATA_SIZE) {
1930+
void *p = (void *) ext4_raw_inode(&is.iloc)->i_block;
1931+
memset(p + i_size, 0,
1932+
EXT4_MIN_INLINE_DATA_SIZE - i_size);
1933+
}
19301934

19311935
EXT4_I(inode)->i_inline_size = i_size <
19321936
EXT4_MIN_INLINE_DATA_SIZE ?

‎fs/ext4/inode.c‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ static int ext4_meta_trans_blocks(struct inode *inode, int lblocks,
144144
*/
145145
static int ext4_inode_is_fast_symlink(struct inode *inode)
146146
{
147-
int ea_blocks = EXT4_I(inode)->i_file_acl ?
148-
(inode->i_sb->s_blocksize >> 9) : 0;
147+
int ea_blocks = EXT4_I(inode)->i_file_acl ?
148+
EXT4_CLUSTER_SIZE(inode->i_sb) >> 9 : 0;
149149

150150
return (S_ISLNK(inode->i_mode) && inode->i_blocks - ea_blocks == 0);
151151
}
@@ -1772,7 +1772,7 @@ static int __ext4_journalled_writepage(struct page *page,
17721772
ret = err;
17731773

17741774
if (!ext4_has_inline_data(inode))
1775-
ext4_walk_page_buffers(handle, page_bufs, 0, len,
1775+
ext4_walk_page_buffers(NULL, page_bufs, 0, len,
17761776
NULL, bput_one);
17771777
ext4_set_inode_state(inode, EXT4_STATE_JDATA);
17781778
out:
@@ -3501,11 +3501,6 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
35013501
if (!S_ISREG(inode->i_mode))
35023502
return -EOPNOTSUPP;
35033503

3504-
if (EXT4_SB(sb)->s_cluster_ratio > 1) {
3505-
/* TODO: Add support for bigalloc file systems */
3506-
return -EOPNOTSUPP;
3507-
}
3508-
35093504
trace_ext4_punch_hole(inode, offset, length);
35103505

35113506
/*

‎fs/ext4/ioctl.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ static long swap_inode_boot_loader(struct super_block *sb,
101101
handle_t *handle;
102102
int err;
103103
struct inode *inode_bl;
104-
struct ext4_inode_info *ei;
105104
struct ext4_inode_info *ei_bl;
106-
struct ext4_sb_info *sbi;
105+
struct ext4_sb_info *sbi = EXT4_SB(sb);
107106

108107
if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) {
109108
err = -EINVAL;
@@ -115,9 +114,6 @@ static long swap_inode_boot_loader(struct super_block *sb,
115114
goto swap_boot_out;
116115
}
117116

118-
sbi = EXT4_SB(sb);
119-
ei = EXT4_I(inode);
120-
121117
inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);
122118
if (IS_ERR(inode_bl)) {
123119
err = PTR_ERR(inode_bl);

‎fs/ext4/namei.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,9 +1425,8 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
14251425
return ERR_PTR(-EIO);
14261426
}
14271427
if (unlikely(ino == dir->i_ino)) {
1428-
EXT4_ERROR_INODE(dir, "'%.*s' linked to parent dir",
1429-
dentry->d_name.len,
1430-
dentry->d_name.name);
1428+
EXT4_ERROR_INODE(dir, "'%pd' linked to parent dir",
1429+
dentry);
14311430
return ERR_PTR(-EIO);
14321431
}
14331432
inode = ext4_iget(dir->i_sb, ino);

0 commit comments

Comments
 (0)