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=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 899BEC433DB for ; Tue, 23 Mar 2021 15:15:14 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F3BF619AB for ; Tue, 23 Mar 2021 15:15:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F3BF619AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616512513; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QroOptEwPDPH56EbglltKb0MiCWC4KtTwLGffnIJMH4=; b=SY/3lyNnP+RXZRKV48Y8KDKP1x2IZ2K3FOgD8pu0XrLYQiBMkdlFy4K3LTquAh3e5Bop3r dk6Fk3g6TaPRkgEE/v7zNejDnkvcAArAjJ0W1ZMoASN2M3GYd9C8+dI2jBta6c/Np+fpmM rmBVJfrsUbQteN3HtgsmR1Kg1fGI82s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-_UYFXKfXPTClSFk-O6OtSw-1; Tue, 23 Mar 2021 11:15:10 -0400 X-MC-Unique: _UYFXKfXPTClSFk-O6OtSw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 780C080006E; Tue, 23 Mar 2021 15:15:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D9911196E3; Tue, 23 Mar 2021 15:15:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D2A751809C83; Tue, 23 Mar 2021 15:15:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12NFCjul014926 for ; Tue, 23 Mar 2021 11:12:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7FBE5196E3; Tue, 23 Mar 2021 15:12:45 +0000 (UTC) Received: from localhost (unknown [10.18.25.174]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8331B19705; Tue, 23 Mar 2021 15:12:39 +0000 (UTC) Date: Tue, 23 Mar 2021 11:12:38 -0400 From: Mike Snitzer To: Mikulas Patocka Message-ID: <20210323151238.GA4898@redhat.com> References: MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Milan Broz Subject: Re: [dm-devel] dm-integrity - add the "reset_recalculate" flag X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Tue, Mar 23 2021 at 10:59am -0400, Mikulas Patocka wrote: > This patch adds a new flag "reset_recalculate" that will restart > recalculating from the beginning of the device. It can be used if we want > to change the hash function. Example: > > #!/bin/sh > dmsetup remove_all > rmmod brd > set -e > modprobe brd rd_size=1048576 > dmsetup create in --table '0 2000000 integrity /dev/ram0 0 16 J 2 internal_hash:sha256 recalculate' > sleep 10 > dmsetup status > dmsetup remove in > dmsetup create in --table '0 2000000 integrity /dev/ram0 0 16 J 2 internal_hash:sha3-256 reset_recalculate' > > Signed-off-by: Mikulas Patocka > > Index: linux-2.6/drivers/md/dm-integrity.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm-integrity.c > +++ linux-2.6/drivers/md/dm-integrity.c > @@ -262,6 +262,7 @@ struct dm_integrity_c { > bool journal_uptodate; > bool just_formatted; > bool recalculate_flag; > + bool reset_recalculate_flag; > bool discard; > bool fix_padding; > bool fix_hmac; > @@ -3134,7 +3135,8 @@ static void dm_integrity_resume(struct d > rw_journal_sectors(ic, REQ_OP_READ, 0, 0, > ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >> SECTOR_SHIFT), NULL); > if (ic->mode == 'B') { > - if (ic->sb->log2_blocks_per_bitmap_bit == ic->log2_blocks_per_bitmap_bit) { > + if (ic->sb->log2_blocks_per_bitmap_bit == ic->log2_blocks_per_bitmap_bit && > + !ic->reset_recalculate_flag) { > block_bitmap_copy(ic, ic->recalc_bitmap, ic->journal); > block_bitmap_copy(ic, ic->may_write_bitmap, ic->journal); > if (!block_bitmap_op(ic, ic->journal, 0, ic->provided_data_sectors, > @@ -3156,7 +3158,8 @@ static void dm_integrity_resume(struct d > } > } else { > if (!(ic->sb->log2_blocks_per_bitmap_bit == ic->log2_blocks_per_bitmap_bit && > - block_bitmap_op(ic, ic->journal, 0, ic->provided_data_sectors, BITMAP_OP_TEST_ALL_CLEAR))) { > + block_bitmap_op(ic, ic->journal, 0, ic->provided_data_sectors, BITMAP_OP_TEST_ALL_CLEAR)) || > + ic->reset_recalculate_flag) { > ic->sb->flags |= cpu_to_le32(SB_FLAG_RECALCULATING); > ic->sb->recalc_sector = cpu_to_le64(0); > } > @@ -3169,6 +3172,10 @@ static void dm_integrity_resume(struct d > dm_integrity_io_error(ic, "writing superblock", r); > } else { > replay_journal(ic); > + if (ic->reset_recalculate_flag) { > + ic->sb->flags |= cpu_to_le32(SB_FLAG_RECALCULATING); > + ic->sb->recalc_sector = cpu_to_le64(0); > + } > if (ic->mode == 'B') { > ic->sb->flags |= cpu_to_le32(SB_FLAG_DIRTY_BITMAP); > ic->sb->log2_blocks_per_bitmap_bit = ic->log2_blocks_per_bitmap_bit; > @@ -3242,6 +3249,7 @@ static void dm_integrity_status(struct d > arg_count += !!ic->meta_dev; > arg_count += ic->sectors_per_block != 1; > arg_count += !!(ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)); > + arg_count += ic->reset_recalculate_flag; > arg_count += ic->discard; > arg_count += ic->mode == 'J'; > arg_count += ic->mode == 'J'; > @@ -3261,6 +3269,8 @@ static void dm_integrity_status(struct d > DMEMIT(" block_size:%u", ic->sectors_per_block << SECTOR_SHIFT); > if (ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)) > DMEMIT(" recalculate"); > + if (ic->reset_recalculate_flag) > + DMEMIT(" reset_recalculate"); > if (ic->discard) > DMEMIT(" allow_discards"); > DMEMIT(" journal_sectors:%u", ic->initial_sectors - SB_SECTORS); > @@ -4058,6 +4068,9 @@ static int dm_integrity_ctr(struct dm_ta > goto bad; > } else if (!strcmp(opt_string, "recalculate")) { > ic->recalculate_flag = true; > + } else if (!strcmp(opt_string, "reset_recalculate")) { > + ic->recalculate_flag = true; > + ic->reset_recalculate_flag = true; > } else if (!strcmp(opt_string, "allow_discards")) { > ic->discard = true; > } else if (!strcmp(opt_string, "fix_padding")) { Do you need to bump the number of feature args supported (from 17 to 18)? Mike -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel