Skip to content

Commit f629afe

Browse files
riteshharjanitytso
authored andcommitted
ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT
Apparently our current rwsem code doesn't like doing the trylock, then lock for real scheme. So change our dax read/write methods to just do the trylock for the RWF_NOWAIT case. This seems to fix AIM7 regression in some scalable filesystems upto ~25% in some cases. Claimed in commit 942491c ("xfs: fix AIM7 regression") Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Matthew Bobrowski <[email protected]> Tested-by: Joseph Qi <[email protected]> Signed-off-by: Ritesh Harjani <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 46cf053 commit f629afe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/ext4/file.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)
8888
struct inode *inode = file_inode(iocb->ki_filp);
8989
ssize_t ret;
9090

91-
if (!inode_trylock_shared(inode)) {
92-
if (iocb->ki_flags & IOCB_NOWAIT)
91+
if (iocb->ki_flags & IOCB_NOWAIT) {
92+
if (!inode_trylock_shared(inode))
9393
return -EAGAIN;
94+
} else {
9495
inode_lock_shared(inode);
9596
}
9697
/*
@@ -487,9 +488,10 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)
487488
bool extend = false;
488489
struct inode *inode = file_inode(iocb->ki_filp);
489490

490-
if (!inode_trylock(inode)) {
491-
if (iocb->ki_flags & IOCB_NOWAIT)
491+
if (iocb->ki_flags & IOCB_NOWAIT) {
492+
if (!inode_trylock(inode))
492493
return -EAGAIN;
494+
} else {
493495
inode_lock(inode);
494496
}
495497

0 commit comments

Comments
 (0)