From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 36EBD168 for ; Thu, 14 Oct 2021 15:14:33 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id c4so4391860pls.6 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=DPZILSJQipsB9HBKGhzjWdLCL26gzGJb3vNNC8PqD+kzND80hyXWkkOZwEm8k3FmFp Ge+Z2n86dYWxp6aGclq4yJkuIalAv/0i1FqyIbvMh94Gyd6aWIWFfuSQx4MXDKv5oW7A RDvdJ9Zl+tIYPumiDnrJnRs7WU6reiOZQbgTn0xDJhZCDxbcRXvDy9uJ7ZLSU2bOCfCI pRH0tDKdOPeOySnTV7AIjheflyguZlR6q/FaE9uImYaPRhLznKb0f0YcermqgZOC35Cg 22gM3N57qkAoLpzeUpYmlefZRY4eqY6lMFIKrEmVb7Nd9//dBJGVgXk/vlr5yHhC7hdp DKdw== X-Gm-Message-State: AOAM530cvLHptRiN4U2KALJkCuh1bZS1kl25YegBlw77DXdw9s9vK9w+ 7oPug+YTsnkKLbb+vu3o53H3hQ== 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> Precedence: bulk X-Mailing-List: ntfs3@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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