All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: Lukas Czerner <lczerner@redhat.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH 1/2] ext4: Change s_last_trim_minblks type to unsigned long
Date: Wed, 3 Nov 2021 14:20:05 -0600	[thread overview]
Message-ID: <BEFE9A1D-A336-4C19-9B9A-5343EC3D4364@dilger.ca> (raw)
In-Reply-To: <20211103145122.17338-1-lczerner@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2182 bytes --]

On Nov 3, 2021, at 8:51 AM, Lukas Czerner <lczerner@redhat.com> wrote:
> 
> 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 <lczerner@redhat.com>
> Suggested-by: Andreas Dilger <adilger@dilger.ca>

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

Could also add for reference:

Fixes: 3d56b8d2c74c ("ext4: Speed up FITRIM by recording flags in ext4_group_info")

> ---
> fs/ext4/ext4.h    | 2 +-
> fs/ext4/mballoc.c | 4 ++--
> 2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 3825195539d7..92a155401f61 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -1660,7 +1660,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;
> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
> index 72bfac2d6dce..eda550ec3956 100644
> --- a/fs/ext4/mballoc.c
> +++ b/fs/ext4/mballoc.c
> @@ -6374,7 +6374,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);
> @@ -6475,7 +6475,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;
> --
> 2.31.1
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]

  parent reply	other threads:[~2021-11-03 20:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 14:51 [PATCH 1/2] ext4: Change s_last_trim_minblks type to unsigned long Lukas Czerner
2021-11-03 14:51 ` [PATCH v3 2/2] ext4: Allow to change s_last_trim_minblks via sysfs Lukas Czerner
2021-11-03 20:20   ` Andreas Dilger
2021-12-20 15:13   ` Lukas Czerner
2022-01-05  3:53   ` Theodore Ts'o
2021-11-03 20:20 ` Andreas Dilger [this message]
2022-01-05  3:52 ` [PATCH 1/2] ext4: Change s_last_trim_minblks type to unsigned long Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BEFE9A1D-A336-4C19-9B9A-5343EC3D4364@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.