public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 7/7] libxfs: reset dirty buffer priority on lookup
Date: Fri,  5 Feb 2016 10:05:08 +1100	[thread overview]
Message-ID: <1454627108-19036-8-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1454627108-19036-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

When a buffer on the dirty MRU is looked up and found, we remove the
buffer from the MRU. However, we've already set the priority ofthe
buffer to "dirty" so when we are donw with it it will go back on the
dirty buffer MRU regardless of whether it needs to or not.

Hence when we move a buffer to a the dirty MRU, reocrd the old
priority and restore it when we remove the buffer from the MRU on
lookup. This will prevent us from putting fixed, now writeable
buffers back on the dirty MRU and allow the cache routine to write,
shake and reclaim the buffers once they are clean.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 include/cache.h | 1 +
 libxfs/cache.c  | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/include/cache.h b/include/cache.h
index 55761d3..3a989d7 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -99,6 +99,7 @@ struct cache_node {
 	unsigned int		cn_count;	/* reference count */
 	unsigned int		cn_hashidx;	/* hash chain index */
 	int			cn_priority;	/* priority, -1 = free list */
+	int			cn_old_priority;/* saved pre-dirty prio */
 	pthread_mutex_t		cn_mutex;	/* node mutex */
 };
 
diff --git a/libxfs/cache.c b/libxfs/cache.c
index d4b4a4e..0398be3 100644
--- a/libxfs/cache.c
+++ b/libxfs/cache.c
@@ -197,6 +197,7 @@ cache_move_to_dirty_mru(
 	mru = &cache->c_mrus[CACHE_DIRTY_PRIORITY];
 
 	pthread_mutex_lock(&mru->cm_mutex);
+	node->cn_old_priority = node->cn_priority;
 	node->cn_priority = CACHE_DIRTY_PRIORITY;
 	list_move(&node->cn_mru, &mru->cm_list);
 	mru->cm_count++;
@@ -325,6 +326,7 @@ cache_node_allocate(
 	list_head_init(&node->cn_mru);
 	node->cn_count = 1;
 	node->cn_priority = 0;
+	node->cn_old_priority = -1;
 	return node;
 }
 
@@ -434,6 +436,10 @@ cache_node_get(
 				mru->cm_count--;
 				list_del_init(&node->cn_mru);
 				pthread_mutex_unlock(&mru->cm_mutex);
+				if (node->cn_old_priority != -1) {
+					node->cn_priority = node->cn_old_priority;
+					node->cn_old_priority = -1;
+				}
 			}
 			node->cn_count++;
 
@@ -534,6 +540,7 @@ cache_node_set_priority(
 	pthread_mutex_lock(&node->cn_mutex);
 	ASSERT(node->cn_count > 0);
 	node->cn_priority = priority;
+	node->cn_old_priority = -1;
 	pthread_mutex_unlock(&node->cn_mutex);
 }
 
-- 
2.5.0

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2016-02-04 23:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 23:05 [PATCH 1/7 v2] repair: big broken filesystems cause pain Dave Chinner
2016-02-04 23:05 ` [PATCH 1/7] repair: parallelise phase 7 Dave Chinner
2016-02-08  8:55   ` Christoph Hellwig
2016-02-09  0:12     ` Dave Chinner
2016-02-04 23:05 ` [PATCH 2/7] repair: parallelise uncertin inode processing in phase 3 Dave Chinner
2016-02-08  8:58   ` Christoph Hellwig
2016-02-04 23:05 ` [PATCH 3/7] libxfs: directory node splitting does not have an extra block Dave Chinner
2016-02-05 14:20   ` Brian Foster
2016-02-08  9:00   ` Christoph Hellwig
2016-02-04 23:05 ` [PATCH 4/7] libxfs: don't discard dirty buffers Dave Chinner
2016-02-08  9:03   ` Christoph Hellwig
2016-02-04 23:05 ` [PATCH 5/7] libxfs: don't repeatedly shake unwritable buffers Dave Chinner
2016-02-08  9:03   ` Christoph Hellwig
2016-02-04 23:05 ` [PATCH 6/7] libxfs: keep unflushable buffers off the cache MRUs Dave Chinner
2016-02-05 14:22   ` Brian Foster
2016-02-08 10:06   ` Christoph Hellwig
2016-02-08 19:54     ` Dave Chinner
2016-02-04 23:05 ` Dave Chinner [this message]
2016-02-05 14:23   ` [PATCH 7/7] libxfs: reset dirty buffer priority on lookup Brian Foster
2016-02-08 10:08   ` Christoph Hellwig

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=1454627108-19036-8-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /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