Re: How does ftruncate() interact with DIO read?

From: Christoph Hellwig
Date: Fri Feb 03 2023 - 11:31:19 EST


On Fri, Feb 03, 2023 at 04:27:10PM +0000, David Howells wrote:
> Hi Christoph,
>
> What does ftruncate() do if there's a conflicting DIO read happening on the
> same file? Does it cancel the bio?

There is no way to cancel a bio. ->setattr is supposed to call
inode_dio_wait to wait for pending I/O, although some file systems
like btrfs have their own hand crafted and more complicated version
of that.