block: also call ->open for incremental partition opens
authorChristoph Hellwig <hch@lst.de>
Thu, 8 Jun 2023 11:02:29 +0000 (13:02 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 12 Jun 2023 14:04:03 +0000 (08:04 -0600)
commit9d1c92872e7082f100f629a58b32fa0214aa1aec
tree5674b55326a5a01ae2e19ae3839b099968fc1a54
parentfece685cc7bbb5e1af89f891223c31c3bcc969f7
block: also call ->open for incremental partition opens

For whole devices ->open is called for each open, but for partitions it
is only called on the first open of a partition, e.g.:

  open("/dev/vdb", ...)
  open("/dev/vdb", ...)
    - 2 call to ->open

  open("/dev/vdb1", ...)
  open("/dev/vdb", ...)
    - 2 call to ->open

  open("/dev/vdb", ...)
  open("/dev/vdb", ...)
    - just open call to ->open

This is problematic as various block drivers look at open flags and
might not do all the required setup if the earlier open was with an
odd flag like O_NDELAY or the magic 3 ioctl-only open mode.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Phillip Potter <phil@philpotter.co.uk>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/r/20230608110258.189493-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bdev.c