Re: [PATCH v3 2/6] ext4: move inode extension/truncate code out from ext4_iomap_end()

Jan Kara
2019-09-24T13:13:31Z

On Mon 23-09-19 18:21:15, Jan Kara wrote:
> On Thu 12-09-19 21:04:00, Matthew Bobrowski wrote:
> So I'd just call ext4_handle_inode_extension() unconditionally like:
>
> error = ext4_handle_inode_extension(inode, offset, ret, len);
>
> and have a quick check at the beginning of that function to avoid starting
> transaction when there isn't anything to do. Something like:
>
> /*
> * DIO and DAX writes get exclusion from truncate (i_rwsem) and
> * page writeback (i_rwsem and flushing all dirty pages).
> */
> WARN_ON_ONCE(i_size_read(inode) != EXT4_I(inode)->i_disksize);
> if (offset + count <= i_size_read(inode))
> return 0;

One correction here. With commit 45d8ec4d9fd54 in mind this should be:

/*
* DIO and DAX writes get exclusion from truncate (i_rwsem). There
* can be pending delalloc writeback beyond the range written by
* DIO though.
*/
WARN_ON_ONCE(i_size_read(inode) < EXT4_I(inode)->i_disksize);
if (offset + count <= EXT4_I(inode)->i_disksize)
return 0;

Honza

> if (len < 0)
> goto truncate;
>
> ... do the heavylifting with transaction start, inode size update,
> and orphan handling...
>
> if (truncate) {
> truncate:
> ext4_truncate_failed_write(inode);
> orphan_del:
> /*
> * If the truncate operation failed early the inode
> * may still be on the orphan list. In that case, we
> * need try remove the inode from the linked list in
> * memory.
> */
> if (inode->i_nlink)
> ext4_orphan_del(NULL, inode);
> }
--
Jan Kara <jack@suse.com>
SUSE Labs, CR