@@ -1966,12 +1966,13 @@ int touch_atime(const struct path *path, bool nowait)
struct vfsmount *mnt = path->mnt;
struct inode *inode = d_inode(path->dentry);
struct timespec64 now;
+ int ret = 0;
if (!atime_needs_update(path, inode))
- return 0;
+ return ret;
if (!sb_start_write_trylock(inode->i_sb))
- return 0;
+ return ret;
if (__mnt_want_write(mnt) != 0)
goto skip_update;
@@ -1985,11 +1986,11 @@ int touch_atime(const struct path *path, bool nowait)
* of the fs read only, e.g. subvolumes in Btrfs.
*/
now = current_time(inode);
- inode_update_time(inode, &now, S_ATIME);
+ ret = inode_update_time(inode, &now, S_ATIME | (nowait ? S_NOWAIT : 0));
__mnt_drop_write(mnt);
skip_update:
sb_end_write(inode->i_sb);
- return 0;
+ return ret;
}
EXPORT_SYMBOL(touch_atime);
@@ -1053,7 +1053,13 @@ xfs_vn_update_time(
if (error)
return error;
- xfs_ilock(ip, XFS_ILOCK_EXCL);
+ if (flags & S_NOWAIT) {
+ if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL))
+ return -EAGAIN;
+ } else {
+ xfs_ilock(ip, XFS_ILOCK_EXCL);
+ }
+
if (flags & S_CTIME)
inode->i_ctime = *now;
if (flags & S_MTIME)
@@ -2198,6 +2198,7 @@ enum file_time_flags {
S_MTIME = 2,
S_CTIME = 4,
S_VERSION = 8,
+ S_NOWAIT = 16,
};
extern bool atime_needs_update(const struct path *, struct inode *);