Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2890914imc; Wed, 13 Mar 2019 04:01:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnJiU5uVbRXmlE5gcbGsltwbLWmSsTVx4O43vtAZnUZNEYHitBFGoSuQSBJIZmhGngvFlU X-Received: by 2002:a62:3047:: with SMTP id w68mr43092335pfw.17.1552474865612; Wed, 13 Mar 2019 04:01:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552474865; cv=none; d=google.com; s=arc-20160816; b=jdfMVYqfKr6tAUz3tTo9YgScVW+v9sQp7xBzlsE50gQSD9Vya7fqo6WLx0+xGszh05 w7Oe8ccqxD0Am6Bp5n3dX9rE+LuBNJ2u46ddBy8ahjcK81Brh/qP49Vto/9LfuSwQANy XR8GXuksbgG9i9JAGbY8Dg6IGU7EYc2oTJbGNu+z7WJJcqmzRTRyMkArATlua5mSEWSM XA0SbY0HcmID2lxPxRr2DEuj+yZhpN6NgmiIq56pW7xy3UJGM8bB8c2igJIOMezFzNeR yNT7fmlnxrW2sS/qebGzvn+x7k5MwE0DimmLKJwJEw/D2jKD/B6KGr/RtvQvdomz9eAk O+lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject; bh=wQNC0VH7a5wxceKRx+fbnZBlPizobmyTGvmUR9+0cpw=; b=VXjTq4Qzej0cco7njGMtcXzYO/l87YeZ5CynMQ5F7obPJnFPOu9diVtgaU3nbkMBXV /bAFJIYh6WxQS/jQ+Sp4mvP/h/Kp8MbEGtqYc/bj2GDXawOSpGs+uSYibcsptAZvH4fK 3Sc3U/iVpTn2DGKP2cUTduZ89B4H9EIhtDkLg+79Q+AVKbb8RUo4CJxKc8YpxDiEp8yE 7BNikoYJwyNrIAyHyHpS0/+ZKsyg72T0fg2LB9DtmqDbZmRVgTsBNWFriJJfDL+4hEfX m0gCak26cgH1YLnbCqr5s1jt/kK+P+4jlI63h2s5IDNgfcJbRmv04v2ZaSYZ3MeblCqI hG9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d16si9674193pgi.148.2019.03.13.04.00.49; Wed, 13 Mar 2019 04:01:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726411AbfCMK7v (ORCPT + 99 others); Wed, 13 Mar 2019 06:59:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:34112 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725868AbfCMK7v (ORCPT ); Wed, 13 Mar 2019 06:59:51 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 83F2FB0E5; Wed, 13 Mar 2019 10:59:49 +0000 (UTC) Subject: Re: [PATCH] btrfs: raid56: properly unmap parity page in finish_parity_scrub() To: Andrea Righi , Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190313101703.GA9155@xps-13> From: Johannes Thumshirn Openpgp: preference=signencrypt Autocrypt: addr=jthumshirn@suse.de; prefer-encrypt=mutual; keydata= xsFNBFTTwPEBEADOadCyru0ZmVLaBn620Lq6WhXUlVhtvZF5r1J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95gk+YAL6flGkJD8rA3jsEucPmo5eko4Ms2rOEdG jKsZetkdPKGBd2qVxxyZgzUkgRXduvyux04b9erEpJmoIXs/lE0IRbL9A9rJ6ASjFPGpXYrb 73pb6Dtkdpvv+hoe4cKeae4dS0AnDc7LWSW3Ub0n61uk/rqpTmKuesmTZeB2GHzLN5GAXfNj ELHAeSVfFLPRFrjF5jjKJkpiyq98+oUnvTtDIPMTg05wSN2JtwKnoQ0TAIHWhiF6coGeEfY8 ikdVLSZDEjW54Td5aIXWCRTBWa6Zqz/G6oESF+Lchu/lDv5+nuN04KZRAwCpXLS++/givJWo M9FMnQSvt4N95dVQE3kDsasl960ct8OzxaxuevW0OV/jQEd9gH50RaFif412DTrsuaPsBz6O l2t2TyTuHm7wVUY2J3gJYgG723/PUGW4LaoqNrYQUr/rqo6NXw6c+EglRpm1BdpkwPwAng63 W5VOQMdnozD2RsDM5GfA4aEFi5m00tE+8XPICCtkduyWw+Z+zIqYk2v+zraPLs9Gs0X2C7X0 yvqY9voUoJjG6skkOToGZbqtMX9K4GOv9JAxVs075QRXL3brHtHONDt6udYobzz+ Message-ID: <34adab7d-6c71-c4d5-ac5b-9aa2187481ef@suse.de> Date: Wed, 13 Mar 2019 11:59:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20190313101703.GA9155@xps-13> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/03/2019 11:17, Andrea Righi wrote: > Parity page is incorrectly unmapped in finish_parity_scrub(), triggering > a reference counter bug on i386, i.e.: > > [ 157.662401] kernel BUG at mm/highmem.c:349! > [ 157.666725] invalid opcode: 0000 [#1] SMP PTI > > Steps to reproduce the bug: > - create a raid5 btrfs filesystem: > # mkfs.btrfs -m raid5 -d raid5 /dev/sdb /dev/sdc /dev/sdd /dev/sde > > - mount it: > # mount /dev/sdb /mnt > > - run btrfs scrub in a loop: > # while :; do btrfs scrub start -BR /mnt; done > > BugLink: https://bugs.launchpad.net/bugs/1812845 > Signed-off-by: Andrea Righi > --- > fs/btrfs/raid56.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c > index 1869ba8e5981..67a6f7d47402 100644 > --- a/fs/btrfs/raid56.c > +++ b/fs/btrfs/raid56.c > @@ -2430,8 +2430,9 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, > bitmap_clear(rbio->dbitmap, pagenr, 1); > kunmap(p); > > - for (stripe = 0; stripe < rbio->real_stripes; stripe++) > + for (stripe = 0; stripe < nr_data; stripe++) > kunmap(page_in_rbio(rbio, stripe, pagenr, 0)); > + kunmap(p_page); > } > > __free_page(p_page); > Code wise this looks ok, but the changelog could really describe what you're changing and why it is correct. I.e. the kunmap(p_page) was completely left out, so we never did an unmap for the p_page and the loop unmapping the rbio page was iterating over the wrong number of stripes, the map is done with nr_data vs rbio->real_stripes for the unmap. With the above (roughly) placed in the changelog: Reviewed-by: Johannes Thumshirn -- Johannes Thumshirn SUSE Labs Filesystems jthumshirn@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850