From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=199.89.1.14 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795919992; b=ulDFpMTDVfR2W7x6bg5zNrLEnC26DMCVOEw/gYHdyRae3kn/olIAzmkju0DaTF9/hopq PZsGqf50fBnTc0Vom900YcrOOSORRC4UoxTNAeO5U9wYAbuSxA36lo9gL/J4qJy5iGu67 593/CjFp1HNDZShC5DpkesRruAzY5Nm9jn8f+XxCG/reAzaiup+LOcLj/yEJp09HKWaD5 vjIa4rU0a3WlMBWSEFcOHSP5rXrT/EOWYpoZN+ULfV2zPUB4oOKoh2fEwjp72zpuIrSw5 hPelLJCXFbzfTiYp05OdKy+4ZNYUEOZm5WC6o3OYlMmLiq6D1UzdI2m1iRmsHugxE9Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795919992; h=DMARC-Filter:Received:DKIM-Signature:X-Virus-Scanned:Received: Received:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc: References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=lZpDBN5qBGDnQ8w+RyA7SaTdymDQz4YQ7WYLHqJBJe8=; b=kkZn7b4GPJg19lLOtyod0b9oYpAogd3tw4uEWETZ9Z0ltQehnfW7fWYOp/CrgomhpHG+ 3tHwDy2RMYXyLloXnDMlA8DZpyR7GCHmtzXibucmvhYvABy3lQJZIucWri2xm+ncpiNgP vNp//zm3MPiENLnl+8oUkA5JxmepVWw7I2CSCpzBnHalp/hMGWUFMhCKBU3AnurOg1ynI 8+z3rJfQNSvU/+qGrHHiMt5R+Q+91U0/hr5nkG8HPYsF8+L0nmkTBp/OpNL+hiIeEYNxf QN2aBOVoTuCkI2zluOEupS8jXUzq5Sh812lxVWZmBbj2fnMzlRnEFFZXX3dZ8UHOvUQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=k0pFTHTh; arc=none smtp.remote-ip=199.89.1.14 Received: from 011.lax.mailroute.net (011.lax.mailroute.net [199.89.1.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A98A606A324; Sun, 29 Nov 2026 02:39:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9A98A606A324 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=k0pFTHTh Received: from localhost (localhost [127.0.0.1]) by 011.lax.mailroute.net (Postfix) with ESMTP id 4jcWZn1LBdz1XM0nk; Sun, 29 Nov 2026 02:39:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:content-language:references:subject:subject :user-agent:mime-version:date:date:message-id:received:received; s=mr01; t=1795919983; x=1798511984; bh=lZpDBN5qBGDnQ8w+RyA7SaTd ymDQz4YQ7WYLHqJBJe8=; b=k0pFTHTheulQ29dwrhV+6APoKwkqTdBi2178zNre ezzyytJDduyh5BMPB60HVItGCybN0IojE/sxwbpkuQoEUXguTrZT3str3dsVBU9S R2hpyUe4CJNLdAylHctuWf0puH1mKTZyIU7ELw6D3iImty9iDOgh9x5D9qWeTHwx ooZ7UDuonT+wpwuI9QbrX9jORBahbgp7gKT3P1riZDT+hFAXFCnKBXHzp0KvgDFy W6/+bY9gADmWGuRdvNjwuxhmkAT8vAchWWkNlvF9Ta5zt7YmBGwKBqq9mzh0Io4y AaHXo8HjdOMXWPVltBByx9q+i8AyUINSHfXZM/pbc0YYaA== X-Virus-Scanned: by MailRoute Received: from 011.lax.mailroute.net ([127.0.0.1]) by localhost (011.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id fWx0UDT2ccl3; Sun, 29 Nov 2026 02:39:43 +0000 (UTC) Received: from [192.168.51.14] (c-24-6-239-25.hsd1.ca.comcast.net [24.6.239.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 011.lax.mailroute.net (Postfix) with ESMTPSA id 4jcWZk5Ghkz1XM6J6; Sun, 29 Nov 2026 02:39:42 +0000 (UTC) Message-ID: <24cbda94-6ac3-4979-b2b9-2bfa6891901b@acm.org> Date: Sat, 28 Nov 2026 18:39:41 -0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/5] scsi: sd: Fix data corruption in WRITE SAME(10) discards To: Chris Down , "Martin K. Petersen" , "James E.J. Bottomley" Cc: Christoph Hellwig , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com References: <8b760dc9733401f8fb5161877a705f4d746e1d32.1795842371.git.chris@chrisdown.name> Content-Language: en-US From: Bart Van Assche In-Reply-To: <8b760dc9733401f8fb5161877a705f4d746e1d32.1795842371.git.chris@chrisdown.name> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/28/26 1:26 AM, Chris Down wrote: > lim = queue_limits_start_update(sdkp->disk->queue); > + /* A revalidate updates the capacity under the limits lock. */ > + if ((mode == SD_LBP_WS10 || mode == SD_LBP_ZERO) && > + !sd_can_use_ws10(sdkp)) { > + queue_limits_cancel_update(sdkp->disk->queue); > + return -EINVAL; > + } That comment isn't correct for removable devices: set_media_not_present() sets sdkp->capacity = 0 without holding q->limits_lock and without updating get_capacity(sdkp->disk). It is called from sd_check_events() and from sd_spinup_disk() (which runs in sd_revalidate_disk() before queue_limits_start_update()). So on a removable disk with capacity > 2^32 blocks, sd_can_use_ws10() can see sdkp->capacity == 0 and allow SD_LBP_WS10 / SD_LBP_ZERO while get_capacity(sdkp->disk) is still > 2^32. Thanks, Bart.