From patchwork Thu Sep 22 01:14:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Whitney X-Patchwork-Id: 673117 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 3sfdj05XjQz9sCZ for ; Thu, 22 Sep 2016 11:10:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=oHnpx4Ae; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754480AbcIVBKo (ORCPT ); Wed, 21 Sep 2016 21:10:44 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:33754 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754297AbcIVBKn (ORCPT ); Wed, 21 Sep 2016 21:10:43 -0400 Received: by mail-qt0-f193.google.com with SMTP id p47so2113565qtc.0 for ; Wed, 21 Sep 2016 18:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=lfjEc1bzwrfMVW+2XwCkAghll/X8voxWPAALEid+9cQ=; b=oHnpx4AeGxX58WbHMuKjtCWwuc/YfH+dZrY/+3OTyNj0p1wTK2FyCNSvKA1WKtQPWl Q+bAk5QsjIbls79ayJollB17IlTxQrt43iYZ94DvFxw29Nu6lvjBK2oCyaxzoPYAEDLp 6a9gG0c77c2wdDh4m1C9wAxLHVaz9beTDFROYqtKLro1gAQxIriWLz62k2lc9iyooJgq jGe2/6qGfwnj5jXE5o6+KETnH5KD3xD63M2GE5axhhFynbUqSmIUvOSW92+7PiM0kUOZ NKFB8BL7BbgsTlBVzbGzwb7Xcvha7D0lRHaeCWJLhdHUy3wedMe8zx1LnQaIpxX5a4Js BdQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=lfjEc1bzwrfMVW+2XwCkAghll/X8voxWPAALEid+9cQ=; b=DJZqNioSd9pi7LDzwf3je7Qnyk/VUCz0mZRPCIqjEy9q2HO5tRD/YGIrZUZfHbsSnD Ud+PADhmphE3oBfpWKwO+7aEVXQuK6A8n/IkYrfRAqmV50o8COv0tVQ3o5O+vrqiEMNd PFosKy28FhC7tpwLKgrRWQcVA3Sp97ACoNjgpLVjFcbo5OR150d9L3MjgV2fOkTu/gpc tioaob+mwlzPvtQpjYpv7wsspKnBZvdLWZHTkAhcH0B0HSoDBQoMVLcYrCSUHtyXZvUi hIdrDk8Dzh5kLQHSmzOEgWfpFuP8G8dpkHkhMmzgYqnBuyww1l37dkYP4mAsN8Csp3QM 0Xfw== X-Gm-Message-State: AE9vXwNXKxVpgmCal5AsKXOcgHWgWD7itLZjLMlzYjF54x01j+mvZ1FYfhNW6HZgrdbtOw== X-Received: by 10.200.47.245 with SMTP id m50mr43678570qta.129.1474506642524; Wed, 21 Sep 2016 18:10:42 -0700 (PDT) Received: from localhost.localdomain (c-50-187-52-22.hsd1.nh.comcast.net. [50.187.52.22]) by smtp.gmail.com with ESMTPSA id 35sm20396277qtn.35.2016.09.21.18.10.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Sep 2016 18:10:42 -0700 (PDT) Date: Wed, 21 Sep 2016 21:14:50 -0400 From: Eric Whitney To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu Subject: [PATCH 1/2] ext4: create function to read journal inode Message-ID: <20160922011450.GB27216@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Factor out the code used in ext4_get_journal() to read a valid journal inode from storage, enabling its reuse in other functions. Signed-off-by: Eric Whitney Reviewed-by: Jan Kara --- fs/ext4/super.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 50912cc..4b0ca25 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -78,6 +78,8 @@ static int ext4_feature_set_ok(struct super_block *sb, int readonly); static void ext4_destroy_lazyinit_thread(void); static void ext4_unregister_li_request(struct super_block *sb); static void ext4_clear_request_list(void); +static struct inode *ext4_get_journal_inode(struct super_block *sb, + unsigned int journal_inum); /* * Lock ordering @@ -4237,18 +4239,16 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal) write_unlock(&journal->j_state_lock); } -static journal_t *ext4_get_journal(struct super_block *sb, - unsigned int journal_inum) +static struct inode *ext4_get_journal_inode(struct super_block *sb, + unsigned int journal_inum) { struct inode *journal_inode; - journal_t *journal; - - BUG_ON(!ext4_has_feature_journal(sb)); - - /* First, test for the existence of a valid inode on disk. Bad - * things happen if we iget() an unused inode, as the subsequent - * iput() will try to delete it. */ + /* + * Test for the existence of a valid inode on disk. Bad things + * happen if we iget() an unused inode, as the subsequent iput() + * will try to delete it. + */ journal_inode = ext4_iget(sb, journal_inum); if (IS_ERR(journal_inode)) { ext4_msg(sb, KERN_ERR, "no journal found"); @@ -4268,6 +4268,20 @@ static journal_t *ext4_get_journal(struct super_block *sb, iput(journal_inode); return NULL; } + return journal_inode; +} + +static journal_t *ext4_get_journal(struct super_block *sb, + unsigned int journal_inum) +{ + struct inode *journal_inode; + journal_t *journal; + + BUG_ON(!ext4_has_feature_journal(sb)); + + journal_inode = ext4_get_journal_inode(sb, journal_inum); + if (!journal_inode) + return NULL; journal = jbd2_journal_init_inode(journal_inode); if (!journal) {