Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2030477lqo; Mon, 13 May 2024 06:08:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWuih69VqaNvQ176EGN4Loyi2VGYRIrZj1LY6owu4XLrxX7sLJxZkc96be8sEf+T6S2CDTFAoBZfxI/3TCHi+/hiw9MsIc1WzfcRGarYw== X-Google-Smtp-Source: AGHT+IGcMrXuetv5ilqAgB6jTWi8vlI8niRmrE2Ay55MiW79Qzz8TjZT3bavGfc51lIQ7CLWI8ig X-Received: by 2002:a05:6214:907:b0:6a3:2941:d3f7 with SMTP id 6a1803df08f44-6a32941d6bcmr56119856d6.45.1715605737492; Mon, 13 May 2024 06:08:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715605737; cv=pass; d=google.com; s=arc-20160816; b=F9EHNnf93V5l8E00fEB5hE5VG3xrOOgbumz6VsOm2sP0UPGgw+dihE03oOE248gk5I 3vEKuR/B4TtPVpX+wUwxaH/q7BCE6TsBxnhHpUB8PzpY/8713BQfyx16dpXo43hdTDHX jnkyfJZLbRwX0SFf8UkEDLz94ooNQ3sizl7pVrtYR/O2hO1Tf2EgK6cxmAZ0dRksajNH L1bEuq8n0lxQTKYVFbwSWJxkVZYrpnpScf2UZzaqwg2Jz77cQEMfFPAwUKz2CHGP2o3E 8ptU0AAZpOF5OH70tFmDwcwDPivr4hfveD6p4wEP/Nt4oFSEm2JHlUL+Lu18fyfwY+jZ 6Aew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=cggCe0HUkevk0FdKw+pT5PdrqyGGJ++JGzquo5nGn+Q=; fh=ESMQYyhNyPBqdYk7cjj8DFkyPUa/LkkB129CmXlurx0=; b=a9jDd6gCDZHwoMveDM9Guv60dqOT3zJSfAvJSdjzN5jjlWmRGUEVVgMi3fnodKfLax 0tIl/wxjy0gRlZn8trfG5KDuLTi9Uy/uIUITtGMGzQ/Utwmox0KwLl9KU8zeSzmlarT4 E3uguvGzTpBH1Gwcff2pmcFmUU6c1kLnVJ5FZ1UyVPLtBVsUHwCw9mQ+zUUlfDG+k7ou ufYtVZkaqtw2ZVGYsGgyxB99imySRb9RcAcaF0fErRq5ri/axsyqoTXsBQlXSSpgXAS+ axMXMQboMS6vH8fSgFmoXw+OtHZ99pq2yRb8tSiasV3hgRttWCZT95JRz6414k2djM88 4gBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KLHbT8oY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6a15f2b6b7asi97018076d6.352.2024.05.13.06.08.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 06:08:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KLHbT8oY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 394E71C227FD for ; Mon, 13 May 2024 13:08:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C1DBB1514C1; Mon, 13 May 2024 13:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KLHbT8oY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CF9E1DF6C; Mon, 13 May 2024 13:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715605724; cv=none; b=L2/OoBKNigAErHGeGHFoY8FcwThCc2ULN6OnWmnI+eEoTKN0dAuCUMYqXfY+lbIMPzgP7mgV0+9NIwjFWDuENaL6xieHWSqhbufaoNmZvgz1/pYbZ9flL7xu0HK4XUcq3QDe0gUEAd1ydNZCIJ7feaxBHacAGHdfcB7kdOPygsQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715605724; c=relaxed/simple; bh=jMBP6V+KrQiY7ae7qCJD7wO2o7LlEvAAj86B765UqAE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZHY05MmvjgRjHn4EjgUXS8XgO+5YCPvGL8PXRmjL+j5In/+D9d2miQlOHABOW7TCaO6xi8RxVOFer+6nFP+1F4MX/TGObyFd9EUCRYMkoutaE4L1lf7zw6Ia9rsk4fxXSD4eRzO63AqfU1lkRkR/fZxQ4pkhtj7ccYuP/cHbbJA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KLHbT8oY; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63C93C32782; Mon, 13 May 2024 13:08:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715605724; bh=jMBP6V+KrQiY7ae7qCJD7wO2o7LlEvAAj86B765UqAE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=KLHbT8oYxB7LFOPNmCzkTbTuUHu5Xo7HGa+GZJwAtDu9mh+NF94yhQVh5y31OmTv8 +9RbHUHEXJhpll++YzGTK9bpuLBF8O5kpnE7eaa+P1SU6PTaIKzhXKNeoAkSaEXORE BNyAfhtWDUhzxfX7xYLTguzxzVa4HGM4XIhMi6t85K6rG1Tv8j0MPoEIsu/n5qVGzA Q6IdgpzRwpfmHUwmdBm8nUIjVteAZDvrp4Yu21v663slo2hGKd6fABS8rTMttFNi3l VP+7+2TpKxG5onWKhFoTFKs3N+dWo7OiXz+5mZtOJ/oJ8Yjb3fGBgO6wy/RnmiCrat eFg5LPWwUyRuQ== Message-ID: Date: Mon, 13 May 2024 22:08:43 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] rust: block: introduce `kernel::block::mq` module To: Andreas Hindborg , Bart Van Assche Cc: Jens Axboe , Christoph Hellwig , Keith Busch , Damien Le Moal , Hannes Reinecke , Ming Lei , "linux-block@vger.kernel.org" , Andreas Hindborg , Wedson Almeida Filho , Greg KH , Matthew Wilcox , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Chaitanya Kulkarni , Luis Chamberlain , Yexuan Yang <1182282462@bupt.edu.cn>, =?UTF-8?Q?Sergio_Gonz=C3=A1lez_Collado?= , Joel Granados , "Pankaj Raghav (Samsung)" , Daniel Gomez , Niklas Cassel , Philipp Stanner , Conor Dooley , Johannes Thumshirn , =?UTF-8?Q?Matias_Bj=C3=B8rling?= , open list , "rust-for-linux@vger.kernel.org" , "lsf-pc@lists.linux-foundation.org" , "gost.dev@samsung.com" References: <20240512183950.1982353-1-nmi@metaspace.dk> <20240512183950.1982353-2-nmi@metaspace.dk> <1b618942-a0fe-45d9-90de-eede429e7284@acm.org> <87r0e5j2st.fsf@metaspace.dk> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <87r0e5j2st.fsf@metaspace.dk> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2024/05/13 21:48, Andreas Hindborg wrote: > > Hi Bart, > > Bart Van Assche writes: > >> On 5/12/24 11:39, Andreas Hindborg wrote: >>> + /// Set the logical block size of the device. >>> + /// >>> + /// This is the smallest unit the storage device can address. It is >>> + /// typically 512 bytes. >> >> Hmm ... all block devices that I have encountered recently have a >> logical block size of 4096 bytes. Isn't this the preferred logical >> block size for SSDs and for SMR hard disks? > > Yes, that is probably true. This text was lifted from the entry on the > sysfs attribute in `Documentation/ABI/stable/sysfs-block`, but maybe > that needs to be updated as well. > >> >>> + /// Set the physical block size of the device. >>> + /// >>> + /// This is the smallest unit a physical storage device can write >>> + /// atomically. It is usually the same as the logical block size but may be >>> + /// bigger. One example is SATA drives with 4KB sectors that expose a >>> + /// 512-byte logical block size to the operating system. >> >> Please be consistent and change "4 KB sectors" into "4 KB physical block >> size". > > OK, I will. I can CC the changes to > `Documentation/ABI/stable/sysfs-block` then' > >> >> I think that the physical block size can also be smaller than the >> logical block size. From the SCSI SBC standard: >> >> Table 91 — LOGICAL BLOCKS PER PHYSICAL BLOCK EXPONENT field >> ----- ------------------------------------------------------------ >> Code Description >> ----- ------------------------------------------------------------ >> 0 One or more physical blocks per logical block (the number of >> physical blocks per logical block is not reported). >> n > 0 2**n logical blocks per physical block >> ----- ------------------------------------------------------------ That text is bad. 0 really means physical == logical. Otherwise, there is no way to know how to access the drive because the logical size is the unit for accessing the drive. In practice, the logical block size is always smaller or equal to the physical block size. The physical block size is always a power of 2 number of logical blocks. > How does that work? Would the drive do a read/modify/write internally? Yes. > Would that not make the physical block size as seen from the OS equal to > the smaller logical block size? Not necessarily. There are a lot of 512e drives out there: 4K physical, 512B logical. So applications/hosts can still do 512B accesses for compatibility but performance may be bad. For such drive, the user should really do 4K aligned accesses. > >> >>> +impl GenDisk { >>> + /// Call to tell the block layer the capacity of the device in sectors (512B). >> >> Why to use any other unit than bytes in Rust block::mq APIs? sector_t >> was introduced before 64-bit CPUs became available to reduce the number >> of bytes required to represent offsets. I don't think that this is still >> a concern today. Hence my proposal to be consistent in the Rust block::mq API >> and to use bytes as the unit in all APIs. > > I think that is very good idea. How do others feel about this? > > BR Andreas > > -- Damien Le Moal Western Digital Research