Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp709525pxm; Fri, 25 Feb 2022 17:56:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBU/W9/W7hRAlppr0fLhjTmWj6R/F50zr2Ia++xqRVyAFm0ZiW9RamF+Cd5gbyqbe8Fhbo X-Received: by 2002:aa7:9382:0:b0:4e0:cf48:e564 with SMTP id t2-20020aa79382000000b004e0cf48e564mr2310378pfe.15.1645840612799; Fri, 25 Feb 2022 17:56:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645840612; cv=none; d=google.com; s=arc-20160816; b=nGbR528qM1wJ8YPoYRHH1c/tGYN4ZFNprkDEFVdWuilXV1gtdWdNLLomP8No+DYQuE 5MB1xXa4Ya3cHOimibIzbF0BPWIw/yQKhH+OY9NCc0YSfoGAs4lNdlGfF+be9Z17w39b j06mLDVSDaxiEUqyjOrSZ2nbHszabHFBNjpThiYLbqe4AJ9rYYbeGcyGZFeHRJUajtzl gluTw0bVJwA5lPP84kC1MATKLJyvDU7Mzky8akNSikgZjPK/26BGNIPG+V6431zImnzL eb7oVAVpFzDxFlKV/Z8cu9hdvBQpuDwtyc78+YDsToP6Z1guHCZ5gGBgZL/hTTnNguBd TTiQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=4YlNvB7NrEBpJJE6cmb8mulZ18i+X9nsh0taaOhh5Pc=; b=cJvHOQ4E6590o8K82GyJUF5KayWpQUOHNSigPzkBW/cyAap+ab6f/TqAEY/vTXRdj/ dXyw4nuM/npv2awq4ZTyAmla+64xFZTLlZ8rV8SO4Yca3y6HcjZDwRcNNWRoBTHvwqOd m4Jy2wOL4ooaokW1itXUPWz+TLx8m8WE6lxp5h0fo5PM3QkwK0Y1asl3UMt9kP98r0Zp 5Tp1tzCvNxwPagvAM2LiozZ4k4Ip9TnpRPnx1V/hClm9E0g5twrP2NFhh9WNYk34Fnjc Pygn/8P9RL6ktigQ0b+rQmIk8VjQZQeOpFKprxRm6/XwCsf1hbbnXeqlFWCKP725Wi6U W2rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MVwDWvjT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d20-20020a056a0024d400b004f3a647af47si3445073pfv.39.2022.02.25.17.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 17:56:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MVwDWvjT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BB462286B44; Fri, 25 Feb 2022 17:40:28 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238345AbiBYVVV (ORCPT + 99 others); Fri, 25 Feb 2022 16:21:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238279AbiBYVVU (ORCPT ); Fri, 25 Feb 2022 16:21:20 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD501F0818; Fri, 25 Feb 2022 13:20:47 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id q17so9148238edd.4; Fri, 25 Feb 2022 13:20:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4YlNvB7NrEBpJJE6cmb8mulZ18i+X9nsh0taaOhh5Pc=; b=MVwDWvjTYS6eO/Y/InyGS/3FRGUUboW79CiOsz/G0Xoq00Ybodmb8j4qXGrUWvfz/W fbCfauAn97Zm+VthvYQGx5ClfD7SsXYuMcKaItY1915fA5iha1EaPX3A6qF7k1ac+0Dh dZRo6Jf3uH3djYL6DnBE5b4sVInTKWQg1Ogr6qQetmJubnF1QfNUjAxVuXPxWsS2QL9L 4n0bmDEXh9rAxIxQ5Gr+WGim8sHiiF0zveo9sL5LOotRSEgmpaq6yStzaye4jVaYIsJT YM6lrdTzYXYzA13aBF0PexAdbXAw7Fk18yA/9n1B60LbMByzOrYOSlw/FKQYC59C44E0 pVWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4YlNvB7NrEBpJJE6cmb8mulZ18i+X9nsh0taaOhh5Pc=; b=XpIpPvEH4URrJN/Ms4l2GRVyFzDlDvHKbb/fgIgto/JuxKCgnw76mGQriwHIhRgZWx ZDDPYOYEczGPYH1BCtJtFY215dZnvMFUPfQqs2lwFJ9nx/yAtfsOxWJnLMRvXf0G1kXP qlO+tGvHb4drImV2x0ibrKLo0BKR/LWoAaMjV8lQg74l1bfKcEMq5J41PW3p2zs0Waht xBlOK29SGLwGHlLxt4c/PUO+ZprsSAP5TpjQi6wCcP+a3RwSu9E5gftYVpEBvo+DUwG7 Kw77u9PXcSdK2V3q7SDTZiUd89wD16kadetU32nIDMpSa+1bxb1iiiNf0Mye1gBn0soB XZ4g== X-Gm-Message-State: AOAM531svbtZkEOaJoX1k40pFyMMsyAhkx46/8QSFPCmlyPkYdRrt5NE E7PRHRu6AoTTVgKqKcfT7quDGaJ6Ips= X-Received: by 2002:a05:6402:90b:b0:412:a7cc:f5f9 with SMTP id g11-20020a056402090b00b00412a7ccf5f9mr8781718edz.136.1645824046394; Fri, 25 Feb 2022 13:20:46 -0800 (PST) Received: from nlaptop.localdomain (178-117-137-225.access.telenet.be. [178.117.137.225]) by smtp.gmail.com with ESMTPSA id ey10-20020a1709070b8a00b006cee56b87b9sm1428959ejc.141.2022.02.25.13.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 13:20:46 -0800 (PST) From: Niels Dossche X-Google-Original-From: Niels Dossche To: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, Niels Dossche , Niels Dossche Subject: [PATCH] btrfs: extend locking to all space_info members accesses Date: Fri, 25 Feb 2022 22:20:28 +0100 Message-Id: <20220225212028.75021-1-niels.dossche@ugent.be> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bytes_pinned is always accessed under space_info->lock, except in btrfs_preempt_reclaim_metadata_space, however the other members are accessed under that lock. The reserved member of the rsv's are also partially accessed under a lock and partially not. Move all these accesses into the same lock to ensure consistency. Signed-off-by: Niels Dossche Signed-off-by: Niels Dossche --- fs/btrfs/space-info.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 294242c194d8..62382ae1eb02 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -1061,7 +1061,6 @@ static void btrfs_preempt_reclaim_metadata_space(struct work_struct *work) trans_rsv->reserved; if (block_rsv_size < space_info->bytes_may_use) delalloc_size = space_info->bytes_may_use - block_rsv_size; - spin_unlock(&space_info->lock); /* * We don't want to include the global_rsv in our calculation, @@ -1092,6 +1091,8 @@ static void btrfs_preempt_reclaim_metadata_space(struct work_struct *work) flush = FLUSH_DELAYED_REFS_NR; } + spin_unlock(&space_info->lock); + /* * We don't want to reclaim everything, just a portion, so scale * down the to_reclaim by 1/4. If it takes us down to 0, -- 2.35.1