From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795980339; b=gcv/zysWW+iL2njQNXZYX3CrJ0auAFHN6wYdG3LVqv/3bl1BE2nraZcSs9cETsgJC5e2 5ePRbWB6sHg8WIwN6CGdzJOd+ejlBxuXx5dBARDiSRU4HgT0NqXW8WhKaZYtqvDvcJyYE Z0wxVKkdkR22D6kwfr6ujwJE9R+HleY/wuWRS/XrwFn02VTrFMrk/KVnV2O7i797Tc+l1 KibnNOcsyiSlxHWGnPhc8UBzwGMGQ+M1lShObND8rVP99nLsjLsckps1Bl0J7gRt221yK x9XMpy4QQV7pavhdStuSjUDJwHNMH7JkL1gjaAShn7yg61Q28iSPDHNrgtpE6+w6xmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795980339; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type:Content-Disposition:User-Agent; bh=hcxHN1V0Y1PfQk8+MATQ1j/HpPSizsxLtS/esMcSUBI=; b=0FjtH7oEmQx3jva/QQFziU8NsXgzoNAzAb8kkbx6dz7o5p5mpvoIAeYAc6BCFJSDQ5dO mnfg1Gj67h9mB15zo/k/o0uZzQAw6gWkZwQHYodoYWDbIMG8oAu+mjQPMjCvjYrZDZ22k BT+Sp8AgsOTSvcTI+n+R7Se+sNsD2dPFkZOKw+wJfvlwqMFPPtJD1/6ZOw5/99auoetoj S/EUyhmWf0OARw8WbYM+jEiWNLPUqWl5TehDL8eUt/32qMNT+rZO8CvgaQUCvrHhy+POY 3cmtEQ0h7o+VefJfiaCt03mDXemPB8X4MJG1DZJOwunsXiSue8Rq/AZ/EdMmE/qms3w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=chrisdown.name; spf=pass smtp.mailfrom=chrisdown.name; dkim=pass header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=N54e2Xuq; arc=none smtp.remote-ip=74.125.224.41 Received: from mail-yx1-f41.google.com (mail-yx1-f41.google.com [74.125.224.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42D1E606A6A9 for ; Sun, 29 Nov 2026 19:25:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 42D1E606A6A9 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.a=rsa-sha256 header.s=google header.b=N54e2Xuq Received: by mail-yx1-f41.google.com with SMTP id 956f58d0204a3-67be1e468a8so9212557d50.0 for ; Sun, 29 Nov 2026 11:25:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1795980338; x=1796585138; darn=vger.kernel.org; h=user-agent:content-disposition:content-type:mime-version:message-id :references:in-reply-to:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=hcxHN1V0Y1PfQk8+MATQ1j/HpPSizsxLtS/esMcSUBI=; b=N54e2XuqJn+XxgWitry2vsTJjXp7/iNISBoWEb5OjM4GspAChBZiCXJV0nOn5IvBYL i9HciIXgfrgqOKKaN/StopAqEUXjoWqdM985jthUUfwWc3KpIK+ttiyPcpcmTFiMwzEI EVH8WVfGZiOU8i5/DNUCzRB07yiTkOZ2LYNTU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795980338; x=1796585138; h=user-agent:content-disposition:content-type:mime-version:message-id :references:in-reply-to:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hcxHN1V0Y1PfQk8+MATQ1j/HpPSizsxLtS/esMcSUBI=; b=tOsEaJ96iQs5FOrcxJ33Sfyk5/d30HXLtKKnOO+ESwKYJXhOhUJziAR+IddGm9Keva /IVi/oEFwZZ2beroNHtfb0LgFB7UTIn8j9TdVgIHC0sLyDn1dXPMDcd6B8DhjawGZfWR 5ahklF+5YB1sZcvH234WpGXoHyBNyPYp0b4dleSIwuAPEd61pqRe6ftJsEbj3aLIId7W xUOePfinBrt8DOU4r7snnmy1GTWUV0P48q8Yi0ZjvjU3oqucXwu6eF4whIJhFAEuZ8Xn 0BGollow/EplC1P60Dx9bwB6KQt07V7bEMwJlU3c1SwWmvK+Cr8hG0rBYHaOX/0UCBQD LvxQ== X-Forwarded-Encrypted: i=1; AL+hErHrfT7zsOEzc/GZSefkzFa+eEdsY7DRwVBGq0mpxDrueJ6nMqnC5yZzc5KdgiBAViNGmUFUsxTPLqibARk=@vger.kernel.org X-Gm-Message-State: APuU4Z9e1160tjZvaiFYN+Lltn36WmkxlAYS0rRxusO7WKMO60aY6lKm BuILA8i1MYnFQTtUz1LdSgLQ1Yi8hHhRg7SKnqO0TBmYf/QPdvQqeAwUAzuX649Gse4= X-Gm-Gg: AZFdTZdMiy2JphbI0xIIoIONoIhPxAF73RUHHM5jGlPUjvZ2JwmnyLPgmMEpfHBtgfu hxX7dnWtDOrzd+NHU7vDNr2wE6tVHP0FhT3agZi2Y8rhr282+qUiHOccPrU6ZkisPfQDHlB1WZb e7dwdiNkbCBOW0ZhLzcCI9KPLE+4NchvYJ/FDt2fZAFHlhJGmBMXOQnU0OO9TBn12u+2QYXwMKU b9wRrCnrPmJcYD1vYYdh+WKeKBm/YeB3Bz8eVbmhWZ8GGCVgM0YMIVPsqIzrLuvbf2AGNBY7z+Q fXF8gyI63Gj9rek5wktNsm9EBAZs8hzDxx+mhmsdAYVMi4jl+qx0ZrnLmDLKySfgA11zZST+Bpz Wg+NjFD+8SyqYRCEmIpxdRa97DOM/BXFxLWmIdYldmxfYZ1M4733CsiBf18/lf632nYBcU8pdY4 sPYXMRiHxWdnKW0rkHjjGaeji3wHqfTMEA/4hxXMcUdZOJHxAjE5FCb+YUhNVqkDZXHn94u4Bxx 3jIujF1fyCwff8yDqR3ocQFoRMxNIejCPsS1BPfA4XaydEXYknpGwDraQoJF5Ia16D4Mnfp1AZs EFRdNqMHi7XXbiARgPl7bGLheI2Wz79B3jv4+hJtH4i4420wD9O62FlHoK6KDWjgX+0JHLbyPAE +FzIyHKuXLKO5dOX3vDemodCpvbd8bM1LzXGaL6xHonr041EGZPVITQZGQ9/TpxQMDBXejyKLCf wCnDyuSyrMGyejQOXe7DJh/OS4LgxMud/RYboBc1pVStU7aNxQv9UFMNhT6CxdZS10edD2UDB6h 6mmvGtYdI0R+3uBpKCntqk= X-Received: by 2002:a05:690e:1243:b0:67d:babd:b806 with SMTP id 956f58d0204a3-67df43ce30dmr16068233d50.32.1795980338326; Sun, 29 Nov 2026 11:25:38 -0800 (PST) Received: from [172.20.0.2] (c-73-207-185-9.hsd1.ga.comcast.net. [73.207.185.9]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-67df3354fe3sm14108132d50.10.2026.11.29.11.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 11:25:37 -0800 (PST) Date: Sun, 29 Nov 2026 11:25:35 -0800 From: Chris Down To: Bart Van Assche Cc: "Martin K. Petersen" , "James E.J. Bottomley" , Christoph Hellwig , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v2 4/5] scsi: sd: Fix WRITE SAME(10) count truncation when the mode changes In-Reply-To: References: Message-ID: 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/2.4.3 (cc9e3943) (2026-10-09) Hi Bart, Bart Van Assche writes: >1. max_write_same_blocks_store() was missed. It still modifies > sdp->no_write_same and sdkp->max_ws_blocks before > queue_limits_start_update(), and calls sd_config_write_same() before > queue_limits_commit_update_frozen() freezes the queue. Yep, I'll move all of that under the lock and the freeze in v3. >2. Both here and in sd_revalidate_disk(), sd_config_discard() and > sd_config_write_same() mutate sdkp->provisioning_mode, > sdkp->zeroing_mode, and sdkp->max_ws_blocks before > queue_limits_commit_update() validates lim. If > queue_limits_commit_update() returns an error, q->limits keeps the > old (potentially larger) limits while sdkp has already switched to > the new mode. That's how it is before this series as well, since sd_config_discard() and sd_config_write_same() have always run before the commit. With the check from your point 4, a request that was sized for the old limits is failed instead of being truncated, so I'd rather not add unwinding to this series on top of that. >3. As sashiko-bot also pointed out, in the `grown` path: > - `if (err) goto out;` is checked after `set_capacity_and_notify()`, > so a failed limits commit still publishes the larger capacity and > skips sd_zbc_revalidate_zones(). This one isn't new either. sd_revalidate_disk() already set the capacity before the commit and only looked at err afterwards. The modes have changed by then even if the commit failed, so the bigger capacity is still one that they can address. > - queue_limits_commit_update() unlocks q->limits_lock, so > `if (grown) set_capacity_and_notify(disk, sectors);` runs unlocked > and can race with a concurrent sd_revalidate_disk() (from > sd_rescan(), sd_open(), or cache_type_store()) that shrinks the > disk back <= 2^32 and re-enables WRITE SAME(10) modes. Yes, that race is there. In v3 I'll set a grown capacity under the limits lock, so that it's always the one the current modes were picked for. > That's another strong reason to also enforce the LBA/count bounds in > sd_setup_write_same10_cmnd(). Agreed. I asked Christoph in [1] whether he'd rather have that or a fix in the block layer, but I can reproduce the partition case on v2 with scsi_debug. A discard through a partition that still ends above 2^32 blocks after the shrink goes out with LBA 0 and unmaps the start of the disk. So I'll add the check in v3 on top of the mode changes. It also takes care of the unsplit discards from your review of patch 5. Thanks! Chris [1] https://lore.kernel.org/r/awqeVFzX-t35Vvs4@chrisdown.name