From patchwork Thu Jul 18 08:07:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Feng X-Patchwork-Id: 813528 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.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 AEB701BDD0 for ; Thu, 18 Jul 2024 08:08:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721290111; cv=none; b=mDU2cxErIsd+ri8PWyJC+glnAXjNOLastx6gR1hQg6wAXRftWoj9FUyQNYSwvyiDY8PqvCN4E4vUrRxrGak/HEuy0bvlIlVAKdHJqGvcEWhdsoT7/O/EnNBmVa3OJD0mol9Tujm7dHL6tAPYKqV5vq1+3jevDqXahahHuf7pIRc= 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.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="ZEb0Wvuw" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3d9306100b5so336006b6e.1 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=IPKbMzgIYqPG2mE1B7jQelS3T+q+nUx5j7qNm5cN3m/Oky5nPNiQfHbBELlLZO6i/a H2/3Wt2YC9PZy3pSMAo2CniGoU8giNQnM0AmT3XtN4Xaes5DcjtqsApDkOybSpRTjj5L MhEhZUdWUUrSh2f0274vNtzoC0Q4tTc81cJrhmmmwmHgOFOobQEQQJEaO1IoszZjxMz2 26T0Ol8WtlwDyeYllKPW5vRp/NX3DL7NsMT9f1vzlreyKsj+Obge2iZ8NK+J6CnIt06+ 9LqQ1JDfUOQC5dlClyRCEtNVlBNImNJouni+fCNMkaKCDz0g98FKmf8Od2e2HKXkJTIj dzTg== X-Forwarded-Encrypted: i=1; AJvYcCX8i3cZx05sVPMeLO1D1ZnWxQzB4yicvFmEpdh27hfaEEeGik/v67AoyXsiPODrDcvBN/wHIOHqzqwGVzNb1z5EFtLKLC9cUk2LIw== X-Gm-Message-State: AOJu0Yx3jaq/pgYHRb68TXl3MaKdxNj0V8VAWqDtRl1W6oHrm+qTcKnE 5tllB413kmbHO6hO0sVKY7be5sudXF3Fx6/HfeQouud9CLJKaG8VKf3tkdjGaj8= 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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, struct scsi_device *sdp, if (buffer[14] & 0x40) /* LBPRZ */ sdkp->lbprz = 1; - - sd_config_discard(sdkp, lim, SD_LBP_WS16); } sdkp->capacity = lba + 1; @@ -3365,8 +3363,6 @@ static void sd_read_block_limits(struct scsi_disk *sdkp, sdkp->unmap_alignment = get_unaligned_be32(&vpd->data[32]) & ~(1 << 31); - sd_config_discard(sdkp, lim, sd_discard_mode(sdkp)); - config_atomic: sdkp->max_atomic = get_unaligned_be32(&vpd->data[44]); sdkp->atomic_alignment = get_unaligned_be32(&vpd->data[48]); @@ -3756,6 +3752,8 @@ static int sd_revalidate_disk(struct gendisk *disk) sd_read_cpr(sdkp); } + sd_config_discard(sdkp, &lim, sd_discard_mode(sdkp)); + sd_print_capacity(sdkp, old_capacity); sd_read_write_protect_flag(sdkp, buffer); From patchwork Thu Jul 18 08:07:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Feng X-Patchwork-Id: 813329 Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) (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 1CE2578C7A for ; Thu, 18 Jul 2024 08:08:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721290118; cv=none; b=q9lALYPf3916GNHs7Y9sqrc5HxtQWMrR7tD4UJD5T3jCs176a+ZHCs0/uFhuU6fiIKmZg5BZGqF0hlGw/81v2yD2d9FhgHHAoqoveoVmjJgJjO8bO7DAgcXUr+B+IKVb6NnkTYo2mFshK3KKde1AajqzXIb0pbQDv54DXwR/EC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721290118; c=relaxed/simple; bh=H4w4bWRvrB8E66jmulgnfGAybN14N6YfNxdxG+lAPUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N7Z1ryL57iE2kBdC+5JC/8VgSftJKzGg3EtbY7Ir0aoaOD5hj8xjLR2J6LgC6HZiB1yF4Qa2L4tQVhCdgWDdgIURHWrmkEHi2BVR2ZOoOyS7F8So28D1h2Vc1bnEUN6NnxeuxAmt/wg/w1HC4kA4nMT4vDZFxh16+ZF3COIA8Mc= 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.44 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-io1-f44.google.com with SMTP id ca18e2360f4ac-810f75a632dso17383139f.2 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=dl7FC9gGS4zTrYdZ9kreXZzI0Oo7ALDpEstOgtKZnjCm8bE1Ws0L6nR3+s0pT4+Gia G72nXspb7i3Ap8URUR1xSYarY1NDlitxpa4y/sMaxFQu2xN2ncVeznX8s7WmNpFqXqJh lbZDbVrF+a2DDKn5cjnvWsFsqNhchAL0Czl5d3dhnC+gLszwNrx5ldkl8Td6AoAAVnoI wzPQRhInRLoQEXNfwSGcejBuYMIx1qPU2dT1TpoAO3lDOtWy/WYgUjuRcZIx37gR8Icf AioBNbk4VepU9f5kyyBpo189qkp7n1CAWeDmmsSU0qFXZQUpQ1TDnytD6ZkUTpnrervk W2Bg== X-Forwarded-Encrypted: i=1; AJvYcCWzljXIcUobl6xFkblgt+b8T8suT7/KG/BebYcQTPtenSi2J55HhrG5Nz0EGA1apIHWyE4z3KAK78DRSIv9SkuRwdYc4eNukkqEWg== X-Gm-Message-State: AOJu0YyKI0DhVPSPJlcraIoG3JLhWltsbR13dWuOznLO9Xm3mj+p4H3C HeVFaoDPusncARA8DJOUDAOEQzvwQHy392h4B1zkRKrooQ0Tt6pG+0r1xuvw4bI= 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-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 = gd; sdkp->index = index; sdkp->max_retries = SD_MAX_RETRIES; - atomic_set(&sdkp->openers, 0); atomic_set(&sdkp->device->ioerr_cnt, 0); if (!sdp->request_queue->rq_timeout) { @@ -3986,13 +3985,7 @@ static int sd_probe(struct device *dev) /* defaults, until the device tells us otherwise */ sdp->sector_size = 512; - sdkp->capacity = 0; sdkp->media_present = 1; - sdkp->write_prot = 0; - sdkp->cache_override = 0; - sdkp->WCE = 0; - sdkp->RCD = 0; - sdkp->ATO = 0; sdkp->first_scan = 1; sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;