lkml.org 
[lkml]   [2021]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.10 152/154] fs: export an inode_update_time helper
    Date
    From: Josef Bacik <josef@toxicpanda.com>

    commit e60feb445fce9e51c1558a6aa7faf9dd5ded533b 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: Josef Bacik <josef@toxicpanda.com>
    Reviewed-by: David Sterba <dsterba@suse.com>
    Signed-off-by: David Sterba <dsterba@suse.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    fs/inode.c | 7 ++++---
    include/linux/fs.h | 2 ++
    2 files changed, 6 insertions(+), 3 deletions(-)

    --- a/fs/inode.c
    +++ b/fs/inode.c
    @@ -1772,12 +1772,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
    @@ -1847,7 +1848,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);
    @@ -1991,7 +1992,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;
    --- a/include/linux/fs.h
    +++ b/include/linux/fs.h
    @@ -2214,6 +2214,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))

    \
     
     \ /
      Last update: 2021-11-24 14:44    [W:4.126 / U:0.024 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site