Skip to contentSkip to conversation

ext4: Two trivial improvements for dio path

PATCH Applied Jan Kara 2 participants 5 messages Sep 27, 2016 – Sep 30, 2016 ext4 file system

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

cover ext4: Two trivial improvements for dio path

Hi Ted!

I have these two trivial improvements locally that are part of larger DAX changes. Those large changes won't make it for the merge window but this is easy enough... Can you please merge them? Thanks!

Honza

author reviewer
#1 lore raw

PATCH 1/2 ext4: Allow unlocked direct IO when pages are cached

Currently we do not allow unlocked (meaning without inode_lock) direct IO when the file has any pages cached. This check is not needed anymore as we keep inode lock until ext4_direct_IO_write() and thus can happily writeback and evict any pages conflicting with current direct IO write.

---
 fs/ext4/file.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/file.c +1 -2
index 261ac3734c58..7e110c1a649d 100644
@@ -91,7 +91,6 @@ ext4_unaligned_aio(struct inode *inode, struct iov_iter *from, loff_t pos)
 static ssize_t
 ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct file *file = iocb->ki_filp;
 	struct inode *inode = file_inode(iocb->ki_filp);
 	struct blk_plug plug;
 	int o_direct = iocb->ki_flags & IOCB_DIRECT;
@@ -138,7 +137,7 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
 		/* check whether we do a DIO overwrite or not */
 		if (ext4_should_dioread_nolock(inode) && !unaligned_aio &&
-		    !file->f_mapping->nrpages && pos + length <= i_size_read(inode)) {
+		    pos + length <= i_size_read(inode)) {
 			struct ext4_map_blocks map;
 			unsigned int blkbits = inode->i_blkbits;
 			int err, len;
Signature · 1 line
2.6.6
maintainer Applied
#2 lore raw

Re: [PATCH 1/2] ext4: Allow unlocked direct IO when pages are cached

Quoted 6 lines · Jan Kara

Currently we do not allow unlocked (meaning without inode_lock) direct IO when the file has any pages cached. This check is not needed anymore as we keep inode lock until ext4_direct_IO_write() and thus can happily writeback and evict any pages conflicting with current direct IO write.

Thanks, applied.

- Ted

author reviewer
#3 lore raw

PATCH 2/2 ext4: Remove plugging from ext4_file_write_iter()

In reply to Jan Kara

do_blockdev_direct_IO() takes care of properly plugging direct IO so there's no need to plug again inside ext4_file_write_iter().

---
 fs/ext4/file.c | 4 ----
 1 file changed, 4 deletions(-)
fs/ext4/file.c +0 -4
index 7e110c1a649d..9c9b7ed08d3c 100644
@@ -92,7 +92,6 @@ static ssize_t
 ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct inode *inode = file_inode(iocb->ki_filp);
-	struct blk_plug plug;
 	int o_direct = iocb->ki_flags & IOCB_DIRECT;
 	int unaligned_aio = 0;
 	int overwrite = 0;
@@ -133,7 +132,6 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	if (o_direct) {
 		size_t length = iov_iter_count(from);
 		loff_t pos = iocb->ki_pos;
-		blk_start_plug(&plug);
 
 		/* check whether we do a DIO overwrite or not */
 		if (ext4_should_dioread_nolock(inode) && !unaligned_aio &&
@@ -170,8 +168,6 @@ ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 
 	if (ret > 0)
 		ret = generic_write_sync(iocb, ret);
-	if (o_direct)
-		blk_finish_plug(&plug);
 
 	return ret;
 
Signature · 1 line
2.6.6
maintainer Applied
#4 lore raw

Re: [PATCH 2/2] ext4: Remove plugging from ext4_file_write_iter()

Quoted 4 lines · Jan Kara

do_blockdev_direct_IO() takes care of properly plugging direct IO so there's no need to plug again inside ext4_file_write_iter().

Thanks, applied.

- Ted