From patchwork Thu Feb 11 05:25:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 12082311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19C3FC433DB for ; Thu, 11 Feb 2021 05:27:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E11E064DE7 for ; Thu, 11 Feb 2021 05:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbhBKF0p (ORCPT ); Thu, 11 Feb 2021 00:26:45 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56440 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229775AbhBKF0b (ORCPT ); Thu, 11 Feb 2021 00:26:31 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5PbPF174986; Thu, 11 Feb 2021 05:25:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=VFHEl0eVVe/SOuqIIYCFFsDLTlodFjUEXb8kQsFj2wA=; b=RYqK4resWP8WGYc4YJJjvDlWYQwn3mllmErzzrzrgNRNv0sizFWjs0ZSvzOeSzMDidmV 3pXRoDqtKIZXU1gP6kN38mEeFQ01PhxaJDBHWoFT52eoocxSkX5JBB6ZrGD1/C3qDsja AJ46YuvUzxd3SCuotJfOXkw18efbx6ZH71w1BF8/T28EGBDljUxC2JrV8GAnZkm3RqNi BPB87alNX5zCDuO4VxuGBf+xTqtneVJIN2asevoaPBKh0Dj4o11Zgz6JQdl8APt+PzSl zd9PpmHoVWU128/IQUBWLBs+Rq54e79pm5XlmikjrsubJqTXyllXZX1hIVUws9tnukQO 3g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 36m4upvkg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:37 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5Ojas183273; Thu, 11 Feb 2021 05:25:36 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 36j4vtqjnd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:36 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 11B5PZen002069; Thu, 11 Feb 2021 05:25:35 GMT Received: from ca-dev104.us.oracle.com (/10.129.135.33) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Feb 2021 21:25:34 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: josef@toxicpanda.com Subject: [PATCH 1/5] btrfs: make btrfs_extent_readonly() static Date: Wed, 10 Feb 2021 21:25:15 -0800 Message-Id: <91acc559ac0f1deee28410bb379b2a248c2b5204.1613019838.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_extent_readonly() is used by can_nocow_extent() in inode.c. So move btrfs_extent_readonly() from extent-tree.c to inode.c and declare it as static. Signed-off-by: Anand Jain --- fs/btrfs/ctree.h | 1 - fs/btrfs/extent-tree.c | 13 ------------- fs/btrfs/inode.c | 13 +++++++++++++ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 40ec3393d2a1..df9dfb322ab4 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2691,7 +2691,6 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans); int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, struct btrfs_ref *generic_ref); -int btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr); void btrfs_clear_space_info_full(struct btrfs_fs_info *info); /* diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 78ad31a59e59..5e228d6ad63f 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2490,19 +2490,6 @@ int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, return __btrfs_mod_ref(trans, root, buf, full_backref, 0); } -int btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr) -{ - struct btrfs_block_group *block_group; - int readonly = 0; - - block_group = btrfs_lookup_block_group(fs_info, bytenr); - if (!block_group || block_group->ro) - readonly = 1; - if (block_group) - btrfs_put_block_group(block_group); - return readonly; -} - static u64 get_alloc_profile_by_root(struct btrfs_root *root, int data) { struct btrfs_fs_info *fs_info = root->fs_info; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 6303034a7e7b..2ed7d736e39a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7256,6 +7256,19 @@ static struct extent_map *btrfs_new_extent_direct(struct btrfs_inode *inode, return em; } +static int btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr) +{ + struct btrfs_block_group *block_group; + int readonly = 0; + + block_group = btrfs_lookup_block_group(fs_info, bytenr); + if (!block_group || block_group->ro) + readonly = 1; + if (block_group) + btrfs_put_block_group(block_group); + return readonly; +} + /* * Check if we can do nocow write into the range [@offset, @offset + @len) * From patchwork Thu Feb 11 05:25:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 12082309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F34F6C433E0 for ; Thu, 11 Feb 2021 05:27:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C4EFC61493 for ; Thu, 11 Feb 2021 05:27:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbhBKF0o (ORCPT ); Thu, 11 Feb 2021 00:26:44 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:57808 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbhBKF0b (ORCPT ); Thu, 11 Feb 2021 00:26:31 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5OUt1032544; Thu, 11 Feb 2021 05:25:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=L9bW0YA0vUbkq6UHLgm/i1FjTeBMGWcflwqqE5oLFWc=; b=h15CswaDbBteF9svsmIeL8tJi/IVzW2BqC5C0ldsqeS1hB9Xu9/nxfGHcRGozNwsqLtW 7n5QeTp/0T2+iW2uup8tXzp7lodS0zXYHhX+NmiwLdgsWZPY8VqY4wTod1lWQ729HHWr 4vUVpV/JL1GQ0rGjlYmZPgEzxxjj6RqZ4bWp/CZK4CncPfJezm9OUdSg7vjWkGXfiAM4 pZBBNGFRK/W0Svt3Mws/qLhzREbqNsZ4dPPPgcvw+Ufpd86TPlyHD5bek0G9pxGdsRb9 08IVNrt7Q94FDl5WwO/96WXpFX6aN6CHOWSezS5qB+kQGKKqUfYcuCnvmgTVOWolCMoM 3Q== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2130.oracle.com with ESMTP id 36hgmap6mm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:36 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5K2P3103300; Thu, 11 Feb 2021 05:25:35 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 36j4pr1u14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:35 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 11B5PZQ3023673; Thu, 11 Feb 2021 05:25:35 GMT Received: from ca-dev104.us.oracle.com (/10.129.135.33) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Feb 2021 21:25:35 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: josef@toxicpanda.com Subject: [PATCH 2/5] btrfs: btrfs_extent_readonly() change return type to bool Date: Wed, 10 Feb 2021 21:25:16 -0800 Message-Id: <3c0e3bc3fa0577bded592b37d281e8fd27a8f779.1613019838.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 bulkscore=0 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110044 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_extent_readonly() checks if the bg is readonly, the bool return type will suffice its need. Signed-off-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2ed7d736e39a..ebb2b8e3a71c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7256,14 +7256,14 @@ static struct extent_map *btrfs_new_extent_direct(struct btrfs_inode *inode, return em; } -static int btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr) +static bool btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr) { struct btrfs_block_group *block_group; - int readonly = 0; + bool readonly = false; block_group = btrfs_lookup_block_group(fs_info, bytenr); if (!block_group || block_group->ro) - readonly = 1; + readonly = true; if (block_group) btrfs_put_block_group(block_group); return readonly; From patchwork Thu Feb 11 05:25:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 12082313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FD68C433E9 for ; Thu, 11 Feb 2021 05:27:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F4FE64E26 for ; Thu, 11 Feb 2021 05:27:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229794AbhBKF0t (ORCPT ); Thu, 11 Feb 2021 00:26:49 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:46102 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbhBKF0h (ORCPT ); Thu, 11 Feb 2021 00:26:37 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5Ols1153218; Thu, 11 Feb 2021 05:25:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=LC5M0UlFez7JCHyiZf8eaEbUTpwYNqKMmAweNOwqVTI=; b=urBoWjl9p+mTT8hUfwf5C/c/vD2S1ZIhFbRo++S7f2G4lG6YSJHUgSI7k5vhdGtoRw51 YROP3RI8FPRXdvQxxgJ7/1eo/TNZhgqXxQUae1LT0TUXueAsi+jHyjtr8G2VmFHf9dyH EGRMnN94ZeBc1x/Kb39IkFv9icZAauM6v23poOC5SAqiXatdqnYt0+VjwYsGgrEviPJG BVL3CiuXLV99ISZDTU+XfgcSz1sO/LN8ZpqibX2lyNBX9Id6Of+z/tYFHnJ2vsr7lz70 Tlp5mpP6OyO8XrHzTrHv3BZZae3bXuNv7r8VuqEzmpiz9VNjV2fS3OSWALPO5scXyHgE ew== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 36mv9dr927-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:37 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5PXcD028259; Thu, 11 Feb 2021 05:25:36 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 36j513j1bs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:36 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 11B5PZF9015025; Thu, 11 Feb 2021 05:25:35 GMT Received: from ca-dev104.us.oracle.com (/10.129.135.33) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Feb 2021 21:25:35 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: josef@toxicpanda.com Subject: [PATCH 3/5] btrfs: scrub drop few function declarations Date: Wed, 10 Feb 2021 21:25:17 -0800 Message-Id: <0b82526e15e6d0cc33ec625f8eab3f42b8a76508.1613019838.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=972 phishscore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 mlxlogscore=985 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 impostorscore=0 mlxscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Drop function declarations at the beginning of the file scrub.c. These functions are defined before they are used in the same file. No functional changes. Signed-off-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/scrub.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 70a90ca2c8da..029477dd77de 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -206,9 +206,6 @@ struct full_stripe_lock { struct mutex mutex; }; -static void scrub_pending_bio_inc(struct scrub_ctx *sctx); -static void scrub_pending_bio_dec(struct scrub_ctx *sctx); -static int scrub_handle_errored_block(struct scrub_block *sblock_to_check); static int scrub_setup_recheck_block(struct scrub_block *original_sblock, struct scrub_block *sblocks_for_recheck); static void scrub_recheck_block(struct btrfs_fs_info *fs_info, @@ -226,14 +223,11 @@ static int scrub_write_page_to_dev_replace(struct scrub_block *sblock, static int scrub_checksum_data(struct scrub_block *sblock); static int scrub_checksum_tree_block(struct scrub_block *sblock); static int scrub_checksum_super(struct scrub_block *sblock); -static void scrub_block_get(struct scrub_block *sblock); static void scrub_block_put(struct scrub_block *sblock); static void scrub_page_get(struct scrub_page *spage); static void scrub_page_put(struct scrub_page *spage); static void scrub_parity_get(struct scrub_parity *sparity); static void scrub_parity_put(struct scrub_parity *sparity); -static int scrub_add_page_to_rd_bio(struct scrub_ctx *sctx, - struct scrub_page *spage); static int scrub_pages(struct scrub_ctx *sctx, u64 logical, u32 len, u64 physical, struct btrfs_device *dev, u64 flags, u64 gen, int mirror_num, u8 *csum, @@ -251,8 +245,6 @@ static int scrub_add_page_to_wr_bio(struct scrub_ctx *sctx, static void scrub_wr_submit(struct scrub_ctx *sctx); static void scrub_wr_bio_end_io(struct bio *bio); static void scrub_wr_bio_end_io_worker(struct btrfs_work *work); -static void __scrub_blocked_if_needed(struct btrfs_fs_info *fs_info); -static void scrub_blocked_if_needed(struct btrfs_fs_info *fs_info); static void scrub_put_ctx(struct scrub_ctx *sctx); static inline int scrub_is_page_on_raid56(struct scrub_page *spage) From patchwork Thu Feb 11 05:25:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 12082315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00561C433E0 for ; Thu, 11 Feb 2021 05:27:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0C3A64E26 for ; Thu, 11 Feb 2021 05:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbhBKF0x (ORCPT ); Thu, 11 Feb 2021 00:26:53 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:57816 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229780AbhBKF0h (ORCPT ); Thu, 11 Feb 2021 00:26:37 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5O01Z032060; Thu, 11 Feb 2021 05:25:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=KKqUbbTwPVUlIXdUb3F3mufLRxeQ6M7lbUnBQOhqP6Q=; b=huoHakfNufIJy81ru6zqW1AghP25R3pERemNNmeHeoyr8VfuaJZsIOQ+/bjYtbYgUEtP SB5/JAwuJOSeNvYE0j+I1JNLJcdR2aXFt3Vtcuk32lCH2SH3qa2xSWkywEKJRglhbjKL oXlKx5tJnagLGNVWsvThtf7kNolWScYrZ9pfOtk3ymCY5HSMnyZGnNFO6Dcs0MKQOGjs ceoDC2/b3UAo5KK9WgS+7eVT1+quK+dyMa/lDEPsinMLQfKmAkwScTYIf6/u39hMMg9z Gig7svc7pGsVYhK+MzV6motvFnrx/4ixgBa04GyODWxyYRLo7ur2h2izUGSn4ne9L74o lQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 36hgmap6mn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:37 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5OiHQ183231; Thu, 11 Feb 2021 05:25:36 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 36j4vtqjnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:36 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 11B5PZ1p015028; Thu, 11 Feb 2021 05:25:36 GMT Received: from ca-dev104.us.oracle.com (/10.129.135.33) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Feb 2021 21:25:35 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: josef@toxicpanda.com Subject: [PATCH 4/5] btrfs: scrub_checksum_tree_block() drop its function declaration Date: Wed, 10 Feb 2021 21:25:18 -0800 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 spamscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 impostorscore=0 suspectscore=0 mlxscore=0 clxscore=1015 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Move the static function scrub_checksum_tree_block() before its use in the scrub.c, and drop its declaration. No functional changes. Signed-off-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/scrub.c | 133 +++++++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 67 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 029477dd77de..bc335dd6a54f 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -221,7 +221,6 @@ static void scrub_write_block_to_dev_replace(struct scrub_block *sblock); static int scrub_write_page_to_dev_replace(struct scrub_block *sblock, int page_num); static int scrub_checksum_data(struct scrub_block *sblock); -static int scrub_checksum_tree_block(struct scrub_block *sblock); static int scrub_checksum_super(struct scrub_block *sblock); static void scrub_block_put(struct scrub_block *sblock); static void scrub_page_get(struct scrub_page *spage); @@ -1506,6 +1505,72 @@ static inline int scrub_check_fsid(u8 fsid[], return !ret; } +static int scrub_checksum_tree_block(struct scrub_block *sblock) +{ + struct scrub_ctx *sctx = sblock->sctx; + struct btrfs_header *h; + struct btrfs_fs_info *fs_info = sctx->fs_info; + SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); + u8 calculated_csum[BTRFS_CSUM_SIZE]; + u8 on_disk_csum[BTRFS_CSUM_SIZE]; + /* + * This is done in sectorsize steps even for metadata as there's a + * constraint for nodesize to be aligned to sectorsize. This will need + * to change so we don't misuse data and metadata units like that. + */ + const u32 sectorsize = sctx->fs_info->sectorsize; + const int num_sectors = fs_info->nodesize >> fs_info->sectorsize_bits; + int i; + struct scrub_page *spage; + char *kaddr; + + BUG_ON(sblock->page_count < 1); + + /* Each member in pagev is just one block, not a full page */ + ASSERT(sblock->page_count == num_sectors); + + spage = sblock->pagev[0]; + kaddr = page_address(spage->page); + h = (struct btrfs_header *)kaddr; + memcpy(on_disk_csum, h->csum, sctx->fs_info->csum_size); + + /* + * we don't use the getter functions here, as we + * a) don't have an extent buffer and + * b) the page is already kmapped + */ + if (spage->logical != btrfs_stack_header_bytenr(h)) + sblock->header_error = 1; + + if (spage->generation != btrfs_stack_header_generation(h)) { + sblock->header_error = 1; + sblock->generation_error = 1; + } + + if (!scrub_check_fsid(h->fsid, spage)) + sblock->header_error = 1; + + if (memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid, + BTRFS_UUID_SIZE)) + sblock->header_error = 1; + + shash->tfm = fs_info->csum_shash; + crypto_shash_init(shash); + crypto_shash_update(shash, kaddr + BTRFS_CSUM_SIZE, + sectorsize - BTRFS_CSUM_SIZE); + + for (i = 1; i < num_sectors; i++) { + kaddr = page_address(sblock->pagev[i]->page); + crypto_shash_update(shash, kaddr, sectorsize); + } + + crypto_shash_final(shash, calculated_csum); + if (memcmp(calculated_csum, on_disk_csum, sctx->fs_info->csum_size)) + sblock->checksum_error = 1; + + return sblock->header_error || sblock->checksum_error; +} + static void scrub_recheck_block_checksum(struct scrub_block *sblock) { sblock->header_error = 0; @@ -1835,72 +1900,6 @@ static int scrub_checksum_data(struct scrub_block *sblock) return sblock->checksum_error; } -static int scrub_checksum_tree_block(struct scrub_block *sblock) -{ - struct scrub_ctx *sctx = sblock->sctx; - struct btrfs_header *h; - struct btrfs_fs_info *fs_info = sctx->fs_info; - SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); - u8 calculated_csum[BTRFS_CSUM_SIZE]; - u8 on_disk_csum[BTRFS_CSUM_SIZE]; - /* - * This is done in sectorsize steps even for metadata as there's a - * constraint for nodesize to be aligned to sectorsize. This will need - * to change so we don't misuse data and metadata units like that. - */ - const u32 sectorsize = sctx->fs_info->sectorsize; - const int num_sectors = fs_info->nodesize >> fs_info->sectorsize_bits; - int i; - struct scrub_page *spage; - char *kaddr; - - BUG_ON(sblock->page_count < 1); - - /* Each member in pagev is just one block, not a full page */ - ASSERT(sblock->page_count == num_sectors); - - spage = sblock->pagev[0]; - kaddr = page_address(spage->page); - h = (struct btrfs_header *)kaddr; - memcpy(on_disk_csum, h->csum, sctx->fs_info->csum_size); - - /* - * we don't use the getter functions here, as we - * a) don't have an extent buffer and - * b) the page is already kmapped - */ - if (spage->logical != btrfs_stack_header_bytenr(h)) - sblock->header_error = 1; - - if (spage->generation != btrfs_stack_header_generation(h)) { - sblock->header_error = 1; - sblock->generation_error = 1; - } - - if (!scrub_check_fsid(h->fsid, spage)) - sblock->header_error = 1; - - if (memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid, - BTRFS_UUID_SIZE)) - sblock->header_error = 1; - - shash->tfm = fs_info->csum_shash; - crypto_shash_init(shash); - crypto_shash_update(shash, kaddr + BTRFS_CSUM_SIZE, - sectorsize - BTRFS_CSUM_SIZE); - - for (i = 1; i < num_sectors; i++) { - kaddr = page_address(sblock->pagev[i]->page); - crypto_shash_update(shash, kaddr, sectorsize); - } - - crypto_shash_final(shash, calculated_csum); - if (memcmp(calculated_csum, on_disk_csum, sctx->fs_info->csum_size)) - sblock->checksum_error = 1; - - return sblock->header_error || sblock->checksum_error; -} - static int scrub_checksum_super(struct scrub_block *sblock) { struct btrfs_super_block *s; From patchwork Thu Feb 11 05:25:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 12082317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35DB4C433DB for ; Thu, 11 Feb 2021 05:27:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3AE964E7C for ; Thu, 11 Feb 2021 05:27:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229780AbhBKF1J (ORCPT ); Thu, 11 Feb 2021 00:27:09 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:45744 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbhBKF0h (ORCPT ); Thu, 11 Feb 2021 00:26:37 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5NtVV027411; Thu, 11 Feb 2021 05:25:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=r06omi6kUt0is18Cnyrbx+Ms8MfGqZqIfs87watTZHQ=; b=HXkalprkd3EGwNbQhf/Vr9Rpf3EOChkV8ZYE+IWwWcEEoBcB6KenEcnLCZc3nsK+1DUr 1uAFm5m5xBcNYC0s8RnKiQBmqsTWy+fyxGFVgmcoY9EeZ0L8jRc6XWGG4kVQUfxZUIl+ s3EtAUla35d8/Tc0/X6kW/OXJoMUOwDuGHNGtN1OdVaRe2zQdjL9TK6t2Umb2TBHgLhz UNzyRxIeZL22E+OVUK0UZBx4i9L/1VQFB2ENVNQYvTiGAH2KfaGceX9ge2Csi39sCI9Q eTruNTCj+hg3P4c3nVotei1umj4uD3llTh8Yq9yhUP8WVOUMS71bIvCY93oAdEOuPGnK /Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 36hkrn60wh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:37 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B5P6E5176939; Thu, 11 Feb 2021 05:25:36 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 36j51yg4j8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 05:25:36 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 11B5PaSQ019898; Thu, 11 Feb 2021 05:25:36 GMT Received: from ca-dev104.us.oracle.com (/10.129.135.33) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Feb 2021 21:25:35 -0800 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: josef@toxicpanda.com Subject: [PATCH 5/5] btrfs: scrub_checksum_data() drop its function declaration Date: Wed, 10 Feb 2021 21:25:19 -0800 Message-Id: <46c9cb7e4a50fc9c40d7dea000f5285e5997124f.1613019838.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102110045 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Move scrub_checksum_data() before its use, and drop its declaration. No functional changes. Signed-off-by: Anand Jain Reviewed-by: Johannes Thumshirn --- fs/btrfs/scrub.c | 61 ++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index bc335dd6a54f..62ea81eded03 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c @@ -220,7 +220,6 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad, static void scrub_write_block_to_dev_replace(struct scrub_block *sblock); static int scrub_write_page_to_dev_replace(struct scrub_block *sblock, int page_num); -static int scrub_checksum_data(struct scrub_block *sblock); static int scrub_checksum_super(struct scrub_block *sblock); static void scrub_block_put(struct scrub_block *sblock); static void scrub_page_get(struct scrub_page *spage); @@ -1505,6 +1504,36 @@ static inline int scrub_check_fsid(u8 fsid[], return !ret; } +static int scrub_checksum_data(struct scrub_block *sblock) +{ + struct scrub_ctx *sctx = sblock->sctx; + struct btrfs_fs_info *fs_info = sctx->fs_info; + SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); + u8 csum[BTRFS_CSUM_SIZE]; + struct scrub_page *spage; + char *kaddr; + + BUG_ON(sblock->page_count < 1); + spage = sblock->pagev[0]; + if (!spage->have_csum) + return 0; + + kaddr = page_address(spage->page); + + shash->tfm = fs_info->csum_shash; + crypto_shash_init(shash); + + /* + * In scrub_pages() and scrub_pages_for_parity() we ensure each spage + * only contains one sector of data. + */ + crypto_shash_digest(shash, kaddr, fs_info->sectorsize, csum); + + if (memcmp(csum, spage->csum, fs_info->csum_size)) + sblock->checksum_error = 1; + return sblock->checksum_error; +} + static int scrub_checksum_tree_block(struct scrub_block *sblock) { struct scrub_ctx *sctx = sblock->sctx; @@ -1870,36 +1899,6 @@ static int scrub_checksum(struct scrub_block *sblock) return ret; } -static int scrub_checksum_data(struct scrub_block *sblock) -{ - struct scrub_ctx *sctx = sblock->sctx; - struct btrfs_fs_info *fs_info = sctx->fs_info; - SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); - u8 csum[BTRFS_CSUM_SIZE]; - struct scrub_page *spage; - char *kaddr; - - BUG_ON(sblock->page_count < 1); - spage = sblock->pagev[0]; - if (!spage->have_csum) - return 0; - - kaddr = page_address(spage->page); - - shash->tfm = fs_info->csum_shash; - crypto_shash_init(shash); - - /* - * In scrub_pages() and scrub_pages_for_parity() we ensure each spage - * only contains one sector of data. - */ - crypto_shash_digest(shash, kaddr, fs_info->sectorsize, csum); - - if (memcmp(csum, spage->csum, fs_info->csum_size)) - sblock->checksum_error = 1; - return sblock->checksum_error; -} - static int scrub_checksum_super(struct scrub_block *sblock) { struct btrfs_super_block *s;