mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zhiguo Niu <niuzhiguo84@gmail.com>
Cc: Zhiguo Niu <zhiguo.niu@unisoc.com>,
	jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, ke.wang@unisoc.com,
	hongyu.jin@unisoc.com
Subject: Re: [PATCH] f2fs: add REQ_TIME time update for some user behaviors
Date: Fri, 15 Mar 2024 11:07:17 +0800	[thread overview]
Message-ID: <2f52570e-da77-40f3-a886-2ee76059fc6b@kernel.org> (raw)
In-Reply-To: <CAHJ8P3+mo+yT8wfv2Xd3Rb7sFtXufmOgh_6CLzZxM5CjtYWC2Q@mail.gmail.com>

On 2024/3/15 9:46, Zhiguo Niu wrote:
> On Thu, Mar 14, 2024 at 9:06 PM Chao Yu <chao@kernel.org> 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 <zhiguo.niu@unisoc.com>
>>> ---
>>>    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);

  reply	other threads:[~2024-03-15  3:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13  4:11 Zhiguo Niu
2024-03-14 13:06 ` Chao Yu
2024-03-15  1:46   ` Zhiguo Niu
2024-03-15  3:07     ` Chao Yu [this message]
2024-03-15  3:29       ` Zhiguo Niu

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=2f52570e-da77-40f3-a886-2ee76059fc6b@kernel.org \
    --to=chao@kernel.org \
    --cc=hongyu.jin@unisoc.com \
    --cc=jaegeuk@kernel.org \
    --cc=ke.wang@unisoc.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=niuzhiguo84@gmail.com \
    --cc=zhiguo.niu@unisoc.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®