public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: swhiteho@redhat.com
To: linux-kernel@vger.kernel.org, cluster-devel@redhat.com
Cc: Steven Whitehouse <swhiteho@redhat.com>
Subject: [PATCH 08/58] [GFS2] Split gfs2_writepage into three cases
Date: Mon, 21 Jan 2008 09:21:26 +0000	[thread overview]
Message-ID: <1200907356883-git-send-email-swhiteho@redhat.com> (raw)
Message-ID: <ec596658f8ed9596efa3d0b406a3d5c47da7ff58.1200905287.git.swhiteho@redhat.com> (raw)
In-Reply-To: <12009073542596-git-send-email-swhiteho@redhat.com>
In-Reply-To: <ba7d43779caabf7d3e6c62c3007564cdff351e40.1200905287.git.swhiteho@redhat.com>

From: Steven Whitehouse <swhiteho@redhat.com>

This patch splits gfs2_writepage into separate functions for each of
the three cases: writeback, ordered and journalled. As a result
it becomes a lot easier to see what each one is doing. The common
code is moved into gfs2_writepage_common.

This fixes a performance bug where we were doing more work than
strictly required in the ordered write case.

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

diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 6c27cea..e901f8f 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -556,17 +556,20 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
 
 	lock_buffer(bd->bd_bh);
 	gfs2_log_lock(sdp);
-	if (!list_empty(&bd->bd_list_tr))
-		goto out;
-	tr->tr_touched = 1;
-	if (gfs2_is_jdata(ip)) {
-		tr->tr_num_buf++;
-		list_add(&bd->bd_list_tr, &tr->tr_list_buf);
+	if (tr) {
+		if (!list_empty(&bd->bd_list_tr))
+			goto out;
+		tr->tr_touched = 1;
+		if (gfs2_is_jdata(ip)) {
+			tr->tr_num_buf++;
+			list_add(&bd->bd_list_tr, &tr->tr_list_buf);
+		}
 	}
 	if (!list_empty(&le->le_list))
 		goto out;
 
-	__glock_lo_add(sdp, &bd->bd_gl->gl_le);
+	if (tr)
+		__glock_lo_add(sdp, &bd->bd_gl->gl_le);
 	if (gfs2_is_jdata(ip)) {
 		gfs2_pin(sdp, bd->bd_bh);
 		tr->tr_num_databuf_new++;
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 207014f..4bf73ed 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -103,16 +103,15 @@ static int gfs2_get_block_direct(struct inode *inode, sector_t lblock,
 }
 
 /**
- * gfs2_writepage - Write complete page
- * @page: Page to write
- *
- * Returns: errno
+ * gfs2_writepage_common - Common bits of writepage
+ * @page: The page to be written
+ * @wbc: The writeback control
  *
- * Some of this is copied from block_write_full_page() although we still
- * call it to do most of the work.
+ * Returns: 1 if writepage is ok, otherwise an error code or zero if no error.
  */
 
-static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
+static int gfs2_writepage_common(struct page *page,
+				 struct writeback_control *wbc)
 {
 	struct inode *inode = page->mapping->host;
 	struct gfs2_inode *ip = GFS2_I(inode);
@@ -120,23 +119,94 @@ static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
 	loff_t i_size = i_size_read(inode);
 	pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
 	unsigned offset;
-	int error;
-	int done_trans = 0;
+	int ret = -EIO;
 
-	if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl))) {
-		unlock_page(page);
-		return -EIO;
-	}
+	if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl)))
+		goto out;
+	ret = 0;
 	if (current->journal_info)
-		goto out_ignore;
-
+		goto redirty;
 	/* Is the page fully outside i_size? (truncate in progress) */
-        offset = i_size & (PAGE_CACHE_SIZE-1);
+	offset = i_size & (PAGE_CACHE_SIZE-1);
 	if (page->index > end_index || (page->index == end_index && !offset)) {
 		page->mapping->a_ops->invalidatepage(page, 0);
-		unlock_page(page);
-		return 0; /* don't care */
+		goto out;
 	}
+	return 1;
+redirty:
+	redirty_page_for_writepage(wbc, page);
+out:
+	unlock_page(page);
+	return 0;
+}
+
+/**
+ * gfs2_writeback_writepage - Write page for writeback mappings
+ * @page: The page
+ * @wbc: The writeback control
+ *
+ */
+
+static int gfs2_writeback_writepage(struct page *page,
+				    struct writeback_control *wbc)
+{
+	int ret;
+
+	ret = gfs2_writepage_common(page, wbc);
+	if (ret <= 0)
+		return ret;
+
+	ret = mpage_writepage(page, gfs2_get_block_noalloc, wbc);
+	if (ret == -EAGAIN)
+		ret = block_write_full_page(page, gfs2_get_block_noalloc, wbc);
+	return ret;
+}
+
+/**
+ * gfs2_ordered_writepage - Write page for ordered data files
+ * @page: The page to write
+ * @wbc: The writeback control
+ *
+ */
+
+static int gfs2_ordered_writepage(struct page *page,
+				  struct writeback_control *wbc)
+{
+	struct inode *inode = page->mapping->host;
+	struct gfs2_inode *ip = GFS2_I(inode);
+	int ret;
+
+	ret = gfs2_writepage_common(page, wbc);
+	if (ret <= 0)
+		return ret;
+
+	if (!page_has_buffers(page)) {
+		create_empty_buffers(page, inode->i_sb->s_blocksize,
+				     (1 << BH_Dirty)|(1 << BH_Uptodate));
+	}
+	gfs2_page_add_databufs(ip, page, 0, inode->i_sb->s_blocksize-1);
+	return block_write_full_page(page, gfs2_get_block_noalloc, wbc);
+}
+
+/**
+ * gfs2_jdata_writepage - Write complete page
+ * @page: Page to write
+ *
+ * Returns: errno
+ *
+ */
+
+static int gfs2_jdata_writepage(struct page *page, struct writeback_control *wbc)
+{
+	struct inode *inode = page->mapping->host;
+	struct gfs2_inode *ip = GFS2_I(inode);
+	struct gfs2_sbd *sdp = GFS2_SB(inode);
+	int error;
+	int done_trans = 0;
+
+	error = gfs2_writepage_common(page, wbc);
+	if (error <= 0)
+		return error;
 
 	if (PageChecked(page)) {
 		error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0);
@@ -838,7 +908,7 @@ cannot_release:
 }
 
 static const struct address_space_operations gfs2_writeback_aops = {
-	.writepage = gfs2_writepage,
+	.writepage = gfs2_writeback_writepage,
 	.writepages = gfs2_writeback_writepages,
 	.readpage = gfs2_readpage,
 	.readpages = gfs2_readpages,
@@ -852,7 +922,7 @@ static const struct address_space_operations gfs2_writeback_aops = {
 };
 
 static const struct address_space_operations gfs2_ordered_aops = {
-	.writepage = gfs2_writepage,
+	.writepage = gfs2_ordered_writepage,
 	.readpage = gfs2_readpage,
 	.readpages = gfs2_readpages,
 	.sync_page = block_sync_page,
@@ -866,7 +936,7 @@ static const struct address_space_operations gfs2_ordered_aops = {
 };
 
 static const struct address_space_operations gfs2_jdata_aops = {
-	.writepage = gfs2_writepage,
+	.writepage = gfs2_jdata_writepage,
 	.readpage = gfs2_readpage,
 	.readpages = gfs2_readpages,
 	.sync_page = block_sync_page,
-- 
1.5.1.2


  parent reply	other threads:[~2008-01-21 10:05 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-21  9:21 [GFS2] Pre-pull patch posting swhiteho
     [not found] ` <ba7d43779caabf7d3e6c62c3007564cdff351e40.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21   ` [PATCH 01/58] [GFS2] Handle multiple glock demote requests swhiteho
     [not found]   ` <5eb92fee617a944b989eb07080ceba0350ec291d.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 02/58] [GFS2] Clean up internal read function swhiteho
     [not found]   ` <5d6eb1480e3e5fb2d833de0cecb5587543c99d7e.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 03/58] [GFS2] Use ->page_mkwrite() for mmap() swhiteho
     [not found]   ` <fdfa2222cde4496cdff43faf8fa4722e53338f54.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 04/58] [GFS2] Remove useless i_cache from inodes swhiteho
     [not found]   ` <987cf4ac1626fc46b738dc2e2aed6128fde709b9.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 05/58] [GFS2] Remove unused field in struct gfs2_inode swhiteho
     [not found]   ` <84de47e81185234c2e5c7c04af1f95d17d9ae5dd.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 06/58] [GFS2] Add gfs2_is_writeback() swhiteho
     [not found]   ` <3efb2aab4ef70fd3c5062d3cae1fdc7201943193.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 07/58] [GFS2] Introduce gfs2_set_aops() swhiteho
     [not found]   ` <ec596658f8ed9596efa3d0b406a3d5c47da7ff58.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` swhiteho [this message]
     [not found]   ` <e00203790f1de31add36d27cb8f8323f8852bd4b.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 09/58] [GFS2] Add writepages for GFS2 jdata swhiteho
     [not found]   ` <c43aab67fce17cfb5b5ce2df6364cd915ff9b743.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 10/58] [GFS2] Don't hold page lock when starting transaction swhiteho
     [not found]   ` <f7271f95d9eb94f98737e2f14907f1fefaa20127.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 11/58] [GFS2] Use correct include file in ops_address.c swhiteho
     [not found]   ` <2b2ccd5cd38298d4b6ed1b07d09bac437e8e2742.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 12/58] [GFS2] Remove unused variables swhiteho
     [not found]   ` <e3723cd69be7f7d85b27127cf92380faa55258f4.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 13/58] [GFS2] Remove "reclaim limit" swhiteho
     [not found]   ` <c22f2c89becb248eb154146a842b1b158dbc291e.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 14/58] [GFS2] Add sync_page to metadata address space operations swhiteho
     [not found]   ` <9e33b02006aaf5de7a99571d6c2da48141b68475.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 15/58] [GFS2] Reorder writeback for glock sync swhiteho
     [not found]   ` <344c0973a755378c913d9e6a71630ed909aaec2f.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 16/58] [GFS2] Remove flags no longer required swhiteho
     [not found]   ` <1083867ce6c8bee18b9e8894b789ce1d0368e23b.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 17/58] [GFS2] Given device ID rather than s_id in "id" sysfs file swhiteho
     [not found]   ` <efa04e414fd6216d16e067a3bced8163c6197376.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 18/58] [GFS2] check kthread_should_stop when waiting swhiteho
     [not found]   ` <1d5e5b3757b8692881c10e0e47665de9a1b6d247.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 19/58] [GFS2] Don't add glocks to the journal swhiteho
     [not found]   ` <c8ee33b1cb02b568a26a56d4fb46920578b509e4.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 20/58] [GFS2] Use atomic_t for journal free blocks counter swhiteho
     [not found]   ` <3072834a761178bb7edcecc00c9b5aa1b439de51.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 21/58] [GFS2] Move gfs2_logd into log.c swhiteho
     [not found]   ` <5b772c19c74692e7f5f3d99002aadf844130587e.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 22/58] [GFS2] Don't periodically update the jindex swhiteho
     [not found]   ` <d9520a457c5ffccfc49dc541c32504a8229e0add.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 23/58] [GFS2] Check for installation of mount helpers for DLM mounts swhiteho
     [not found]   ` <edc7d54bfba582d1815ad00ffe9f7faff9d51ba0.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 24/58] [GFS2] tidy up error message swhiteho
     [not found]   ` <54ef8f1d6dc14b392540209198dce8f21e01dbae.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 25/58] [GFS2] Fix runtime issue with UP kernels swhiteho
     [not found]   ` <be5784b198847d5cdfa103c6882383c11eb6d7d2.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 26/58] [GFS2] Revise gfs2_logd and flush thresholds swhiteho
     [not found]   ` <406c292988bbf9cab8eb8b83e290c1f44151f76f.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 27/58] [GFS2] remove unnecessary permission checks swhiteho
     [not found]   ` <11258dc52a0dec585f009e85ba7289e2cbead850.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 28/58] [GFS2] Fix build warnings swhiteho
     [not found]   ` <cc2cd5260a4f2ca55ba561fa08539f86c304d872.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 29/58] [GFS2] Remove unrequired code swhiteho
     [not found]   ` <227a0179e629becefe2057de1af20b1881226067.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 30/58] [GFS2] Remove lock methods for lock_nolock protocol swhiteho
     [not found]   ` <43ddd9bb92c549ac3e7021a1ae5f4657a162c878.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 31/58] [GFS2] patch to check for recursive lock requests in gfs2_rename code path swhiteho
     [not found]   ` <247dc1e2ac7f0af8393a0514fc7db99cf6142747.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 32/58] [GFS2] Remove unused variable swhiteho
     [not found]   ` <ab3bb4dcd58fb0236e220007044ea74b3ca714e7.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 33/58] [GFS2] use pid for plock owner for nfs clients swhiteho
     [not found]   ` <56ee48574f36af5149e578772604f71d184ff1be.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 34/58] [GFS2] Remove function gfs2_get_block swhiteho
     [not found]   ` <c88670144f90a2d52cc7c80057cf4f5a9b1ce7b5.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 35/58] [GFS2] Fix typo in log.c swhiteho
     [not found]   ` <fb8217df7708e3f6d72442476d2b25178db21a66.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 36/58] [GFS2] Journal extent mapping swhiteho
     [not found]   ` <0c49902611713aaaa068bd588b88299e19c8ce71.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 37/58] [GFS2] Get rid of useless "found" variable in quota.c swhiteho
     [not found]   ` <b9c762a12de432548486e9b3ec0a5b657d3fd00a.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 38/58] [GFS2] Run through full bitmaps quicker in gfs2_bitfit swhiteho
     [not found]   ` <beb922fe3a443dba9e6c23f30689d5f2f0adeca1.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 39/58] [GFS2] Reorganize function gfs2_glmutex_lock swhiteho
     [not found]   ` <c5ea4a39fe373c8baa74e7a85942d2b959b8f190.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 40/58] [GFS2] Only fetch the dinode once in block_map swhiteho
     [not found]   ` <45b8feb4ecf3b4fecdfad14337e64fccae811763.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:21     ` [PATCH 41/58] [GFS2] Function meta_read optimization swhiteho
     [not found]   ` <dc29b5db8bbc2422deeaa86806b18b9d72dff824.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 42/58] [GFS2] Incremental patch to fix compiler warning swhiteho
     [not found]   ` <74bfe16e314ed23a9633debae6a1db7c19202208.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 43/58] [GFS2] Eliminate the no longer needed sd_statfs_mutex swhiteho
     [not found]   ` <b8ee332646d8dd1fb5ea64063ac9d6b804e1652b.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 44/58] [GFS2] Minor correction swhiteho
     [not found]   ` <50ab1e5a407b4e8b1dd9b26e5841965300c17af0.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 45/58] [GFS2] Fix log block mapper swhiteho
     [not found]   ` <265b3e84047d5333b9d35417d136e15e80ecefba.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 46/58] [GFS2] Remove unused variable swhiteho
     [not found]   ` <21533d0d9964d00cc9a39a175da1dc77d9a0a877.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 47/58] [GFS2] Allow page migration for writeback and ordered pages swhiteho
     [not found]   ` <c9d42363fcc84800dfccec017bff2801da604adc.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 48/58] [GFS2] Initialize extent_list earlier swhiteho
     [not found]   ` <b526ae07f31beb4a17525805f3dfff25465dd02f.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 49/58] [GFS2] Fix problems relating to execution of files on GFS2 swhiteho
     [not found]   ` <db2dea335b81b73a856d2dc5bcb13201be4d56e6.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 50/58] [GFS2] Fix assert in log code swhiteho
     [not found]   ` <708a52fa14264415fbab6e6ba3d3630f464fa062.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 51/58] [GFS2] Reduce inode size by moving i_alloc out of line swhiteho
     [not found]   ` <9f67c39fd54bd4d77d494854e1a7de0a8afb46aa.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 52/58] [GFS2] Remove unneeded i_spin swhiteho
     [not found]   ` <51b22fb453b7c234ecfee616047d2ccc6ec77f11.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 53/58] [GFS2] gfs2_alloc_required performance swhiteho
     [not found]   ` <bf67702abc309510aad346d4c9511439366f3a2d.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 54/58] [GFS2] Fix write alloc required shortcut calculation swhiteho
     [not found]   ` <c2df7196bc9e5f059d0b835cc4ddd37b5a654d5b.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 55/58] [GFS2] Fix typo swhiteho
     [not found]   ` <3fa0be40338b94030dcf4794198c65cc99e260fa.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 56/58] [GFS2] Fix page_mkwrite truncation race path swhiteho
     [not found]   ` <7244134b8007d7ec8f2a93d039a3bb6720e2466f.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 57/58] [GFS2] Lockup on error swhiteho
     [not found]   ` <7ecd8d8b2b13714181d4ae3bde6ce4005e5a304e.1200905287.git.swhiteho@redhat.com>
2008-01-21  9:22     ` [PATCH 58/58] [GFS2] Allow journal recovery on read-only mount swhiteho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1200907356883-git-send-email-swhiteho@redhat.com \
    --to=swhiteho@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox