From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:58274 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbeA2WSx (ORCPT ); Mon, 29 Jan 2018 17:18:53 -0500 From: Andreas Gruenbacher To: cluster-devel@redhat.com Cc: Christoph Hellwig , Dave Chinner , linux-fsdevel@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH v2 2/6] gfs2: Remove ordered write mode handling from gfs2_trans_add_data Date: Mon, 29 Jan 2018 23:18:40 +0100 Message-Id: <20180129221844.19476-3-agruenba@redhat.com> In-Reply-To: <20180129221844.19476-1-agruenba@redhat.com> References: <20180129221844.19476-1-agruenba@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: In journaled data mode, we need to add each buffer head to the current transaction. In ordered write mode, we only need to add the inode to the ordered inode list. So far, both cases are handled in gfs2_trans_add_data. This makes the code look misleading and is inefficient for small block sizes as well. Handle both cases separately instead. Signed-off-by: Andreas Gruenbacher --- fs/gfs2/aops.c | 7 ++++--- fs/gfs2/bmap.c | 12 ++++++++---- fs/gfs2/log.h | 7 ++++++- fs/gfs2/quota.c | 5 ++++- fs/gfs2/trans.c | 27 ++++++++------------------- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 8ed34aa9997c..84db5759fe3d 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -54,8 +54,7 @@ static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page, continue; if (start >= to) break; - if (gfs2_is_jdata(ip)) - set_buffer_uptodate(bh); + set_buffer_uptodate(bh); gfs2_trans_add_data(ip->i_gl, bh); } } @@ -891,8 +890,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, goto out2; } - if (!gfs2_is_writeback(ip)) + if (gfs2_is_jdata(ip)) gfs2_page_add_databufs(ip, page, pos & ~PAGE_MASK, len); + else + gfs2_ordered_add_inode(ip); ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); page = NULL; diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 86863792f36a..72e22b99ade7 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -89,10 +89,12 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, map_bh(bh, inode->i_sb, block); set_buffer_uptodate(bh); - if (!gfs2_is_jdata(ip)) - mark_buffer_dirty(bh); - if (!gfs2_is_writeback(ip)) + if (gfs2_is_jdata(ip)) gfs2_trans_add_data(ip->i_gl, bh); + else { + mark_buffer_dirty(bh); + gfs2_ordered_add_inode(ip); + } if (release) { unlock_page(page); @@ -951,8 +953,10 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from, err = 0; } - if (!gfs2_is_writeback(ip)) + if (gfs2_is_jdata(ip)) gfs2_trans_add_data(ip->i_gl, bh); + else + gfs2_ordered_add_inode(ip); zero_user(page, offset, length); mark_buffer_dirty(bh); diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h index 93b52ac1ca1f..1634c67bd660 100644 --- a/fs/gfs2/log.h +++ b/fs/gfs2/log.h @@ -14,6 +14,7 @@ #include #include #include "incore.h" +#include "inode.h" /** * gfs2_log_lock - acquire the right to mess with the log manager @@ -50,8 +51,12 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp, static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + struct gfs2_sbd *sdp; + if (!gfs2_is_ordered(ip)) + return; + + sdp = GFS2_SB(&ip->i_inode); if (!test_bit(GIF_ORDERED, &ip->i_flags)) { spin_lock(&sdp->sd_ordered_lock); if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags)) diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 7a98abd340ee..e8585dfd209f 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -735,7 +735,10 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index, if (!buffer_uptodate(bh)) goto unlock_out; } - gfs2_trans_add_data(ip->i_gl, bh); + if (gfs2_is_jdata(ip)) + gfs2_trans_add_data(ip->i_gl, bh); + else + gfs2_ordered_add_inode(ip); /* If we need to write to the next block as well */ if (to_write > (bsize - boff)) { diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index c75cacaa349b..064c9a0ef046 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -143,32 +143,21 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl, * @gl: The inode glock associated with the buffer * @bh: The buffer to add * - * This is used in two distinct cases: - * i) In ordered write mode - * We put the data buffer on a list so that we can ensure that it's - * synced to disk at the right time - * ii) In journaled data mode - * We need to journal the data block in the same way as metadata in - * the functions above. The difference is that here we have a tag - * which is two __be64's being the block number (as per meta data) - * and a flag which says whether the data block needs escaping or - * not. This means we need a new log entry for each 251 or so data - * blocks, which isn't an enormous overhead but twice as much as - * for normal metadata blocks. + * This is used in journaled data mode. + * We need to journal the data block in the same way as metadata in + * the functions above. The difference is that here we have a tag + * which is two __be64's being the block number (as per meta data) + * and a flag which says whether the data block needs escaping or + * not. This means we need a new log entry for each 251 or so data + * blocks, which isn't an enormous overhead but twice as much as + * for normal metadata blocks. */ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) { struct gfs2_trans *tr = current->journal_info; struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; - struct address_space *mapping = bh->b_page->mapping; - struct gfs2_inode *ip = GFS2_I(mapping->host); struct gfs2_bufdata *bd; - if (!gfs2_is_jdata(ip)) { - gfs2_ordered_add_inode(ip); - return; - } - lock_buffer(bh); if (buffer_pinned(bh)) { set_bit(TR_TOUCHED, &tr->tr_flags); -- 2.14.3 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Gruenbacher Date: Mon, 29 Jan 2018 23:18:40 +0100 Subject: [Cluster-devel] [PATCH v2 2/6] gfs2: Remove ordered write mode handling from gfs2_trans_add_data In-Reply-To: <20180129221844.19476-1-agruenba@redhat.com> References: <20180129221844.19476-1-agruenba@redhat.com> Message-ID: <20180129221844.19476-3-agruenba@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit In journaled data mode, we need to add each buffer head to the current transaction. In ordered write mode, we only need to add the inode to the ordered inode list. So far, both cases are handled in gfs2_trans_add_data. This makes the code look misleading and is inefficient for small block sizes as well. Handle both cases separately instead. Signed-off-by: Andreas Gruenbacher --- fs/gfs2/aops.c | 7 ++++--- fs/gfs2/bmap.c | 12 ++++++++---- fs/gfs2/log.h | 7 ++++++- fs/gfs2/quota.c | 5 ++++- fs/gfs2/trans.c | 27 ++++++++------------------- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 8ed34aa9997c..84db5759fe3d 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -54,8 +54,7 @@ static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page, continue; if (start >= to) break; - if (gfs2_is_jdata(ip)) - set_buffer_uptodate(bh); + set_buffer_uptodate(bh); gfs2_trans_add_data(ip->i_gl, bh); } } @@ -891,8 +890,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, goto out2; } - if (!gfs2_is_writeback(ip)) + if (gfs2_is_jdata(ip)) gfs2_page_add_databufs(ip, page, pos & ~PAGE_MASK, len); + else + gfs2_ordered_add_inode(ip); ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata); page = NULL; diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 86863792f36a..72e22b99ade7 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -89,10 +89,12 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, map_bh(bh, inode->i_sb, block); set_buffer_uptodate(bh); - if (!gfs2_is_jdata(ip)) - mark_buffer_dirty(bh); - if (!gfs2_is_writeback(ip)) + if (gfs2_is_jdata(ip)) gfs2_trans_add_data(ip->i_gl, bh); + else { + mark_buffer_dirty(bh); + gfs2_ordered_add_inode(ip); + } if (release) { unlock_page(page); @@ -951,8 +953,10 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from, err = 0; } - if (!gfs2_is_writeback(ip)) + if (gfs2_is_jdata(ip)) gfs2_trans_add_data(ip->i_gl, bh); + else + gfs2_ordered_add_inode(ip); zero_user(page, offset, length); mark_buffer_dirty(bh); diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h index 93b52ac1ca1f..1634c67bd660 100644 --- a/fs/gfs2/log.h +++ b/fs/gfs2/log.h @@ -14,6 +14,7 @@ #include #include #include "incore.h" +#include "inode.h" /** * gfs2_log_lock - acquire the right to mess with the log manager @@ -50,8 +51,12 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp, static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip) { - struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); + struct gfs2_sbd *sdp; + if (!gfs2_is_ordered(ip)) + return; + + sdp = GFS2_SB(&ip->i_inode); if (!test_bit(GIF_ORDERED, &ip->i_flags)) { spin_lock(&sdp->sd_ordered_lock); if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags)) diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 7a98abd340ee..e8585dfd209f 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c @@ -735,7 +735,10 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index, if (!buffer_uptodate(bh)) goto unlock_out; } - gfs2_trans_add_data(ip->i_gl, bh); + if (gfs2_is_jdata(ip)) + gfs2_trans_add_data(ip->i_gl, bh); + else + gfs2_ordered_add_inode(ip); /* If we need to write to the next block as well */ if (to_write > (bsize - boff)) { diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c index c75cacaa349b..064c9a0ef046 100644 --- a/fs/gfs2/trans.c +++ b/fs/gfs2/trans.c @@ -143,32 +143,21 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl, * @gl: The inode glock associated with the buffer * @bh: The buffer to add * - * This is used in two distinct cases: - * i) In ordered write mode - * We put the data buffer on a list so that we can ensure that it's - * synced to disk at the right time - * ii) In journaled data mode - * We need to journal the data block in the same way as metadata in - * the functions above. The difference is that here we have a tag - * which is two __be64's being the block number (as per meta data) - * and a flag which says whether the data block needs escaping or - * not. This means we need a new log entry for each 251 or so data - * blocks, which isn't an enormous overhead but twice as much as - * for normal metadata blocks. + * This is used in journaled data mode. + * We need to journal the data block in the same way as metadata in + * the functions above. The difference is that here we have a tag + * which is two __be64's being the block number (as per meta data) + * and a flag which says whether the data block needs escaping or + * not. This means we need a new log entry for each 251 or so data + * blocks, which isn't an enormous overhead but twice as much as + * for normal metadata blocks. */ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh) { struct gfs2_trans *tr = current->journal_info; struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; - struct address_space *mapping = bh->b_page->mapping; - struct gfs2_inode *ip = GFS2_I(mapping->host); struct gfs2_bufdata *bd; - if (!gfs2_is_jdata(ip)) { - gfs2_ordered_add_inode(ip); - return; - } - lock_buffer(bh); if (buffer_pinned(bh)) { set_bit(TR_TOUCHED, &tr->tr_flags); -- 2.14.3