From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795980339; b=VaKsiH9GP1wzj5giNoVTCxMQbCPbYj9T5F+p8Mz3p6q+rtLTywp6jIAdRq+5Nt+r2IJ+ dXpQiZBI79CZouOAKo2L0CdXGLP676Y4+eoxtg/e7goOB5x2UbaHPec38hTLJwqysqpK5 YSoZLI305UC/24tGJIpuYb8G5ViIIWjGJdkhRP8fv4GPBaCpaP0EOIdtb9kXY4/on/oTc Yp6f35gqAkW4Jd+yCqE+hXKET8XS2oh1zlUDRQr82OOD4u1kXvzUfaEsfAZpoQAPZFO7O L06/c1anjvuATgRMyahJKB1olUx11fl284wE0+CAAl+Ek0Zuv6NJxeoxRyXzWWLBriw== 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=a/D4D4TQO5JJx7DWJo/HrbCt/zmK3Bl+xO8s/JgW7v2b9w4cOD+qwxYkzH73kJIz0LnK wx1UdDxSrFOa2OtT22MzPu/M9pHT+Rxn2NYe3QAHaUWWpQxaDfobyBsb4Dl4hUzKgHs1b LVgx8AyN9Wgyq5KfNOXl6e5gtXYTeD5L7Dc148DNW71vm93u5FeY0gOuDvO9/9ql8Gkuf PYTkev/+JeGxkPHxmhc1E/WUzEUx8frRcHGuyu1IBv9a52Dvuu/7wDmddYqLNdI3SXI5v j6ykwB3MGzQ3lrRkfyFc/8ThSV7eo2QWAelzpIKxR4OJw9Xp0FVvP1hZaMzlWWrf5pA== 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.52 Received: from mail-yx1-f52.google.com (mail-yx1-f52.google.com [74.125.224.52]) (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 319EC606A695 for ; Sun, 29 Nov 2026 19:25:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 319EC606A695 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-f52.google.com with SMTP id 956f58d0204a3-67db6d4054eso10540324d50.1 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=hA6hXsbnqE3s4iikD4AdR0NPIg5k29ZRW5YtmmOfga5Q6cJmm9meRIXtG/E0l3C3Gu fbKj2pEzeC1g4CdqnTHTCsFAeuemwfj9rGLxp/RNFMbRNhEHJJuY4I49ajVDvEa+7+9S xDP0YxLpx9msANocWu/CuiTJ/DSiRoJkkiR7kvp0KXaZVqfZmXXBgD9N5aICcLl/GZ9J ZnYvdHLnZwZFcFn5gC6lDR+t09L5nUPvOpB2lmL0+yOkYQ8AowgMbedrcfy3BqyENgX2 dkT3o98YcsvNIwQCTIw+ZS2KKQdpvYYz2tvw92XV3DpKh3PNfwmpNwrg2uYhc0r8ZlAl kFRw== X-Forwarded-Encrypted: i=1; AL+hErEoEpOoj8K/f5cCzJTAGqD4Y3a2rlbOpEGWfhFjjl5sxp0/qh2wbLIZ0hhTeveYr3cusa853as4W0tX@vger.kernel.org X-Gm-Message-State: APuU4Z/lKXkAwIckfDbTbgXTO2iO28mlRTGWIvqIX4iA7NTOUtmLrjkA hfolmJKIc21C9ai9XO4bgjF745/QIFKAeLNjMJMQ++4sKZBC5yWLz43wDoBN/IJ2jDs= X-Gm-Gg: AZFdTZe2xD4//2jxwY0vDT9A2ifd7Tfn73GVIthQ1VnwZVAHhGKwXp9dMd3HuKx0zuj Vyma63AmeSd162sxEwHRRWb2mAbdGHlSZo+WBFq2LdgMWRuLND3RhdX1V1ZsHuipSizh1w0CFHr u+StoZlXFF4qRBdKJvnI0fPj5uG5QTJFUXjVGhHOrzKBvfzzC9eP0wXlUv41VIVhiiQrqhGcE8/ nTffK9coGkIzsuejy+lC5F7GJX4+WizqMbv3kmBv9MKUDuCW5sgTGD4kecHAwygFQpWIQ6+UgUt DSS+meRMZo2ooUJaF2g2jijx+2Q0pqA1Bdtvt4ALsTEb/gwl4EyWe5atl5h9wMMruOpvQs1eP7O q3FMuJLUoLzW3DtX/1hX/iN4a99yUdkyX+cjQYWwXSbdrX1jL96mk/NIJuF/xmP8qovKr47ea5U bG5o4ml6j2c1UHoI2cYHPyvLg6JP3T+Ixzk8L6gB1GKzPWU9tg13OLeikl4JNk6VCzwrpMhQTdW t1KU5nsSPuc0REq664+4dgtHR0bDiY1PvKRZnnCq4KASRIcxytGefGDBKP1kfLwhd36EmaSQNxi HbjngF9OMgkWDx+wflS7XDUgoWRR6DqwWLq//XMADUY47o8dZE4LWTTOj61KrAcZCV6F6JDL6G6 tKPrkrHdYn8bYgsR9yyrCNgdikeSq8egamFoVZGlM0Ac1MieURAdx8CloFfqF9pC8gI1uSXxjcS hD8asNV1TqLRw6mFk+oke2EX0rzuJiQ/DjFGjuX+kXwp5cbXP0Lo8pHaUR8N1rQgpb1ZzNCPQAe lHYp6LWYPz7IXFsNX9zI7E= 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-scsi@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