From patchwork Wed Sep 20 19:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 725126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 172A0C04FF3 for ; Wed, 20 Sep 2023 19:16:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230239AbjITTQa (ORCPT ); Wed, 20 Sep 2023 15:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230156AbjITTP7 (ORCPT ); Wed, 20 Sep 2023 15:15:59 -0400 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC311CC1; Wed, 20 Sep 2023 12:15:09 -0700 (PDT) Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2746ab05409so72895a91.0; Wed, 20 Sep 2023 12:15:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695237308; x=1695842108; 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=Gz5gAPk4mxUQW5gf9Uo6zqlxjaguhwx3I942w6MrIHs=; b=osHpZCsehDvC8t0KRZ/wjKmRjdTMVZtBXiKDwMpTvBfi3BAeEqQnRWxRiZu7rwotNm 1/sINkebSCRjgUwt6M+ukY+sgQ4dLaKHENiWwVlbb1tm7Ut9RJwoNDkH9s0M2cwSi4/7 AxsrDiY9LntWSFPNVo+Jgza/JBp2IlujTFAThj/1u7aBjVSQj9ImAJlNq+hEycoBJhy3 3sE1/BomzQcZjwM3D9WUzkVEnO25wt0cxWF0QLn3DEWLTPwRE0xknTgRiA665Eh8NT/p G7ksFSa7vOz8m9v0qPfw6sj7LQDxvrl7ep6GhGrzOTVX0zDpWM7398XRHeVSEzFq0YGb hblw== X-Gm-Message-State: AOJu0YwhBBs0FGHYaWcSdU2nYQojuxetcprCofHKvoK7XNibvxcBEzfC 2LjzOrDJi2DotomSzqXBekQ= X-Google-Smtp-Source: AGHT+IGPkH24Y7WHt+4Roljg4OKK1k1jXjfqpQ9Q94t3iyH4lcPUQhUfviEtzUdRwOWyjX9VKSvlXw== X-Received: by 2002:a17:90b:314c:b0:26d:b12:8383 with SMTP id ip12-20020a17090b314c00b0026d0b128383mr3580497pjb.8.1695237308521; Wed, 20 Sep 2023 12:15:08 -0700 (PDT) Received: from bvanassche-linux.mtv.corp.google.com ([2620:15c:211:201:b0c6:e5b6:49ef:e0bd]) by smtp.gmail.com with ESMTPSA id a13-20020a17090a8c0d00b002633fa95ac2sm1656318pjo.13.2023.09.20.12.15.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 12:15:08 -0700 (PDT) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, "Martin K . Petersen" , Christoph Hellwig , Bart Van Assche , Douglas Gilbert , "James E.J. Bottomley" Subject: [PATCH 12/13] scsi_debug: Implement the IO Advice Hints Grouping mode page Date: Wed, 20 Sep 2023 12:14:37 -0700 Message-ID: <20230920191442.3701673-13-bvanassche@acm.org> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog In-Reply-To: <20230920191442.3701673-1-bvanassche@acm.org> References: <20230920191442.3701673-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Implement an IO Advice Hints Grouping mode page with three permanent streams. A permanent stream is a stream for which the device server does not allow closing or otherwise modifying the configuration of that stream. The stream identifier enable (ST_ENBLE) bit specifies whether the stream identifier may be used in the GROUP NUMBER field of SCSI WRITE commands. Cc: Martin K. Petersen Cc: Douglas Gilbert Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_debug.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index a96eb0d10346..ae46bcf8374b 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -2241,6 +2241,33 @@ static int resp_ctrl_m_pg(unsigned char *p, int pcontrol, int target) return sizeof(ctrl_m_pg); } +/* IO Advice Hints Grouping mode page */ +static int resp_grouping_m_pg(unsigned char *p, int pcontrol, int target) +{ + /* IO Advice Hints Grouping mode page */ + struct grouping_m_pg { + u8 page_code; + u8 subpage_code; + __be16 page_length; + u8 reserved[12]; + struct scsi_io_group_descriptor descr[4]; + }; + static const struct grouping_m_pg gr_m_pg = { + .page_code = 0xa, + .subpage_code = 5, + .page_length = cpu_to_be16(sizeof(gr_m_pg) - 4), + .descr = { + { .st_enble = 1 }, + { .st_enble = 1 }, + { .st_enble = 1 }, + { .st_enble = 0 }, + } + }; + + BUILD_BUG_ON(sizeof(struct grouping_m_pg) != 16 + 4 * 16); + memcpy(p, &gr_m_pg, sizeof(gr_m_pg)); + return sizeof(gr_m_pg); +} static int resp_iec_m_pg(unsigned char *p, int pcontrol, int target) { /* Informational Exceptions control mode page for mode_sense */ @@ -2420,9 +2447,17 @@ static int resp_mode_sense(struct scsi_cmnd *scp, } break; case 0xa: /* Control Mode page, all devices */ - if (subpcode > 0x0 && subpcode < 0xff) + switch (subpcode) { + case 0: + case 0xff: + len = resp_ctrl_m_pg(ap, pcontrol, target); + break; + case 0x05: + len = resp_grouping_m_pg(ap, pcontrol, target); + break; + default: goto bad_subpcode; - len = resp_ctrl_m_pg(ap, pcontrol, target); + } offset += len; break; case 0x19: /* if spc==1 then sas phy, control+discover */