Skip to content

Commit a5adcfc

Browse files
committed
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 updates from Ted Ts'o: "A large number of bug fixes and cleanups. One new feature to allow users to more easily find the jbd2 journal thread for a particular ext4 file system" * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (25 commits) jbd2: jbd2_get_transaction does not need to return a value jbd2: fix invalid descriptor block checksum ext4: fix bigalloc cluster freeing when hole punching under load ext4: add sysfs attr /sys/fs/ext4/<disk>/journal_task ext4: Change debugging support help prefix from EXT4 to Ext4 ext4: fix compile error when using BUFFER_TRACE jbd2: fix compile warning when using JBUFFER_TRACE ext4: fix some error pointer dereferences ext4: annotate more implicit fall throughs ext4: annotate implicit fall throughs ext4: don't update s_rev_level if not required jbd2: fold jbd2_superblock_csum_{verify,set} into their callers jbd2: fix race when writing superblock ext4: fix crash during online resizing ext4: disallow files with EXT4_JOURNAL_DATA_FL from EXT4_IOC_SWAP_BOOT ext4: add mask of ext4 flags to swap ext4: update quota information while swapping boot loader inode ext4: cleanup pagecache before swap i_data ext4: fix check of inode in swap_inode_boot_loader ext4: unlock unused_pages timely when doing writeback ...
2 parents 2b0a80b + 0df6f46 commit a5adcfc

File tree

18 files changed

+257
-147
lines changed

18 files changed

+257
-147
lines changed

Documentation/ABI/testing/sysfs-fs-ext4

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,10 @@ Description:
109109
write operation (since a 4k random write might turn
110110
into a much larger write due to the zeroout
111111
operation).
112+
113+
What: /sys/fs/ext4/<disk>/journal_task
114+
Date: February 2019
115+
Contact: "Theodore Ts'o" <tytso@mit.edu>
116+
Description:
117+
This file is read-only and shows the pid of journal thread in
118+
current pid-namespace or 0 if task is unreachable.

fs/ext4/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ config EXT4_FS_SECURITY
9797
extended attributes for file security labels, say N.
9898

9999
config EXT4_DEBUG
100-
bool "EXT4 debugging support"
100+
bool "Ext4 debugging support"
101101
depends on EXT4_FS
102102
help
103103
Enables run-time debugging support for the ext4 filesystem.

fs/ext4/ext4.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ struct flex_groups {
425425
/* Flags that are appropriate for non-directories/regular files. */
426426
#define EXT4_OTHER_FLMASK (EXT4_NODUMP_FL | EXT4_NOATIME_FL)
427427

428+
/* The only flags that should be swapped */
429+
#define EXT4_FL_SHOULD_SWAP (EXT4_HUGE_FILE_FL | EXT4_EXTENTS_FL)
430+
428431
/* Mask out flags that are inappropriate for the given type of inode. */
429432
static inline __u32 ext4_mask_flags(umode_t mode, __u32 flags)
430433
{
@@ -1661,6 +1664,8 @@ static inline void ext4_clear_state_flags(struct ext4_inode_info *ei)
16611664
#define EXT4_FEATURE_INCOMPAT_INLINE_DATA 0x8000 /* data in inode */
16621665
#define EXT4_FEATURE_INCOMPAT_ENCRYPT 0x10000
16631666

1667+
extern void ext4_update_dynamic_rev(struct super_block *sb);
1668+
16641669
#define EXT4_FEATURE_COMPAT_FUNCS(name, flagname) \
16651670
static inline bool ext4_has_feature_##name(struct super_block *sb) \
16661671
{ \
@@ -1669,6 +1674,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
16691674
} \
16701675
static inline void ext4_set_feature_##name(struct super_block *sb) \
16711676
{ \
1677+
ext4_update_dynamic_rev(sb); \
16721678
EXT4_SB(sb)->s_es->s_feature_compat |= \
16731679
cpu_to_le32(EXT4_FEATURE_COMPAT_##flagname); \
16741680
} \
@@ -1686,6 +1692,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
16861692
} \
16871693
static inline void ext4_set_feature_##name(struct super_block *sb) \
16881694
{ \
1695+
ext4_update_dynamic_rev(sb); \
16891696
EXT4_SB(sb)->s_es->s_feature_ro_compat |= \
16901697
cpu_to_le32(EXT4_FEATURE_RO_COMPAT_##flagname); \
16911698
} \
@@ -1703,6 +1710,7 @@ static inline bool ext4_has_feature_##name(struct super_block *sb) \
17031710
} \
17041711
static inline void ext4_set_feature_##name(struct super_block *sb) \
17051712
{ \
1713+
ext4_update_dynamic_rev(sb); \
17061714
EXT4_SB(sb)->s_es->s_feature_incompat |= \
17071715
cpu_to_le32(EXT4_FEATURE_INCOMPAT_##flagname); \
17081716
} \
@@ -2666,7 +2674,6 @@ do { \
26662674

26672675
#endif
26682676

2669-
extern void ext4_update_dynamic_rev(struct super_block *sb);
26702677
extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
26712678
__u32 compat);
26722679
extern int ext4_update_rocompat_feature(handle_t *handle,

fs/ext4/extents.c

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,14 +2956,17 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
29562956
if (err < 0)
29572957
goto out;
29582958

2959-
} else if (sbi->s_cluster_ratio > 1 && end >= ex_end) {
2959+
} else if (sbi->s_cluster_ratio > 1 && end >= ex_end &&
2960+
partial.state == initial) {
29602961
/*
2961-
* If there's an extent to the right its first cluster
2962-
* contains the immediate right boundary of the
2963-
* truncated/punched region. Set partial_cluster to
2964-
* its negative value so it won't be freed if shared
2965-
* with the current extent. The end < ee_block case
2966-
* is handled in ext4_ext_rm_leaf().
2962+
* If we're punching, there's an extent to the right.
2963+
* If the partial cluster hasn't been set, set it to
2964+
* that extent's first cluster and its state to nofree
2965+
* so it won't be freed should it contain blocks to be
2966+
* removed. If it's already set (tofree/nofree), we're
2967+
* retrying and keep the original partial cluster info
2968+
* so a cluster marked tofree as a result of earlier
2969+
* extent removal is not lost.
29672970
*/
29682971
lblk = ex_end + 1;
29692972
err = ext4_ext_search_right(inode, path, &lblk, &pblk,
@@ -4048,18 +4051,8 @@ ext4_ext_handle_unwritten_extents(handle_t *handle, struct inode *inode,
40484051
} else
40494052
allocated = ret;
40504053
map->m_flags |= EXT4_MAP_NEW;
4051-
/*
4052-
* if we allocated more blocks than requested
4053-
* we need to make sure we unmap the extra block
4054-
* allocated. The actual needed block will get
4055-
* unmapped later when we find the buffer_head marked
4056-
* new.
4057-
*/
4058-
if (allocated > map->m_len) {
4059-
clean_bdev_aliases(inode->i_sb->s_bdev, newblock + map->m_len,
4060-
allocated - map->m_len);
4054+
if (allocated > map->m_len)
40614055
allocated = map->m_len;
4062-
}
40634056
map->m_len = allocated;
40644057

40654058
map_out:

fs/ext4/hash.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ int ext4fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
231231
break;
232232
case DX_HASH_HALF_MD4_UNSIGNED:
233233
str2hashbuf = str2hashbuf_unsigned;
234+
/* fall through */
234235
case DX_HASH_HALF_MD4:
235236
p = name;
236237
while (len > 0) {
@@ -244,6 +245,7 @@ int ext4fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
244245
break;
245246
case DX_HASH_TEA_UNSIGNED:
246247
str2hashbuf = str2hashbuf_unsigned;
248+
/* fall through */
247249
case DX_HASH_TEA:
248250
p = name;
249251
while (len > 0) {

fs/ext4/indirect.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,18 +1183,21 @@ void ext4_ind_truncate(handle_t *handle, struct inode *inode)
11831183
ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
11841184
i_data[EXT4_IND_BLOCK] = 0;
11851185
}
1186+
/* fall through */
11861187
case EXT4_IND_BLOCK:
11871188
nr = i_data[EXT4_DIND_BLOCK];
11881189
if (nr) {
11891190
ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
11901191
i_data[EXT4_DIND_BLOCK] = 0;
11911192
}
1193+
/* fall through */
11921194
case EXT4_DIND_BLOCK:
11931195
nr = i_data[EXT4_TIND_BLOCK];
11941196
if (nr) {
11951197
ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
11961198
i_data[EXT4_TIND_BLOCK] = 0;
11971199
}
1200+
/* fall through */
11981201
case EXT4_TIND_BLOCK:
11991202
;
12001203
}
@@ -1433,6 +1436,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
14331436
ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 1);
14341437
i_data[EXT4_IND_BLOCK] = 0;
14351438
}
1439+
/* fall through */
14361440
case EXT4_IND_BLOCK:
14371441
if (++n >= n2)
14381442
return 0;
@@ -1441,6 +1445,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
14411445
ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 2);
14421446
i_data[EXT4_DIND_BLOCK] = 0;
14431447
}
1448+
/* fall through */
14441449
case EXT4_DIND_BLOCK:
14451450
if (++n >= n2)
14461451
return 0;
@@ -1449,6 +1454,7 @@ int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
14491454
ext4_free_branches(handle, inode, NULL, &nr, &nr+1, 3);
14501455
i_data[EXT4_TIND_BLOCK] = 0;
14511456
}
1457+
/* fall through */
14521458
case EXT4_TIND_BLOCK:
14531459
;
14541460
}

fs/ext4/inode.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void ext4_da_update_reserve_space(struct inode *inode,
391391
* inode's preallocations.
392392
*/
393393
if ((ei->i_reserved_data_blocks == 0) &&
394-
(atomic_read(&inode->i_writecount) == 0))
394+
!inode_is_open_for_write(inode))
395395
ext4_discard_preallocations(inode);
396396
}
397397

@@ -678,8 +678,6 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
678678
if (flags & EXT4_GET_BLOCKS_ZERO &&
679679
map->m_flags & EXT4_MAP_MAPPED &&
680680
map->m_flags & EXT4_MAP_NEW) {
681-
clean_bdev_aliases(inode->i_sb->s_bdev, map->m_pblk,
682-
map->m_len);
683681
ret = ext4_issue_zeroout(inode, map->m_lblk,
684682
map->m_pblk, map->m_len);
685683
if (ret) {
@@ -1194,7 +1192,6 @@ static int ext4_block_write_begin(struct page *page, loff_t pos, unsigned len,
11941192
if (err)
11951193
break;
11961194
if (buffer_new(bh)) {
1197-
clean_bdev_bh_alias(bh);
11981195
if (PageUptodate(page)) {
11991196
clear_buffer_new(bh);
12001197
set_buffer_uptodate(bh);
@@ -2489,10 +2486,6 @@ static int mpage_map_one_extent(handle_t *handle, struct mpage_da_data *mpd)
24892486
}
24902487

24912488
BUG_ON(map->m_len == 0);
2492-
if (map->m_flags & EXT4_MAP_NEW) {
2493-
clean_bdev_aliases(inode->i_sb->s_bdev, map->m_pblk,
2494-
map->m_len);
2495-
}
24962489
return 0;
24972490
}
24982491

@@ -2835,12 +2828,12 @@ static int ext4_writepages(struct address_space *mapping,
28352828
goto unplug;
28362829
}
28372830
ret = mpage_prepare_extent_to_map(&mpd);
2831+
/* Unlock pages we didn't use */
2832+
mpage_release_unused_pages(&mpd, false);
28382833
/* Submit prepared bio */
28392834
ext4_io_submit(&mpd.io_submit);
28402835
ext4_put_io_end_defer(mpd.io_submit.io_end);
28412836
mpd.io_submit.io_end = NULL;
2842-
/* Unlock pages we didn't use */
2843-
mpage_release_unused_pages(&mpd, false);
28442837
if (ret < 0)
28452838
goto unplug;
28462839

@@ -2908,10 +2901,11 @@ static int ext4_writepages(struct address_space *mapping,
29082901
handle = NULL;
29092902
mpd.do_map = 0;
29102903
}
2911-
/* Submit prepared bio */
2912-
ext4_io_submit(&mpd.io_submit);
29132904
/* Unlock pages we didn't use */
29142905
mpage_release_unused_pages(&mpd, give_up_on_write);
2906+
/* Submit prepared bio */
2907+
ext4_io_submit(&mpd.io_submit);
2908+
29152909
/*
29162910
* Drop our io_end reference we got from init. We have
29172911
* to be careful and use deferred io_end finishing if
@@ -5349,7 +5343,6 @@ static int ext4_do_update_inode(handle_t *handle,
53495343
err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
53505344
if (err)
53515345
goto out_brelse;
5352-
ext4_update_dynamic_rev(sb);
53535346
ext4_set_feature_large_file(sb);
53545347
ext4_handle_sync(handle);
53555348
err = ext4_handle_dirty_super(handle, sb);
@@ -6000,7 +5993,7 @@ int ext4_expand_extra_isize(struct inode *inode,
60005993

60015994
ext4_write_lock_xattr(inode, &no_expand);
60025995

6003-
BUFFER_TRACE(iloc.bh, "get_write_access");
5996+
BUFFER_TRACE(iloc->bh, "get_write_access");
60045997
error = ext4_journal_get_write_access(handle, iloc->bh);
60055998
if (error) {
60065999
brelse(iloc->bh);

0 commit comments

Comments
 (0)