Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp511549pxb; Wed, 3 Nov 2021 07:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnie16bIUhFwW812q61MWQ2EmaX82O3u1EcTnXDh6HZlSJD4dfam6CmJvV5zPx92zET8J4 X-Received: by 2002:a05:6e02:1b85:: with SMTP id h5mr1084514ili.112.1635951190375; Wed, 03 Nov 2021 07:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635951190; cv=none; d=google.com; s=arc-20160816; b=sPeN83vwhn0j20EEphv0C3ZKLxthcQqGQaLIxuPKRgCZWWv8ZcGAiaLpvX2uKZFr04 2OL4bM4irG8acCy9R5wd6xfEIQlK1L2CrVOIkTik3FQJcVeYkDOoAVAXC7iK4ApSIMR4 X32ryNW9JGnc9fuAH/A1V+bmw3Y53dLHHxnNX682aROSSlnYJTad04V8Q75mKuJd++Ib ywLf1gKf9uOIcIZFhK0OowGEAUjWwUSwJkJZcvAScu60CVQjDLuc2THBwqruMX+dNPOs Q9m5uRom/0f/aXft8iR+ybONxGq6P5H0qC/Hcguvs/+q3bEKqOwFIvSvdexmEdkXJLxC 3flQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EwA3ck65BnklSw0Q8bTU6cLSaLcjx0hPlwL4wTRnb4E=; b=KYOR5SlpmRrddp8CaWCEAGWQ6kY8BZNqyLTWo0SJFX2JDE3LENFl5iLzaavKP5sLhV KZMWG2XUX2JrpV0hjVocZQSZmbtG/wsPabBgNkf81fVmQPOb3NikI2309akI91hRbqzV i6KKxd0Z586YD+pivSzPOiebvcGtpQci+3iMpULwXedEA9qjKHnFCS65vPVAcQ1R9vXD B94GvWy442YVfcewY306o6tHGgBUG3QkNPO+OmsY5kDnBweVw9VbIU4FOU4GRrmTa4WX AVO6pMviRBuVwa001Do5tjsw5Dm0GglgFYVjZGzBE1FZEcefRYSjs4D2HtX6zoGDzttN tIIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TwJqYhCJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si4366716ilx.88.2021.11.03.07.52.37; Wed, 03 Nov 2021 07:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TwJqYhCJ; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbhKCOzH (ORCPT + 99 others); Wed, 3 Nov 2021 10:55:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57316 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230132AbhKCOzG (ORCPT ); Wed, 3 Nov 2021 10:55:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635951149; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=EwA3ck65BnklSw0Q8bTU6cLSaLcjx0hPlwL4wTRnb4E=; b=TwJqYhCJvu0Wtl67rpr2IM1QZ1cyqv/ArhmTLIqTxZRUKe3fQEej5CTKLAUtJ+U/NyA3dX 95pXKY1avBjOQlfOKfkA8qdVbRbxKSrZSm0YoRvnVq1Eev2RjBnc/dpVGjJLdHulUVH1P+ GpXPwbWCpooIPY5fwl/zUoUHeBrlnFE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-234-YPONvtusP1ef1j8FB1Smqw-1; Wed, 03 Nov 2021 10:52:26 -0400 X-MC-Unique: YPONvtusP1ef1j8FB1Smqw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5643A40D4; Wed, 3 Nov 2021 14:51:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id B38E719741; Wed, 3 Nov 2021 14:51:26 +0000 (UTC) From: Lukas Czerner To: linux-ext4@vger.kernel.org, tytso@mit.edu Cc: adilger@dilger.ca Subject: [PATCH 1/2] ext4: Change s_last_trim_minblks type to unsigned long Date: Wed, 3 Nov 2021 15:51:21 +0100 Message-Id: <20211103145122.17338-1-lczerner@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 Suggested-by: Andreas Dilger --- 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