From nobody Sun Feb 8 07:21:45 2026 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ABDF3612CB for ; Mon, 12 Jan 2026 15:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768232445; cv=none; b=izEJMK+BYLsko8FUFyl6klw5odZdPDZcceO9GjLhN+eDHVuUwRild3MlKIEecftUTwF2d9zSYmhRk66UOV4eAvnogQTGXISkFS/+B76XzPiAVUdjKSRe+T1Z/ic740twJD//GmSS0Szs/76j9PoXQxWu4SlAKPT3E8rV5KPUuUw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768232445; c=relaxed/simple; bh=KXDBNYPs6o6+d58AfV6DwmytZgbc95aSZNdy7bL0lhc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=jO91jXH9n3TeJX9n2vZp70t/UuV4JYJFhIvSbfc+tRCMGNP28UecWIGytns0wZMIFN4VBCWA7Ol5tWapWyp8VTmHTHAZc0/3DbfmnxrKEuQNPdSOCVxkPT06gOYh8+Vs7aJPAU9bA546b3ZTh9HbulmkpWYUJ7ipIHYnDk6nhe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Jb9ZozaZ; arc=none smtp.client-ip=209.85.210.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Jb9ZozaZ" Received: by mail-ot1-f51.google.com with SMTP id 46e09a7af769-7c7533dbd87so5086714a34.2 for ; Mon, 12 Jan 2026 07:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768232443; x=1768837243; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yE1TQIm91uYk1rly71VaN4veqRSHPeBF3rZ1SklWl0A=; b=Jb9ZozaZy8nW96ga9P3GRK8Ubi3hkicFeyaSDhn2QsB31S2QbrkAC7jRHyDiQsB41a sQj2oZYmHoI6b5LvCRbEqC0D+i5CD/GujrMbLH1aZ7e8FOHkxgQUCNbFel/MpbXR/NM0 BzGwJh2zZFQhXjf8gWFuj+mvLCyV86gtkSQFMc1mTpH2WEaav4hHDFdV8PyE8PwER+LM /EmxJ7YOIT/MLfPc9QNvRumsBPW/J/J4+wkTp1B3zdl1dU5zOa1RJ8u1RZHei6xC6//O pyxy5T1LJdiXSgt4xD0vHP0wWp/6Zv+FqBYEWiNs71ggUl4qMcZ1G3lfObQtV/iYBgUB ALkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768232443; x=1768837243; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yE1TQIm91uYk1rly71VaN4veqRSHPeBF3rZ1SklWl0A=; b=RqzeE/5/AFd77sWHJr/q0KKP+EcutcOHNrpn7gF9o/E82owFwr8R0grmCSq90clxnG dt81yKoTstdgM3AexVE59b27rMZXvnODW6669ukKBaKErDkzYs1iwhb1WBkK1r0lzg0V LLQ6SlPrrypKVfgGRt8IUbzdD7zMvNqSolOiQhG/LEkBNWd8Ocpvz1vhWF2ujaoUHMX0 gOn9zLpE01SvyEYEgUg9fWAEtlQT7Y6uIwJPenl2GR8VBFr2EvbQvSbNujNNbCzcjKXF K6FHG5RVGIaPdxN1dq7Ta6qjFjM2bncSwQsra6LhjwlbPjQXF+88z6sJLuNCtk3n8sBZ igXQ== X-Forwarded-Encrypted: i=1; AJvYcCWbmtD4nuIrVDESkCQC/bOJHmlfJXu+lChIYXofUz1wTxX+fw4J+pWDajsqubwxYkkzoXmtiaUXEKBn3j8=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7wOuDQPMF+0kavPIR4l08pnRhCZXsHX3Dt8DEERXShHhy0Z9j bEIembcCra7l+Z8oHHY8AZYadxlKbRb8Wc7ARDEobf9qCz1VU5paEVcS X-Gm-Gg: AY/fxX4HEePn/0st72nu/jmHvHLn1wqriu3C7WYB1/Xhm3WAly3NLWrX2VFcRJvCyig pKTN1yupFt2bDcVb/KTzMOarxrfNmMl2i/YkCFaAGXxFWnF8EMlMdRZU4E/liOuWiLMLbQmhvu3 1++XW4UPtYdhdkmN2RmzmCtAGNYiVdLgO/HIegAsZk5oEAEQvFekhyceWRBJQrXrWuIkXEJvRAt LmFtR5r6+cb2pID5GoPqMv6sXsujEWdcJ95G3qQp5MiFk7RQx0eDa+s0ANcZQI+L+6dE9+L4qXH dZ+AFOdWPDghfc0xs2QnFUbnpAEPAYVSplTqwNQOiqkX01TN/DEyKMYyQ9raqwJPUDo4Fc2+/k7 FzFWhHaJ+ojFKbAPJgjoTg59gphVXynVxNsiJ+E2wGm+LKoQ12QLK3AjAZek37of3ysWxn3njti 4KGJ0XT04ppLAN3ohFkhtxNmEBR9ZepEwxQxsAYdAp9M4= X-Google-Smtp-Source: AGHT+IE3iTYZiF9/gdz5+xlFIrbcHiCazX2ptLJ7lv/yoamUJcApstAyZmEQ2vt6NrrX7xjd0X4+nw== X-Received: by 2002:a05:6820:4702:b0:65c:fe8b:53b9 with SMTP id 006d021491bc7-65f54f5e824mr6754811eaf.44.1768232443208; Mon, 12 Jan 2026 07:40:43 -0800 (PST) Received: from newman.cs.purdue.edu ([128.10.127.250]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-3ffa516150fsm12207861fac.20.2026.01.12.07.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jan 2026 07:40:42 -0800 (PST) From: Jiasheng Jiang To: Chris Mason , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jiasheng Jiang Subject: [PATCH] btrfs: zoned: remove redundant space_info lock and variable in do_allocation_zoned Date: Mon, 12 Jan 2026 15:40:40 +0000 Message-Id: <20260112154040.35746-1-jiashengjiangcool@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In do_allocation_zoned, the code acquires space_info->lock followed by block_group->lock. However, the critical section does not access or modify any members of the space_info structure, making the lock acquisition and the space_info local variable redundant. This unnecessary locking also creates a potential circular wait deadlock (AB-BA) risk. Other paths, such as background reclaim or space reporting, could acquire block_group->lock and subsequently attempt to acquire space_info->lock to update global counters. This behavior diverges from other Zoned-specific paths like __btrfs_add_free_space_zoned which only rely on block_group->lock. Removing the acquisition of space_info->lock and its corresponding definition in do_allocation_zoned eliminates the deadlock risk and improves concurrency by reducing contention on the global space_info lock. Signed-off-by: Jiasheng Jiang --- fs/btrfs/extent-tree.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e4cae34620d1..43d78056c274 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -3839,7 +3839,6 @@ static int do_allocation_zoned(struct btrfs_block_gro= up *block_group, struct btrfs_block_group **bg_ret) { struct btrfs_fs_info *fs_info =3D block_group->fs_info; - struct btrfs_space_info *space_info =3D block_group->space_info; struct btrfs_free_space_ctl *ctl =3D block_group->free_space_ctl; u64 start =3D block_group->start; u64 num_bytes =3D ffe_ctl->num_bytes; @@ -3900,7 +3899,6 @@ static int do_allocation_zoned(struct btrfs_block_gro= up *block_group, */ } =20 - spin_lock(&space_info->lock); spin_lock(&block_group->lock); spin_lock(&fs_info->treelog_bg_lock); spin_lock(&fs_info->relocation_bg_lock); @@ -4002,7 +4000,6 @@ static int do_allocation_zoned(struct btrfs_block_gro= up *block_group, spin_unlock(&fs_info->relocation_bg_lock); spin_unlock(&fs_info->treelog_bg_lock); spin_unlock(&block_group->lock); - spin_unlock(&space_info->lock); return ret; } =20 --=20 2.25.1