Commit a447d7cd authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: update atime before I/O in xfs_file_dio_aio_read

After the call to __blkdev_direct_IO the final reference to the file
might have been dropped by aio_complete already, and the call to
file_accessed might cause a use after free.

Instead update the access time before the I/O, similar to how we
update the time stamps before writes.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reported-and-tested-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 5694fe9a
...@@ -269,6 +269,8 @@ xfs_file_dio_aio_read( ...@@ -269,6 +269,8 @@ xfs_file_dio_aio_read(
return -EINVAL; return -EINVAL;
} }
file_accessed(iocb->ki_filp);
/* /*
* Locking is a bit tricky here. If we take an exclusive lock for direct * Locking is a bit tricky here. If we take an exclusive lock for direct
* IO, we effectively serialise all new concurrent read IO to this file * IO, we effectively serialise all new concurrent read IO to this file
...@@ -323,7 +325,6 @@ xfs_file_dio_aio_read( ...@@ -323,7 +325,6 @@ xfs_file_dio_aio_read(
} }
xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED); xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
file_accessed(iocb->ki_filp);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment