On Tue, Apr 30, 2019 at 12:09:30AM +0200, Andreas Gruenbacher wrote: > From: Christoph Hellwig <hch@xxxxxx> > > Move the call to __generic_write_end into iomap_write_end instead of > duplicating it in each of the three branches. This requires open coding > the generic_write_end for the buffer_head case. > > Signed-off-by: Christoph Hellwig <hch@xxxxxx> > Signed-off-by: Andreas Gruenbacher <agruenba@xxxxxxxxxx> > Reviewed-by: Jan Kara <jack@xxxxxxx> Looks ok, Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --D > --- > fs/iomap.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/fs/iomap.c b/fs/iomap.c > index 97cb9d486a7d..2344c662e6fc 100644 > --- a/fs/iomap.c > +++ b/fs/iomap.c > @@ -738,13 +738,11 @@ __iomap_write_end(struct inode *inode, loff_t pos, unsigned len, > * uptodate page as a zero-length write, and force the caller to redo > * the whole thing. > */ > - if (unlikely(copied < len && !PageUptodate(page))) { > - copied = 0; > - } else { > - iomap_set_range_uptodate(page, offset_in_page(pos), len); > - iomap_set_page_dirty(page); > - } > - return __generic_write_end(inode, pos, copied, page); > + if (unlikely(copied < len && !PageUptodate(page))) > + return 0; > + iomap_set_range_uptodate(page, offset_in_page(pos), len); > + iomap_set_page_dirty(page); > + return copied; > } > > static int > @@ -761,7 +759,6 @@ iomap_write_end_inline(struct inode *inode, struct page *page, > kunmap_atomic(addr); > > mark_inode_dirty(inode); > - __generic_write_end(inode, pos, copied, page); > return copied; > } > > @@ -774,12 +771,13 @@ iomap_write_end(struct inode *inode, loff_t pos, unsigned len, > if (iomap->type == IOMAP_INLINE) { > ret = iomap_write_end_inline(inode, page, iomap, pos, copied); > } else if (iomap->flags & IOMAP_F_BUFFER_HEAD) { > - ret = generic_write_end(NULL, inode->i_mapping, pos, len, > - copied, page, NULL); > + ret = block_write_end(NULL, inode->i_mapping, pos, len, copied, > + page, NULL); > } else { > ret = __iomap_write_end(inode, pos, len, copied, page, iomap); > } > > + ret = __generic_write_end(inode, pos, ret, page); > if (iomap->page_done) > iomap->page_done(inode, pos, copied, page, iomap); > > -- > 2.20.1 >