From patchwork Thu Sep 8 00:26:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Roesch X-Patchwork-Id: 12969510 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A110CC6FA82 for ; Thu, 8 Sep 2022 00:27:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbiIHA1A (ORCPT ); Wed, 7 Sep 2022 20:27:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230191AbiIHA06 (ORCPT ); Wed, 7 Sep 2022 20:26:58 -0400 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60499D0232 for ; Wed, 7 Sep 2022 17:26:56 -0700 (PDT) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 287HnglT011049 for ; Wed, 7 Sep 2022 17:26:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=is9Y7XjgKHvRGTljgTWJnvm7mK7pSl22GMfdkPrRC9w=; b=Zx6pCPf7KnmJhls6XsNxbW/U3vfIbE3UgvQi8t9L/awKTDsUNYaqJH6TfjOwW4tiXEHB ZS17iTNi9Gkwjh2BedQFNPl/v+O6f2JZS7sYtQmeIj7+gmxKnOYZ9Ve8n7QjKju3Xt0e EfFvaE+/Zt/fCM9MxxE/KMG2av44th9RLt4= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3jegypfdnm-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 07 Sep 2022 17:26:54 -0700 Received: from twshared13579.04.prn5.facebook.com (2620:10d:c085:108::8) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 7 Sep 2022 17:26:53 -0700 Received: by dev1180.prn1.facebook.com (Postfix, from userid 425415) id EA1711D2F048; Wed, 7 Sep 2022 17:26:19 -0700 (PDT) From: Stefan Roesch To: , , CC: , , , Subject: [PATCH v2 11/12] btrfs: add assert to search functions Date: Wed, 7 Sep 2022 17:26:15 -0700 Message-ID: <20220908002616.3189675-12-shr@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220908002616.3189675-1-shr@fb.com> References: <20220908002616.3189675-1-shr@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: wd09Ghxfc2pRxgr7PRqg3TjcbrJEKMCA X-Proofpoint-GUID: wd09Ghxfc2pRxgr7PRqg3TjcbrJEKMCA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-07_10,2022-09-07_02,2022-06-22_01 Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org This adds warnings to search functions, which should not have the nowait flag set when called. Signed-off-by: Stefan Roesch --- fs/btrfs/ctree.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 71b238364939..9caf0f87cbcb 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -2165,6 +2165,9 @@ int btrfs_search_old_slot(struct btrfs_root *root, const struct btrfs_key *key, lowest_level = p->lowest_level; WARN_ON(p->nodes[0] != NULL); + if (WARN_ON_ONCE(p->nowait == 1)) + return -EINVAL; + if (p->search_commit_root) { BUG_ON(time_seq); return btrfs_search_slot(NULL, root, key, p, 0, 0); @@ -4465,6 +4468,9 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, int ret = 1; int keep_locks = path->keep_locks; + if (WARN_ON_ONCE(path->nowait == 1)) + return -EINVAL; + path->keep_locks = 1; again: cur = btrfs_read_lock_root_node(root); @@ -4645,6 +4651,9 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, int ret; int i; + if (WARN_ON_ONCE(path->nowait == 1)) + return -EINVAL; + nritems = btrfs_header_nritems(path->nodes[0]); if (nritems == 0) return 1;