On Wed, Jan 03, 2024 at 12:51:55AM -0800, Christoph Hellwig wrote: > On Sun, Dec 31, 2023 at 12:14:20PM -0800, Darrick J. Wong wrote: > > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > > > In the next few patches, we're going into introduce buffer targets that > > are not block devices. Introduce block_device helpers so that the > > compiler can check that we're not feeding an xfile object to something > > expecting a block device. > > I don't see how these helpers allow the compiler to check anything. > I also don't see any other good reason for the helpers, but maybe I'm > just missing something. Oh, right -- originally, this patch made struct xfs_buftarg do this: struct xfs_buftarg { dev_t bt_dev; union { struct block_device *bt_bdev; struct xfile *bt_xfile; }; struct dax_device *bt_daxdev; Dereferencing bt_bdev/bt_xfile was controlled through a buftarg flag. IOWs, it employed the tagged union pattern. When bt_bdev_handle came about, I gave up on the tagged union and simply added another pointer to struct xfs_buftarg. There aren't that many of them floating around in the system, so the extra 8 bytes isn't a giant drain on resources. struct xfs_buftarg { dev_t bt_dev; struct bdev_handle *bt_bdev_handle; struct block_device *bt_bdev; struct dax_device *bt_daxdev; struct xfile *bt_xfile; Now we don't need these wrappers since we can't accidentally dereference bt_xfile as a struct block_device. I'll drop this one. --D