aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorBenjamin Marzinski <bmarzins@redhat.com>2013-06-14 12:38:29 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2013-06-19 04:41:59 -0400
commit5d054964f57ade1adb310313c3cfb8e93e804e8f (patch)
treec04a28ef48bc298d5aaffda4e0cf2cda10eba43e /fs/gfs2
parent512cbf02fde42b747c5752f135afd3f3f6d598e2 (diff)
GFS2: aggressively issue revokes in gfs2_log_flush
This patch looks at all the outstanding blocks in all the transactions on the log, and moves the completed ones to the ail2 list. Then it issues revokes for these blocks. This will hopefully speed things up in situations where there is a lot of contention for glocks, especially if they are acquired serially. revoke_lo_before_commit will issue at most one log block's full of these preemptive revokes. The amount of reserved log space that gfs2_log_reserve() ignores has been incremented to allow for this extra block. This patch also consolidates the common revoke instructions into one function, gfs2_add_revoke(). Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/glops.c8
-rw-r--r--fs/gfs2/log.c78
-rw-r--r--fs/gfs2/log.h2
-rw-r--r--fs/gfs2/lops.c1
-rw-r--r--fs/gfs2/meta_io.c4
-rw-r--r--fs/gfs2/trans.c8
6 files changed, 78 insertions, 23 deletions
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index c66e99c97571..5f2e5224c51c 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -54,7 +54,6 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
54 struct gfs2_bufdata *bd, *tmp; 54 struct gfs2_bufdata *bd, *tmp;
55 struct buffer_head *bh; 55 struct buffer_head *bh;
56 const unsigned long b_state = (1UL << BH_Dirty)|(1UL << BH_Pinned)|(1UL << BH_Lock); 56 const unsigned long b_state = (1UL << BH_Dirty)|(1UL << BH_Pinned)|(1UL << BH_Lock);
57 sector_t blocknr;
58 57
59 gfs2_log_lock(sdp); 58 gfs2_log_lock(sdp);
60 spin_lock(&sdp->sd_ail_lock); 59 spin_lock(&sdp->sd_ail_lock);
@@ -65,13 +64,6 @@ static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
65 continue; 64 continue;
66 gfs2_ail_error(gl, bh); 65 gfs2_ail_error(gl, bh);
67 } 66 }
68 blocknr = bh->b_blocknr;
69 bh->b_private = NULL;
70 gfs2_remove_from_ail(bd); /* drops ref on bh */
71
72 bd->bd_bh = NULL;
73 bd->bd_blkno = blocknr;
74
75 gfs2_trans_add_revoke(sdp, bd); 67 gfs2_trans_add_revoke(sdp, bd);
76 } 68 }
77 GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count)); 69 GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count));
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index b404f4853034..610613fb65b5 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -211,15 +211,16 @@ static void gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
211static int gfs2_ail1_empty(struct gfs2_sbd *sdp) 211static int gfs2_ail1_empty(struct gfs2_sbd *sdp)
212{ 212{
213 struct gfs2_trans *tr, *s; 213 struct gfs2_trans *tr, *s;
214 int oldest_tr = 1;
214 int ret; 215 int ret;
215 216
216 spin_lock(&sdp->sd_ail_lock); 217 spin_lock(&sdp->sd_ail_lock);
217 list_for_each_entry_safe_reverse(tr, s, &sdp->sd_ail1_list, tr_list) { 218 list_for_each_entry_safe_reverse(tr, s, &sdp->sd_ail1_list, tr_list) {
218 gfs2_ail1_empty_one(sdp, tr); 219 gfs2_ail1_empty_one(sdp, tr);
219 if (list_empty(&tr->tr_ail1_list)) 220 if (list_empty(&tr->tr_ail1_list) && oldest_tr)
220 list_move(&tr->tr_list, &sdp->sd_ail2_list); 221 list_move(&tr->tr_list, &sdp->sd_ail2_list);
221 else 222 else
222 break; 223 oldest_tr = 0;
223 } 224 }
224 ret = list_empty(&sdp->sd_ail1_list); 225 ret = list_empty(&sdp->sd_ail1_list);
225 spin_unlock(&sdp->sd_ail_lock); 226 spin_unlock(&sdp->sd_ail_lock);
@@ -317,7 +318,7 @@ static void ail2_empty(struct gfs2_sbd *sdp, unsigned int new_tail)
317 318
318int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks) 319int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
319{ 320{
320 unsigned reserved_blks = 6 * (4096 / sdp->sd_vfs->s_blocksize); 321 unsigned reserved_blks = 7 * (4096 / sdp->sd_vfs->s_blocksize);
321 unsigned wanted = blks + reserved_blks; 322 unsigned wanted = blks + reserved_blks;
322 DEFINE_WAIT(wait); 323 DEFINE_WAIT(wait);
323 int did_wait = 0; 324 int did_wait = 0;
@@ -545,6 +546,76 @@ void gfs2_ordered_del_inode(struct gfs2_inode *ip)
545 spin_unlock(&sdp->sd_ordered_lock); 546 spin_unlock(&sdp->sd_ordered_lock);
546} 547}
547 548
549void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
550{
551 struct buffer_head *bh = bd->bd_bh;
552 struct gfs2_glock *gl = bd->bd_gl;
553
554 gfs2_remove_from_ail(bd);
555 bd->bd_bh = NULL;
556 bh->b_private = NULL;
557 bd->bd_blkno = bh->b_blocknr;
558 bd->bd_ops = &gfs2_revoke_lops;
559 sdp->sd_log_num_revoke++;
560 atomic_inc(&gl->gl_revokes);
561 set_bit(GLF_LFLUSH, &gl->gl_flags);
562 list_add(&bd->bd_list, &sdp->sd_log_le_revoke);
563}
564
565void gfs2_write_revokes(struct gfs2_sbd *sdp)
566{
567 struct gfs2_trans *tr;
568 struct gfs2_bufdata *bd, *tmp;
569 int have_revokes = 0;
570 int max_revokes = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) / sizeof(u64);
571
572 gfs2_ail1_empty(sdp);
573 spin_lock(&sdp->sd_ail_lock);
574 list_for_each_entry(tr, &sdp->sd_ail1_list, tr_list) {
575 list_for_each_entry(bd, &tr->tr_ail2_list, bd_ail_st_list) {
576 if (list_empty(&bd->bd_list)) {
577 have_revokes = 1;
578 goto done;
579 }
580 }
581 }
582done:
583 spin_unlock(&sdp->sd_ail_lock);
584 if (have_revokes == 0)
585 return;
586 while (sdp->sd_log_num_revoke > max_revokes)
587 max_revokes += (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / sizeof(u64);
588 max_revokes -= sdp->sd_log_num_revoke;
589 if (!sdp->sd_log_num_revoke) {
590 atomic_dec(&sdp->sd_log_blks_free);
591 /* If no blocks have been reserved, we need to also
592 * reserve a block for the header */
593 if (!sdp->sd_log_blks_reserved)
594 atomic_dec(&sdp->sd_log_blks_free);
595 }
596 gfs2_log_lock(sdp);
597 spin_lock(&sdp->sd_ail_lock);
598 list_for_each_entry(tr, &sdp->sd_ail1_list, tr_list) {
599 list_for_each_entry_safe(bd, tmp, &tr->tr_ail2_list, bd_ail_st_list) {
600 if (max_revokes == 0)
601 goto out_of_blocks;
602 if (!list_empty(&bd->bd_list))
603 continue;
604 gfs2_add_revoke(sdp, bd);
605 max_revokes--;
606 }
607 }
608out_of_blocks:
609 spin_unlock(&sdp->sd_ail_lock);
610 gfs2_log_unlock(sdp);
611
612 if (!sdp->sd_log_num_revoke) {
613 atomic_inc(&sdp->sd_log_blks_free);
614 if (!sdp->sd_log_blks_reserved)
615 atomic_inc(&sdp->sd_log_blks_free);
616 }
617}
618
548/** 619/**
549 * log_write_header - Get and initialize a journal header buffer 620 * log_write_header - Get and initialize a journal header buffer
550 * @sdp: The GFS2 superblock 621 * @sdp: The GFS2 superblock
@@ -562,7 +633,6 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
562 lh = page_address(page); 633 lh = page_address(page);
563 clear_page(lh); 634 clear_page(lh);
564 635
565 gfs2_ail1_empty(sdp);
566 tail = current_tail(sdp); 636 tail = current_tail(sdp);
567 637
568 lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC); 638 lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h
index 3566f35915e0..37216634f0aa 100644
--- a/fs/gfs2/log.h
+++ b/fs/gfs2/log.h
@@ -72,5 +72,7 @@ extern void gfs2_ail1_flush(struct gfs2_sbd *sdp, struct writeback_control *wbc)
72extern void gfs2_log_shutdown(struct gfs2_sbd *sdp); 72extern void gfs2_log_shutdown(struct gfs2_sbd *sdp);
73extern void gfs2_meta_syncfs(struct gfs2_sbd *sdp); 73extern void gfs2_meta_syncfs(struct gfs2_sbd *sdp);
74extern int gfs2_logd(void *data); 74extern int gfs2_logd(void *data);
75extern void gfs2_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd);
76extern void gfs2_write_revokes(struct gfs2_sbd *sdp);
75 77
76#endif /* __LOG_DOT_H__ */ 78#endif /* __LOG_DOT_H__ */
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 33f18b7282b2..17c5b5d7dc88 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -606,6 +606,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
606 struct page *page; 606 struct page *page;
607 unsigned int length; 607 unsigned int length;
608 608
609 gfs2_write_revokes(sdp);
609 if (!sdp->sd_log_num_revoke) 610 if (!sdp->sd_log_num_revoke)
610 return; 611 return;
611 612
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 1a89afb68472..0da390686c08 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -296,10 +296,6 @@ void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, int
296 if (bd) { 296 if (bd) {
297 spin_lock(&sdp->sd_ail_lock); 297 spin_lock(&sdp->sd_ail_lock);
298 if (bd->bd_tr) { 298 if (bd->bd_tr) {
299 gfs2_remove_from_ail(bd);
300 bh->b_private = NULL;
301 bd->bd_bh = NULL;
302 bd->bd_blkno = bh->b_blocknr;
303 gfs2_trans_add_revoke(sdp, bd); 299 gfs2_trans_add_revoke(sdp, bd);
304 } 300 }
305 spin_unlock(&sdp->sd_ail_lock); 301 spin_unlock(&sdp->sd_ail_lock);
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index 7374907742a8..0fa0dbaf04a2 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -274,15 +274,9 @@ void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
274 struct gfs2_trans *tr = current->journal_info; 274 struct gfs2_trans *tr = current->journal_info;
275 275
276 BUG_ON(!list_empty(&bd->bd_list)); 276 BUG_ON(!list_empty(&bd->bd_list));
277 BUG_ON(!list_empty(&bd->bd_ail_st_list)); 277 gfs2_add_revoke(sdp, bd);
278 BUG_ON(!list_empty(&bd->bd_ail_gl_list));
279 bd->bd_ops = &gfs2_revoke_lops;
280 tr->tr_touched = 1; 278 tr->tr_touched = 1;
281 tr->tr_num_revoke++; 279 tr->tr_num_revoke++;
282 sdp->sd_log_num_revoke++;
283 atomic_inc(&gl->gl_revokes);
284 set_bit(GLF_LFLUSH, &gl->gl_flags);
285 list_add(&bd->bd_list, &sdp->sd_log_le_revoke);
286} 280}
287 281
288void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno, unsigned int len) 282void gfs2_trans_add_unrevoke(struct gfs2_sbd *sdp, u64 blkno, unsigned int len)