From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (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 786E83939A6 for ; Mon, 16 Mar 2026 12:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773662541; cv=none; b=m6I60UM8wFkApZCX7DZ8Q7/nzzXIqpSP1I6kzC/eCmS8rmhiw2RquvPyKSGWlou3kiojT+4lmnfRhkybE44gs2cxZ+x4VdsqGhpjyPwUYD92pRxV0uFnsKh9xCmboAeBjArU2kBI0nuY7qydmYTmFnE8I87y8HQRLkwuZ4ZSsUU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773662541; c=relaxed/simple; bh=763wC3RRPxIsptrmNPCWXS4C9poStXcpGsCSDU2gvlQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=U1n81eFSbpWjfGkacoKhxAa15sdLllPPmRp7LSHD4T8ZpIGE1E8MrbFs+XRT75NBx1nHXpFn2CkCcJQdHh2lSBbJ6DyfKIl19Oc7gun27huy0lZQwFBOU7ZzncfErCTpj1nj8vbNAqVSVNZ0p95hnzB4B+EZXCiVXOSeHbcWu+s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wF+QsSY/; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wF+QsSY/" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-48553fdd03dso26256715e9.0 for ; Mon, 16 Mar 2026 05:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773662539; x=1774267339; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UX+URBpTt60dMhGkY9Id85Iw5Xtu00SbMnwBlBMIQ14=; b=wF+QsSY/GQEgB0KYucoeprZCajrScL9vnmSkDBafohk5snzh9c5n/hawYgI/k+MB1B /Pgt2z//Y2bsHpclpB4ewebNbslyjK24KrACWrZcr/8172tv9mwnr492CTEBO3xByOlI QeZwFk/JYx1FA4VQqYDjlxnPzFm4tgzj/UBDQwlwBbems5621c8da7oyNgm9oEscDxLK nuFR3dE3YrGRnStqmu7pSdJkHu2GAQuoIqrn+EkmBnv6NK64Dab6i61iQwR0EbITIFY4 UXTU6y0A9FUlxABmJ9q0K5uS6MxEPGkN3wEoUc3oF0sPCOgM4kaLRaL8rb6hVaghQM0e Vw4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773662539; x=1774267339; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UX+URBpTt60dMhGkY9Id85Iw5Xtu00SbMnwBlBMIQ14=; b=hmnCCLLCzsdsKes6yuTGQ79KpZTi73qgs51U7mKW/gCRiQpEr5fVMshwuOV9T1UZsR EMWui8WT/F15UHqif9A5z12TTxbvV2fbfLEfwwdyeR69oRGNA7zQFniAShehoJNRpaKW dS7OL2OgclnLpjkfhKwqphMnaadnuxYa6HhoX/nfGgctb6luafEmkRQlFRQ3OP7fmbL/ +2UzeVMp+P1OGAlUHqIyS9X17uQwEBvGpQQRDX7l3U5biBLtG+iTlFsvYL7k11wveUWg QFsn0lnnTCVGWATcJMMwT7NaTZ1gt+5nTZYYSNAH3XtvCQfjQi2MB2yhe9N+Ef9KEPMb 8/vg== X-Forwarded-Encrypted: i=1; AJvYcCVgqWZQvrgDdWgcyPLMx8WkHYfjSKVmZ+ORbT6oUthXkwBNe+J5m/nxCzECnyUmGrNjesR4fZ7bSf+gIsU=@vger.kernel.org X-Gm-Message-State: AOJu0YyocC7JKrTPpmvTL9u6QxxV42caKtPG456FYy9OhD6nylRAglLX r7/2vmts20m7RyJTfLegbMMp7EHhG6m6DdXVWsLcByieNlePlfZep/EEln/sVynpFV6wSC4zDml ayuZbp5W1amOkOjL6kg== X-Received: from wmi8.prod.google.com ([2002:a05:600c:208:b0:485:513d:66da]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:3b16:b0:480:69b6:dfed with SMTP id 5b1f17b1804b1-4855671e83bmr211989475e9.24.1773662538650; Mon, 16 Mar 2026 05:02:18 -0700 (PDT) Date: Mon, 16 Mar 2026 12:02:17 +0000 In-Reply-To: <20260216-rnull-v6-19-rc5-send-v1-26-de9a7af4b469@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260216-rnull-v6-19-rc5-send-v1-0-de9a7af4b469@kernel.org> <20260216-rnull-v6-19-rc5-send-v1-26-de9a7af4b469@kernel.org> Message-ID: Subject: Re: [PATCH 26/79] block: rnull: add badblocks support From: Alice Ryhl To: Andreas Hindborg Cc: Boqun Feng , Jens Axboe , Miguel Ojeda , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Trevor Gross , Danilo Krummrich , FUJITA Tomonori , Frederic Weisbecker , Lyude Paul , Thomas Gleixner , Anna-Maria Behnsen , John Stultz , Stephen Boyd , Lorenzo Stoakes , "Liam R. Howlett" , linux-block@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="utf-8" On Mon, Feb 16, 2026 at 12:35:13AM +0100, Andreas Hindborg wrote: > Add badblocks support to the rnull driver with a configfs interface for > managing bad sectors. > > - Configfs attribute for adding/removing bad blocks via "+start-end" and > "-start-end" syntax. > - Request handling that checks for bad blocks and returns IO errors. > - Updated request completion to handle error status properly. > > The badblocks functionality is disabled by default and is enabled when > first bad block is added. > > Signed-off-by: Andreas Hindborg > + fn store(this: &DeviceConfig, page: &[u8]) -> Result { > + // This attribute can be set while device is powered. > + > + for line in core::str::from_utf8(page)?.lines() { > + let mut chars = line.chars(); > + match chars.next() { > + Some(sign @ '+' | sign @ '-') => { > + if let Some((start, end)) = chars.as_str().split_once('-') { > + let start: u64 = start.parse().map_err(|_| EINVAL)?; > + let end: u64 = end.parse().map_err(|_| EINVAL)?; > + > + if start > end { > + return Err(EINVAL); > + } > + > + this.data.lock().bad_blocks.enable(); > + > + if sign == '+' { > + this.data.lock().bad_blocks.set_bad(start..=end, true)?; > + } else { > + this.data.lock().bad_blocks.set_good(start..=end)?; Taking lock twice: TOCTOU. > @@ -118,6 +125,7 @@ fn make_group( > home_node: bindings::NUMA_NO_NODE, > discard: false, > no_sched: false, > + bad_blocks: Arc::pin_init(BadBlocks::new(false), GFP_KERNEL)?, > }), > }), > core::iter::empty(), [..] > @@ -155,6 +160,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit { > home_node: *module_parameters::home_node.value(), > discard: *module_parameters::discard.value() != 0, > no_sched: *module_parameters::no_sched.value() != 0, > + bad_blocks: Arc::pin_init(BadBlocks::new(false), GFP_KERNEL)?, It seems weird to construct this Arc in two places. Is it shared or not? Alice