From patchwork Tue Aug 23 08:02:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 1087572 Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7N85THL011581 for ; Tue, 23 Aug 2011 08:05:50 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7N82sAC026869; Tue, 23 Aug 2011 04:02:56 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7N82p8B016724 for ; Tue, 23 Aug 2011 04:02:51 -0400 Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.17]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7N82kCB015242; Tue, 23 Aug 2011 04:02:46 -0400 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7N82j9Z020645; Tue, 23 Aug 2011 04:02:45 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 9C6478E857; Tue, 23 Aug 2011 10:02:44 +0200 (CEST) Date: Tue, 23 Aug 2011 18:02:35 +1000 From: NeilBrown To: dm-devel@redhat.com, Heinz Mauelshagen Message-ID: <20110823180235.2920da02@notabene.brown> Mime-Version: 1.0 X-RedHat-Spam-Score: -2.773 (RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.17 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH] dmraid: allow "dmraid --erase_metadata" to work with ddf X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development 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-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 23 Aug 2011 08:05:50 +0000 (UTC) Hi, current dmraid cannot erase ddf metadata. It tries to seek to an offset too big by a factor of 512, and then writes zero bytes to the anchor. "ddf1->anchor_offset" is set to a number of bytes and sometimes treated as bytes - sometimes as sectors. This patch makes it always sectors and also sets the size of the anchor metadata area to DDF1_BLKSIZE Signed-off-by: NeilBrown --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: lib/format/ddf/ddf1.c =================================================================== RCS file: /cvs/dm/dmraid/lib/format/ddf/ddf1.c,v retrieving revision 1.8 diff -u -r1.8 ddf1.c --- lib/format/ddf/ddf1.c 18 Mar 2010 16:53:17 -0000 1.8 +++ lib/format/ddf/ddf1.c 23 Aug 2011 08:01:13 -0000 @@ -526,7 +526,7 @@ ddf1_sboffset) || !is_ddf1(lc, di, ddf1)) goto bad; - ddf1->anchor_offset = ddf1_sboffset; + ddf1->anchor_offset = ddf1_sboffset / 512; /* Convert endianness */ ddf1->in_cpu_format = 0; @@ -962,6 +962,7 @@ ma[i].offset = ddf1->primary->primary_table_lba; ma->offset = ddf1->anchor_offset; + ma->size = DDF1_BLKSIZE; (ma++)->area = &ddf1->anchor; (ma++)->area = ddf1->primary; Index: lib/format/ddf/ddf1_dump.c =================================================================== RCS file: /cvs/dm/dmraid/lib/format/ddf/ddf1_dump.c,v retrieving revision 1.3 diff -u -r1.3 ddf1_dump.c --- lib/format/ddf/ddf1_dump.c 13 Jul 2010 20:22:38 -0000 1.3 +++ lib/format/ddf/ddf1_dump.c 23 Aug 2011 08:01:13 -0000 @@ -60,7 +60,7 @@ { log_print(lc, "%s (%s):", di->path, handler); log_print(lc, "DDF1 anchor at %llu with tables in %s-endian format.", - ddf1->anchor_offset / DDF1_BLKSIZE, + ddf1->anchor_offset, (ddf1->disk_format == LITTLE_ENDIAN ? "little" : "big")); }