Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp241928pxf; Wed, 10 Mar 2021 05:28:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEx6b7tH28KBT1vwW4eHYTR1soHxnH81IUrbQl+f7JYdK0AUDCmyAOYZF7GWAxXA06x6Df X-Received: by 2002:a50:ec81:: with SMTP id e1mr3260789edr.0.1615382927673; Wed, 10 Mar 2021 05:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615382927; cv=none; d=google.com; s=arc-20160816; b=NQguf2t3EbWFjj68vz9l5QXc5JbtwHsZ5yKZwH5jg+qEb1Nevo/T3TxXo6vtyX8h6N 1Ppv5hasruuvLuHut8RAPWqdJoN/MiNfeEsCgAuWY1lgqfQaeHNPn6nQpe7earbilcz0 UG8xi3NLYH/PO+wXnQu28PFRB0Uy7DHZueBGOc1vN1rR5vhzufFSO1NOs/h95I+ygZUM GsCZRZ2Bf57/o5qp5hFsZTGTyhQg9pYOOBVmt9kdCu2l+so8YdpC2QIUIInHGCJIHD3L 5vLwJ/LjNV94CCRxQnfZWzTLqcLlRYMYfSdrIJGRQH7UM9G/3s8JzG62tSnArm09DSAa +2Dg== 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=2M8rT6nOVtWdoH5vI5c/uKiI1O60IX0N4pDwHfG7JzQ=; b=xNiEumfRj4sW3aitDvGyc8nB1PbNJGAy29qDbges3zq5sh7dMbLV82cZ01NjJkFReD +tWmaiySgfVetmJAa4BtVabNQFwjPEVaJb+5pPA+aJPy31zw0XqULcOITU05jCr9cAd4 j+DQVeG/ZomVEqnK9r/Q6jQH0DhJ3kIawZnYIz2LKF/Ard2aYZId2h5qZNwq1atv2AtX vJ1334It2+1dZEc80QZ5fEkJ3MZshuIX5wkBm+raH0rmh2yLgUsIa7tp/Ox5QY5Cgk+G +3IfSA0vHMQ8aJZY9woJ9J40VAvpNSOsThMWCOCAgiNTG+HSdY9+xrHhNzWfWG8hByR3 FeFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qyBqgYBb; 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 c10si10953747edq.212.2021.03.10.05.28.24; Wed, 10 Mar 2021 05:28:47 -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=qyBqgYBb; 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 S233982AbhCJN1q (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:46616 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233196AbhCJNZE (ORCPT ); Wed, 10 Mar 2021 08:25:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2808764FEE; Wed, 10 Mar 2021 13:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382704; bh=wuObpUnoJjjDOvL8yCLHFnREMgh0pVK4LpjMl6IBIPE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qyBqgYBbZeojfRHWBCxwzmNzoSi5xCJk2huiD9dyJ8NrpkZzwQNGjX3xglvkobn82 q184UWTN0zEjgo5mnoxvuCI1HEcjqrSBOF3CtRqe8isPYOL96JP9CZCamEOI3vZFpE 1h7flcjVflkk1YQ90vFOA+PjmHFN3lNPVIHHpF7I= 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.14 01/20] btrfs: raid56: simplify tracking of Q stripe presence Date: Wed, 10 Mar 2021 14:24:38 +0100 Message-Id: <20210310132320.559756662@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132320.512307035@linuxfoundation.org> References: <20210310132320.512307035@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 @@ -1190,22 +1190,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. @@ -1249,7 +1246,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 @@ -2325,8 +2322,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; @@ -2336,14 +2332,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; @@ -2365,7 +2359,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); @@ -2388,8 +2382,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