On Tue, Nov 01, 2016 at 10:06:11PM +0100, Jan Kara wrote: > Factor out checks of 'from' and whether we are overwriting out of > ext4_file_write_iter() so that the function is easier to follow. > > Signed-off-by: Jan Kara <jack@xxxxxxx> > --- > fs/ext4/file.c | 97 ++++++++++++++++++++++++++++++---------------------------- > 1 file changed, 50 insertions(+), 47 deletions(-) > > diff --git a/fs/ext4/file.c b/fs/ext4/file.c > index 2a822d30e73f..a6a7becb9465 100644 > --- a/fs/ext4/file.c > +++ b/fs/ext4/file.c > @@ -88,6 +88,51 @@ ext4_unaligned_aio(struct inode *inode, struct iov_iter *from, loff_t pos) > return 0; > } > > +/* Is IO overwriting allocated and initialized blocks? */ > +static bool ext4_overwrite_io(struct inode *inode, loff_t pos, loff_t len) > +{ > + struct ext4_map_blocks map; > + unsigned int blkbits = inode->i_blkbits; > + int err, blklen; > + > + if (pos + len > i_size_read(inode)) > + return false; > + > + map.m_lblk = pos >> blkbits; > + map.m_len = EXT4_MAX_BLOCKS(len, pos, blkbits); > + blklen = map.m_len; > + > + err = ext4_map_blocks(NULL, inode, &map, 0); > + /* > + * 'err==len' means that all of blocks has been preallocated no matter > + * they are initialized or not. For excluding unwritten extents, we > + * need to check m_flags. Does it make sense to clean up this comment, since you're moving it anyway? i.e.: 'err==len' means that all of the blocks have been preallocated, regardless of whether they have been initialized or not. To exclude unwritten extents we need to check m_flags. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html