Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5120043rwd; Sun, 4 Jun 2023 21:20:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6x68SY8zDqq6motH/P/nOm8KV/+8WxD2QIez+kRU5phJ0MjWjTYjPlG3MBB5xHTd8sNBxf X-Received: by 2002:a05:622a:1493:b0:3ef:58ac:82f4 with SMTP id t19-20020a05622a149300b003ef58ac82f4mr7402915qtx.38.1685938853096; Sun, 04 Jun 2023 21:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685938853; cv=none; d=google.com; s=arc-20160816; b=DxX7LnLaiYzYpLnNrq2I/smCXBfPVwoUgDp3Jtwuq826z7kNNvamQ+cXi9BUUDaUS3 7CFfGnyUzII3oAfOBVNT8Lr3oE/yUB+WGuGsDdi/Nsvk+piuijID3N/o+1Ne0qOaLiAf 4BkwCJn+49cnGCAxSVOx4BqYO7LAYFFeIfkLmbN5g+dfDyNPOJcLGHKz3kfmNl+eSBAP MPR4NJ1UWfAbTklJmAR++DPV+ZnodNJB6XZT8DTBbeH5S+Mfoqgn4ngUW3QMYsXQUGAZ Jqy9gxAY6QYutrokqB0DklVkC/ncs2lO/9UOYGCGHH3TqYH+3d/hz5zHTrPWvC62wTq7 ZWrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=yjUUT3waqNPlxWcFxSlwoMqWdjh7LAYjwr7gNffPup8=; b=JvaUwpBtUQhvxKrR8U3oDEsSEJ5Bk/mSt6DPHTUj6uxO8weDubiViVpebL+zCZ+sPf IWu4Z2saJ3yNBgqTr3+R2VcwDZaj5VZ0nF3Y5kwKiCwK9oMg1qlfh0hGXHrn7HDn966+ 4MTjQttbK3g7jIrphFS0cBdY0Rf+XenkNIOp7oRkdngIa0w5kYxh/KSAT8yzOsBc6QQe 9Y9+k2eYkrOWDuWXxhWQQwdUESfpmBb9RVepgMKOkN9Nwt4fRsmchZYAjiKQCkB2j+5a sVpXWzIDN5rYVE9MAIXDuCTxGu9KjThayTveeypup8ehzFo5QhDFkq7gezdlbQMDu4sv t2Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K872SEU+; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a63730b000000b0054294720d56si5086855pgc.387.2023.06.04.21.20.37; Sun, 04 Jun 2023 21:20:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K872SEU+; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231737AbjFEEPU (ORCPT + 99 others); Mon, 5 Jun 2023 00:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231243AbjFEEPT (ORCPT ); Mon, 5 Jun 2023 00:15:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7EE8A6; Sun, 4 Jun 2023 21:15:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4C1A861DF3; Mon, 5 Jun 2023 04:15:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A317C433EF; Mon, 5 Jun 2023 04:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685938517; bh=iJ39RWeiHKTXkYUaE5+ijY3+twwWnAlDiMVKlAoRUck=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=K872SEU+6YKR+UJDjfnvMCYQOVIAXkQh7BbvM3fP5AvF9eyhx24mNMgSNketAI8NJ hJb8UjAhBCWdYfmPYA/NpHaBk1IoJ9CmI6OkI5yKKoOAHsGGRcP/XQw5rmqliblcLn 7dPkKZ/UNgDP0Y0+hIM82KoN6+gaSSCl7U8CEH5B67cFFFvRql+ep2DRtaHABo82X5 buPskWqDb5Wvc7D3nYgIF5qzPilMr7YO9DSQqEVmgrXFeu9OoIGhu/fXD33g3XdH29 U91d9aEZpaoiBnZ2LU2ruBcaoU9k/H5WGbxrpHl2YGlAQvVoUrgEzVNBWJt0J3J7al QxJISBkH7Oeyw== Message-ID: <4f0d6bd4-f393-9879-37c2-2495db4506c9@kernel.org> Date: Mon, 5 Jun 2023 12:15:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v2] ext4: fix to report fstrim.minlen back to userspace Content-Language: en-US To: Theodore Ts'o Cc: Andreas Dilger , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara References: <20230406150410.3853001-1-chao@kernel.org> <20230421093940.k2crghkblpx2fqlv@quack3> From: Chao Yu In-Reply-To: <20230421093940.k2crghkblpx2fqlv@quack3> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Ping, On 2023/4/21 17:39, Jan Kara wrote: > On Thu 06-04-23 23:04:10, Chao Yu wrote: >> Quoted from manual of fstrim(8): >> >> "-m, --minimum minimum-size >> ..., if it's smaller than the device's minimum, and report that >> (fstrim_range.minlen) back to userspace." >> >> So this patch tries to report adjusted fstrim_range.minlen back to >> userspace via FITRIM interface, if the value is smaller than device's >> minimum discard granularity. >> >> Signed-off-by: Chao Yu > > Looks good to me. Feel free to add: > > Reviewed-by: Jan Kara > > Honza > >> --- >> v2: >> - fix the wrong calculation of range->minlen. >> fs/ext4/mballoc.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c >> index d8b9d6a83d1e..4af51a16fc64 100644 >> --- a/fs/ext4/mballoc.c >> +++ b/fs/ext4/mballoc.c >> @@ -6491,6 +6491,10 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range) >> discard_granularity >> sb->s_blocksize_bits); >> if (minlen > EXT4_CLUSTERS_PER_GROUP(sb)) >> goto out; >> + >> + /* Report adjusted minlen back to userspace */ >> + range->minlen = EXT4_C2B(EXT4_SB(sb), minlen) << >> + sb->s_blocksize_bits; >> } >> if (end >= max_blks - 1) { >> end = max_blks - 1; >> -- >> 2.25.1 >>