kernel_optimize_test/fs/ext4
Ritesh Harjani aa9714d0e3 ext4: Start with shared i_rwsem in case of DIO instead of exclusive
Earlier there was no shared lock in DIO read path. But this patch
(16c54688592ce: ext4: Allow parallel DIO reads)
simplified some of the locking mechanism while still allowing for parallel DIO
reads by adding shared lock in inode DIO read path.

But this created problem with mixed read/write workload. It is due to the fact
that in DIO path, we first start with exclusive lock and only when we determine
that it is a ovewrite IO, we downgrade the lock. This causes the problem, since
we still have shared locking in DIO reads.

So, this patch tries to fix this issue by starting with shared lock and then
switching to exclusive lock only when required based on ext4_dio_write_checks().

Other than that, it also simplifies below cases:-

1. Simplified ext4_unaligned_aio API to ext4_unaligned_io. Previous API was
abused in the sense that it was not really checking for AIO anywhere also it
used to check for extending writes. So this API was renamed and simplified to
ext4_unaligned_io() which actully only checks if the IO is really unaligned.

Now, in case of unaligned direct IO, iomap_dio_rw needs to do zeroing of partial
block and that will require serialization against other direct IOs in the same
block. So we take a exclusive inode lock for any unaligned DIO. In case of AIO
we also need to wait for any outstanding IOs to complete so that conversion from
unwritten to written is completed before anyone try to map the overlapping block.
Hence we take exclusive inode lock and also wait for inode_dio_wait() for
unaligned DIO case. Please note since we are anyway taking an exclusive lock in
unaligned IO, inode_dio_wait() becomes a no-op in case of non-AIO DIO.

2. Added ext4_extending_io(). This checks if the IO is extending the file.

3. Added ext4_dio_write_checks(). In this we start with shared inode lock and
only switch to exclusive lock if required. So in most cases with aligned,
non-extending, dioread_nolock & overwrites, it tries to write with a shared
lock. If not, then we restart the operation in ext4_dio_write_checks(), after
acquiring exclusive lock.

Reviewed-by: Jan Kara <jack@suse.cz>
Tested-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/20191212055557.11151-3-riteshh@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-12-22 23:57:27 -05:00
..
acl.c
acl.h
balloc.c
bitmap.c
block_validity.c ext4: use RCU API in debug_print_tree 2019-12-15 21:41:04 -05:00
dir.c ext4: optimize __ext4_check_dir_entry() 2019-12-14 17:23:14 -05:00
ext4_extents.h
ext4_jbd2.c
ext4_jbd2.h
ext4.h
extents_status.c
extents_status.h
extents.c
file.c ext4: Start with shared i_rwsem in case of DIO instead of exclusive 2019-12-22 23:57:27 -05:00
fsmap.c
fsmap.h
fsync.c
hash.c
ialloc.c ext4: reserve revoke credits in __ext4_new_inode 2019-12-14 17:47:13 -05:00
indirect.c
inline.c
inode-test.c
inode.c Ext4 bug fixes (including a regression fix) for 5.5 2019-12-22 10:41:48 -08:00
ioctl.c
Kconfig
Makefile
mballoc.c
mballoc.h
migrate.c
mmp.c
move_extent.c
namei.c ext4: fix unused-but-set-variable warning in ext4_add_entry() 2019-12-21 21:00:53 -05:00
page-io.c
readpage.c
resize.c
super.c Ext4 bug fixes (including a regression fix) for 5.5 2019-12-22 10:41:48 -08:00
symlink.c
sysfs.c
truncate.h
verity.c
xattr_security.c
xattr_trusted.c
xattr_user.c
xattr.c
xattr.h