From: Andrew Morton <akpm@zip.com.au>
To: Linus Torvalds <torvalds@transmeta.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [patch 15/19] ext3: clean up journal_try_to_free_buffers()
Date: Sun, 16 Jun 2002 23:53:23 -0700 [thread overview]
Message-ID: <3D0D8763.B0DE6E98@zip.com.au> (raw)
Clean up ext3's journal_try_to_free_buffers(). Now that the
releasepage() a_op is non-blocking and need not perform I/O, this
function becomes much simpler.
--- 2.5.22/fs/jbd/transaction.c~cleanup-journal_try_to_free_buffers Sun Jun 16 23:12:52 2002
+++ 2.5.22-akpm/fs/jbd/transaction.c Sun Jun 16 23:12:52 2002
@@ -1601,8 +1601,7 @@ void journal_unfile_buffer(struct journa
*
* Returns non-zero iff we were able to free the journal_head.
*/
-static int __journal_try_to_free_buffer(struct buffer_head *bh,
- int *locked_or_dirty)
+static inline int __journal_try_to_free_buffer(struct buffer_head *bh)
{
struct journal_head *jh;
@@ -1610,12 +1609,7 @@ static int __journal_try_to_free_buffer(
jh = bh2jh(bh);
- if (buffer_locked(bh) || buffer_dirty(bh)) {
- *locked_or_dirty = 1;
- goto out;
- }
-
- if (!buffer_uptodate(bh)) /* AKPM: why? */
+ if (buffer_locked(bh) || buffer_dirty(bh))
goto out;
if (jh->b_next_transaction != 0)
@@ -1630,8 +1624,7 @@ static int __journal_try_to_free_buffer(
__journal_remove_journal_head(bh);
__brelse(bh);
}
- }
- else if (jh->b_cp_transaction != 0 && jh->b_transaction == 0) {
+ } else if (jh->b_cp_transaction != 0 && jh->b_transaction == 0) {
/* written-back checkpointed metadata buffer */
if (jh->b_jlist == BJ_None) {
JBUFFER_TRACE(jh, "remove from checkpoint list");
@@ -1647,10 +1640,8 @@ out:
}
/*
- * journal_try_to_free_buffers(). For all the buffers on this page,
- * if they are fully written out ordered data, move them onto BUF_CLEAN
- * so try_to_free_buffers() can reap them. Called with lru_list_lock
- * not held. Does its own locking.
+ * journal_try_to_free_buffers(). Try to remove all this page's buffers
+ * from the journal.
*
* This complicates JBD locking somewhat. We aren't protected by the
* BKL here. We wish to remove the buffer from its committing or
@@ -1669,50 +1660,28 @@ out:
* journal_try_to_free_buffer() is changing its state. But that
* cannot happen because we never reallocate freed data as metadata
* while the data is part of a transaction. Yes?
- *
- * This function returns non-zero if we wish try_to_free_buffers()
- * to be called. We do this is the page is releasable by try_to_free_buffers().
- * We also do it if the page has locked or dirty buffers and the caller wants
- * us to perform sync or async writeout.
*/
int journal_try_to_free_buffers(journal_t *journal,
- struct page *page, int gfp_mask)
+ struct page *page, int unused_gfp_mask)
{
+ struct buffer_head *head;
struct buffer_head *bh;
- struct buffer_head *tmp;
- int locked_or_dirty = 0;
- int call_ttfb = 1;
- int ret;
+ int ret = 0;
J_ASSERT(PageLocked(page));
- bh = page_buffers(page);
- tmp = bh;
+ head = page_buffers(page);
+ bh = head;
spin_lock(&journal_datalist_lock);
do {
- struct buffer_head *p = tmp;
-
- tmp = tmp->b_this_page;
- if (buffer_jbd(p))
- if (!__journal_try_to_free_buffer(p, &locked_or_dirty))
- call_ttfb = 0;
- } while (tmp != bh);
+ if (buffer_jbd(bh) && !__journal_try_to_free_buffer(bh)) {
+ spin_unlock(&journal_datalist_lock);
+ goto busy;
+ }
+ } while ((bh = bh->b_this_page) != head);
spin_unlock(&journal_datalist_lock);
-
- if (!(gfp_mask & (__GFP_IO|__GFP_WAIT)))
- goto out;
- if (!locked_or_dirty)
- goto out;
- /*
- * The VM wants us to do writeout, or to block on IO, or both.
- * So we allow try_to_free_buffers to be called even if the page
- * still has journalled buffers.
- */
- call_ttfb = 1;
-out:
- ret = 0;
- if (call_ttfb)
- ret = try_to_free_buffers(page);
+ ret = try_to_free_buffers(page);
+busy:
return ret;
}
-
reply other threads:[~2002-06-17 7:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=3D0D8763.B0DE6E98@zip.com.au \
--to=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.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