From: Christoph Hellwig <hch@infradead.org>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@infradead.org>,
"Darrick J . Wong" <djwong@kernel.org>,
Ojaswin Mujoo <ojaswin@linux.ibm.com>
Subject: Re: [RFCv2 5/8] ext2: Move direct-io to use iomap
Date: Mon, 10 Apr 2023 22:46:12 -0700 [thread overview]
Message-ID: <ZDT0JFmwg/9ijdcv@infradead.org> (raw)
In-Reply-To: <e51f9a43f976d1b70d163fed791d960b88f044e2.1681188927.git.ritesh.list@gmail.com>
On Tue, Apr 11, 2023 at 10:51:53AM +0530, Ritesh Harjani (IBM) wrote:
> +extern void ext2_write_failed(struct address_space *mapping, loff_t to);
No need for the extern.
> + /* handle case for partial write and for fallback to buffered write */
> + if (ret >= 0 && iov_iter_count(from)) {
> + loff_t pos, endbyte;
> + ssize_t status;
> + int ret2;
> +
> + iocb->ki_flags &= ~IOCB_DIRECT;
> + pos = iocb->ki_pos;
> + status = generic_perform_write(iocb, from);
> + if (unlikely(status < 0)) {
> + ret = status;
> + goto out_unlock;
> + }
> +
> + iocb->ki_pos += status;
> + ret += status;
> + endbyte = pos + status - 1;
> + ret2 = filemap_write_and_wait_range(inode->i_mapping, pos,
> + endbyte);
> + if (!ret2)
> + invalidate_mapping_pages(inode->i_mapping,
> + pos >> PAGE_SHIFT,
> + endbyte >> PAGE_SHIFT);
> + if (ret > 0)
> + generic_write_sync(iocb, ret);
> + }
Nit, but to me it would seem cleaner if all the fallback handling
was moved into a separate helper function. Or in fact by not
using generic_file_write_iter even for buffered I/O and at doing
the pre-I/O checks and the final generic_write_sync in common code in
ext2 for direct and buffered I/O.
> + /*
> + * For writes that could fill holes inside i_size on a
> + * DIO_SKIP_HOLES filesystem we forbid block creations: only
> + * overwrites are permitted.
> + */
> + if ((flags & IOMAP_DIRECT) && (first_block << blkbits < i_size_read(inode)))
> + create = 0;
No need for braes around the < operation, but I think you might need
them around the shift.
Also an overly long line here.
> + if ((flags & IOMAP_WRITE) && (offset + length > i_size_read(inode)))
No need for the second set of inner braces here either.
next prev parent reply other threads:[~2023-04-11 5:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 5:21 [RFCv2 0/8] ext2: DIO to use iomap Ritesh Harjani (IBM)
2023-04-11 5:21 ` [RFCv2 1/8] ext2/dax: Fix ext2_setsize when len is page aligned Ritesh Harjani (IBM)
2023-04-11 14:29 ` Darrick J. Wong
2023-04-11 5:21 ` [RFCv2 2/8] libfs: Add __generic_file_fsync_nolock implementation Ritesh Harjani (IBM)
2023-04-11 5:27 ` Christoph Hellwig
2023-04-11 12:33 ` Matthew Wilcox
2023-04-11 15:12 ` Ritesh Harjani
2023-04-12 11:43 ` Christoph Hellwig
2023-04-12 14:02 ` Ritesh Harjani
2023-04-13 9:51 ` Christian Brauner
2023-04-11 5:21 ` [RFCv2 3/8] ext4: Use " Ritesh Harjani (IBM)
2023-04-11 5:21 ` [RFCv2 4/8] ext2: " Ritesh Harjani (IBM)
2023-04-11 5:21 ` [RFCv2 5/8] ext2: Move direct-io to use iomap Ritesh Harjani (IBM)
2023-04-11 5:46 ` Christoph Hellwig [this message]
2023-04-11 15:21 ` Ritesh Harjani
2023-04-12 11:43 ` Christoph Hellwig
2023-04-12 14:03 ` Ritesh Harjani
2023-04-11 5:21 ` [RFCv2 6/8] iomap: Remove IOMAP_DIO_NOSYNC unused dio flag Ritesh Harjani (IBM)
2023-04-11 5:27 ` Christoph Hellwig
2023-04-11 5:21 ` [RFCv2 7/8] fs.h: Add IOCB_STRINGS for use in trace points Ritesh Harjani (IBM)
2023-04-11 5:38 ` Christoph Hellwig
2023-04-11 5:21 ` [RFCv2 8/8] ext2: Add direct-io " Ritesh Harjani (IBM)
2023-04-11 5:38 ` Christoph Hellwig
2023-04-11 14:34 ` Darrick J. Wong
2023-04-11 15:11 ` Ritesh Harjani
2023-04-12 11:44 ` Christoph Hellwig
2023-04-12 14:07 ` Ritesh Harjani
2023-04-12 11:45 ` [RFCv2 0/8] ext2: DIO to use iomap Jan Kara
2023-04-12 14:10 ` Ritesh Harjani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZDT0JFmwg/9ijdcv@infradead.org \
--to=hch@infradead.org \
--cc=djwong@kernel.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).