Re: [PATCH v2 1/2] block: add sync_blockdev_range()

From: Christoph Hellwig
Date: Thu Apr 07 2022 - 04:11:43 EST


On Wed, Apr 06, 2022 at 10:21:15AM +0000, Yuezhang.Mo@xxxxxxxx wrote:
> > From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
> > > --- a/block/bdev.c
> > > +++ b/block/bdev.c
> > > @@ -200,6 +200,16 @@ int sync_blockdev(struct block_device *bdev) }
> > > EXPORT_SYMBOL(sync_blockdev);
> > >
> > > +int sync_blockdev_range(struct block_device *bdev, loff_t lstart,
> > > +loff_t lend) {
> > > + if (!bdev)
> > > + return 0;
> >
> > This check isn't really needed, and I don't think we need a !CONFIG_BLOCK
> > stub for this either.
>
> sync_blockdev() and related helpers have this check and a !CONFIG_BLOCK stub.
> I would like to understand the background of your comment, could you explain a little more?

sync_blockdev and sync_blockdev do that because they are unconditionally
called from sync_filesystem, and not just from block-dependent code.
Eventually that should be cleaned up as well, but please don't add it to
new code.