Skip to content

Commit 845802b

Browse files
agruenbaAstralBob
authored andcommitted
gfs2: Remove ordered write mode handling from gfs2_trans_add_data
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 <agruenba@redhat.com> Signed-off-by: Bob Peterson <rpeterso@redhat.com>
1 parent d6382a3 commit 845802b

5 files changed

Lines changed: 30 additions & 28 deletions

File tree

‎fs/gfs2/aops.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ static void gfs2_page_add_databufs(struct gfs2_inode *ip, struct page *page,
5454
continue;
5555
if (start >= to)
5656
break;
57-
if (gfs2_is_jdata(ip))
58-
set_buffer_uptodate(bh);
57+
set_buffer_uptodate(bh);
5958
gfs2_trans_add_data(ip->i_gl, bh);
6059
}
6160
}
@@ -894,8 +893,10 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping,
894893
goto out2;
895894
}
896895

897-
if (!gfs2_is_writeback(ip))
896+
if (gfs2_is_jdata(ip))
898897
gfs2_page_add_databufs(ip, page, pos & ~PAGE_MASK, len);
898+
else
899+
gfs2_ordered_add_inode(ip);
899900

900901
ret = generic_write_end(file, mapping, pos, len, copied, page, fsdata);
901902
page = NULL;

‎fs/gfs2/bmap.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ static int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh,
8989
map_bh(bh, inode->i_sb, block);
9090

9191
set_buffer_uptodate(bh);
92-
if (!gfs2_is_jdata(ip))
93-
mark_buffer_dirty(bh);
94-
if (!gfs2_is_writeback(ip))
92+
if (gfs2_is_jdata(ip))
9593
gfs2_trans_add_data(ip->i_gl, bh);
94+
else {
95+
mark_buffer_dirty(bh);
96+
gfs2_ordered_add_inode(ip);
97+
}
9698

9799
if (release) {
98100
unlock_page(page);
@@ -1028,8 +1030,10 @@ static int gfs2_block_zero_range(struct inode *inode, loff_t from,
10281030
err = 0;
10291031
}
10301032

1031-
if (!gfs2_is_writeback(ip))
1033+
if (gfs2_is_jdata(ip))
10321034
gfs2_trans_add_data(ip->i_gl, bh);
1035+
else
1036+
gfs2_ordered_add_inode(ip);
10331037

10341038
zero_user(page, offset, length);
10351039
mark_buffer_dirty(bh);

‎fs/gfs2/log.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/spinlock.h>
1515
#include <linux/writeback.h>
1616
#include "incore.h"
17+
#include "inode.h"
1718

1819
/**
1920
* 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,
5051

5152
static inline void gfs2_ordered_add_inode(struct gfs2_inode *ip)
5253
{
53-
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
54+
struct gfs2_sbd *sdp;
5455

56+
if (!gfs2_is_ordered(ip))
57+
return;
58+
59+
sdp = GFS2_SB(&ip->i_inode);
5560
if (!test_bit(GIF_ORDERED, &ip->i_flags)) {
5661
spin_lock(&sdp->sd_ordered_lock);
5762
if (!test_and_set_bit(GIF_ORDERED, &ip->i_flags))

‎fs/gfs2/quota.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,10 @@ static int gfs2_write_buf_to_page(struct gfs2_inode *ip, unsigned long index,
735735
if (!buffer_uptodate(bh))
736736
goto unlock_out;
737737
}
738-
gfs2_trans_add_data(ip->i_gl, bh);
738+
if (gfs2_is_jdata(ip))
739+
gfs2_trans_add_data(ip->i_gl, bh);
740+
else
741+
gfs2_ordered_add_inode(ip);
739742

740743
/* If we need to write to the next block as well */
741744
if (to_write > (bsize - boff)) {

‎fs/gfs2/trans.c‎

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,32 +143,21 @@ static struct gfs2_bufdata *gfs2_alloc_bufdata(struct gfs2_glock *gl,
143143
* @gl: The inode glock associated with the buffer
144144
* @bh: The buffer to add
145145
*
146-
* This is used in two distinct cases:
147-
* i) In ordered write mode
148-
* We put the data buffer on a list so that we can ensure that it's
149-
* synced to disk at the right time
150-
* ii) In journaled data mode
151-
* We need to journal the data block in the same way as metadata in
152-
* the functions above. The difference is that here we have a tag
153-
* which is two __be64's being the block number (as per meta data)
154-
* and a flag which says whether the data block needs escaping or
155-
* not. This means we need a new log entry for each 251 or so data
156-
* blocks, which isn't an enormous overhead but twice as much as
157-
* for normal metadata blocks.
146+
* This is used in journaled data mode.
147+
* We need to journal the data block in the same way as metadata in
148+
* the functions above. The difference is that here we have a tag
149+
* which is two __be64's being the block number (as per meta data)
150+
* and a flag which says whether the data block needs escaping or
151+
* not. This means we need a new log entry for each 251 or so data
152+
* blocks, which isn't an enormous overhead but twice as much as
153+
* for normal metadata blocks.
158154
*/
159155
void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
160156
{
161157
struct gfs2_trans *tr = current->journal_info;
162158
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
163-
struct address_space *mapping = bh->b_page->mapping;
164-
struct gfs2_inode *ip = GFS2_I(mapping->host);
165159
struct gfs2_bufdata *bd;
166160

167-
if (!gfs2_is_jdata(ip)) {
168-
gfs2_ordered_add_inode(ip);
169-
return;
170-
}
171-
172161
lock_buffer(bh);
173162
if (buffer_pinned(bh)) {
174163
set_bit(TR_TOUCHED, &tr->tr_flags);

0 commit comments

Comments
 (0)