From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D323C1C2DA1 for ; Thu, 10 Oct 2024 16:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=140.211.166.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728577045; cv=none; b=K2Uxc+l4T22z7jI4frvJOMUDhycZ5+V8hC6Ql4fePx5gfawB8VtZnaOMRKnHxkW2pRq/9oGIEfx7OAAtKPuj2KJG8zdY60oOGdzIrnh6QlC3xj3BYMYAhVcjWJgoH6m19inmerB3aY8i/vgYH6g/sqZQcYp1/rYfypFradV83Vs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728577045; c=relaxed/simple; bh=sDPEpumwOwMXVZF1NJRop458vAqJf5bX1yKinckuCQc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: In-Reply-To:Content-Type:Content-Disposition; b=adGX2wXmQpAk3KM+BM/f1LdZ8dKN0c5tUNhsGmO2fpIPyirq4jRr1fHyxgvVo1gp4kOEt7t07vtGH3VgB9obD0ZbaI3Gv8/KPGEcpG8NUFPTncGuN/YLvgoMhRXxB+Jc/C/IHeXLCYJJiE0pzegUBAX79nKWG5Ioe8m0acKc2F0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TTG8YlAL; arc=none smtp.client-ip=140.211.166.133 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TTG8YlAL" Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 674F240484 for ; Thu, 10 Oct 2024 16:17:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org X-Spam-Flag: NO X-Spam-Score: -5.79 X-Spam-Level: Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id AqnfG1GmCcuT for ; Thu, 10 Oct 2024 16:17:22 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mst@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org D82F040445 Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D82F040445 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TTG8YlAL Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id D82F040445 for ; Thu, 10 Oct 2024 16:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1728577040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=F8D07boHcgY+s1K9ISE/p5PpbEV3g5iXZthl0RwXjm8=; b=TTG8YlALUG4zwrRBeT0zqsiJhdKGTulki/qDwheIzLiM9wv8BSxxLZjWd/6PkJM5WwP1Vt exN0xm/A9zBPpZydn5QAmPexC5W9EmaBdCzzBKU7wBOXvh9FxyObDhhCjWOqjChIxhc+T3 +Q4VQPCxb+u8C6PIlXDJziLUbDQFXho= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-434-_HR-jzMzMyuKw4zdtmj1zg-1; Thu, 10 Oct 2024 12:17:19 -0400 X-MC-Unique: _HR-jzMzMyuKw4zdtmj1zg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4311412e042so6837385e9.2 for ; Thu, 10 Oct 2024 09:17:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728577038; x=1729181838; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=F8D07boHcgY+s1K9ISE/p5PpbEV3g5iXZthl0RwXjm8=; b=jHYiYjmj0PR3emZMHa4URXG1WTYiiYhtj4FhyryKLKx/6MR0SVDIGpbBSmXdrsp9qG qkPWVFFIlLZzKTtXJWhdX+m1FRhqaoG/X/mutbhdnEgEHM9ApDr/Xe6xQxOQcY/BebAt vCM7WR2gV8GdOYXmyYSnBRt/7Eej6AhDg8KKOPeD27AvQeuw6MRmOHR1+bMc7RU+X1jG EctfODEMHNfxz11+9h6J5jjq6Lmo2CI+UwGiMX72FznS1/BFEuutrjtweMWEGXnamkvv wiSJCAG6uq6ze47B25REJ6QV6i3tnMjg/UmBKlDnztPfcws9gINZA7yB0AEzWRzX4c7Q siSQ== X-Forwarded-Encrypted: i=1; AJvYcCVW0I94vW+oXAvHzk/LQ0ba7kXU+P52/61sYfkW+2u3j7aVDO+p+2urH91nBDo+XBbXwYRZy5lXB19GBti0gg==@lists.linux-foundation.org X-Gm-Message-State: AOJu0YykeQtkIYpoqcnDyFWwpUNdhNKVWGp1X7xFE+K4fzWRbq2zvp5H 7qT+fJyvy3IaajaimrSXQ3pbNJUdW2DDOrW8jCtGMPOF3rCyEzEwgtGIstWbteA5IdGync71HRM HpASoHFk/cNrBeRvEny0/59DS8ypAxZ/wqknHlsYh51riNrLNBmcvJ/nRTOuuPV9TOK311kK1oD BnywI= X-Received: by 2002:a05:600c:70a:b0:431:1c68:1db5 with SMTP id 5b1f17b1804b1-4311c681f02mr3514115e9.14.1728577037638; Thu, 10 Oct 2024 09:17:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnmlNv8/qz4Exm3aw9q+r+Px6+nvOrDA7PzICnxgepk68yQ0PNm4OIk0tANHMdzoON7eYBQg== X-Received: by 2002:a05:600c:70a:b0:431:1c68:1db5 with SMTP id 5b1f17b1804b1-4311c681f02mr3513855e9.14.1728577037124; Thu, 10 Oct 2024 09:17:17 -0700 (PDT) Received: from redhat.com ([2a02:14f:17d:fb13:fd72:22f:64e2:b824]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4311835d8f6sm20261105e9.44.2024.10.10.09.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 09:17:15 -0700 (PDT) Date: Thu, 10 Oct 2024 12:17:11 -0400 From: "Michael S. Tsirkin" To: Max Gurtovoy Cc: dverkamp@chromium.org, virtualization@lists.linux-foundation.org, mvaralar@redhat.com, stefanha@redhat.com, virtio-dev@lists.linux.dev, oren@nvidia.com, parav@nvidia.com, nitzanc@nvidia.com, benwalker@nvidia.com Subject: Re: [PATCH v4 1/1] virtio-blk: Add description for blk_size field Message-ID: <20241010121303-mutt-send-email-mst@kernel.org> References: <20241010160725.3087-1-mgurtovoy@nvidia.com> Precedence: bulk X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20241010160725.3087-1-mgurtovoy@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 10, 2024 at 07:07:25PM +0300, Max Gurtovoy wrote: > This field is only valid when the VIRTIO_BLK_F_BLK_SIZE feature bit is > offered by the device. > > The blk_size field actually represents the logical block size of the > device. It is always a power of two and typically ranges from 512 bytes > to larger values such as 4 KB. > > Add description for this field to provide clarity on its constraints. > > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/208 > Reviewed-by: Daniel Verkamp > Reviewed-by: Stefan Hajnoczi > Signed-off-by: Max Gurtovoy I have a general question here. Do we need this field before feature negotiation? If not, I would actually say here that it exists only if feature has been negotiated. This opens the door for devices to detect legacy drivers that do not read block size and work around, somehow. > --- > device-types/blk/description.tex | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/device-types/blk/description.tex b/device-types/blk/description.tex > index 2712ada..0ddc223 100644 > --- a/device-types/blk/description.tex > +++ b/device-types/blk/description.tex > @@ -135,6 +135,9 @@ \subsection{Device configuration layout}\label{sec:Device Types / Block Device / > present. The availability of the others all depend on various feature > bits as indicated above. > > +The field \field{blk_size} exists only if VIRTIO_BLK_F_BLK_SIZE is offered by the device. > +This field reports the block size of the device, expressed in bytes. I would reorder here, too. The field \field{blk_size} reports the block size of the device, expressed in bytes. This field exists only if VIRTIO_BLK_F_BLK_SIZE is offered by the device. > + > The field \field{num_queues} only exists if VIRTIO_BLK_F_MQ is set. This field specifies > the number of queues. > > @@ -282,6 +285,13 @@ \subsection{Device Initialization}\label{sec:Device Types / Block Device / Devic > > \drivernormative{\subsubsection}{Device Initialization}{Device Types / Block Device / Device Initialization} > > +Drivers SHOULD negotiate VIRTIO_BLK_F_BLK_SIZE if the feature is offered by the > +device. When negotiated, drivers SHOULD interpret the \field{blk_size} as the > +logical block size. > + > +If the VIRTIO_BLK_F_BLK_SIZE feature is not offered by the device, then drivers > +MAY assume that the logical block size is 512 bytes. > + > Drivers SHOULD NOT negotiate VIRTIO_BLK_F_FLUSH if they are incapable of > sending VIRTIO_BLK_T_FLUSH commands. > > @@ -319,6 +329,10 @@ \subsection{Device Initialization}\label{sec:Device Types / Block Device / Devic > > \devicenormative{\subsubsection}{Device Initialization}{Device Types / Block Device / Device Initialization} > > +Devices SHOULD always offer I don't get what does always mean here. also the feature? > VIRTIO_BLK_F_BLK_SIZE feature. When this feature is > +offered, devices MUST initialize \field{blk_size} to a power of two greater > +than or equal to 512. > + > Devices SHOULD always offer VIRTIO_BLK_F_FLUSH, and MUST offer it > if they offer VIRTIO_BLK_F_CONFIG_WCE. > > @@ -879,6 +893,14 @@ \subsection{Device Operation}\label{sec:Device Types / Block Device / Device Ope > The length of \field{data} MUST be a multiple of 512 bytes for VIRTIO_BLK_T_IN > and VIRTIO_BLK_T_OUT requests. > > +When the VIRTIO_BLK_F_BLK_SIZE feature is offered by the device, the length of > +\field{data} SHOULD be a multiple of \field{blk_size} for VIRTIO_BLK_T_IN and > +VIRTIO_BLK_T_OUT requests. > + > +When the VIRTIO_BLK_F_BLK_SIZE feature is offered by the device, the value of > +\field{sector} (multiplied by 512) SHOULD be a multiple of \field{blk_size} for > +VIRTIO_BLK_T_IN and VIRTIO_BLK_T_OUT requests. > + > The length of \field{data} MUST be a multiple of the size of struct > virtio_blk_discard_write_zeroes for VIRTIO_BLK_T_DISCARD, > VIRTIO_BLK_T_SECURE_ERASE and VIRTIO_BLK_T_WRITE_ZEROES requests. > @@ -966,6 +988,16 @@ \subsection{Device Operation}\label{sec:Device Types / Block Device / Device Ope > for a write request if the VIRTIO_BLK_F_RO feature if offered, and MUST NOT > write any data. > > +When the VIRTIO_BLK_F_BLK_SIZE feature is offered by the device, the device MAY > +set the \field{status} to VIRTIO_BLK_S_IOERR for VIRTIO_BLK_T_IN or > +VIRTIO_BLK_T_OUT requests if the requested \field{sector} (multiplied by 512) > +is not an integer multiple of the device's \field{blk_size}. > + > +When the VIRTIO_BLK_F_BLK_SIZE feature is offered by the device, the device MAY > +set the \field{status} to VIRTIO_BLK_S_IOERR for VIRTIO_BLK_T_IN or > +VIRTIO_BLK_T_OUT requests if the length of the requested \field{data} is not an > +integer multiple of the device's \field{blk_size}. > + > The device MUST set the \field{status} byte to VIRTIO_BLK_S_UNSUPP for > discard, secure erase and write zeroes commands if any unknown flag is set. > Furthermore, the device MUST set the \field{status} byte to > -- > 2.18.1