Skip to content

Commit 2327fb2

Browse files
Lukas Czernertytso
authored andcommitted
ext4: change s_last_trim_minblks type to unsigned long
There is no good reason for the s_last_trim_minblks to be atomic. There is no data integrity needed and there is no real danger in setting and reading it in a racy manner. Change it to be unsigned long, the same type as s_clusters_per_group which is the maximum that's allowed. Signed-off-by: Lukas Czerner <[email protected]> Suggested-by: Andreas Dilger <[email protected]> Reviewed-by: Andreas Dilger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent bbc605c commit 2327fb2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

fs/ext4/ext4.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,7 @@ struct ext4_sb_info {
16631663
struct task_struct *s_mmp_tsk;
16641664

16651665
/* record the last minlen when FITRIM is called. */
1666-
atomic_t s_last_trim_minblks;
1666+
unsigned long s_last_trim_minblks;
16671667

16681668
/* Reference to checksum algorithm driver via cryptoapi */
16691669
struct crypto_shash *s_chksum_driver;

fs/ext4/mballoc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6369,7 +6369,7 @@ ext4_trim_all_free(struct super_block *sb, ext4_group_t group,
63696369
ext4_lock_group(sb, group);
63706370

63716371
if (!EXT4_MB_GRP_WAS_TRIMMED(e4b.bd_info) ||
6372-
minblocks < atomic_read(&EXT4_SB(sb)->s_last_trim_minblks)) {
6372+
minblocks < EXT4_SB(sb)->s_last_trim_minblks) {
63736373
ret = ext4_try_to_trim_range(sb, &e4b, start, max, minblocks);
63746374
if (ret >= 0)
63756375
EXT4_MB_GRP_SET_TRIMMED(e4b.bd_info);
@@ -6478,7 +6478,7 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
64786478
}
64796479

64806480
if (!ret)
6481-
atomic_set(&EXT4_SB(sb)->s_last_trim_minblks, minlen);
6481+
EXT4_SB(sb)->s_last_trim_minblks = minlen;
64826482

64836483
out:
64846484
range->len = EXT4_C2B(EXT4_SB(sb), trimmed) << sb->s_blocksize_bits;

0 commit comments

Comments
 (0)