From patchwork Tue Sep 2 22:46:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Theodore Ts'o X-Patchwork-Id: 385349 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E0A6114017D for ; Wed, 3 Sep 2014 08:47:01 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755308AbaIBWrB (ORCPT ); Tue, 2 Sep 2014 18:47:01 -0400 Received: from imap.thunk.org ([74.207.234.97]:33754 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755274AbaIBWrA (ORCPT ); Tue, 2 Sep 2014 18:47:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=thunk.org; s=ef5046eb; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=abmS9E3pxv4uNvrkGVX5fEZrEpVTSwgUshUqElkQvuo=; b=OShSlZ40U49SvJZxUFBigjoYewzWv3aU79iDf3wSfuIaqKJepME8WT5rD4+hDp7GebBCED+G1HFLjcBk4KbGbVhfLMHrDmu5oX0pjImADgsHaGgN7O48FQHMXkF5Aj49++dbgAyIueLPRy0jN6keQg2qG+PMFMVI5StIqZEXrWk=; Received: from root (helo=closure.thunk.org) by imap.thunk.org with local-esmtp (Exim 4.80) (envelope-from ) id 1XOwqq-0002e0-Bz; Tue, 02 Sep 2014 22:47:00 +0000 Received: by closure.thunk.org (Postfix, from userid 15806) id BCCFA580126; Tue, 2 Sep 2014 18:46:59 -0400 (EDT) From: Theodore Ts'o To: Ext4 Developers List Cc: Theodore Ts'o Subject: [PATCH 1/2] jbd2: don't call get_bh() before calling __jbd2_journal_remove_checkpoint() Date: Tue, 2 Sep 2014 18:46:39 -0400 Message-Id: <1409698000-18126-1-git-send-email-tytso@mit.edu> X-Mailer: git-send-email 2.1.0 In-Reply-To: <20140902215930.GJ6232@thunk.org> References: <20140902215930.GJ6232@thunk.org> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org The __jbd2_journal_remove_checkpoint() doesn't require an elevated b_count; indeed, until the jh structure gets released by the call to jbd2_journal_put_journal_head(), the bh's b_count is elevated by virtue of the existence of the jh structure. Suggested-by: Jan Kara Signed-off-by: Theodore Ts'o Reviewed-by: Jan Kara --- fs/jbd2/checkpoint.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index 22fcd50..cb6e17c 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -100,11 +100,8 @@ static int __try_to_free_cp_buf(struct journal_head *jh) * Get our reference so that bh cannot be freed before * we unlock it */ - get_bh(bh); JBUFFER_TRACE(jh, "remove from checkpoint list"); ret = __jbd2_journal_remove_checkpoint(jh) + 1; - BUFFER_TRACE(bh, "release"); - __brelse(bh); } return ret; } @@ -216,7 +213,7 @@ int jbd2_log_do_checkpoint(journal_t *journal) struct buffer_head *bh; transaction_t *transaction; tid_t this_tid; - int result, batch_count = 0, done = 0; + int result, batch_count = 0; jbd_debug(1, "Start checkpoint\n"); @@ -291,11 +288,9 @@ restart: if (!buffer_dirty(bh)) { if (unlikely(buffer_write_io_error(bh)) && !result) result = -EIO; - get_bh(bh); BUFFER_TRACE(bh, "remove from checkpoint"); __jbd2_journal_remove_checkpoint(jh); spin_unlock(&journal->j_list_lock); - __brelse(bh); goto retry; } /* @@ -338,7 +333,7 @@ restart2: transaction->t_tid != this_tid) goto out; - while (!done && transaction->t_checkpoint_io_list) { + while (transaction->t_checkpoint_io_list) { jh = transaction->t_checkpoint_io_list; bh = jh2bh(jh); get_bh(bh); @@ -359,8 +354,9 @@ restart2: * know that it has been written out and so we can * drop it from the list */ - done = __jbd2_journal_remove_checkpoint(jh); __brelse(bh); + if (__jbd2_journal_remove_checkpoint(jh)) + break; } out: spin_unlock(&journal->j_list_lock);