Skip to content

Commit

Permalink
ext4: change s_last_trim_minblks type to unsigned long
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Lukas Czerner authored and tytso committed Jan 10, 2022
1 parent bbc605c commit 2327fb2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,7 @@ struct ext4_sb_info {
struct task_struct *s_mmp_tsk;

/* record the last minlen when FITRIM is called. */
atomic_t s_last_trim_minblks;
unsigned long s_last_trim_minblks;

/* Reference to checksum algorithm driver via cryptoapi */
struct crypto_shash *s_chksum_driver;
Expand Down
4 changes: 2 additions & 2 deletions fs/ext4/mballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6369,7 +6369,7 @@ ext4_trim_all_free(struct super_block *sb, ext4_group_t group,
ext4_lock_group(sb, group);

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

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

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

0 comments on commit 2327fb2

Please sign in to comment.