Clean up journaled data writing
From db89914d206f42c288801848d2a0b46796573543 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Mon, 17 Sep 2007 10:59:52 +0100
Subject: [PATCH] [GFS2] Clean up journaled data writing
This patch cleans up the code for writing journaled data into the log. It also removes the need to allocate a small "tag" structure for each block written into the log. Instead we just keep count of the outstanding I/O so that we can be sure that its all been written at the correct time. Another result of this patch is that a number of ll_rw_block() calls have become submit_bh() calls, closing some races at the same time.
Signed-off-by Steven Whitehouse <[email protected]>
fs/gfs2/incore.h +2 -7
@@ -341,12 +341,6 @@ struct gfs2_quota_data {unsigned long qd_last_touched; }; -struct gfs2_log_buf { -struct list_head lb_list; -struct buffer_head *lb_bh; -struct buffer_head *lb_real; -}; -struct gfs2_trans {unsigned long tr_ip;
@@ -631,7 +625,8 @@ struct gfs2_sbd {unsigned long sd_log_flush_time;struct rw_semaphore sd_log_flush_lock; -struct list_head sd_log_flush_list; +atomic_t sd_log_in_flight; +wait_queue_head_t sd_log_flush_wait;unsigned int sd_log_flush_head;u64 sd_log_flush_wrapped;
fs/gfs2/log.c +83 -62
228 lines not on this page · raw message
fs/gfs2/log.h +1 -0
@@ -52,6 +52,7 @@ int gfs2_ail1_empty(struct gfs2_sbd *sdp, int flags);int gfs2_log_reserve (struct gfs2_sbd *sdp,unsigned int blks,int wait);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); struct buffer_head *gfs2_log_fake_buf(struct gfs2_sbd *sdp,
fs/gfs2/lops.c +126 -116
335 lines not on this page · raw message
fs/gfs2/meta_io.c +32 -23
71 lines not on this page · raw message
fs/gfs2/meta_io.h +3 -0
@@ -51,6 +51,9 @@ int gfs2_meta_wait(struct gfs2_sbd *sdp, struct buffer_head *bh);void gfs2_attach_bufdata (struct gfs2_glock *gl,struct buffer_head *bh,int meta); +void gfs2_remove_from_journal (struct buffer_head *bh,struct gfs2_trans *tr, +int meta); +void gfs2_meta_wipe (struct gfs2_inode *ip,u64 bstart,u32 blen);void gfs2_meta_cache_flush (struct gfs2_inode *ip);
fs/gfs2/ops_address.c +6 -5
@@ -414,7 +414,8 @@ static int gfs2_prepare_write(struct file *file, struct page *page,if (ind_blocks || data_blocks) rblocks +=RES_STATFS +RES_QUOTA ; - error =gfs2_trans_begin (sdp, rblocks,0 ); + error =gfs2_trans_begin (sdp, rblocks, +PAGE_CACHE_SIZE /sdp->sd_sb.sb_bsize);if (error) goto out_trans_fail;
@@ -625,10 +626,10 @@ static void gfs2_discard(struct gfs2_sbd *sdp, struct buffer_head *bh)clear_buffer_dirty (bh); bd = bh->b_private;if (bd) { -if (!list_empty (&bd->bd_le.le_list)) { -if (!buffer_pinned (bh)) -list_del_init (&bd->bd_le.le_list); - } +if (!list_empty (&bd->bd_le.le_list) && !buffer_pinned (bh)) +list_del_init (&bd->bd_le.le_list); +else +gfs2_remove_from_journal (bh, current->journal_info,0 ); } bh->b_bdev =NULL ;clear_buffer_mapped (bh);
fs/gfs2/ops_fstype.c +2 -1
@@ -89,7 +89,8 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)INIT_LIST_HEAD (&sdp->sd_ail2_list);init_rwsem (&sdp->sd_log_flush_lock); -INIT_LIST_HEAD (&sdp->sd_log_flush_list); +atomic_set (&sdp->sd_log_in_flight,0 ); +init_waitqueue_head (&sdp->sd_log_flush_wait);INIT_LIST_HEAD (&sdp->sd_revoke_list);
fs/gfs2/ops_inode.c +6 -1
@@ -905,12 +905,17 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd)static int setattr_size (struct inode *inode,struct iattr *attr) {struct gfs2_inode *ip =GFS2_I (inode); +struct gfs2_sbd *sdp =GFS2_SB (inode);int error;if (attr->ia_size != ip->i_di.di_size) { - error =vmtruncate (inode, attr->ia_size); + error =gfs2_trans_begin (sdp,0 , sdp->sd_jdesc->jd_blocks);if (error)return error; + error =vmtruncate (inode, attr->ia_size); +gfs2_trans_end (sdp); +if (error) +return error; } error =gfs2_truncatei (ip, attr->ia_size);
fs/gfs2/ops_super.c +8 -5
@@ -455,12 +455,15 @@ static void gfs2_delete_inode(struct inode *inode) } error =gfs2_dinode_dealloc (ip); -/* -* Must do this before unlock to avoid trying to write back -* potentially dirty data now that inode no longer exists -* on disk. -*/ +if (error) + goto out_unlock; + + error =gfs2_trans_begin (sdp,0 , sdp->sd_jdesc->jd_blocks); +if (error) + goto out_unlock; +/* Needs to be done before glock release & also in a transaction */ truncate_inode_pages (&inode->i_data,0 ); +gfs2_trans_end (sdp); out_unlock:gfs2_glock_dq (&ip->i_iopen_gh);
Signature · 1 line
1.5.1.2