[Virtio-fs] [PATCH 3/3] virtio-fs: Waiting for pending forget requests to finish
Peng Tao
tao.peng at linux.alibaba.com
Tue Jun 4 04:06:40 UTC 2019
On 2019/6/1 02:57, Vivek Goyal wrote:
> Keep a track of pending forget requests and wait for these to finish
> during ->kill_sb()
>
> Signed-off-by: Vivek Goyal <vgoyal at redhat.com>
> ---
> fs/fuse/virtio_fs.c | 38 +++++++++++++++++++++++++++++++++++++-
> 1 file changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> index 737e92cdc5ed..abdb58285805 100644
> --- a/fs/fuse/virtio_fs.c
> +++ b/fs/fuse/virtio_fs.c
> @@ -32,6 +32,7 @@ struct virtio_fs_vq {
> struct delayed_work dispatch_work;
> struct fuse_dev *fud;
> bool connected;
> + long in_flight;
> char name[24];
> } ____cacheline_aligned_in_smp;
>
> @@ -183,8 +184,10 @@ static void virtio_fs_hiprio_done_work(struct work_struct *work)
>
> virtqueue_disable_cb(vq);
>
> - while ((req = virtqueue_get_buf(vq, &len)) != NULL)
> + while ((req = virtqueue_get_buf(vq, &len)) != NULL) {
> kfree(req);
> + fsvq->in_flight--;
> + }
> } while (!virtqueue_enable_cb(vq) && likely(!virtqueue_is_broken(vq)));
> spin_unlock(&fsvq->lock);
> }
> @@ -244,6 +247,7 @@ static void virtio_fs_hiprio_dispatch_work(struct work_struct *work)
> return;
> }
>
> + fsvq->in_flight++;
> notify = virtqueue_kick_prepare(vq);
> spin_unlock(&fsvq->lock);
>
> @@ -753,6 +757,7 @@ __releases(fiq->waitq.lock)
> goto out;
> }
>
> + fsvq->in_flight++;
> notify = virtqueue_kick_prepare(vq);
>
> spin_unlock(&fsvq->lock);
> @@ -982,6 +987,36 @@ __releases(fiq->waitq.lock)
> }
> }
>
> +static void virtio_fs_flush_hiprio_queue(struct virtio_fs_vq *fsvq)
> +{
> + struct virtio_fs_forget *forget;
> +
> + WARN_ON(fsvq->in_flight < 0);
> +
> + /* Go through pending forget reuests and free them */
> + spin_lock(&fsvq->lock);
> + while(1) {
> + forget = list_first_entry_or_null(&fsvq->queued_reqs,
> + struct virtio_fs_forget, list);
> + if (!forget)
> + break;
missing list_del()?
Cheers,
Tao
More information about the Virtio-fs
mailing list