From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796063762; b=s5Y5gQmCdNOYr2VXWYhwr9rIvZRIj2LfJEHRq2w9Es68Q0lPEEKi2i01QfI+uaHsfwxk Xex8L80bUfkPWlKIOwgq7S9u2M+wD6MHENgfubMHNOy2F2nWv30a3d8QshzO53TF7bFzJ 2pL7wYkPtXLW1J+aSyyiSdfhKj/o+dfTbXKTh3yuZAHmDMYvbtMWG1YjNnq6SvMv0XEPb Ek0u5VwmJBVTZjx28oRKo10KBfvElmmXN8zFTXpDWTFCbaq3C+yKHM+D9X2rNOaxz6N7v mKxUB57ILuEUOnklvrli9/qJpz+1heFeOE70HzfkhxwhRktUODaLV959NIhHCV/mxsA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796063762; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=8uxw8v1t85wKPbee8tWCXR0S1EquajcEwIriQtsDUlA=; b=hMbT5Y0v01inTZtYrZzYwgT3AnW6JCaV3g/ne4x01uba6r57I6r/opAv/8BtKLyQYpJB 3eeUs4EBegO4si5K+6xlrEEK/ZMJpuGvCe2076VNME3ECXVr49KK4+Aq/3SDduQSn17RT WYtLWX7b0vjawYsVsl1usKgcYZ703HP6hiAJCyQPznLgrjIqViKkpPz8inaS1cC8IWtkA XSIiRcJBx94QsgeJW9Ese0lQUnVwwPG5+uEes8pYxYlU2AcViX7JotpS0bg4Sa/2gGns7 mjLQdwUITsgroNaiPu+Jc0Sc27Zb7wXST17S1L2qVoWOK7KIEhEEcQPTlFh+jfFUxdw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=maQJErrj; arc=none smtp.remote-ip=95.215.58.16 Received: from mta1.migadu.com (out-16.mta1.migadu.com [95.215.58.16]) (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 4AB7B606A31C for ; Mon, 30 Nov 2026 18:36:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4AB7B606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=maQJErrj X-Envelope-To: linux-scsi@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=piWyADcg3TEHR1CPJrVHD91bKRrtrULi/DpczvVoaG8=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796063759; v=1; x=1796668559; b=maQJErrjcM/ywr+CvBMT/V82nnfYh/rYAeIMjsIkUN/45Q6ZNQalINWMKYc/ViCwzpH8opee 3uGRG3WP4Ew8u56Bc3Qrko2LfhgGX4WyEOIxwbYQt/G5VvFvAq/hJQmbOdA0ERPw2Fl487wFCh9 2Qyziy6tLxtUtnd1bi7UoPJw= X-Envelope-To: linux-scsi@vger.kernel.org Received: by mta11.migadu.com with ESMTPS id 76df11b2919f6106; Mon, 30 Nov 2026 18:35:59 +0000 X-Mizu-Trace-ID: 76df11b2919f6106 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Mon, 30 Nov 2026 18:35:55 +0000 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] scsi: scsi_debug: handle protection information for WRITE ATOMIC(16) To: Tal Zussman , "James E.J. Bottomley" , "Martin K. Petersen" , "Darrick J. Wong" , Luis Chamberlain , Jens Axboe , Douglas Gilbert Cc: Bart Van Assche , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261110-scsi-debug-pi-v1-0-539829902b3a@columbia.edu> <20261110-scsi-debug-pi-v1-1-539829902b3a@columbia.edu> Content-Language: en-US From: John Garry In-Reply-To: <20261110-scsi-debug-pi-v1-1-539829902b3a@columbia.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/10/26 18:28, Tal Zussman wrote: Apologies for the slow response. I only noticed this patch from Christoph's review today. > resp_atomic_write() writes the data but ignores the protection > information sent with the command, so the blocks keep the tags of their > previous contents and reading them back fails the guard check. > > With scsi_debug loaded with dif=1 dix=1 atomic_wr=1, every RWF_ATOMIC > write that overwrites a block makes it unreadable, so xfstests > generic/770 fails on XFS. > > Make resp_atomic_write() write through __resp_write_dt0() like WRITE > does, passing a new atomic argument down to do_device_access(). The > protection information is then verified and stored under the meta write > lock before the data is copied, as it is for WRITE. > > Fixes: 84f3a3c01d70 ("scsi: scsi_debug: Atomic write support") > Signed-off-by: Tal Zussman > --- > drivers/scsi/scsi_debug.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c > index a922c8318a2f..7d5065039637 100644 > --- a/drivers/scsi/scsi_debug.c > +++ b/drivers/scsi/scsi_debug.c > @@ -5175,7 +5175,8 @@ static int __resp_write_dt0_dix(struct scsi_cmnd *scp, > static int __resp_write_dt0(struct scsi_cmnd *scp, > struct sdebug_dev_info *devip, > struct sdeb_store_info *sip, u64 lba, u32 num, > - u32 ei_lba, u8 group, bool lbp, int *scsi_status) > + u32 ei_lba, u8 group, bool lbp, bool atomic, > + int *scsi_status) If you check do_device_access(), we write all the atomic atomically under sdeb_data_lock(sip, atomic) - should we be writing the PI also atomically (along with the data)? If so, I appreciate that it would be messy to implement. Thanks, John > { > int ret; > > @@ -5191,7 +5192,7 @@ static int __resp_write_dt0(struct scsi_cmnd *scp, > return ret; > } > > - ret = do_device_access(sip, scp, 0, lba, num, group, true, false); > + ret = do_device_access(sip, scp, 0, lba, num, group, true, atomic); > if (ret < 0) > *scsi_status = DID_ERROR << 16; > > @@ -5286,11 +5287,11 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip) > (sdebug_dix && scsi_prot_sg_count(scp)) || lbp) { > sdeb_meta_write_lock(sip); > ret = __resp_write_dt0(scp, devip, sip, lba, num, ei_lba, group, > - lbp, &scsi_status); > + lbp, false, &scsi_status); > sdeb_meta_write_unlock(sip); > } else { > ret = __resp_write_dt0(scp, devip, sip, lba, num, ei_lba, group, > - lbp, &scsi_status); > + lbp, false, &scsi_status); > } > > if (unlikely(-1 == ret)) > @@ -6328,6 +6329,7 @@ static int resp_atomic_write(struct scsi_cmnd *scp, > u16 boundary, len; > u64 lba, lba_tmp; > bool lbp = scsi_debug_lbp(); > + int scsi_status = DID_ERROR << 16; > int ret; > > if (!scsi_debug_atomic_write()) { > @@ -6384,17 +6386,18 @@ static int resp_atomic_write(struct scsi_cmnd *scp, > if (scsi_bufflen(scp) < len * sdebug_sector_size) > return DID_ERROR << 16; > > - if (lbp) { > + if ((sdebug_dix && scsi_prot_sg_count(scp)) || lbp) { > sdeb_meta_write_lock(sip); > - ret = do_device_access(sip, scp, 0, lba, len, 0, true, true); > - map_region(sip, lba, len); > + ret = __resp_write_dt0(scp, devip, sip, lba, len, 0, 0, lbp, > + true, &scsi_status); > sdeb_meta_write_unlock(sip); > } else { > - ret = do_device_access(sip, scp, 0, lba, len, 0, true, true); > + ret = __resp_write_dt0(scp, devip, sip, lba, len, 0, 0, lbp, > + true, &scsi_status); > } > > if (unlikely(ret < 0)) > - return DID_ERROR << 16; > + return scsi_status; > if (unlikely(ret != len * sdebug_sector_size)) > return DID_ERROR << 16; > >