Skip to content

Commit d69a3c6

Browse files
committed
GFS2: Move log buffer lists into transaction
Over time, we hope to be able to improve the concurrency available in the log code. This is one small step towards that, by moving the buffer lists from the super block, and into the transaction structure, so that each transaction builds its own buffer lists. At transaction commit time, the buffer lists are merged into the currently accumulating transaction. That transaction then is passed into the before and after commit functions at journal flush time. Thus there should be no change in overall behaviour yet. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 654a6d2 commit d69a3c6

7 files changed

Lines changed: 53 additions & 29 deletions

File tree

‎fs/gfs2/glops.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
8282
struct gfs2_trans tr;
8383

8484
memset(&tr, 0, sizeof(tr));
85+
INIT_LIST_HEAD(&tr.tr_buf);
86+
INIT_LIST_HEAD(&tr.tr_databuf);
8587
tr.tr_revokes = atomic_read(&gl->gl_ail_count);
8688

8789
if (!tr.tr_revokes)

‎fs/gfs2/incore.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct gfs2_log_header_host {
5252
*/
5353

5454
struct gfs2_log_operations {
55-
void (*lo_before_commit) (struct gfs2_sbd *sdp);
55+
void (*lo_before_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
5656
void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_trans *tr);
5757
void (*lo_before_scan) (struct gfs2_jdesc *jd,
5858
struct gfs2_log_header_host *head, int pass);
@@ -476,6 +476,8 @@ struct gfs2_trans {
476476
unsigned int tr_num_revoke_rm;
477477

478478
struct list_head tr_list;
479+
struct list_head tr_databuf;
480+
struct list_head tr_buf;
479481

480482
unsigned int tr_first;
481483
struct list_head tr_ail1_list;
@@ -756,9 +758,7 @@ struct gfs2_sbd {
756758
unsigned int sd_log_num_rg;
757759
unsigned int sd_log_num_databuf;
758760

759-
struct list_head sd_log_le_buf;
760761
struct list_head sd_log_le_revoke;
761-
struct list_head sd_log_le_databuf;
762762
struct list_head sd_log_le_ordered;
763763
spinlock_t sd_ordered_lock;
764764

‎fs/gfs2/log.c‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
712712
tr->tr_first = sdp->sd_log_flush_head;
713713

714714
gfs2_ordered_write(sdp);
715-
lops_before_commit(sdp);
715+
lops_before_commit(sdp, tr);
716716
gfs2_log_flush_bio(sdp, WRITE);
717717

718718
if (sdp->sd_log_head != sdp->sd_log_flush_head) {
@@ -744,6 +744,27 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
744744
kfree(tr);
745745
}
746746

747+
/**
748+
* gfs2_merge_trans - Merge a new transaction into a cached transaction
749+
* @old: Original transaction to be expanded
750+
* @new: New transaction to be merged
751+
*/
752+
753+
static void gfs2_merge_trans(struct gfs2_trans *old, struct gfs2_trans *new)
754+
{
755+
WARN_ON_ONCE(old->tr_attached != 1);
756+
757+
old->tr_num_buf_new += new->tr_num_buf_new;
758+
old->tr_num_databuf_new += new->tr_num_databuf_new;
759+
old->tr_num_buf_rm += new->tr_num_buf_rm;
760+
old->tr_num_databuf_rm += new->tr_num_databuf_rm;
761+
old->tr_num_revoke += new->tr_num_revoke;
762+
old->tr_num_revoke_rm += new->tr_num_revoke_rm;
763+
764+
list_splice_tail_init(&new->tr_databuf, &old->tr_databuf);
765+
list_splice_tail_init(&new->tr_buf, &old->tr_buf);
766+
}
767+
747768
static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
748769
{
749770
unsigned int reserved;
@@ -766,8 +787,9 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
766787
sdp->sd_jdesc->jd_blocks);
767788
sdp->sd_log_blks_reserved = reserved;
768789

769-
if (sdp->sd_log_tr == NULL &&
770-
(tr->tr_num_buf_new || tr->tr_num_databuf_new)) {
790+
if (sdp->sd_log_tr) {
791+
gfs2_merge_trans(sdp->sd_log_tr, tr);
792+
} else if (tr->tr_num_buf_new || tr->tr_num_databuf_new) {
771793
gfs2_assert_withdraw(sdp, tr->tr_t_gh.gh_gl);
772794
sdp->sd_log_tr = tr;
773795
tr->tr_attached = 1;

‎fs/gfs2/lops.c‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -491,24 +491,23 @@ static void gfs2_before_commit(struct gfs2_sbd *sdp, unsigned int limit,
491491
gfs2_log_unlock(sdp);
492492
}
493493

494-
static void buf_lo_before_commit(struct gfs2_sbd *sdp)
494+
static void buf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
495495
{
496496
unsigned int limit = buf_limit(sdp); /* 503 for 4k blocks */
497-
498-
gfs2_before_commit(sdp, limit, sdp->sd_log_num_buf,
499-
&sdp->sd_log_le_buf, 0);
497+
if (tr == NULL)
498+
return;
499+
gfs2_before_commit(sdp, limit, sdp->sd_log_num_buf, &tr->tr_buf, 0);
500500
}
501501

502502
static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
503503
{
504-
struct list_head *head = &sdp->sd_log_le_buf;
504+
struct list_head *head;
505505
struct gfs2_bufdata *bd;
506506

507-
if (tr == NULL) {
508-
gfs2_assert(sdp, list_empty(head));
507+
if (tr == NULL)
509508
return;
510-
}
511509

510+
head = &tr->tr_buf;
512511
while (!list_empty(head)) {
513512
bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
514513
list_del_init(&bd->bd_list);
@@ -620,7 +619,7 @@ static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
620619
jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
621620
}
622621

623-
static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
622+
static void revoke_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
624623
{
625624
struct gfs2_meta_header *mh;
626625
unsigned int offset;
@@ -760,12 +759,12 @@ static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
760759
*
761760
*/
762761

763-
static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
762+
static void databuf_lo_before_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
764763
{
765764
unsigned int limit = buf_limit(sdp) / 2;
766-
767-
gfs2_before_commit(sdp, limit, sdp->sd_log_num_databuf,
768-
&sdp->sd_log_le_databuf, 1);
765+
if (tr == NULL)
766+
return;
767+
gfs2_before_commit(sdp, limit, sdp->sd_log_num_databuf, &tr->tr_databuf, 1);
769768
}
770769

771770
static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
@@ -840,14 +839,13 @@ static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
840839

841840
static void databuf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
842841
{
843-
struct list_head *head = &sdp->sd_log_le_databuf;
842+
struct list_head *head;
844843
struct gfs2_bufdata *bd;
845844

846-
if (tr == NULL) {
847-
gfs2_assert(sdp, list_empty(head));
845+
if (tr == NULL)
848846
return;
849-
}
850847

848+
head = &tr->tr_databuf;
851849
while (!list_empty(head)) {
852850
bd = list_entry(head->next, struct gfs2_bufdata, bd_list);
853851
list_del_init(&bd->bd_list);

‎fs/gfs2/lops.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ static inline unsigned int databuf_limit(struct gfs2_sbd *sdp)
4646
return limit;
4747
}
4848

49-
static inline void lops_before_commit(struct gfs2_sbd *sdp)
49+
static inline void lops_before_commit(struct gfs2_sbd *sdp,
50+
struct gfs2_trans *tr)
5051
{
5152
int x;
5253
for (x = 0; gfs2_log_ops[x]; x++)
5354
if (gfs2_log_ops[x]->lo_before_commit)
54-
gfs2_log_ops[x]->lo_before_commit(sdp);
55+
gfs2_log_ops[x]->lo_before_commit(sdp, tr);
5556
}
5657

5758
static inline void lops_after_commit(struct gfs2_sbd *sdp,

‎fs/gfs2/ops_fstype.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
114114

115115
spin_lock_init(&sdp->sd_log_lock);
116116
atomic_set(&sdp->sd_log_pinned, 0);
117-
INIT_LIST_HEAD(&sdp->sd_log_le_buf);
118117
INIT_LIST_HEAD(&sdp->sd_log_le_revoke);
119-
INIT_LIST_HEAD(&sdp->sd_log_le_databuf);
120118
INIT_LIST_HEAD(&sdp->sd_log_le_ordered);
121119
spin_lock_init(&sdp->sd_ordered_lock);
122120

‎fs/gfs2/trans.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,
5151
if (revokes)
5252
tr->tr_reserved += gfs2_struct2blk(sdp, revokes,
5353
sizeof(u64));
54+
INIT_LIST_HEAD(&tr->tr_databuf);
55+
INIT_LIST_HEAD(&tr->tr_buf);
56+
5457
sb_start_intwrite(sdp->sd_vfs);
5558
gfs2_holder_init(sdp->sd_trans_gl, LM_ST_SHARED, 0, &tr->tr_t_gh);
5659

@@ -211,7 +214,7 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
211214
gfs2_pin(sdp, bd->bd_bh);
212215
tr->tr_num_databuf_new++;
213216
sdp->sd_log_num_databuf++;
214-
list_add_tail(&bd->bd_list, &sdp->sd_log_le_databuf);
217+
list_add_tail(&bd->bd_list, &tr->tr_databuf);
215218
}
216219
gfs2_log_unlock(sdp);
217220
unlock_buffer(bh);
@@ -239,7 +242,7 @@ static void meta_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
239242
mh->__pad0 = cpu_to_be64(0);
240243
mh->mh_jid = cpu_to_be32(sdp->sd_jdesc->jd_jid);
241244
sdp->sd_log_num_buf++;
242-
list_add(&bd->bd_list, &sdp->sd_log_le_buf);
245+
list_add(&bd->bd_list, &tr->tr_buf);
243246
tr->tr_num_buf_new++;
244247
}
245248

0 commit comments

Comments
 (0)