[Cluster-devel] [GFS2] Use write_one_page() for writeback of in-place data

Steven Whitehouse swhiteho at redhat.com
Mon Aug 20 15:06:33 UTC 2007


>From fe2c07e31e0ed90422fab685eef97997d5befcac Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <swhiteho at redhat.com>
Date: Mon, 20 Aug 2007 15:48:00 +0100
Subject: [PATCH] [GFS2] Use write_one_page() for writeback of in-place data

When writing back in-place data, we need to hold the page lock
when testing whether a page (or bh) has been truncated or not.
This is tricky since the lists were designed to work with buffer
heads, but the following patch works well. If we do find a page
thats been truncated, we push the bh into the ail2 list.

Signed-off-by: Steven Whitehouse <swhiteho at redhat.com>

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index d0e6b42..76493a3 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -70,43 +70,43 @@ static void gfs2_ail1_start_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 {
 	struct gfs2_bufdata *bd, *s;
 	struct buffer_head *bh;
-	int retry;
 
 	BUG_ON(!spin_is_locked(&sdp->sd_log_lock));
 
-	do {
-		retry = 0;
-
-		list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list,
+	list_for_each_entry_safe_reverse(bd, s, &ai->ai_ail1_list,
 						 bd_ail_st_list) {
-			bh = bd->bd_bh;
-
-			gfs2_assert(sdp, bd->bd_ail == ai);
+		bh = bd->bd_bh;
+		gfs2_assert(sdp, bd->bd_ail == ai);
 
-			if (!buffer_busy(bh)) {
-				if (!buffer_uptodate(bh)) {
-					gfs2_log_unlock(sdp);
-					gfs2_io_error_bh(sdp, bh);
-					gfs2_log_lock(sdp);
-				}
-				list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list);
-				continue;
+		if (!buffer_busy(bh)) {
+			if (!buffer_uptodate(bh)) {
+				gfs2_log_unlock(sdp);
+				gfs2_io_error_bh(sdp, bh);
+				gfs2_log_lock(sdp);
 			}
+			list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list);
+			continue;
+		}
 
-			if (!buffer_dirty(bh))
-				continue;
+		if (!buffer_dirty(bh))
+			continue;
 
-			list_move(&bd->bd_ail_st_list, &ai->ai_ail1_list);
+		list_move(&bd->bd_ail_st_list, &ai->ai_ail1_list);
 
-			gfs2_log_unlock(sdp);
-			wait_on_buffer(bh);
-			ll_rw_block(WRITE, 1, &bh);
+		get_bh(bh);
+		gfs2_log_unlock(sdp);
+		lock_page(bh->b_page);
+		if (bh->b_page->mapping != NULL) {
+			write_one_page(bh->b_page, 0);
 			gfs2_log_lock(sdp);
-
-			retry = 1;
-			break;
+		} else {
+			unlock_page(bh->b_page);
+			gfs2_log_lock(sdp);
+			clear_buffer_dirty(bh);
+			list_move(&bd->bd_ail_st_list, &ai->ai_ail2_list);
 		}
-	} while (retry);
+		brelse(bh);
+	}
 }
 
 /**
-- 
1.5.1.2






More information about the Cluster-devel mailing list