Various patches
Hi,
Following this message will be a variety of patches which constitute my current patch queue. They are aimed at solving a number of issues which have been reported recently relating to performance and memory usage.
A number of the patches are standalone, if you ignore the last patch in the series. The final patch is the one which is probably the most interesting. The idea in this one is to improve the performance of the journaling code by being more careful about when log flushes occur. It both reduces the maximum time between flushes on almost idle systems and increases the likelihood of flushes being large (and thus more efficient) when the system is busy. My postmark tests suggest that the patches in combination result in about a 20% improvement on a busy system.
I'm intending to post a future patch to allow automatic adjustment of the two new log thresholds which are introduced in this patch series. The current limits of 2/5 and 4/5 of the journal size seem to work well in practise for the default 128M journal size.
Note also that the final patch is still in draft form (hence the printk on each journal flush). I'll remove that before final submission, but its useful for anybody testing these to be able to see the state of the journal while running a test.
Although the patch set as a whole improves the performance, thats not true of each patch on its own, in particular if you don't apply the final patch, but only the ones leading up to it, you'll see a regression at least on some workloads.
As you can probably tell from the description above, this patch set is not yet in its final form, I'm just posting them now in the spirit of releasing early,
Steve.
[Cluster-devel] [GFS2] Don't add glocks to the journal
From e5ed47ae7797209a5d86842093e48bd35ba873e6 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Thu, 8 Nov 2007 14:25:12 +0000
Subject: [PATCH] [GFS2] Don't add glocks to the journal
The only reason for adding glocks to the journal was to keep track of which locks required a log flush prior to release. We add a flag to the glock to allow this check to be made in a simpler way.
This reduces the size of a glock (by 12 bytes on i386, 24 on x86_64) and means that we can avoid extra work during the journal flush.
fs/gfs2/glock.c +0 -3
@@ -346,7 +346,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, gl->gl_object =NULL ; gl->gl_sbd = sdp; gl->gl_aspace =NULL ; -lops_init_le (&gl->gl_le, &gfs2_glock_lops);INIT_DELAYED_WORK (&gl->gl_work, glock_work_func);/* If this glock protects actual on-disk data or metadata blocks,
@@ -1900,8 +1899,6 @@ static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl)print_dbg (gi," req_bh = %s\n" , (gl->gl_req_bh) ?"yes" :"no" );print_dbg (gi," lvb_count = %d\n" ,atomic_read (&gl->gl_lvb_count));print_dbg (gi," object = %s\n" , (gl->gl_object) ?"yes" :"no" ); -print_dbg (gi," le = %s\n" , - (list_empty (&gl->gl_le.le_list)) ?"no" :"yes" );print_dbg (gi," reclaim = %s\n" , (list_empty (&gl->gl_reclaim)) ?"no" :"yes" );if (gl->gl_aspace)
fs/gfs2/incore.h +1 -3
@@ -168,6 +168,7 @@ enum {GLF_PENDING_DEMOTE =4 ,GLF_DIRTY =5 ,GLF_DEMOTE_IN_PROGRESS =6 , + GLF_LFLUSH = 7, }; struct gfs2_glock {
@@ -208,7 +209,6 @@ struct gfs2_glock {struct gfs2_sbd *gl_sbd;struct inode *gl_aspace; -struct gfs2_log_element gl_le;struct list_head gl_ail_list;atomic_t gl_ail_count;struct delayed_work gl_work;
@@ -584,13 +584,11 @@ struct gfs2_sbd {unsigned int sd_log_commited_databuf;unsigned int sd_log_commited_revoke; -unsigned int sd_log_num_gl;unsigned int sd_log_num_buf;unsigned int sd_log_num_revoke;unsigned int sd_log_num_rg;unsigned int sd_log_num_databuf; -struct list_head sd_log_le_gl;struct list_head sd_log_le_buf;struct list_head sd_log_le_revoke;struct list_head sd_log_le_rg;
fs/gfs2/inode.c +2 -1
@@ -362,7 +362,8 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip)if (error) goto out_rg_gunlock; -gfs2_trans_add_gl (ip->i_gl); +set_bit (GLF_DIRTY , &ip->i_gl->gl_flags); +set_bit (GLF_LFLUSH , &ip->i_gl->gl_flags);gfs2_free_di (rgd, ip);
fs/gfs2/log.c +5 -10
@@ -692,20 +692,16 @@ static void gfs2_ordered_wait(struct gfs2_sbd *sdp)* */ -void gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl) +void __gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl) {struct gfs2_ail *ai;down_write (&sdp->sd_log_flush_lock); -if (gl) { -gfs2_log_lock (sdp); -if (list_empty (&gl->gl_le.le_list)) { -gfs2_log_unlock (sdp); -up_write (&sdp->sd_log_flush_lock); -return ; - } -gfs2_log_unlock (sdp); +/* Log might have been flushed while we waited for the flush lock */ +if (gl && !test_bit (GLF_LFLUSH , &gl->gl_flags)) { +up_write (&sdp->sd_log_flush_lock); +return ; } ai =kzalloc (sizeof (struct gfs2_ail ),GFP_NOFS | __GFP_NOFAIL);
@@ -823,7 +819,6 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)down_write (&sdp->sd_log_flush_lock);gfs2_assert_withdraw (sdp, !sdp->sd_log_blks_reserved); -gfs2_assert_withdraw (sdp, !sdp->sd_log_num_gl);gfs2_assert_withdraw (sdp, !sdp->sd_log_num_buf);gfs2_assert_withdraw (sdp, !sdp->sd_log_num_revoke);gfs2_assert_withdraw (sdp, !sdp->sd_log_num_rg);
fs/gfs2/log.h +8 -1
@@ -57,7 +57,14 @@ void gfs2_log_incr_head(struct gfs2_sbd *sdp);struct buffer_head *gfs2_log_get_buf (struct gfs2_sbd *sdp);struct buffer_head *gfs2_log_fake_buf (struct gfs2_sbd *sdp,struct buffer_head *real); -void gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl); +void __gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl); + +static inline void gfs2_log_flush (struct gfs2_sbd *sbd,struct gfs2_glock *gl) +{ +if (!gl ||test_bit (GLF_LFLUSH , &gl->gl_flags)) +__gfs2_log_flush (sbd, gl); +} +void gfs2_log_commit (struct gfs2_sbd *sdp,struct gfs2_trans *trans);void gfs2_remove_from_ail (struct gfs2_bufdata *bd);
fs/gfs2/lops.c +5 -53
94 lines not on this page · raw message
fs/gfs2/ops_fstype.c +0 -1
@@ -77,7 +77,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)spin_lock_init (&sdp->sd_log_lock); -INIT_LIST_HEAD (&sdp->sd_log_le_gl);INIT_LIST_HEAD (&sdp->sd_log_le_buf);INIT_LIST_HEAD (&sdp->sd_log_le_revoke);INIT_LIST_HEAD (&sdp->sd_log_le_rg);
fs/gfs2/trans.c +0 -5
@@ -114,11 +114,6 @@ void gfs2_trans_end(struct gfs2_sbd *sdp)gfs2_log_flush (sdp,NULL ); } -void gfs2_trans_add_gl (struct gfs2_glock *gl) -{ -lops_add (gl->gl_sbd, &gl->gl_le); -} -/** * gfs2_trans_add_bh - Add a to-be-modified buffer to the current transaction * @gl: the glock the buffer belongs to
fs/gfs2/trans.h +0 -1
@@ -30,7 +30,6 @@ int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks,void gfs2_trans_end (struct gfs2_sbd *sdp); -void gfs2_trans_add_gl (struct gfs2_glock *gl);void gfs2_trans_add_bh (struct gfs2_glock *gl,struct buffer_head *bh,int meta);void gfs2_trans_add_revoke (struct gfs2_sbd *sdp,struct gfs2_bufdata *bd);void gfs2_trans_add_unrevoke (struct gfs2_sbd *sdp,u64 blkno);
Signature · 1 line
1.5.1.2
[Cluster-devel] [GFS2] Use atomic_t for journal free blocks counter
In reply to Steven WhitehouseFrom 4b9510f05a676623069d22f49cd9da64ea6f708b Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Thu, 8 Nov 2007 14:55:03 +0000
Subject: [PATCH] [GFS2] Use atomic_t for journal free blocks counter
This patch changes the counter which keeps track of the free blocks in the journal to an atomic_t in preparation for the following patch which will update the log reservation code.
fs/gfs2/incore.h +1 -1
@@ -595,7 +595,7 @@ struct gfs2_sbd {struct list_head sd_log_le_databuf;struct list_head sd_log_le_ordered; -unsigned int sd_log_blks_free; +atomic_t sd_log_blks_free;struct mutex sd_log_reserve_mutex;u64 sd_log_sequence;
fs/gfs2/log.c +13 -13
@@ -301,7 +301,7 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)mutex_lock (&sdp->sd_log_reserve_mutex);gfs2_log_lock (sdp); -while (sdp->sd_log_blks_free <= (blks + reserved_blks)) { +while (atomic_read (&sdp->sd_log_blks_free) <= (blks + reserved_blks)) {gfs2_log_unlock (sdp);gfs2_ail1_empty (sdp,0 );gfs2_log_flush (sdp,NULL );
@@ -310,7 +310,7 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)gfs2_ail1_start (sdp,0 );gfs2_log_lock (sdp); } - sdp->sd_log_blks_free -= blks; +atomic_sub (blks, &sdp->sd_log_blks_free);gfs2_log_unlock (sdp);mutex_unlock (&sdp->sd_log_reserve_mutex);
@@ -330,9 +330,9 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks) {gfs2_log_lock (sdp); - sdp->sd_log_blks_free += blks; +atomic_add (blks, &sdp->sd_log_blks_free);gfs2_assert_withdraw (sdp, - sdp->sd_log_blks_free <= sdp->sd_jdesc->jd_blocks); +atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks);gfs2_log_unlock (sdp);up_read (&sdp->sd_log_flush_lock); }
@@ -559,8 +559,8 @@ static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail)ail2_empty (sdp, new_tail);gfs2_log_lock (sdp); - sdp->sd_log_blks_free += dist; -gfs2_assert_withdraw (sdp, sdp->sd_log_blks_free <= sdp->sd_jdesc->jd_blocks); +atomic_add (dist, &sdp->sd_log_blks_free); +gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks);gfs2_log_unlock (sdp); sdp->sd_log_tail = new_tail;
@@ -733,7 +733,7 @@ void __gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)log_flush_commit (sdp); else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle){gfs2_log_lock (sdp); - sdp->sd_log_blks_free--;/* Adjust for unreserved buffer */ +atomic_dec (&sdp->sd_log_blks_free);/* Adjust for unreserved buffer */ gfs2_log_unlock (sdp);log_write_header (sdp,0 ,PULL ); }
@@ -773,12 +773,12 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr) sdp->sd_log_commited_revoke += tr->tr_num_revoke - tr->tr_num_revoke_rm;gfs2_assert_withdraw (sdp, ((int )sdp->sd_log_commited_revoke) >=0 ); reserved =calc_reserved (sdp); - old = sdp->sd_log_blks_free; - sdp->sd_log_blks_free += tr->tr_reserved - - (reserved - sdp->sd_log_blks_reserved); + old =atomic_read (&sdp->sd_log_blks_free); +atomic_add (tr->tr_reserved - (reserved - sdp->sd_log_blks_reserved), + &sdp->sd_log_blks_free); -gfs2_assert_withdraw (sdp, sdp->sd_log_blks_free >= old); -gfs2_assert_withdraw (sdp, sdp->sd_log_blks_free <= +gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) >= old); +gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks); sdp->sd_log_blks_reserved = reserved;
@@ -831,7 +831,7 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)log_write_header (sdp,GFS2_LOG_HEAD_UNMOUNT , (sdp->sd_log_tail ==current_tail (sdp)) ?0 :PULL ); -gfs2_assert_warn (sdp, sdp->sd_log_blks_free == sdp->sd_jdesc->jd_blocks); +gfs2_assert_warn (sdp,atomic_read (&sdp->sd_log_blks_free) == sdp->sd_jdesc->jd_blocks);gfs2_assert_warn (sdp, sdp->sd_log_head == sdp->sd_log_tail);gfs2_assert_warn (sdp,list_empty (&sdp->sd_ail2_list));
fs/gfs2/ops_fstype.c +2 -2
@@ -339,7 +339,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)if (sdp->sd_args.ar_spectator) { sdp->sd_jdesc =gfs2_jdesc_find (sdp,0 ); - sdp->sd_log_blks_free = sdp->sd_jdesc->jd_blocks; +atomic_set (&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); }else {if (sdp->sd_lockstruct.ls_jid >=gfs2_jindex_size (sdp)) { fs_err(sdp, "can't mount journal #%u\n",
@@ -376,7 +376,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) sdp->sd_jdesc->jd_jid, error); goto fail_jinode_gh; } - sdp->sd_log_blks_free = sdp->sd_jdesc->jd_blocks; +atomic_set (&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); }if (sdp->sd_lockstruct.ls_first) {
Signature · 1 line
1.5.1.2
[Cluster-devel] [GFS2] Move gfs2_logd into log.c
In reply to Steven WhitehouseFrom fbf7c723b65e7eccf462b80bb378bbe5ea8037b0 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Fri, 9 Nov 2007 10:01:41 +0000
Subject: [PATCH] [GFS2] Move gfs2_logd into log.c
This means that we can mark gfs2_ail1_empty static and prepares the way for further changes.
fs/gfs2/daemon.c +0 -50
@@ -83,56 +83,6 @@ int gfs2_recoverd(void *data) }/** -* gfs2_logd - Update log tail as Active Items get flushed to in-place blocks -* @sdp: Pointer to GFS2 superblock -* -* Also, periodically check to make sure that we're using the most recent -* journal index. -*/ - -int gfs2_logd (void *data) -{ -struct gfs2_sbd *sdp = data; -struct gfs2_holder ji_gh; -unsigned long t; -int need_flush; - -while (!kthread_should_stop ()) { -/* Advance the log tail */ - - t = sdp->sd_log_flush_time + -gfs2_tune_get (sdp, gt_log_flush_secs) *HZ ; - -gfs2_ail1_empty (sdp,DIO_ALL ); -gfs2_log_lock (sdp); - need_flush = sdp->sd_log_num_buf >gfs2_tune_get (sdp, gt_incore_log_blocks); -gfs2_log_unlock (sdp); -if (need_flush ||time_after_eq (jiffies, t)) { -gfs2_log_flush (sdp,NULL ); - sdp->sd_log_flush_time = jiffies; - } - -/* Check for latest journal index */ - - t = sdp->sd_jindex_refresh_time + -gfs2_tune_get (sdp, gt_jindex_refresh_secs) *HZ ; - -if (time_after_eq (jiffies, t)) { -if (!gfs2_jindex_hold (sdp, &ji_gh)) -gfs2_glock_dq_uninit (&ji_gh); - sdp->sd_jindex_refresh_time = jiffies; - } - - t =gfs2_tune_get (sdp, gt_logd_secs) *HZ ; -if (freezing (current)) -refrigerator (); -schedule_timeout_interruptible (t); - } - -return 0 ; -} - -/** * gfs2_quotad - Write cached quota changes into the quota file * @sdp: Pointer to GFS2 superblock *
fs/gfs2/daemon.h +0 -1
@@ -12,7 +12,6 @@int gfs2_glockd (void *data);int gfs2_recoverd (void *data); -int gfs2_logd (void *data);int gfs2_quotad (void *data);#endif /* __DAEMON_DOT_H__ */
fs/gfs2/log.c +55 -1
77 lines not on this page · raw message
fs/gfs2/log.h +1 -2
@@ -48,8 +48,6 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,unsigned int gfs2_struct2blk (struct gfs2_sbd *sdp,unsigned int nstruct,unsigned int ssize); -int gfs2_ail1_empty (struct gfs2_sbd *sdp,int flags); -int gfs2_log_reserve (struct gfs2_sbd *sdp,unsigned int blks);void gfs2_log_release (struct gfs2_sbd *sdp,unsigned int blks);void gfs2_log_incr_head (struct gfs2_sbd *sdp);
@@ -70,5 +68,6 @@ void gfs2_remove_from_ail(struct gfs2_bufdata *bd);void gfs2_log_shutdown (struct gfs2_sbd *sdp);void gfs2_meta_syncfs (struct gfs2_sbd *sdp); +int gfs2_logd (void *data);#endif /* __LOG_DOT_H__ */
Signature · 1 line
1.5.1.2
[Cluster-devel] [GFS2] Don't periodically update the jindex
In reply to Steven WhitehouseFrom b5dc3ccdb88e58656aadac428452d2c3050802bc Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Fri, 9 Nov 2007 10:07:21 +0000
Subject: [PATCH] [GFS2] Don't periodically update the jindex
We only care about the content of the jindex in two cases, one is when we mount the fs and the other is when we need to recover another journal. In both cases we have to update the jindex anyway, so there is no point in updating it periodically between times, so this removes it to simplify gfs2_logd.
fs/gfs2/incore.h +0 -1
@@ -411,7 +411,6 @@ struct gfs2_tune {unsigned int gt_demote_secs;/* Cache retention for unheld glock */ unsigned int gt_incore_log_blocks;unsigned int gt_log_flush_secs; -unsigned int gt_jindex_refresh_secs;/* Check for new journal index */ unsigned int gt_recoverd_secs;unsigned int gt_logd_secs;
fs/gfs2/log.c +0 -13
@@ -28,7 +28,6 @@#include "meta_io.h" #include "util.h" #include "dir.h" -#include "super.h" #define PULL 1
@@ -874,7 +873,6 @@ void gfs2_meta_syncfs(struct gfs2_sbd *sdp)int gfs2_logd (void *data) {struct gfs2_sbd *sdp = data; -struct gfs2_holder ji_gh;unsigned long t;int need_flush;
@@ -893,17 +891,6 @@ int gfs2_logd(void *data) sdp->sd_log_flush_time = jiffies; } -/* Check for latest journal index */ - - t = sdp->sd_jindex_refresh_time + -gfs2_tune_get (sdp, gt_jindex_refresh_secs) *HZ ; - -if (time_after_eq (jiffies, t)) { -if (!gfs2_jindex_hold (sdp, &ji_gh)) -gfs2_glock_dq_uninit (&ji_gh); - sdp->sd_jindex_refresh_time = jiffies; - } - t =gfs2_tune_get (sdp, gt_logd_secs) *HZ ;if (freezing (current))refrigerator ();
fs/gfs2/super.c +0 -1
@@ -54,7 +54,6 @@ void gfs2_tune_init(struct gfs2_tune *gt) gt->gt_demote_secs =300 ; gt->gt_incore_log_blocks =1024 ; gt->gt_log_flush_secs =60 ; - gt->gt_jindex_refresh_secs =60 ; gt->gt_recoverd_secs =60 ; gt->gt_logd_secs =1 ; gt->gt_quotad_secs =5 ;
fs/gfs2/sys.c +0 -2
@@ -428,7 +428,6 @@ TUNE_ATTR_2(name, name##_store)TUNE_ATTR (demote_secs,0 );TUNE_ATTR (incore_log_blocks,0 );TUNE_ATTR (log_flush_secs,0 ); -TUNE_ATTR (jindex_refresh_secs,0 );TUNE_ATTR (quota_warn_period,0 );TUNE_ATTR (quota_quantum,0 );TUNE_ATTR (atime_quantum,0 );
@@ -450,7 +449,6 @@ static struct attribute *tune_attrs[] = { &tune_attr_demote_secs.attr, &tune_attr_incore_log_blocks.attr, &tune_attr_log_flush_secs.attr, - &tune_attr_jindex_refresh_secs.attr, &tune_attr_quota_warn_period.attr, &tune_attr_quota_quantum.attr, &tune_attr_atime_quantum.attr,
Signature · 1 line
1.5.1.2
[Cluster-devel] [GFS2] Introduce two log thresholds
In reply to Steven WhitehouseFrom 58e3f72430511ae57378bf96b062ba99ef6575ad Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Fri, 9 Nov 2007 11:16:23 +0000
Subject: [PATCH] [GFS2] Introduce two log thresholds
This patch intriduces two new log thresholds:
o thresh1 is the point at which we wake up gfs2_logd due to the pinned block count. It is initialised at mount time to 1/3rd of the size of the journal. Currently it does not change during the course of the mount, but the intention is to adjust it automatically based upon various conditions. This automatic adjustment will be the subject of later patches.
o thresh2 is the point at which we wake up gfs2_logd due to the total of pinned blocks and AIL blocks. It is initialised at mount time to 2/3rd of the size of the journal. The reason for not making it equal to 100% of journal size is to give gfs2_logd time to start up and do something before the processes filling the journal before they land up stalling, and waiting on journal flushes.
At the same time, the incore_log_blocks tunable is removed since it was wrong (just a basic fixed threshold set to a number plucked out of the air) and it was being compared against the wrong thing (the amount of metadata in the journal) rather than the total number of blocks.
Also, since the free blocks count is now an atomic variable, a number of these comparisons now do not need locking, so that the log lock has been removed around some operations.
fs/gfs2/incore.h +3 -1
@@ -409,7 +409,6 @@ struct gfs2_tune {spinlock_t gt_spin;unsigned int gt_demote_secs;/* Cache retention for unheld glock */ -unsigned int gt_incore_log_blocks;unsigned int gt_log_flush_secs;unsigned int gt_recoverd_secs;
@@ -583,6 +582,7 @@ struct gfs2_sbd {unsigned int sd_log_commited_databuf;unsigned int sd_log_commited_revoke; +atomic_t sd_log_pinned;unsigned int sd_log_num_buf;unsigned int sd_log_num_revoke;unsigned int sd_log_num_rg;
@@ -594,6 +594,8 @@ struct gfs2_sbd {struct list_head sd_log_le_databuf;struct list_head sd_log_le_ordered; +atomic_t sd_log_thresh1; +atomic_t sd_log_thresh2;atomic_t sd_log_blks_free;struct mutex sd_log_reserve_mutex;
fs/gfs2/log.c +17 -15
@@ -331,11 +331,9 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)void gfs2_log_release (struct gfs2_sbd *sdp,unsigned int blks) { -gfs2_log_lock (sdp);atomic_add (blks, &sdp->sd_log_blks_free); -gfs2_assert_withdraw (sdp, -atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks); -gfs2_log_unlock (sdp); +gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= + sdp->sd_jdesc->jd_blocks);up_read (&sdp->sd_log_flush_lock); }
@@ -560,10 +558,9 @@ static void log_pull_tail(struct gfs2_sbd *sdp, unsigned int new_tail)ail2_empty (sdp, new_tail); -gfs2_log_lock (sdp);atomic_add (dist, &sdp->sd_log_blks_free); -gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= sdp->sd_jdesc->jd_blocks); -gfs2_log_unlock (sdp); +gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= + sdp->sd_jdesc->jd_blocks); sdp->sd_log_tail = new_tail; }
@@ -793,6 +790,13 @@ static void log_refund(struct gfs2_sbd *sdp, struct gfs2_trans *tr)* @sdp: the filesystem * @tr: the transaction * +* We wake up gfs2_logd if the number of pinned blocks exceed thresh1 +* or the total number of used blocks (pinned blocks plus AIL blocks) +* is greater than thresh2. +* +* At mount time thresh1 is 1/3rd of journal size, thresh2 is 2/3rd of +* journal size. +* * Returns: errno */
@@ -804,10 +808,10 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr) sdp->sd_vfs->s_dirt =1 ;up_read (&sdp->sd_log_flush_lock); -gfs2_log_lock (sdp); -if (sdp->sd_log_num_buf >gfs2_tune_get (sdp, gt_incore_log_blocks)) +if (atomic_read (&sdp->sd_log_pinned) >atomic_read (&sdp->sd_log_thresh1) || + ((sdp->sd_jdesc->jd_blocks -atomic_read (&sdp->sd_log_blks_free)) < +atomic_read (&sdp->sd_log_thresh2)))wake_up_process (sdp->sd_logd_process); -gfs2_log_unlock (sdp); }/**
@@ -874,7 +878,6 @@ int gfs2_logd(void *data) {struct gfs2_sbd *sdp = data;unsigned long t; -int need_flush;while (!kthread_should_stop ()) {/* Advance the log tail */
@@ -883,10 +886,9 @@ int gfs2_logd(void *data)gfs2_tune_get (sdp, gt_log_flush_secs) *HZ ;gfs2_ail1_empty (sdp,DIO_ALL ); -gfs2_log_lock (sdp); - need_flush = sdp->sd_log_num_buf >gfs2_tune_get (sdp, gt_incore_log_blocks); -gfs2_log_unlock (sdp); -if (need_flush ||time_after_eq (jiffies, t)) { +if ((atomic_read (&sdp->sd_log_pinned) > +atomic_read (&sdp->sd_log_thresh1)) || +time_after_eq (jiffies, t)) {gfs2_log_flush (sdp,NULL ); sdp->sd_log_flush_time = jiffies; }
fs/gfs2/lops.c +2 -0
@@ -52,6 +52,7 @@ static void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh)if (bd->bd_ail)list_move (&bd->bd_ail_st_list, &bd->bd_ail->ai_ail2_list);get_bh (bh); +atomic_inc (&sdp->sd_log_pinned); }/**
@@ -90,6 +91,7 @@ static void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,clear_bit (GLF_LFLUSH , &bd->bd_gl->gl_flags);gfs2_log_unlock (sdp);unlock_buffer (bh); +atomic_dec (&sdp->sd_log_pinned); }
fs/gfs2/ops_fstype.c +5 -1
@@ -76,7 +76,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)mutex_init (&sdp->sd_quota_mutex);spin_lock_init (&sdp->sd_log_lock); - +atomic_set (&sdp->sd_log_pinned,0 );INIT_LIST_HEAD (&sdp->sd_log_le_buf);INIT_LIST_HEAD (&sdp->sd_log_le_revoke);INIT_LIST_HEAD (&sdp->sd_log_le_rg);
@@ -340,6 +340,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)if (sdp->sd_args.ar_spectator) { sdp->sd_jdesc =gfs2_jdesc_find (sdp,0 );atomic_set (&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); +atomic_set (&sdp->sd_log_thresh1, sdp->sd_jdesc->jd_blocks/3 ); +atomic_set (&sdp->sd_log_thresh2,2 *sdp->sd_jdesc->jd_blocks/3 ); }else {if (sdp->sd_lockstruct.ls_jid >=gfs2_jindex_size (sdp)) { fs_err(sdp, "can't mount journal #%u\n",
@@ -377,6 +379,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) goto fail_jinode_gh; }atomic_set (&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); +atomic_set (&sdp->sd_log_thresh1, sdp->sd_jdesc->jd_blocks/3 ); +atomic_set (&sdp->sd_log_thresh2,2 *sdp->sd_jdesc->jd_blocks/3 ); }if (sdp->sd_lockstruct.ls_first) {
fs/gfs2/super.c +0 -1
@@ -52,7 +52,6 @@ void gfs2_tune_init(struct gfs2_tune *gt)spin_lock_init (>->gt_spin); gt->gt_demote_secs =300 ; - gt->gt_incore_log_blocks =1024 ; gt->gt_log_flush_secs =60 ; gt->gt_recoverd_secs =60 ; gt->gt_logd_secs =1 ;
fs/gfs2/sys.c +0 -2
@@ -426,7 +426,6 @@ static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\ TUNE_ATTR_2(name, name##_store)TUNE_ATTR (demote_secs,0 ); -TUNE_ATTR (incore_log_blocks,0 );TUNE_ATTR (log_flush_secs,0 );TUNE_ATTR (quota_warn_period,0 );TUNE_ATTR (quota_quantum,0 );
@@ -447,7 +446,6 @@ TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);static struct attribute *tune_attrs[] = { &tune_attr_demote_secs.attr, - &tune_attr_incore_log_blocks.attr, &tune_attr_log_flush_secs.attr, &tune_attr_quota_warn_period.attr, &tune_attr_quota_quantum.attr,
Signature · 1 line
1.5.1.2
[Cluster-devel] [GFS2] Don't hold rgrps over transactions
In reply to Steven WhitehouseFrom 2bdc85e19200bc7e59bdd51364a821e239a0c786 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Fri, 9 Nov 2007 11:24:50 +0000
Subject: [PATCH] [GFS2] Don't hold rgrps over transactions
We don't need to hold rgrps over transactions because we know that the rgrp glock must be held, and the only way that the rgrp glock can be dropped is if the log is flushed, the removing the need to hold the rgrp at this point in time.
Thus we can remove this from the journaling code to clean/speed it up.
fs/gfs2/lops.c +0 -2
@@ -470,7 +470,6 @@ static void rg_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)gfs2_log_unlock (sdp);return ; } -gfs2_rgrp_bh_hold (rgd); sdp->sd_log_num_rg++;list_add (&le->le_list, &sdp->sd_log_le_rg);gfs2_log_unlock (sdp);
@@ -487,7 +486,6 @@ static void rg_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai) sdp->sd_log_num_rg--;gfs2_rgrp_repolish_clones (rgd); -gfs2_rgrp_bh_put (rgd); }gfs2_assert_warn (sdp, !sdp->sd_log_num_rg); }
fs/gfs2/rgrp.c +0 -10
@@ -750,16 +750,6 @@ fail:return error; } -void gfs2_rgrp_bh_hold (struct gfs2_rgrpd *rgd) -{ -struct gfs2_sbd *sdp = rgd->rd_sbd; - -spin_lock (&sdp->sd_rindex_spin); -gfs2_assert_warn (rgd->rd_sbd, rgd->rd_bh_count); - rgd->rd_bh_count++; -spin_unlock (&sdp->sd_rindex_spin); -} -/** * gfs2_rgrp_bh_put - Release RG bitmaps read in with gfs2_rgrp_bh_get() * @rgd: the struct gfs2_rgrpd describing the RG to read in
fs/gfs2/rgrp.h +0 -1
@@ -24,7 +24,6 @@ void gfs2_clear_rgrpd(struct gfs2_sbd *sdp);int gfs2_rindex_hold (struct gfs2_sbd *sdp,struct gfs2_holder *ri_gh);int gfs2_rgrp_bh_get (struct gfs2_rgrpd *rgd); -void gfs2_rgrp_bh_hold (struct gfs2_rgrpd *rgd);void gfs2_rgrp_bh_put (struct gfs2_rgrpd *rgd);void gfs2_rgrp_repolish_clones (struct gfs2_rgrpd *rgd);
Signature · 1 line
1.5.1.2
[Cluster-devel] [GFS2] Update journal wake up/flushing
In reply to Steven WhitehouseThis patch has several important features:
o Log flushing removed from gfs2_log_reserve so that this just waits
in the case that we try to start a transaction when there are not enough free blocks in the journal. We use an exclusive wait queue to avoid the thundering herd and to ensure we don't have starvation of any particular thread.
o The wake up of gfs2_logd is changed so that we now wake up:
- At the end of a transaction if one of the two thresholds is exceeded
- At the start of a transaction if we've had to wait for log space
- Every 30 secs (adjustable via sysfs) if there has been no other log flush in the mean time. Note that previously we flushed every 60 secs and we did that even if there had been another log flush.
o I've altered the thresholds from the 1/3 and 2/3 in the previous patch to 2/5 and 4/5 of the journal size since that gives slightly better performance on my machine, but bear in mind that these will hopefully be adjusted automatically at some point in the future.
The debugging printk in gfs2_logd has been left in this patch, but will be removed before its added to the git tree.
fs/gfs2/incore.h +2 -4
@@ -409,7 +409,6 @@ struct gfs2_tune {spinlock_t gt_spin;unsigned int gt_demote_secs;/* Cache retention for unheld glock */ -unsigned int gt_log_flush_secs;unsigned int gt_recoverd_secs;unsigned int gt_logd_secs;
@@ -541,7 +540,6 @@ struct gfs2_sbd {spinlock_t sd_jindex_spin;struct mutex sd_jindex_mutex;unsigned int sd_journals; -unsigned long sd_jindex_refresh_time;struct gfs2_jdesc *sd_jdesc;struct gfs2_holder sd_journal_gh;
@@ -597,14 +595,14 @@ struct gfs2_sbd {atomic_t sd_log_thresh1;atomic_t sd_log_thresh2;atomic_t sd_log_blks_free; -struct mutex sd_log_reserve_mutex; +wait_queue_head_t sd_log_waitq; +wait_queue_head_t sd_logd_waitq;u64 sd_log_sequence;unsigned int sd_log_head;unsigned int sd_log_tail;int sd_log_idle; -unsigned long sd_log_flush_time;struct rw_semaphore sd_log_flush_lock;atomic_t sd_log_in_flight;wait_queue_head_t sd_log_flush_wait;
fs/gfs2/log.c +80 -51
201 lines not on this page · raw message
fs/gfs2/log.h +0 -1
@@ -49,7 +49,6 @@ unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, unsigned int ssize);int gfs2_log_reserve (struct gfs2_sbd *sdp,unsigned int blks); -void gfs2_log_release (struct gfs2_sbd *sdp,unsigned int blks);void gfs2_log_incr_head (struct gfs2_sbd *sdp);struct buffer_head *gfs2_log_get_buf (struct gfs2_sbd *sdp);
fs/gfs2/meta_io.c +1 -0
@@ -303,6 +303,7 @@ void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, intstruct gfs2_sbd *sdp =GFS2_SB (bh->b_page->mapping->host);struct gfs2_bufdata *bd = bh->b_private;if (test_clear_buffer_pinned (bh)) { +atomic_dec (&sdp->sd_log_pinned);list_del_init (&bd->bd_le.le_list);if (meta) {gfs2_assert_warn (sdp, sdp->sd_log_num_buf);
fs/gfs2/ops_fstype.c +6 -8
@@ -83,7 +83,8 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)INIT_LIST_HEAD (&sdp->sd_log_le_databuf);INIT_LIST_HEAD (&sdp->sd_log_le_ordered); -mutex_init (&sdp->sd_log_reserve_mutex); +init_waitqueue_head (&sdp->sd_log_waitq); +init_waitqueue_head (&sdp->sd_logd_waitq);INIT_LIST_HEAD (&sdp->sd_ail1_list);INIT_LIST_HEAD (&sdp->sd_ail2_list);
@@ -340,8 +341,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)if (sdp->sd_args.ar_spectator) { sdp->sd_jdesc =gfs2_jdesc_find (sdp,0 );atomic_set (&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); -atomic_set (&sdp->sd_log_thresh1, sdp->sd_jdesc->jd_blocks/3 ); -atomic_set (&sdp->sd_log_thresh2,2 *sdp->sd_jdesc->jd_blocks/3 ); +atomic_set (&sdp->sd_log_thresh1,2 *sdp->sd_jdesc->jd_blocks/5 ); +atomic_set (&sdp->sd_log_thresh2,4 *sdp->sd_jdesc->jd_blocks/5 ); }else {if (sdp->sd_lockstruct.ls_jid >=gfs2_jindex_size (sdp)) { fs_err(sdp, "can't mount journal #%u\n",
@@ -379,8 +380,8 @@ static int init_journal(struct gfs2_sbd *sdp, int undo) goto fail_jinode_gh; }atomic_set (&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); -atomic_set (&sdp->sd_log_thresh1, sdp->sd_jdesc->jd_blocks/3 ); -atomic_set (&sdp->sd_log_thresh2,2 *sdp->sd_jdesc->jd_blocks/3 ); +atomic_set (&sdp->sd_log_thresh1,2 *sdp->sd_jdesc->jd_blocks/5 ); +atomic_set (&sdp->sd_log_thresh2,4 *sdp->sd_jdesc->jd_blocks/5 ); }if (sdp->sd_lockstruct.ls_first) {
@@ -612,9 +613,6 @@ static int init_threads(struct gfs2_sbd *sdp, int undo)if (undo) goto fail_quotad; - sdp->sd_log_flush_time = jiffies; - sdp->sd_jindex_refresh_time = jiffies; - p =kthread_run (gfs2_logd, sdp,"gfs2_logd" ); error =IS_ERR (p);if (error) {
fs/gfs2/super.c +1 -2
@@ -52,9 +52,8 @@ void gfs2_tune_init(struct gfs2_tune *gt)spin_lock_init (>->gt_spin); gt->gt_demote_secs =300 ; - gt->gt_log_flush_secs =60 ; gt->gt_recoverd_secs =60 ; - gt->gt_logd_secs =1 ; + gt->gt_logd_secs =30 ; gt->gt_quotad_secs =5 ; gt->gt_quota_simul_sync =64 ; gt->gt_quota_warn_period =10 ;
fs/gfs2/sys.c +0 -2
@@ -426,7 +426,6 @@ static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\ TUNE_ATTR_2(name, name##_store)TUNE_ATTR (demote_secs,0 ); -TUNE_ATTR (log_flush_secs,0 );TUNE_ATTR (quota_warn_period,0 );TUNE_ATTR (quota_quantum,0 );TUNE_ATTR (atime_quantum,0 );
@@ -446,7 +445,6 @@ TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);static struct attribute *tune_attrs[] = { &tune_attr_demote_secs.attr, - &tune_attr_log_flush_secs.attr, &tune_attr_quota_warn_period.attr, &tune_attr_quota_quantum.attr, &tune_attr_atime_quantum.attr,
fs/gfs2/trans.c +16 -0
@@ -79,6 +79,22 @@ fail_holder_uninit:return error; } +/** +* gfs2_log_release - Release a given number of log blocks +* @sdp: The GFS2 superblock +* @blks: The number of blocks +* +*/ + +static void gfs2_log_release (struct gfs2_sbd *sdp,unsigned int blks) +{ + +atomic_add (blks, &sdp->sd_log_blks_free); +gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= + sdp->sd_jdesc->jd_blocks); +up_read (&sdp->sd_log_flush_lock); +} +void gfs2_trans_end (struct gfs2_sbd *sdp) {struct gfs2_trans *tr = current->journal_info;