Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp520392lqb; Thu, 14 Mar 2024 20:07:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU99lMW9RpnrJB3DNgIfFOKNkeZ/0iI2Y/GzlgraJzWILF7zp5xlLsowUU/lyhdyQGyDOPkv0B4fsa8zJG12h0NV31SOrrtx/tSTdJ33w== X-Google-Smtp-Source: AGHT+IGkHXNkQ8uSopN4vYIEc1ihdatBbW2Cmyff4ZJ72RPZdW8RnKinS+y35EUlFygga0KIHgD/ X-Received: by 2002:ac8:5c0f:0:b0:42e:24e6:4118 with SMTP id i15-20020ac85c0f000000b0042e24e64118mr2877839qti.34.1710472050307; Thu, 14 Mar 2024 20:07:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710472050; cv=pass; d=google.com; s=arc-20160816; b=MtA6zxJOCMemmf9OccrEBE0ALrjGJgRsVhEC8hM6lFSzWAYX4p9te46LKGqa3CQqhY S0+kpuaE1YaVn5Tb5Cd3hBsu7rTk9yJltSTdBaiJpUE7vbwdoWKMVznx4cSRpsTMPgqM OIdNOnT11eSNe4JRcMt7ATfo3dgT71W3ikvpyG4/7y+biJ1+Q/YoiyExAWcIB8crO1yr lK+HtzMKaWU+eObuhMQxyZO3y1UhYwWleZJwIliEZW1FeXcaREUi+RMi+FnUWalS+l+6 z0XwTlKGg1QR1MdANNeI/vortqdcavFiXFWMYEWQ6nBEBmBA6C5ePKiVhgPLefs4uRUE aJnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=njxoMDl8Og/lx3BwHzEs7Wvirt9XGJ4aheOQ1X2+r4U=; fh=bmJMP5ZABTubPEgidfBiEdusydDuNG0BjCBCe+D3FK0=; b=qvFRVMnOUE6elB9ConwR9zMTO1kC/O2V6EbZURJg85nqYr4o1ZGU6e9NVJGt/Z25Qc KzgZnPTEROtmxta0X/knwKTELy7k2/FDzXyIAP0nBp+x1u4hq4xCPYf6vl/0M2NFnFc4 4+mcMZn9EVcB3+lMUWV+MFiK+a99xE18fFbdHlzeppMwTa2CmGkICO6H7Oa28Hr5J8CV 6Pc/Gi0KkHtG2gLTBjoBUSxR7GmHIXIZnxxggnF1TdYiMtzFBZqHJBIZd1XACWXVj/Kb 1UU7JaF3xc3PEZnX8VYyNCfNJlTe6wbDlNxCOSbl+5zj+k8RM//gbs97+Nw5R6CctQsM j1uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMoUWt5K; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-104007-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v20-20020a05622a145400b0042f204c71a4si2930967qtx.271.2024.03.14.20.07.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 20:07:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104007-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XMoUWt5K; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-104007-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F2D091C219F1 for ; Fri, 15 Mar 2024 03:07:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA45BD299; Fri, 15 Mar 2024 03:07:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XMoUWt5K" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05245C8CE for ; Fri, 15 Mar 2024 03:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710472043; cv=none; b=npd4oG5C2tlcSftKLlceu22EUbr7Xt0hGtxaF418q785nBBB8SlPp1jlm7FEihix6001FFC+o4616BMplR1J3MvDTOFt3hg4LbeyAduHk7A/KP8vQ+e9kx/NbxODnKzt+trHN0qkQgi6u8jfcNbcDrrxg2IeIqrBftd0iFmHSyA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710472043; c=relaxed/simple; bh=6lYTqdfGaED9bBcx3A78bnPc1ZpdAyPHBX3yhSNiIrU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=o/K2LjMcrnwvmU4Dq+MaFuDzjPoiPPPRVTuwePrq769aClNYqhPjrhsIwRQQijdxYcBu4jQZxrKHFevN/PbPWMDitsazGMaJhvuiocuq3EX5cAJqSjmWFKaI6o/8OlotsmN+IO6F8XXr6g54w0OkQtMyfhqdr53Pfliw6mJntoA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XMoUWt5K; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58CB4C433F1; Fri, 15 Mar 2024 03:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710472042; bh=6lYTqdfGaED9bBcx3A78bnPc1ZpdAyPHBX3yhSNiIrU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=XMoUWt5KRwLZSFLag7ec3RndzrJ5btvQkotqROm9fyslkgiC0wp7mapJ2U25h5FrJ wkaXLuT2kHnxPyJGQ6n7RtqjCw0Pyu9VJN9M2DwFxx3m0db/SfgFkvdCAUWkzGUOyR uviSwVLlWjrsjBcmNQaO3QxC7vMUmaoDi8sGT654WuAIMVxN0jFSXKpsQxTXDatctA FL57VKc/i3172jp3jias8LI7r8lB7qpuyX4Uq2v7JYv+h2lkx7mVopQQulTbEBRWHO 5lEIHTDCHfeDqq7ZbrrYcCdz/ItI6O5GZBoEc2MHzeN331pd/80VrZx7MZNotDUnY9 kZ6MnQJumcytQ== Message-ID: <2f52570e-da77-40f3-a886-2ee76059fc6b@kernel.org> Date: Fri, 15 Mar 2024 11:07:17 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] f2fs: add REQ_TIME time update for some user behaviors Content-Language: en-US To: Zhiguo Niu Cc: Zhiguo Niu , jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, ke.wang@unisoc.com, hongyu.jin@unisoc.com References: <1710303061-16822-1-git-send-email-zhiguo.niu@unisoc.com> From: Chao Yu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/3/15 9:46, Zhiguo Niu wrote: > On Thu, Mar 14, 2024 at 9:06 PM Chao Yu wrote: >> >> On 2024/3/13 12:11, Zhiguo Niu wrote: >>> some user behaviors requested filesystem operations, which >>> will cause filesystem not idle. >>> Meanwhile adjust f2fs_update_time(REQ_TIME) of >>> f2fs_ioc_defragment to successful case. >>> >>> Signed-off-by: Zhiguo Niu >>> --- >>> fs/f2fs/file.c | 9 ++++++++- >>> 1 file changed, 8 insertions(+), 1 deletion(-) >>> >>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>> index 4dfe38e..dac3836 100644 >>> --- a/fs/f2fs/file.c >>> +++ b/fs/f2fs/file.c >>> @@ -2784,7 +2784,6 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg) >>> err = f2fs_defragment_range(sbi, filp, &range); >>> mnt_drop_write_file(filp); >>> >>> - f2fs_update_time(sbi, REQ_TIME); >> >> I guess we need to call f2fs_update_time() here if any data was >> migrated. > OK! >> >> if (range->len) >> f2fs_update_time(sbi, REQ_TIME); >> >>> if (err < 0) >>> return err; >>> >>> @@ -2792,6 +2791,7 @@ static int f2fs_ioc_defragment(struct file *filp, unsigned long arg) >>> sizeof(range))) >>> return -EFAULT; >>> >>> + f2fs_update_time(sbi, REQ_TIME); >>> return 0; >>> } >>> >>> @@ -3331,6 +3331,7 @@ static int f2fs_ioc_resize_fs(struct file *filp, unsigned long arg) >>> if (copy_from_user(&block_count, (void __user *)arg, >>> sizeof(block_count))) >>> return -EFAULT; >>> + f2fs_update_time(sbi, REQ_TIME); >> >> There will be no further IO in the end of f2fs_ioc_resize_fs(), so we don't >> need to update time to delay gc/discard thread? >> >>> >>> return f2fs_resize_fs(filp, block_count); >>> } >>> @@ -3424,6 +3425,7 @@ static int f2fs_ioc_setfslabel(struct file *filp, unsigned long arg) >>> f2fs_up_write(&sbi->sb_lock); >>> >>> mnt_drop_write_file(filp); >>> + f2fs_update_time(sbi, REQ_TIME); >> >> Ditto, > Dear Chao, > > The two parts you proposed should be similar to the below scenario? > --------------------------------------------------------- > static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) > { > struct inode *inode = file_inode(filp); > > if (!f2fs_sb_has_encrypt(F2FS_I_SB(inode))) > return -EOPNOTSUPP; > > f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); > > return fscrypt_ioctl_set_policy(filp, (const void __user *)arg); fscrypt_ioctl_set_policy() will dirty inode, so we need to keep f2fs_update_time(), but it's better to update time after fscrypt_ioctl_set_policy()? Thanks, > } > ----------------------------------------------------------- > thanks! > > >> >> Thanks, >> >>> out: >>> kfree(vbuf); >>> return err; >>> @@ -3597,6 +3599,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) >>> >>> filemap_invalidate_unlock(inode->i_mapping); >>> f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); >>> + f2fs_update_time(sbi, REQ_TIME); >>> out: >>> inode_unlock(inode); >>> >>> @@ -3766,6 +3769,7 @@ static int f2fs_reserve_compress_blocks(struct file *filp, unsigned long arg) >>> clear_inode_flag(inode, FI_COMPRESS_RELEASED); >>> inode_set_ctime_current(inode); >>> f2fs_mark_inode_dirty_sync(inode, true); >>> + f2fs_update_time(sbi, REQ_TIME); >>> } >>> unlock_inode: >>> inode_unlock(inode); >>> @@ -3964,6 +3968,7 @@ static int f2fs_sec_trim_file(struct file *filp, unsigned long arg) >>> if (len) >>> ret = f2fs_secure_erase(prev_bdev, inode, prev_index, >>> prev_block, len, range.flags); >>> + f2fs_update_time(sbi, REQ_TIME); >>> out: >>> filemap_invalidate_unlock(mapping); >>> f2fs_up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); >>> @@ -4173,6 +4178,7 @@ static int f2fs_ioc_decompress_file(struct file *filp) >>> if (ret) >>> f2fs_warn(sbi, "%s: The file might be partially decompressed (errno=%d). Please delete the file.", >>> __func__, ret); >>> + f2fs_update_time(sbi, REQ_TIME); >>> out: >>> inode_unlock(inode); >>> file_end_write(filp); >>> @@ -4252,6 +4258,7 @@ static int f2fs_ioc_compress_file(struct file *filp) >>> if (ret) >>> f2fs_warn(sbi, "%s: The file might be partially compressed (errno=%d). Please delete the file.", >>> __func__, ret); >>> + f2fs_update_time(sbi, REQ_TIME); >>> out: >>> inode_unlock(inode); >>> file_end_write(filp);