From patchwork Mon Dec 18 17:34:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Thornber X-Patchwork-Id: 10121101 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFAE6603B5 for ; Mon, 18 Dec 2017 17:34:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C6A228CBB for ; Mon, 18 Dec 2017 17:34:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9134A28CE1; Mon, 18 Dec 2017 17:34:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 43F7128CBB for ; Mon, 18 Dec 2017 17:34:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2559C552DC; Mon, 18 Dec 2017 17:34:18 +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 55E055DD8C; Mon, 18 Dec 2017 17:34:17 +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 714271801218; Mon, 18 Dec 2017 17:34:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vBIHYEQl015133 for ; Mon, 18 Dec 2017 12:34:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id AA24E7F783; Mon, 18 Dec 2017 17:34:14 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from localhost (unknown [10.33.36.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id A038F600C0; Mon, 18 Dec 2017 17:34:10 +0000 (UTC) Date: Mon, 18 Dec 2017 17:34:09 +0000 From: Joe Thornber To: monty_pavel@sina.com, dm-devel@redhat.com, ejt@redhat.com Message-ID: <20171218173409.px65ncx2kp7d6p2v@reti> Mail-Followup-To: monty_pavel@sina.com, dm-devel@redhat.com, ejt@redhat.com References: <20171218212758.GA12360@yyp.> <20171218171307.obyq62v3jt4lgqwg@reti> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171218171307.obyq62v3jt4lgqwg@reti> User-Agent: NeoMutt/20170609 (1.8.3) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com Subject: Re: [dm-devel] [PATCH] persistent-data: fix bug about btree of updating internal node's minima key in btree_split_beneath. 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 18 Dec 2017 17:34:18 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Dec 18, 2017 at 05:13:08PM +0000, Joe Thornber wrote: > Hi Monty, > > On Mon, Dec 18, 2017 at 04:27:58PM -0500, monty wrote: > > Subject: [PATCH] persistent-data: fix bug about btree of updating internal node's minima > > key in btree_split_beneath. > > > > fix bug about btree_split_beneath func, this bug may cause a key had > > been inserted to btree, but dm_btree_lookup can not find the key in > > btree later. > > I think you've spotted a real issue, but I don't like where you've > fixed up the btree_split_beneath() function. I'll post a patch in a > bit. Patch below. This is completely untested. I'll test tomorrow and update. Instead of fiddling with the spine we unlock both the new children and let the current spine entry (which now has just two entries) continue. That way the bounds on the lowest key is adjusted within the main loop of btree_insert_raw(). - Joe --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel diff --git a/drivers/md/persistent-data/dm-btree.c b/drivers/md/persistent-data/dm-btree.c index 416060c2570..ee2c01685f5 100644 --- a/drivers/md/persistent-data/dm-btree.c +++ b/drivers/md/persistent-data/dm-btree.c @@ -572,23 +572,8 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key) pn->keys[1] = rn->keys[0]; memcpy_disk(value_ptr(pn, 1), &val, sizeof(__le64)); - /* - * rejig the spine. This is ugly, since it knows too - * much about the spine - */ - if (s->nodes[0] != new_parent) { - unlock_block(s->info, s->nodes[0]); - s->nodes[0] = new_parent; - } - if (key < le64_to_cpu(rn->keys[0])) { - unlock_block(s->info, right); - s->nodes[1] = left; - } else { - unlock_block(s->info, left); - s->nodes[1] = right; - } - s->count = 2; - + unlock_block(s->info, left); + unlock_block(s->info, right); return 0; }