[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <87wn2izbpn.fsf@doe.com>
Date: Tue, 11 Apr 2023 20:51:24 +0530
From: Ritesh Harjani (IBM) <ritesh.list@...il.com>
To: Christoph Hellwig <hch@...radead.org>
Cc: linux-fsdevel@...r.kernel.org, linux-ext4@...r.kernel.org,
Jan Kara <jack@...e.cz>, Christoph Hellwig <hch@...radead.org>,
"Darrick J . Wong" <djwong@...nel.org>,
Ojaswin Mujoo <ojaswin@...ux.ibm.com>
Subject: Re: [RFCv2 5/8] ext2: Move direct-io to use iomap
Christoph Hellwig <hch@...radead.org> writes:
> 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.
>
Sure will drop it.
>> + /* 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.
>
Make sense. However, since we are on the path to modify ext2 buffered-io
code as well to move to iomap interface, I wouldn't bother too much as
of now for this code as, all of this is going to go away anyways.
>> + /*
>> + * 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.
left-shift has a higher precedence. But let me make it more clear in
next rev.
>
> Also an overly long line here.
>
Sure, will see to it.
>> + if ((flags & IOMAP_WRITE) && (offset + length > i_size_read(inode)))
>
> No need for the second set of inner braces here either.
It's just avoids any confusion this way.
-ritesh
Powered by blists - more mailing lists