@@ -157,7 +157,7 @@ static ssize_t hypfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
if (!count)
return -EFAULT;
iocb->ki_pos = pos + count;
- file_accessed(file);
+ file_accessed(file, false);
return count;
}
@@ -601,7 +601,7 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
ret = kiocb_write_and_wait(iocb, count);
if (ret < 0)
goto reexpand;
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
ret = blkdev_direct_IO(iocb, to);
if (ret >= 0) {
@@ -2013,7 +2013,7 @@ static int btrfs_file_mmap(struct file *filp, struct vm_area_struct *vma)
if (!mapping->a_ops->read_folio)
return -ENOEXEC;
- file_accessed(filp);
+ file_accessed(filp, false);
vma->vm_ops = &btrfs_file_vm_ops;
return 0;
@@ -10153,7 +10153,7 @@ ssize_t btrfs_encoded_read(struct kiocb *iocb, struct iov_iter *iter,
struct extent_map *em;
bool unlocked = false;
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
btrfs_inode_lock(inode, BTRFS_ILOCK_SHARED);
@@ -436,12 +436,12 @@ static int coda_readdir(struct file *coda_file, struct dir_context *ctx)
if (host_file->f_op->iterate_shared) {
inode_lock_shared(host_inode);
ret = host_file->f_op->iterate_shared(host_file, ctx);
- file_accessed(host_file);
+ file_accessed(host_file, false);
inode_unlock_shared(host_inode);
} else {
inode_lock(host_inode);
ret = host_file->f_op->iterate(host_file, ctx);
- file_accessed(host_file);
+ file_accessed(host_file, false);
inode_unlock(host_inode);
}
}
@@ -44,7 +44,7 @@ static ssize_t ext2_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
ret = dax_iomap_rw(iocb, to, &ext2_iomap_ops);
inode_unlock_shared(inode);
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
return ret;
}
@@ -127,7 +127,7 @@ static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma)
if (!IS_DAX(file_inode(file)))
return generic_file_mmap(file, vma);
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &ext2_dax_vm_ops;
return 0;
}
@@ -94,7 +94,7 @@ static ssize_t ext4_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
ret = iomap_dio_rw(iocb, to, &ext4_iomap_ops, NULL, 0, NULL, 0);
inode_unlock_shared(inode);
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
return ret;
}
@@ -122,7 +122,7 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
ret = dax_iomap_rw(iocb, to, &ext4_iomap_ops);
inode_unlock_shared(inode);
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
return ret;
}
#endif
@@ -820,7 +820,7 @@ static int ext4_file_mmap(struct file *file, struct vm_area_struct *vma)
if (!daxdev_mapping_supported(vma, dax_dev))
return -EOPNOTSUPP;
- file_accessed(file);
+ file_accessed(file, false);
if (IS_DAX(file_inode(file))) {
vma->vm_ops = &ext4_dax_vm_ops;
vm_flags_set(vma, VM_HUGEPAGE);
@@ -524,7 +524,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
if (!f2fs_is_compress_backend_ready(inode))
return -EOPNOTSUPP;
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &f2fs_file_vm_ops;
set_inode_flag(inode, FI_MMAP_FILE);
return 0;
@@ -4380,7 +4380,7 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
f2fs_up_read(&fi->i_gc_rwsem[READ]);
- file_accessed(file);
+ file_accessed(file, false);
out:
trace_f2fs_direct_IO_exit(inode, pos, count, READ, ret);
return ret;
@@ -858,7 +858,7 @@ static const struct vm_operations_struct fuse_dax_vm_ops = {
int fuse_dax_mmap(struct file *file, struct vm_area_struct *vma)
{
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &fuse_dax_vm_ops;
vm_flags_set(vma, VM_MIXEDMAP | VM_HUGEPAGE);
return 0;
@@ -2496,7 +2496,7 @@ static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
fuse_link_write_file(file);
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &fuse_file_vm_ops;
return 0;
}
@@ -3193,7 +3193,7 @@ static ssize_t __fuse_copy_file_range(struct file *file_in, loff_t pos_in,
clear_bit(FUSE_I_SIZE_UNSTABLE, &fi_out->state);
inode_unlock(inode_out);
- file_accessed(file_in);
+ file_accessed(file_in, false);
fuse_flush_time_update(inode_out);
@@ -601,7 +601,7 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)
return error;
/* grab lock to update inode */
gfs2_glock_dq_uninit(&i_gh);
- file_accessed(file);
+ file_accessed(file, false);
}
vma->vm_ops = &gfs2_vm_ops;
@@ -161,7 +161,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
return -EINVAL;
inode_lock(inode);
- file_accessed(file);
+ file_accessed(file, false);
ret = -ENOMEM;
if (!hugetlb_reserve_pages(inode,
@@ -119,7 +119,7 @@ static const struct vm_operations_struct nilfs_file_vm_ops = {
static int nilfs_file_mmap(struct file *file, struct vm_area_struct *vma)
{
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &nilfs_file_vm_ops;
return 0;
}
@@ -412,7 +412,7 @@ static int orangefs_file_mmap(struct file *file, struct vm_area_struct *vma)
/* set the sequential readahead hint */
vm_flags_mod(vma, VM_SEQ_READ, VM_RAND_READ);
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &orangefs_file_vm_ops;
return 0;
}
@@ -597,7 +597,7 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb,
ret = total_count;
if (ret > 0) {
if (type == ORANGEFS_IO_READ) {
- file_accessed(file);
+ file_accessed(file, false);
} else {
file_update_time(file);
if (*offset > i_size_read(inode))
@@ -393,7 +393,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
wake_up_interruptible_sync_poll(&pipe->rd_wait, EPOLLIN | EPOLLRDNORM);
kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
if (ret > 0)
- file_accessed(filp);
+ file_accessed(filp, false);
return ret;
}
@@ -267,7 +267,7 @@ static int ramfs_nommu_mmap(struct file *file, struct vm_area_struct *vma)
if (!is_nommu_shared_mapping(vma->vm_flags))
return -ENOSYS;
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &generic_file_vm_ops;
return 0;
}
@@ -68,7 +68,7 @@ int iterate_dir(struct file *file, struct dir_context *ctx)
res = file->f_op->iterate(file, ctx);
file->f_pos = ctx->pos;
fsnotify_access(file);
- file_accessed(file);
+ file_accessed(file, ctx->flags & DIR_CONTEXT_F_NOWAIT);
}
if (shared)
inode_unlock_shared(inode);
@@ -1307,7 +1307,7 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
rc = target_tcon->ses->server->ops->copychunk_range(xid,
smb_file_src, smb_file_target, off, len, destoff);
- file_accessed(src_file);
+ file_accessed(src_file, false);
/* force revalidate of size and timestamps of target file now
* that target is updated on the server
@@ -1104,7 +1104,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
done:
pipe->tail = pipe->head = 0;
- file_accessed(in);
+ file_accessed(in, false);
return bytes;
read_failure:
@@ -1603,7 +1603,7 @@ static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_ops = &ubifs_file_vm_ops;
if (IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT))
- file_accessed(file);
+ file_accessed(file, false);
return 0;
}
@@ -191,7 +191,7 @@ static int udf_release_file(struct inode *inode, struct file *filp)
static int udf_file_mmap(struct file *file, struct vm_area_struct *vma)
{
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &udf_file_vm_ops;
return 0;
@@ -227,7 +227,7 @@ xfs_file_dio_read(
if (!iov_iter_count(to))
return 0; /* skip atime */
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
ret = xfs_ilock_iocb(iocb, XFS_IOLOCK_SHARED);
if (ret)
@@ -257,7 +257,7 @@ xfs_file_dax_read(
ret = dax_iomap_rw(iocb, to, &xfs_read_iomap_ops);
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
return ret;
}
@@ -1434,7 +1434,7 @@ xfs_file_mmap(
if (!daxdev_mapping_supported(vma, target->bt_daxdev))
return -EOPNOTSUPP;
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &xfs_file_vm_ops;
if (IS_DAX(inode))
vm_flags_set(vma, VM_HUGEPAGE);
@@ -323,7 +323,7 @@ static int zonefs_file_mmap(struct file *file, struct vm_area_struct *vma)
(vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE))
return -EINVAL;
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &zonefs_file_vm_ops;
return 0;
@@ -736,7 +736,7 @@ static ssize_t zonefs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
ret = -EINVAL;
goto inode_unlock;
}
- file_accessed(iocb->ki_filp);
+ file_accessed(iocb->ki_filp, false);
ret = iomap_dio_rw(iocb, to, &zonefs_read_iomap_ops,
&zonefs_read_dio_ops, 0, NULL, 0);
} else {
@@ -2204,10 +2204,11 @@ extern bool atime_needs_update(const struct path *, struct inode *);
extern int touch_atime(const struct path *path, bool nowait);
int inode_update_time(struct inode *inode, struct timespec64 *time, int flags);
-static inline void file_accessed(struct file *file)
+static inline int file_accessed(struct file *file, bool nowait)
{
if (!(file->f_flags & O_NOATIME))
- touch_atime(&file->f_path, false);
+ return touch_atime(&file->f_path, nowait);
+ return 0;
}
extern int file_modified(struct file *file);
@@ -2723,7 +2723,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
folio_batch_init(&fbatch);
} while (iov_iter_count(iter) && iocb->ki_pos < isize && !error);
- file_accessed(filp);
+ file_accessed(filp, false);
return already_read ? already_read : error;
}
@@ -2809,7 +2809,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
retval = kiocb_write_and_wait(iocb, count);
if (retval < 0)
return retval;
- file_accessed(file);
+ file_accessed(file, false);
retval = mapping->a_ops->direct_IO(iocb, iter);
if (retval >= 0) {
@@ -2978,7 +2978,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos,
out:
folio_batch_release(&fbatch);
- file_accessed(in);
+ file_accessed(in, false);
return total_spliced ? total_spliced : error;
}
@@ -3613,7 +3613,7 @@ int generic_file_mmap(struct file *file, struct vm_area_struct *vma)
if (!mapping->a_ops->read_folio)
return -ENOEXEC;
- file_accessed(file);
+ file_accessed(file, false);
vma->vm_ops = &generic_file_vm_ops;
return 0;
}
@@ -2317,7 +2317,7 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
/* arm64 - allow memory tagging on RAM-based files */
vm_flags_set(vma, VM_MTE_ALLOWED);
- file_accessed(file);
+ file_accessed(file, false);
/* This is anonymous shared memory if it is unlinked at the time of mmap */
if (inode->i_nlink)
vma->vm_ops = &shmem_vm_ops;
@@ -2727,7 +2727,7 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
}
*ppos = ((loff_t) index << PAGE_SHIFT) + offset;
- file_accessed(file);
+ file_accessed(file, false);
return retval ? retval : error;
}
@@ -2859,7 +2859,7 @@ static ssize_t shmem_file_splice_read(struct file *in, loff_t *ppos,
if (folio)
folio_put(folio);
- file_accessed(in);
+ file_accessed(in, false);
return total_spliced ? total_spliced : error;
}