Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1239282

Re: [PATCH v2] jbd2: gate checksum calculations on crc driver presence, not sb flags

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Nikolay Borisov <kernel@kyup.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] jbd2: gate checksum calculations on crc driver presence, not sb flags
Date Mon, 05 Oct 2015 07:50:02 +0200
Message-ID <qg6OS-6BP-9@gated-at.bofh.it> (permalink)
References <qflZD-6Vz-5@gated-at.bofh.it>
X-Original-To "Darrick J. Wong" <darrick.wong@oracle.com>, Jan Kara <jack@suse.com>, Theodore Ts'o <tytso@mit.edu>
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=9s7zeXTNVVCz9Q12AIKEyg8+KpTK86CwB6MjB0fU5JU=; b=a68IXw8uuGM1wCOPtGQ9bWZ288W70ebjRI7mFR3qh+QnQ2uG4fLkZNEEDgzOTnZBpG bEKfIfYvO4aqd+/uEQPKb+3i72wqvWsP0hzwLMIcjGSiQRla3te0+W9jPiZWDo9L/LCQ odAxGuBIrOu6V17k9FfDQEDa6Tq9x8MZTWTt8MqKbdthZDPW/HGfXz5OXT17XmMn0GgV M9bDqUjcdupzVecTx0Wq6x+dCoyDfFXMwyLOY1tQgPoD1ECE1fc8Nxt5GXsCrEzxyULV 1QBPnOIEoGGwNQ1FWJ7tWVtyRSXuZAqGDB1Zaja+0Dc2JzruR4DEfKzWSe/MZ980ULQ2 VFSA==
X-Gm-Message-State ALoCoQlJERAnNGBbifuBIEKF7mXIKAO8MkNjSN/bwTpMe1BCGrApBtX4RY33lj+IYGXG8+oK0WAG
X-Received by 10.194.238.228 with SMTP id vn4mr27931351wjc.13.1444023817061; Sun, 04 Oct 2015 22:43:37 -0700 (PDT)
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 83
Organization linux.* mail to news gateway
X-Original-Cc linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, SiteGround Operations <operations@siteground.com>, linux-ext4 <linux-ext4@vger.kernel.org>
X-Original-Date Mon, 5 Oct 2015 08:43:34 +0300
X-Original-Message-ID <56120E06.4040103@kyup.com>
X-Original-References <20151003034601.GN10390@birch.djwong.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1239282

Show key headers only | View raw


It is just me or am I not seeing this feature test helper in this patch ?

On 10/03/2015 06:46 AM, Darrick J. Wong wrote:
> Change the journal's checksum functions to gate on whether or not the
> crc32c driver is loaded, and gate the loading on the superblock bits.
> This prevents a journal crash if someone loads a journal in no-csum
> mode and then randomizes the superblock, thus flipping on the feature
> bits.
> 
> v2: Create a feature-test helper, use it everywhere.
> 
> Tested-By: Nikolay Borisov <kernel@kyup.com>
> Reported-by: Nikolay Borisov <kernel@kyup.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/jbd2/journal.c    |    6 +++---
>  include/linux/jbd2.h |   13 +++++++++----
>  2 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index 8270fe9..00f7dbd 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -124,7 +124,7 @@ EXPORT_SYMBOL(__jbd2_debug);
>  /* Checksumming functions */
>  static int jbd2_verify_csum_type(journal_t *j, journal_superblock_t *sb)
>  {
> -	if (!jbd2_journal_has_csum_v2or3(j))
> +	if (!jbd2_journal_has_csum_v2or3_feature(j))
>  		return 1;
>  
>  	return sb->s_checksum_type == JBD2_CRC32C_CHKSUM;
> @@ -1531,7 +1531,7 @@ static int journal_get_superblock(journal_t *journal)
>  		goto out;
>  	}
>  
> -	if (jbd2_journal_has_csum_v2or3(journal) &&
> +	if (jbd2_journal_has_csum_v2or3_feature(journal) &&
>  	    JBD2_HAS_COMPAT_FEATURE(journal, JBD2_FEATURE_COMPAT_CHECKSUM)) {
>  		/* Can't have checksum v1 and v2 on at the same time! */
>  		printk(KERN_ERR "JBD2: Can't enable checksumming v1 and v2/3 "
> @@ -1545,7 +1545,7 @@ static int journal_get_superblock(journal_t *journal)
>  	}
>  
>  	/* Load the checksum driver */
> -	if (jbd2_journal_has_csum_v2or3(journal)) {
> +	if (jbd2_journal_has_csum_v2or3_feature(journal)) {
>  		journal->j_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
>  		if (IS_ERR(journal->j_chksum_driver)) {
>  			printk(KERN_ERR "JBD2: Cannot load crc32c driver.\n");
> diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
> index df07e78..6da6f89 100644
> --- a/include/linux/jbd2.h
> +++ b/include/linux/jbd2.h
> @@ -1338,13 +1338,18 @@ static inline int tid_geq(tid_t x, tid_t y)
>  extern int jbd2_journal_blocks_per_page(struct inode *inode);
>  extern size_t journal_tag_bytes(journal_t *journal);
>  
> +static inline bool jbd2_journal_has_csum_v2or3_feature(journal_t *j)
> +{
> +	return JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V2) ||
> +	       JBD2_HAS_INCOMPAT_FEATURE(j, JBD2_FEATURE_INCOMPAT_CSUM_V3);
> +}
> +
>  static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
>  {
> -	if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V2) ||
> -	    JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_CSUM_V3))
> -		return 1;
> +	WARN_ON_ONCE(jbd2_journal_has_csum_v2or3_feature(journal) &&
> +		     journal->j_chksum_driver == NULL);
>  
> -	return 0;
> +	return journal->j_chksum_driver != NULL;
>  }
>  
>  /*
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2] jbd2: gate checksum calculations on crc driver presence,  not sb flags "Darrick J. Wong" <darrick.wong@oracle.com> - 2015-10-03 05:50 +0200
  Re: [PATCH v2] jbd2: gate checksum calculations on crc driver  presence, not sb flags Nikolay Borisov <kernel@kyup.com> - 2015-10-05 07:50 +0200
    Re: [PATCH v2] jbd2: gate checksum calculations on crc driver  presence, not sb flags "Darrick J. Wong" <darrick.wong@oracle.com> - 2015-10-05 08:30 +0200
      Re: [PATCH v2] jbd2: gate checksum calculations on crc driver  presence, not sb flags Nikolay Borisov <kernel@kyup.com> - 2015-10-05 08:30 +0200
        Re: [PATCH v2] jbd2: gate checksum calculations on crc driver  presence, not sb flags "Darrick J. Wong" <darrick.wong@oracle.com> - 2015-10-05 09:20 +0200

csiph-web