提交 5f772595 编写于 作者: J Josef Bacik 提交者: Zheng Zengkai

fs: export an inode_update_time helper

stable inclusion
form stable-v5.10.82
commit 9febc9d8d2b4f367c364ccf3b4a4a2335291cff2
bugzilla: 185877 https://gitee.com/openeuler/kernel/issues/I4QU6V

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9febc9d8d2b4f367c364ccf3b4a4a2335291cff2

--------------------------------

commit e60feb44 upstream.

If you already have an inode and need to update the time on the inode
there is no way to do this properly.  Export this helper to allow file
systems to update time on the inode so the appropriate handler is
called, either ->update_time or generic_update_time.
Signed-off-by: NJosef Bacik <josef@toxicpanda.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 c97cc2a5
......@@ -1779,12 +1779,13 @@ EXPORT_SYMBOL(generic_update_time);
* This does the actual work of updating an inodes time or version. Must have
* had called mnt_want_write() before calling this.
*/
static int update_time(struct inode *inode, struct timespec64 *time, int flags)
int inode_update_time(struct inode *inode, struct timespec64 *time, int flags)
{
if (inode->i_op->update_time)
return inode->i_op->update_time(inode, time, flags);
return generic_update_time(inode, time, flags);
}
EXPORT_SYMBOL(inode_update_time);
/**
* touch_atime - update the access time
......@@ -1854,7 +1855,7 @@ void touch_atime(const struct path *path)
* of the fs read only, e.g. subvolumes in Btrfs.
*/
now = current_time(inode);
update_time(inode, &now, S_ATIME);
inode_update_time(inode, &now, S_ATIME);
__mnt_drop_write(mnt);
skip_update:
sb_end_write(inode->i_sb);
......@@ -1998,7 +1999,7 @@ int file_update_time(struct file *file)
if (__mnt_want_write_file(file))
return 0;
ret = update_time(inode, &now, sync_it);
ret = inode_update_time(inode, &now, sync_it);
__mnt_drop_write_file(file);
return ret;
......
......@@ -2260,6 +2260,8 @@ enum file_time_flags {
extern bool atime_needs_update(const struct path *, struct inode *);
extern void touch_atime(const struct path *);
int inode_update_time(struct inode *inode, struct timespec64 *time, int flags);
static inline void file_accessed(struct file *file)
{
if (!(file->f_flags & O_NOATIME))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册