From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795980340; b=tjal3DWjUYnzvhgEVk9gXjsSqNhsMDpybzxlxJgReanDB5gBocYaQw7ESG9sFtNtyQxF FctFa7ewwrwEm5uqzqfQAtofXANGQ+Hgx/qWsHPeB8sKBv410xNIu6HR3RgXX0FZdursy QjpRM6+5Km0ZFBSJGjrM+g9oMOVIUhB4WEJ67kIe1wIMwHMaq/2n3oHBPsKIwdnKn0kMh 6xWRug8Mxhovh82tXO800Mweh0zsBBUlQHsdP6q9MojkFB35tt6FUho2x69DZgHiFWMfI yQUWfodC1Io1YRchkAqBKT/Tf6diIulvg56rgIXXrM0hi+lq2dRPCmbRVIFtXmHgUeQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795980340; 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=weQ1MP23WLGxJ8R1KxsYs9AL1X14UDP6yGvqqKzZ7hc=; b=qnVpV0iXB6AhfrBrWPGySSWpqsKliKIxpTvVg0B1VWVbrK3XoL7GxgiTHBrzsLDiGGna E3Yui+kBbVI1bLiO+wpzFTvlM1zLCTNRVj/oCV2YTnPrNv7pguttQOe4Vqj9EbOvzQjZo mMG2pZXzra32KRAO/zDwaiPxw7w3W+AfDWvtZIsQ9ovPxxXfNeQYH2jahZN4U6I1DeeYR qYHUQ297D0FoTHaw/RFQREbl1yNhPOfgspXg2xUIBms69Vswzev0zyarnj0rVI3RPJhxG SP/mqegRcYsSIe5mIQ8UKCDCmNzl1joSpXGbzl2cMmZzruEJRro4jOJCZY9kJUeQF6A== 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="sSz/NlxA"; arc=none smtp.remote-ip=74.125.224.48 Received: from mail-yx1-f48.google.com (mail-yx1-f48.google.com [74.125.224.48]) (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 7627F606A33B for ; Sun, 29 Nov 2026 19:25:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7627F606A33B 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=sSz/NlxA Received: by mail-yx1-f48.google.com with SMTP id 956f58d0204a3-67df3b1ca06so10764943d50.2 for ; Sun, 29 Nov 2026 11:25:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1795980339; x=1796585139; 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=weQ1MP23WLGxJ8R1KxsYs9AL1X14UDP6yGvqqKzZ7hc=; b=sSz/NlxABC1mTGYGypHh+2xq/yypXwwO7P0iKICQt/eoVfb8+LO2Yc+JJVsWUeZxx4 e4VP0s5ydzsbhJ8al5MzWW5mv4ms3O+pus+/vVHS7hQ9EIw2LrrzlbSc2vvdfvn499Wo B3pcUCZjVb2cBm+ShJjUDkh5lcadyAZjNKUjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795980339; x=1796585139; 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=weQ1MP23WLGxJ8R1KxsYs9AL1X14UDP6yGvqqKzZ7hc=; b=2qI1/A4QsHKC4ZHz+xjPazk8OJPDMZGGvgGY/hJdB6Q5FT2Uh5Z6wvzTu9wf84hgHm LIqMGsOZwC1fr2guJ8kgZ2feHsor22by+OGAs37eHE+J2C/Qn6wLmxFL4Fo8Fl+ZNrtG E2CeL6Ma4nrDOSLY3jG6C6DWhWZTXCMYsHaGQyHwQfqmQbwHQIgIXvK/2P+OpPiIYYJz KhlZ9Wwu9KJ3c36ZZccGZzZL5RUbwYE7DEK35Sc0A644Lyw2K7qiixovaRwOiy39ZMGI EV3Dq9mZ8kUB1f9RF+Hx6dURXae9YnaPfeNX09ocgMwsxL60vH2D1eLAoQI6Q8hF78pF vclA== X-Forwarded-Encrypted: i=1; AL+hErGIx+wrWaLJmJP5wTp6DD62BxFtHYNhuyuh5+4VdylY3l5GJZE8z6ccnEeTuSh5IEc2L2VEXkCSTnpv@vger.kernel.org X-Gm-Message-State: APuU4Z9YIbMPYbDP2isfCsDWp3R5e29HlSKJxJBKmLFxrTaxSbyiQDU3 whX8AItKRFxCc00ux/dq+7kRxZVP3MlXx63PMqT7upTgJo9AbpXwIV5AoNjAxpjlDeLuiD6QvFH efaYWXkTRk5n430M3YQ== X-Gm-Gg: AZFdTZf7sQYMmmQ04cP11ybnol8PKEvyE57Gg5foK/+/YfVD7wh6VWGs57YjIWdFqFO C8R7gWqmE3M3WJCtASzScdVr5g39OetLXcHAwPsWgKXk1NdnQNr4MSjinvEg/ML14gUskxK9NVI 14/wFpZY3RaONN/jXrPepyYiynvPV/iqOhpDFYEwviha3mg9/nHFQza7mzg/6CzycCa03uej0Rq YGXEL5jddB5QCW1B65FXhpSqffASAnm3JtveXLtNlIX9L7IW+fEfhaNZl77SpRkpcI3exPq8zUG nWcKgOb/BPoV1mJkalP54wCWWbtr78s+i/kXv56ZF+GeWePlreZLuCi8wEZyw44M/rQIpHKnSU1 FCZ5CWsgxUUSv3ShTR6mRmjizRhY4rgAp7GU1sNWJ1IVBo5P6CX33z4yZGaQiSZgwnCYHTaB2bD rfLido6Z2kgNtbcSR43fNxX+P8bwuJli9MoUjPntkcY0CVKwvp3imqy67q2iHUliwCT4LlF55QU UBg61DpK9TIaa44PeVAvaHsASW0LcDVVRF1zHsGkV/2/EuFMVJnSAVm7m8TuNSx87sRONC7GXuX BYrUjZzfp6OYWgFwuQ8SyOPeXndQEhrqV4y6wBAHH2P36bn3Yhk8fan1CUJI7Ol73R+yCpHJ6Oz O0ld5oH9dczoQpUlo1UaGh/tcUVMS57OIvzLGRCDEs8a02ibqrHxDeZivjevM2vh7+8kGh9TrKr +EUFdI+q2iEeSzhC7OYXpocJQBonmkr9hgTQa/HmWe1TYKtg3Dx9zjFV0lJSzWyRgcW0pfdBPXe u2VSITHeYBEVjaBQn/6a9w= X-Received: by 2002:a05:690e:1381:b0:67c:ace:30ec with SMTP id 956f58d0204a3-67df43d0726mr12171674d50.29.1795980339573; Sun, 29 Nov 2026 11:25:39 -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-67df33d64a0sm14723789d50.22.2026.11.29.11.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 11:25:38 -0800 (PST) Date: Sun, 29 Nov 2026 11:25:37 -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 5/5] scsi: sd: Fix unsplit discards when the granularity exceeds the limit In-Reply-To: <73aefcc3-319d-42a0-afae-7b88ac6594dc@acm.org> References: <6e833f169d0c31a3a7da7581c68d4aee5d348ca1.1795842371.git.chris@chrisdown.name> <73aefcc3-319d-42a0-afae-7b88ac6594dc@acm.org> 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: > Since this is a block-layer invariant (already worked around in mmc > and drbd as well), shouldn't blk_validate_limits() and/or > __bio_split_discard() handle it centrally? Yeah, I think that's the right place for it. sd isn't told when the user limit changes, so it can only ever cover the case where the device's own granularity is above its limit. I'll drop this patch from v3 and look at fixing it in the block layer separately. With the check in sd_setup_write_same10_cmnd() from your review of patch 4, a discard that reaches sd unsplit in the meantime is failed instead of being sent with a truncated count. >2. In provisioning_mode_store(), if the user explicitly writes > "writesame_10" or "writesame_zero" and this check overrides > sdkp->provisioning_mode to SD_LBP_DISABLE, the sysfs store still > returns success (`count`) instead of -EINVAL (inconsistent with > patch 3). That goes away with the patch. >3. Pre-existing, but right above this hunk, > `sdkp->unmap_granularity * logical_block_size` is computed in 32-bit > unsigned int from a raw u32 VPD field. A large unmap_granularity > (e.g. >= 0x800000 for 512-byte blocks) overflows and wraps > lim->discard_granularity to a small value, defeating this check. Good catch. That one isn't specific to WRITE SAME(10), so I'll look at it separately as well. Thanks! Chris