Message ID | 20190429163239.4874-1-agruenba@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v6,1/4] iomap: Clean up __generic_write_end calling | expand |
On Mon, 29 Apr 2019 at 18:32, Andreas Gruenbacher <agruenba@redhat.com> wrote: > From: Christoph Hellwig <hch@lst.de> > > 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. Wouldn't it make sense to turn __generic_write_end into a void function? Right now, it just oddly return its copied argument. Andreas
On Mon, Apr 29, 2019 at 07:46:29PM +0200, Andreas Gruenbacher wrote: > On Mon, 29 Apr 2019 at 18:32, Andreas Gruenbacher <agruenba@redhat.com> wrote: > > From: Christoph Hellwig <hch@lst.de> > > > > 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. > > Wouldn't it make sense to turn __generic_write_end into a void > function? Right now, it just oddly return its copied argument. Yes, we could remove the return value. That should be a separate patch after this one, though.
On Mon 29-04-19 18:32:36, Andreas Gruenbacher wrote: > From: Christoph Hellwig <hch@lst.de> > > 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@lst.de> > Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Looks good to me. You can add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > 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 >
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);