From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1696FC19759 for ; Thu, 1 Aug 2019 09:04:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E909620644 for ; Thu, 1 Aug 2019 09:04:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731037AbfHAJE3 (ORCPT ); Thu, 1 Aug 2019 05:04:29 -0400 Received: from mx2.suse.de ([195.135.220.15]:33058 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729084AbfHAJE2 (ORCPT ); Thu, 1 Aug 2019 05:04:28 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1AEA5AC63; Thu, 1 Aug 2019 09:04:27 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 4EC4E1E3F4D; Thu, 1 Aug 2019 11:04:26 +0200 (CEST) Date: Thu, 1 Aug 2019 11:04:26 +0200 From: Jan Kara To: Thomas Gleixner Cc: LKML , Peter Zijlstra , Ingo Molnar , Sebastian Siewior , Anna-Maria Gleixner , Steven Rostedt , Julia Cartwright , linux-ext4@vger.kernel.org, Theodore Tso , Jan Kara , Jan Kara , Matthew Wilcox , Alexander Viro , linux-fsdevel@vger.kernel.org, Mark Fasheh , Joseph Qi , Joel Becker Subject: Re: [patch V2 5/7] fs/jbd2: Simplify journal_unmap_buffer() Message-ID: <20190801090426.GF25064@quack2.suse.cz> References: <20190801010126.245731659@linutronix.de> <20190801010944.364767635@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190801010944.364767635@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 01-08-19 03:01:31, Thomas Gleixner wrote: > journal_unmap_buffer() checks first whether the buffer head is a journal. > If so it takes locks and then invokes jbd2_journal_grab_journal_head() > followed by another check whether this is journal head buffer. > > The double checking is pointless. > > Replace the initial check with jbd2_journal_grab_journal_head() which > alredy checks whether the buffer head is actually a journal. > > Allows also early access to the journal head pointer for the upcoming > conversion of state lock to a regular spinlock. > > Signed-off-by: Thomas Gleixner > Cc: linux-ext4@vger.kernel.org > Cc: "Theodore Ts'o" > Cc: Jan Kara Nice simplification. You can add: Reviewed-by: Jan Kara Honza > --- > V2: New patch > --- > fs/jbd2/transaction.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > --- a/fs/jbd2/transaction.c > +++ b/fs/jbd2/transaction.c > @@ -2196,7 +2196,8 @@ static int journal_unmap_buffer(journal_ > * holding the page lock. --sct > */ > > - if (!buffer_jbd(bh)) > + jh = jbd2_journal_grab_journal_head(bh); > + if (!jh) > goto zap_buffer_unlocked; > > /* OK, we have data buffer in journaled mode */ > @@ -2204,10 +2205,6 @@ static int journal_unmap_buffer(journal_ > jbd_lock_bh_state(bh); > spin_lock(&journal->j_list_lock); > > - jh = jbd2_journal_grab_journal_head(bh); > - if (!jh) > - goto zap_buffer_no_jh; > - > /* > * We cannot remove the buffer from checkpoint lists until the > * transaction adding inode to orphan list (let's call it T) > @@ -2329,7 +2326,6 @@ static int journal_unmap_buffer(journal_ > */ > jh->b_modified = 0; > jbd2_journal_put_journal_head(jh); > -zap_buffer_no_jh: > spin_unlock(&journal->j_list_lock); > jbd_unlock_bh_state(bh); > write_unlock(&journal->j_state_lock); > > -- Jan Kara SUSE Labs, CR