Re: [PATCH RFC] fuse: Prevent background write requests increase inode size

From: Miklos Szeredi
Date: Wed Jan 23 2019 - 04:37:32 EST


On Tue, Nov 6, 2018 at 3:03 PM Kirill Tkhai <ktkhai@xxxxxxxxxxxxx> wrote:
>
> Hi, Miklos,
>
> this is not a well-tested patch, this is a concept,
> showing the places, where it looks we have a problem.
>
> Commit 7879c4e58b7c made io->async careless about inode size,
> and this is wrong. Asyncronuos background requests may be sent
> to userspace after inode becomes unlocked, when background
> queue is throttled. In this case we execute a write request
> extending inode size without any protection, and this ruines
> everything. Fix that.
>
> Also, some write background requests do not increment fi->writectr,
> e.g.:
> fuse_direct_IO()
> fuse_direct_io()
> fuse_send_write()
> fuse_async_req_send()
> fuse_request_send_background()

inode_lock should prevent mischief for sync DIO. For AIO DIO the
order of operations is not deterministic, so it's fine if truncate and
an extending AIO write race, as far as I understand.

Thanks,
Miklos