From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41406C433F5 for ; Thu, 14 Oct 2021 15:15:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 077A3603E5 for ; Thu, 14 Oct 2021 15:15:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 077A3603E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kk58q1N6iOKJV9MmXM4g94KiVUwgBacQdDgb8dq+Hqc=; b=GQutwtExsGZ0Ew/PtqhmwXMiFw 1H+hOB0z05+ml8jr6G8HHfT/Uv/8bDOQrQRXPZJrgLPeO9IWC4Pkk080c7bO0cqcTTC0Bno4vMGN+ FMjYHhdLDVONF4tJoJXqKcIK/4tYVaYm8+HX3y1yyH6BQRBUsKKmnFQjOTViKnG8tOk5IaKNxx/hN 4zD/ep9QZ9P3FstYtCs3P5JzyctB2TErmU6H5oTfSgRvhO3IKhTSuot47ggxSyDZrKXSU/Tl11gyJ 1NtEjskcBX9d1mFez5LiaZMi5NQAkG7zrikaT0peSR4UPWKOlNSHCoxUM3QD2qrSe74zJ9o1xNpXr gIR87E8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mb2S8-003bWd-Bs; Thu, 14 Oct 2021 15:15:28 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mb2RG-003bGJ-6c for linux-nvme@lists.infradead.org; Thu, 14 Oct 2021 15:14:35 +0000 Received: by mail-pj1-x102c.google.com with SMTP id oa12-20020a17090b1bcc00b0019f715462a8so4987036pjb.3 for ; Thu, 14 Oct 2021 08:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kk58q1N6iOKJV9MmXM4g94KiVUwgBacQdDgb8dq+Hqc=; b=mlZB9Nj4m8jk1JFv+iCH7Znrwanh3CDPQczVzomtmeQ5BLbFN1inwmhXkfQwL1sdEQ hih7m3SNinxkOxv1CMzByR9lFDUUB4oAxo3E3cDYo/S67L6xZfuz5zRsWVJKP1+73Scy QCwjhJQjGzKf7SNt+QV8U3nYErgEHf4yODN/I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=kk58q1N6iOKJV9MmXM4g94KiVUwgBacQdDgb8dq+Hqc=; b=U/+YiJzDXNWMMz3O2Kg9gTRqqY9lFShTB3JqWj10Ym09PpnDsNUCq5tV1QBowRQLJg G6b4Pij/ro0MEGG2XFwlutIAZC/NF/7XZH8XcIiMqw3fjhIzQjqls+CSbRHt3NsCnzVL ZPuOtCETB6eJ68tz0kTKUm0GrXV0Q1wlG5iVcF7ZEAMgoh3LIgberPgDCjxNXM0V48rv mul2V8QOit6NmYWEjUbhO1buUhZjns1N3q7DxwxWgv7uYIU/eCJNo/g79/q53RbViC4G jZiLSH369FCmk4kRq1j4dxHujRPuFtPMx0M86IkPUUirw8+eljUwRVQSPHg0C1jCwuMS VKfA== X-Gm-Message-State: AOAM530wbPoGrwEKvclXnEwOuzUjflzZ8snZArPlF9sjDvvMZFeBgso5 db5kpD+cQwjEmUXxRheuWZDgVw== X-Google-Smtp-Source: ABdhPJz+A28iMSsGMew00w4bTffNulDM4PlP1p1A1+RouZBKHQoPJUsZrDvvxCBzVTavFWwP5kdepA== X-Received: by 2002:a17:90a:86:: with SMTP id a6mr20774739pja.190.1634224472530; Thu, 14 Oct 2021 08:14:32 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id w4sm2822114pfb.3.2021.10.14.08.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 08:14:32 -0700 (PDT) Date: Thu, 14 Oct 2021 08:14:31 -0700 From: Kees Cook To: Dave Kleikamp Cc: Anton Altaparmakov , Christoph Hellwig , Jens Axboe , Coly Li , Mike Snitzer , Song Liu , David Sterba , Josef Bacik , Theodore Ts'o , OGAWA Hirofumi , Ryusuke Konishi , Konstantin Komarov , Phillip Lougher , Jan Kara , "linux-block@vger.kernel.org" , "dm-devel@redhat.com" , "drbd-dev@lists.linbit.com" , "linux-bcache@vger.kernel.org" , "linux-raid@vger.kernel.org" , "linux-mtd@lists.infradead.org" , "linux-nvme@lists.infradead.org" , "linux-scsi@vger.kernel.org" , "target-devel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-btrfs@vger.kernel.org" , "linux-ext4@vger.kernel.org" , "jfs-discussion@lists.sourceforge.net" , "linux-nfs@vger.kernel.org" , "linux-nilfs@vger.kernel.org" , "linux-ntfs-dev@lists.sourceforge.net" , "ntfs3@lists.linux.dev" , "reiserfs-devel@vger.kernel.org" Subject: Re: don't use ->bd_inode to access the block device size Message-ID: <202110140813.44C95229@keescook> References: <20211013051042.1065752-1-hch@lst.de> <20211014062844.GA25448@lst.de> <3AB8052D-DD45-478B-85F2-BFBEC1C7E9DF@tuxera.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211014_081434_268069_1A2E63C1 X-CRM114-Status: GOOD ( 26.05 ) X-Mailman-Approved-At: Thu, 14 Oct 2021 08:15:26 -0700 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On Thu, Oct 14, 2021 at 08:13:59AM -0500, Dave Kleikamp wrote: > On 10/14/21 4:32AM, Anton Altaparmakov wrote: > > Hi Christoph, > > > > > On 14 Oct 2021, at 07:28, Christoph Hellwig wrote: > > > > > > On Wed, Oct 13, 2021 at 07:10:13AM +0200, Christoph Hellwig wrote: > > > > I wondered about adding a helper for looking at the size in byte units > > > > to avoid the SECTOR_SHIFT shifts in various places. But given that > > > > I could not come up with a good name and block devices fundamentally > > > > work in sector size granularity I decided against that. > > > > > > So it seems like the biggest review feedback is that we should have > > > such a helper. I think the bdev_size name is the worst as size does > > > not imply a particular unit. bdev_nr_bytes is a little better but I'm > > > not too happy. Any other suggestions or strong opinions? > > > > bdev_byte_size() would seem to address your concerns? > > > > bdev_nr_bytes() would work though - it is analogous to bdev_nr_sectors() after all. > > > > No strong opinion here but I do agree with you that bdev_size() is a bad choice for sure. It is bound to cause bugs down the line when people forget what unit it is in. > > I don't really mind bdev_size since it's analogous to i_size, but > bdev_nr_bytes seems good to me. I much prefer bdev_nr_bytes(), as "size" has no units. -- Kees Cook