@@ -2137,6 +2137,27 @@ EXPORT_SYMBOL(file_update_time);
* Return: 0 on success, negative errno on failure.
*/
int file_modified(struct file *file)
+{
+ return file_modified_async(file, 0);
+}
+EXPORT_SYMBOL(file_modified);
+
+/**
+ * file_modified_async - handle mandated vfs changes when modifying a file
+ * @file: file that was modified
+ * @flags: kiocb flags
+ *
+ * When file has been modified ensure that special
+ * file privileges are removed and time settings are updated.
+ *
+ * If IOCB_NOWAIT is set, special file privileges will not be removed and
+ * time settings will not be updated. It will return -EAGAIN.
+ *
+ * Context: Caller must hold the file's inode lock.
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int file_modified_async(struct file *file, int flags)
{
int ret;
struct dentry *dentry = file_dentry(file);
@@ -2163,10 +2184,12 @@ int file_modified(struct file *file)
ret = file_needs_update_time(inode, file, &now);
if (ret <= 0)
return ret;
+ if (flags & IOCB_NOWAIT)
+ return -EAGAIN;
return __file_update_time(inode, file, &now, ret);
}
-EXPORT_SYMBOL(file_modified);
+EXPORT_SYMBOL(file_modified_async);
int inode_needs_sync(struct inode *inode)
{
@@ -410,7 +410,7 @@ xfs_file_write_checks(
spin_unlock(&ip->i_flags_lock);
out:
- return file_modified(file);
+ return file_modified_async(file, iocb->ki_flags);
}
static int
@@ -2382,6 +2382,7 @@ static inline void file_accessed(struct file *file)
}
extern int file_modified(struct file *file);
+extern int file_modified_async(struct file *file, int flags);
int sync_inode_metadata(struct inode *inode, int wait);
This modifies xfs file_modified() function to return -EAGAIN if the request either requires to remove privileges or needs to update the file modification time. This is required for async buffered writes, so the request gets handled in the io worker of io-uring. Signed-off-by: Stefan Roesch <shr@fb.com> --- fs/inode.c | 25 ++++++++++++++++++++++++- fs/xfs/xfs_file.c | 2 +- include/linux/fs.h | 1 + 3 files changed, 26 insertions(+), 2 deletions(-)