Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp244445pxf; Wed, 10 Mar 2021 05:32:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4rXktM5YrcYyINPFzQvZs3RvTtIe7XYTuY/bRFqcKZ0SRly/EMUCxu067sH8SzPn6SU01 X-Received: by 2002:aa7:db15:: with SMTP id t21mr3271810eds.145.1615383139750; Wed, 10 Mar 2021 05:32:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383139; cv=none; d=google.com; s=arc-20160816; b=djvF97ojJBVEji2IPcKDyc1P6J6H80V4NBEzbcFoRY91foidQ/6zoWi7XvhrHtM7o2 egOfkpIYtA1EqvoQBY5xGhkE4wZOW4/bpPwwEXfJzm4k5AbiB3QkEB6H+62oJE7HYpXq q76o7hV+Hz/p2oLn4rxzbHuGED+DCHOwrhI53AVLrEd5j4zZE8BSILHyTB/6gAwcWkXN GWlun0AZFznhVX8a+9BgCNrnG8nm9c4yKZaExfl5+GFksJ2mNhwaxYxmiQdroc9w8YTk N2V53JKT/N5b9G2SCifFECmyy1MHMeNMh7mDhQ0jvcHmM4XtMiIuqx+8F6/SvtrscFlI tb/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PLrk+Tv1H3A8T8/1CXfs4UR2diVtBR9TKsPpDkmgwsw=; b=BTP8re2mpL4uKxSN2RtErw2aQyExdosLCTSBUHa5QrVo1nzBuwE5SGPYSe8EyuQCJ9 U660h11mHmxLKnVZcuCe7BB0dhvsspAkvfNTlXb3U+gPGZKMf53x2HjOtC/aEhX8J3+i RiDLgBLTo3qXUB8lNcyF/rbNn/3KEinHEGhbcTVmWx4qdh8SlwoBckxgCLfw2lgf1rC0 7p5As37/J/oF9jtImUhfLVyLWqWnlayO3ais05Y3jUWW1ZGkiVGwjrGm3YXyK3QYoAby YE2XE0x1kgp776169aIpx/ZdPgRhuhUKIrXHksZMQ5ApvE99JSfPBMYfegV1ezFVrlp7 NGKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zHa9y6Y+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si12005101edt.553.2021.03.10.05.31.56; Wed, 10 Mar 2021 05:32:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zHa9y6Y+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233651AbhCJN26 (ORCPT + 99 others); Wed, 10 Mar 2021 08:28:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:47264 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233289AbhCJNZS (ORCPT ); Wed, 10 Mar 2021 08:25:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFF5064FDC; Wed, 10 Mar 2021 13:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382717; bh=TvNSHLl+C7ZTcKM+N6l3V2JitAAwCQT/LFrSkASm0rw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zHa9y6Y+KYg/qWcuZbjlq8+hcZIvxFWNrjDlZOfok7SAGWI5/YABO34vPO1hLxWPt HlpQK/gfBKFNp3VcG+0NYcsjdRGYpha5ls/bNRtdHliEhlTDxkmlrDCh/BZ2ngRDdE 22SNtd+b/pUYbay+TMn55Tsz61Nm65e7hyCoLlmc= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Thumshirn , David Sterba Subject: [PATCH 4.9 01/11] btrfs: raid56: simplify tracking of Q stripe presence Date: Wed, 10 Mar 2021 14:25:00 +0100 Message-Id: <20210310132320.441895184@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132320.393957501@linuxfoundation.org> References: <20210310132320.393957501@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: David Sterba commit c17af96554a8a8777cbb0fd53b8497250e548b43 upstream. There are temporary variables tracking the index of P and Q stripes, but none of them is really used as such, merely for determining if the Q stripe is present. This leads to compiler warnings with -Wunused-but-set-variable and has been reported several times. fs/btrfs/raid56.c: In function ‘finish_rmw’: fs/btrfs/raid56.c:1199:6: warning: variable ‘p_stripe’ set but not used [-Wunused-but-set-variable] 1199 | int p_stripe = -1; | ^~~~~~~~ fs/btrfs/raid56.c: In function ‘finish_parity_scrub’: fs/btrfs/raid56.c:2356:6: warning: variable ‘p_stripe’ set but not used [-Wunused-but-set-variable] 2356 | int p_stripe = -1; | ^~~~~~~~ Replace the two variables with one that has a clear meaning and also get rid of the warnings. The logic that verifies that there are only 2 valid cases is unchanged. Reviewed-by: Johannes Thumshirn Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/raid56.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1179,22 +1179,19 @@ static noinline void finish_rmw(struct b int nr_data = rbio->nr_data; int stripe; int pagenr; - int p_stripe = -1; - int q_stripe = -1; + bool has_qstripe; struct bio_list bio_list; struct bio *bio; int ret; bio_list_init(&bio_list); - if (rbio->real_stripes - rbio->nr_data == 1) { - p_stripe = rbio->real_stripes - 1; - } else if (rbio->real_stripes - rbio->nr_data == 2) { - p_stripe = rbio->real_stripes - 2; - q_stripe = rbio->real_stripes - 1; - } else { + if (rbio->real_stripes - rbio->nr_data == 1) + has_qstripe = false; + else if (rbio->real_stripes - rbio->nr_data == 2) + has_qstripe = true; + else BUG(); - } /* at this point we either have a full stripe, * or we've read the full stripe from the drive. @@ -1238,7 +1235,7 @@ static noinline void finish_rmw(struct b SetPageUptodate(p); pointers[stripe++] = kmap(p); - if (q_stripe != -1) { + if (has_qstripe) { /* * raid6, add the qstripe and call the @@ -2306,8 +2303,7 @@ static noinline void finish_parity_scrub int nr_data = rbio->nr_data; int stripe; int pagenr; - int p_stripe = -1; - int q_stripe = -1; + bool has_qstripe; struct page *p_page = NULL; struct page *q_page = NULL; struct bio_list bio_list; @@ -2317,14 +2313,12 @@ static noinline void finish_parity_scrub bio_list_init(&bio_list); - if (rbio->real_stripes - rbio->nr_data == 1) { - p_stripe = rbio->real_stripes - 1; - } else if (rbio->real_stripes - rbio->nr_data == 2) { - p_stripe = rbio->real_stripes - 2; - q_stripe = rbio->real_stripes - 1; - } else { + if (rbio->real_stripes - rbio->nr_data == 1) + has_qstripe = false; + else if (rbio->real_stripes - rbio->nr_data == 2) + has_qstripe = true; + else BUG(); - } if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) { is_replace = 1; @@ -2346,7 +2340,7 @@ static noinline void finish_parity_scrub goto cleanup; SetPageUptodate(p_page); - if (q_stripe != -1) { + if (has_qstripe) { q_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM); if (!q_page) { __free_page(p_page); @@ -2369,8 +2363,7 @@ static noinline void finish_parity_scrub /* then add the parity stripe */ pointers[stripe++] = kmap(p_page); - if (q_stripe != -1) { - + if (has_qstripe) { /* * raid6, add the qstripe and call the * library function to fill in our p/q