From nobody Wed Dec 17 01:12:02 2025 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B61CB78C7A for ; Thu, 18 Jul 2024 08:08:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721290111; cv=none; b=j3+0Wc6CjFdP8k0cySDtdOlhK0BngwWGicCitf+VJ0N9HAvycC8S+oDGeruDUD0kLIzTCbCsblvJi6WOzsqOUP7EWMwCl2VE26/5Wz1KIpaeOSxDRD9C9hQtQuOV6glJ9RXe566K6VuVFvVCypfTmUtCISEnmJ5xR5Cu96do8tE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721290111; c=relaxed/simple; bh=qLABD9T71TLKm1suUkJYcBMQCLNJkiu/KGSyf+3z+TA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pVdEc8on5YjEh4qN0RxEOSJmLWwadRI6QjdfN1NBFON903HvYF15Pfh56k0Abjzw+b9w7Ozk/C/g2GwRyS3hFgOj6gQ3CeTd92NkmVcRdVo2cL7ZgtjukIlzLxeeXoUglJHiWkH8R3Ur48fLbeMhI7TpXECHcEI2IOixJ3zYSB8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=smartx.com; spf=none smtp.mailfrom=smartx.com; dkim=pass (2048-bit key) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.b=ZEb0Wvuw; arc=none smtp.client-ip=209.85.167.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=smartx.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=smartx.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.b="ZEb0Wvuw" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3d94293f12fso318272b6e.3 for ; Thu, 18 Jul 2024 01:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1721290109; x=1721894909; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IR8iierOPTZzBaSqo6PfOiKbzROZot6u1VYWUcPh8N8=; b=ZEb0WvuwATX+5Q3DpIELbshQ2UC+dMxvm37Zfl4sGxkmjigyB73lUiJ+ti64mdfFiJ bqmyNYXQF8HeYt4aYAFRGHTO09O1ae4+yQSUgOMa1uGqbYUACzXLqQAveaonEV2485tj gqCAk8YdO+vPEngYt24p05scCPLNOfmH+XWiurDAWoRckvYCghwzr9v6LRKb2jUbYbYG GP3BmVIDAq1sUDiem9QiRNOUqQsj46YQRZ6R+JvalltI1KjIvRLH5kUySB1hHa1iXsIQ 7GgAzxSzOQkKIm/gEO3bag0S6Ml/e31ZVQB+Bt2xoh6Ezrioa3EDNiP7TAD+9pCW0jwg V5lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721290109; x=1721894909; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IR8iierOPTZzBaSqo6PfOiKbzROZot6u1VYWUcPh8N8=; b=xLZpXTwDtjSA8RfHbMCnGzNGVfe7/aRZHFtDLLNHsspKAR6YpTtVScAVMF1IJWbBcC 1c0NgSQ1meiSErsoIYsQGCsBDc2VmRrLdV6HaTyCTQcI6EbCC+baghETTN1jAYmNyhxY 1Pkuwvqut8vOjZ3ZXPrRO6U9lxvbEO8m8o9s1EBqJLpC+GoFHhc7LL8WcGDLG3lhdocR QATbleJ9ZJNjp+KqHJ68zMkbyUMg/FlbzzhUUhQMs+uDVjn2durzBZzzYVQyRrP+fVhF LGxVh1NhziTqhpFQTLUXAjIapX8eEsgwxy99uVkQLw6CSExl0gEVgec1Ap2CBc0aDSYl RSXA== X-Forwarded-Encrypted: i=1; AJvYcCWGNvD9JiuFjNnsKI79S7M7jWnOlMPTF0Tsj5gmNn/v1F6q1fnb2+Ri6vUY9mc1RHjaPmltN5Vfg8CO1FYFSlYwbFuG9RLBFa1f9T+b X-Gm-Message-State: AOJu0YyjiN5pTHlQTIT9B6NtZkkNynfSaInUeEXFiGQJzSegjiXdnOxe YjFKlsOOTab99dQeTeTpYqf4EM0dAjoN1Ip0sxogtKwlweYxejVIL1oWKXg5YYs= X-Google-Smtp-Source: AGHT+IFt/GDmyO6/5KiJNmP9PcE4OTbvejTawUJC8MDoIi9vUQcTBV/LIKuenQfb/Mg/W51y9Y9O/A== X-Received: by 2002:a05:6808:1a1b:b0:3d9:2b5a:4ac6 with SMTP id 5614622812f47-3dad76e96a4mr2141051b6e.6.1721290108310; Thu, 18 Jul 2024 01:08:28 -0700 (PDT) Received: from localhost.localdomain.gitgo.cc (vps-bd302c4a.vps.ovh.ca. [15.235.142.94]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-78e34d2c4d3sm7385958a12.48.2024.07.18.01.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 01:08:27 -0700 (PDT) From: Li Feng To: Jens Axboe , "James E.J. Bottomley" , linux-kernel@vger.kernel.org (open list), linux-scsi@vger.kernel.org (open list:SCSI SUBSYSTEM), "Martin K. Petersen" Cc: Christoph Hellwig , Damien Le Moal , Christoph Hellwig Subject: [PATCH v3 1/2] scsi: sd: Keep the discard mode stable Date: Thu, 18 Jul 2024 16:07:22 +0800 Message-ID: <20240718080751.313102-2-fengli@smartx.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718080751.313102-1-fengli@smartx.com> References: <20240718080751.313102-1-fengli@smartx.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" There is a scenario where a large number of discard commands are issued when the iscsi initiator connects to the target and then performs a session rescan operation. There is a time window, most of the commands are in UNMAP mode, and some discard commands become WRITE SAME with UNMAP. The discard mode has been negotiated during the SCSI probe. If the mode is temporarily changed from UNMAP to WRITE SAME with UNMAP, IO ERROR may occur because the target may not implement WRITE SAME with UNMAP. Keep the discard mode stable to fix this issue. Signed-off-by: Li Feng Reviewed-by: Christoph Hellwig Reviewed-by: Martin K. Petersen --- drivers/scsi/sd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 8bb3a3611851..c180427e2c98 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2711,8 +2711,6 @@ static int read_capacity_16(struct scsi_disk *sdkp, s= truct scsi_device *sdp, =20 if (buffer[14] & 0x40) /* LBPRZ */ sdkp->lbprz =3D 1; - - sd_config_discard(sdkp, lim, SD_LBP_WS16); } =20 sdkp->capacity =3D lba + 1; @@ -3365,8 +3363,6 @@ static void sd_read_block_limits(struct scsi_disk *sd= kp, sdkp->unmap_alignment =3D get_unaligned_be32(&vpd->data[32]) & ~(1 << 31); =20 - sd_config_discard(sdkp, lim, sd_discard_mode(sdkp)); - config_atomic: sdkp->max_atomic =3D get_unaligned_be32(&vpd->data[44]); sdkp->atomic_alignment =3D get_unaligned_be32(&vpd->data[48]); @@ -3756,6 +3752,8 @@ static int sd_revalidate_disk(struct gendisk *disk) sd_read_cpr(sdkp); } =20 + sd_config_discard(sdkp, &lim, sd_discard_mode(sdkp)); + sd_print_capacity(sdkp, old_capacity); =20 sd_read_write_protect_flag(sdkp, buffer); --=20 2.45.2 From nobody Wed Dec 17 01:12:02 2025 Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2765178C88 for ; Thu, 18 Jul 2024 08:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721290119; cv=none; b=XVBbdWPejUptNnMz/06YY9SBPgyupoYl0wV2ASSS1Q62CPjpnlDrkeLboYMji+/EiN6umTt+ml5ttzOM8oETbL7DsqZUwcn5/nxo61w1RLeij8qq89qhw4mOAAeG36nJ3VawCWF3bJ2o5L5hzMeQZuOpUsJrVQhNbXYaS6szzfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721290119; c=relaxed/simple; bh=H4w4bWRvrB8E66jmulgnfGAybN14N6YfNxdxG+lAPUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gZIfYbD2Ov/EOU4+xrz1AoVTqKI7t4irL02Y1vxxLBh0cypG9r8pkyZotsIN2GYiyeY0Y28cN+qN7Sy35viSV4qtJzfTbUbaD7S9EYJ6fTYL8xmbHqB8V/zcMhcWsXGtQXw1eNOK1B2RIINaFetcjsZ9xI/5PPOwlDHdc9ICQhs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=smartx.com; spf=none smtp.mailfrom=smartx.com; dkim=pass (2048-bit key) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.b=mOwTuxfH; arc=none smtp.client-ip=209.85.166.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=smartx.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=smartx.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=smartx-com.20230601.gappssmtp.com header.i=@smartx-com.20230601.gappssmtp.com header.b="mOwTuxfH" Received: by mail-il1-f172.google.com with SMTP id e9e14a558f8ab-38f69f73966so652215ab.3 for ; Thu, 18 Jul 2024 01:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20230601.gappssmtp.com; s=20230601; t=1721290116; x=1721894916; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0zvKcJeZW/5nlFPVZg7CuEvKzbd3IdJrobgY1LSpsC0=; b=mOwTuxfHHIKADmb10i1U0f3ttUyT2kANWxCx4emcJIEKCuUQdjiMjs2s2uRZ1zOQZc 1YdgqrNEU+jMT1xu5vt4JWtSTzM2MUxqbvkoCwM+s3c5FTRRJnsxNfuzLGr8Egtou2Fx m1o9eAoqiuVDx/yxiS/DRHSpxHG3IvP+jnad4lq3Z3SOQDMxAD20bSM/yNnvf+CGX9Es Bi2DIEuxriAZx7X6E9ei+Yucz3/GJgQeL9uuuM5S79eBcXpd2kDGrAKv2ppLE/yoVkbt c189/3baiPCN63d5+zVnfiDgVM/h4bCPSQJHr9k2jaifCtaQUzzfff0CG7B/fYsPlTkK 1F6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721290116; x=1721894916; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0zvKcJeZW/5nlFPVZg7CuEvKzbd3IdJrobgY1LSpsC0=; b=uZPW6Iqq4jKImSSVsh1dcI/fQSli23h77r//j6qmYZFRlXXTL8k9gNm3BP8bWgwPH0 3q48kDpP4c0NOr24TAqgbksLRK5atGBx5RdZdp6raBGtyncxWH17vOs4X2xunuNyTmzo Joo2ovWk3/sQLnZl5idxkhBJBjwJuSc/j4nEjnk59lrCvjblfcqvEwtOTvHvZPks3YtW b2WjxU4FNTly7sqQHoaCz1DuMAhd4j+ujXJGbgssqLxDrE3ggVfmyKRub/WUFVWSLJai 4x9Sz01V7kIxfhBkooEoOW0r6lVb24dPk5cIGsl6m1jgxc9WP2OZyvOQC75SwwOcjJPP vekQ== X-Forwarded-Encrypted: i=1; AJvYcCUvi8i01EcKHyGhw+RdhhrvLeZXvqYL7xq+s7BHupBtfW8+0TFa5iP6aUkorJ5mkM2U5Nnrh8vqsVVzM0gH59uBeA8+MT3uwzD4ToWM X-Gm-Message-State: AOJu0Yy4ac/eBM8V5tGhpek62ZUgeJcXIcS0elAFac+jRFCP7VOOYb1K qygIxL/HB/4ea1IZ9qjSLSNKtOwYGdFt8cNe8Kd+T0/tMno1ztNYZcIflg0hwB+3l23NrcIbu/e FKQAUbA== X-Google-Smtp-Source: AGHT+IG+282LO3MdKEtecYTgxT/0LeZXejY4bHurHDfBCc4XmaLwlg8D0qa19SjkP31nyxE0heR9UA== X-Received: by 2002:a05:6e02:168d:b0:376:1264:d82d with SMTP id e9e14a558f8ab-3955760e43fmr49523385ab.30.1721290115841; Thu, 18 Jul 2024 01:08:35 -0700 (PDT) Received: from localhost.localdomain.gitgo.cc (vps-bd302c4a.vps.ovh.ca. [15.235.142.94]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-78e34d2c4d3sm7385958a12.48.2024.07.18.01.08.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 01:08:35 -0700 (PDT) From: Li Feng To: Jens Axboe , "James E.J. Bottomley" , linux-kernel@vger.kernel.org (open list), linux-scsi@vger.kernel.org (open list:SCSI SUBSYSTEM), "Martin K. Petersen" Cc: Christoph Hellwig , Damien Le Moal , Haoqian He Subject: [PATCH v3 2/2] scsi: sd: remove some redundant initialization code Date: Thu, 18 Jul 2024 16:07:23 +0800 Message-ID: <20240718080751.313102-3-fengli@smartx.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240718080751.313102-1-fengli@smartx.com> References: <20240718080751.313102-1-fengli@smartx.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Haoqian He Since the memory allocated by kzalloc for sdkp has been initialized to 0, the code that initializes some sdkp fields to 0 is no longer needed. Signed-off-by: Haoqian He Reviewed-by: Damien Le Moal Signed-off-by: Li Feng --- drivers/scsi/sd.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index c180427e2c98..3921b8fd71d1 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3953,7 +3953,6 @@ static int sd_probe(struct device *dev) sdkp->disk =3D gd; sdkp->index =3D index; sdkp->max_retries =3D SD_MAX_RETRIES; - atomic_set(&sdkp->openers, 0); atomic_set(&sdkp->device->ioerr_cnt, 0); =20 if (!sdp->request_queue->rq_timeout) { @@ -3986,13 +3985,7 @@ static int sd_probe(struct device *dev) =20 /* defaults, until the device tells us otherwise */ sdp->sector_size =3D 512; - sdkp->capacity =3D 0; sdkp->media_present =3D 1; - sdkp->write_prot =3D 0; - sdkp->cache_override =3D 0; - sdkp->WCE =3D 0; - sdkp->RCD =3D 0; - sdkp->ATO =3D 0; sdkp->first_scan =3D 1; sdkp->max_medium_access_timeouts =3D SD_MAX_MEDIUM_TIMEOUTS; =20 --=20 2.45.2