Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp242966pxf; Wed, 10 Mar 2021 05:30:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJwajTygk5cxEorLEupJodsjrjEV1pNTmGBoHfQFJNm8kbjRfpS2EAEs0kWcrliRnatH473a X-Received: by 2002:aa7:ccd7:: with SMTP id y23mr3319376edt.190.1615383019360; Wed, 10 Mar 2021 05:30:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615383019; cv=none; d=google.com; s=arc-20160816; b=plCkntMrrQxEMWN6noAcsbmIYx6tBnKbh8c1yzD0KeJqPfV3hp2738kWTMdj8kF3uk 507Lev81z7tt72CgKcYdbeD8t5iE1WcTZP0msCMCAGhi4uvo/JrK2YQBy4HrflLvZLCv Y1Ucdpmz/1p7tXiJvrEHJWy3c8GLSXEf6yTrq0pghf9J7Mp3y3usSvnGdcmseHIHIUpE jCE+vHJRk3GZBizVLVmyPr4jsZ94tJgw1ul2r+yxM8BZzJ56zAoR01/l0XMIKi8afEKE 5cThODTHb6HWYCcbX2qJ8/uXD/tk85QmZ2lLyDsiqykI5b8O6AtuclfYgvq/mFLaN+A4 JJMg== 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=4lFaezCrCUaMDawDI4BzQAXYoWkIiEuDQjtfVkCPOmc=; b=QganNGyFkgzM4XbbB2uxADzeOKnclYJmzJsZDFSScLgLjof0aB3rKrMSwHwQ7Buqy3 78xaNiJYehSlG3m50r9oXFaUDafb+WZtFSDmcbV+XB4VOkIjd8tyG72ZVhdT1vBGjev+ XK+V/8ps7Y8YcRbk+dg0dTKoEZ89K9p7WRCPwkt27ApNWQssCKqy6hKaO8sSE+jjYz1c Uu2Eg447X1r1PzDYnIEujuuxgXbLm8U3x9ezbqd18ZYgF5O6ECi8xr6vjrrWMMK7R6BR kTJuT278NcmZmrycEoLAFkMXQVx/C9Ao3u6+8KdDThDROKdbzlOuqPI2tmuC+Eh5i0EB vggA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n1+35ziu; 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 n18si11176618ejk.69.2021.03.10.05.29.55; Wed, 10 Mar 2021 05:30: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=n1+35ziu; 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 S233629AbhCJN1A (ORCPT + 99 others); Wed, 10 Mar 2021 08:27:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:46368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232778AbhCJNYy (ORCPT ); Wed, 10 Mar 2021 08:24:54 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2120F64FF4; Wed, 10 Mar 2021 13:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615382694; bh=e+8MzZTVu7iNtGHTVIgwl13SATBvXV9MVraN2L/OmPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1+35ziuzoMtl6Wl9YBthhxdZBWuZj85bpbz1E2m/OCXV9Wd/nmFkOPJjUnIvfEnn x0SSeD1ywcJH9wiiJ6bFuDRnj85t8rgm60mccnwDtGeWEhjLp5RzOvoqF167ptu2LA jGWiFYbDqC3A47+nDjKYYPJQHO8IzNCl6PxRzncg= 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.19 01/39] btrfs: raid56: simplify tracking of Q stripe presence Date: Wed, 10 Mar 2021 14:24:09 +0100 Message-Id: <20210310132319.754920785@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210310132319.708237392@linuxfoundation.org> References: <20210310132319.708237392@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 @@ -1182,22 +1182,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. @@ -1241,7 +1238,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 @@ -2340,8 +2337,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; @@ -2351,14 +2347,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; @@ -2380,7 +2374,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); @@ -2403,8 +2397,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