Logd patches
Hi,
Since the posting the other day of a bunch of patches for gfs2_logd, I've merged some of them, dropped one (only temporarily), and the remaining two have been merged into a single patch which is now attached here. I've also removed the printk which was there for debugging purposes in the initial version of this which I posted, so this is now the remaining proposed patch for merging.
Steve.
From a3e7bb2908abb176b30c4ce06658f2d01f9a5c47 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Thu, 15 Nov 2007 10:04:42 +0000
Subject: [PATCH] [GFS2] Revise gfs2_logd and flush 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 2/5ths 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 4/5ths 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.
This patch also ensures that there are no races when gfs2_logd is woken up. It also changes the behavour of the periodic sync so that instead of occuring every 60 secs, they will now occur every 30 secs (which can be set via /sysfs still) if there have been no other log flushes in the mean time.
When we reserve blocks at the start of a transaction, we now use a waitqueue too. This means we can remove the old mutex and the fast path through that code is just a couple of atomic operations now. Also we no longer do log flushing at this point in the code. Instead we wake up gfs2_logd to do it for us (this shouldn't happen if the log is large enough and if gfs2_logd is properly tuned) and do an exclusive wait.
As a result of these changes, postmark on my test machine runs about 20% faster, mainly due to increased efficiency in flushing the journal.
fs/gfs2/incore.h +5 -5
@@ -409,8 +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;unsigned int gt_logd_secs;
@@ -542,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;
@@ -583,6 +580,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,15 +592,17 @@ 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; +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 +85 -61
229 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/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/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 +7 -5
@@ -76,14 +76,15 @@ 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);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,6 +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,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",
@@ -377,6 +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,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) {
@@ -608,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 -3
@@ -52,10 +52,8 @@ 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 ; + 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 -4
@@ -426,8 +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 );TUNE_ATTR (atime_quantum,0 );
@@ -447,8 +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_incore_log_blocks.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;
Signature · 1 line
1.5.1.2