Re: [PATCH v2 31/34] block: use file->f_op to indicate restricted writes

Jan Kara
2024-02-01T17:36:33Z

On Thu 01-02-24 17:16:02, Christian Brauner wrote:
> On Thu, Feb 01, 2024 at 12:08:58PM +0100, Jan Kara wrote:
> > On Tue 23-01-24 14:26:48, Christian Brauner wrote:
> > > Make it possible to detected a block device that was opened with
> > > restricted write access solely based on its file operations that it was
> > > opened with. This avoids wasting an FMODE_* flag.
> > >
> > > def_blk_fops isn't needed to check whether something is a block device
> > > checking the inode type is enough for that. And def_blk_fops_restricted
> > > can be kept private to the block layer.
> > >
> > > Signed-off-by: Christian Brauner <brauner@kernel.org>
> >
> > I don't think we need def_blk_fops_restricted. If we have BLK_OPEN_WRITE
> > file against a bdev with bdev_writes_blocked() == true, we are sure this is
> > the handle blocking other writes so we can unblock them in
> > bdev_yield_write_access()...

...

> - if (mode & BLK_OPEN_RESTRICT_WRITES)
> + if (mode & BLK_OPEN_WRITE) {
> + if (bdev_writes_blocked(bdev))
> + bdev_unblock_writes(bdev);
> + else
> + bdev->bd_writers--;
> + }
> + if (bdev_file->f_op == &def_blk_fops_restricted)

Uh, why are you leaving def_blk_fops_restricted check here? I'd expect you
can delete def_blk_fops_restricted completely...

Honza

--
Jan Kara <jack@suse.com>
SUSE Labs, CR