From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 939E8C43215 for ; Thu, 21 Nov 2019 05:50:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 74DB92068E for ; Thu, 21 Nov 2019 05:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbfKUFue (ORCPT ); Thu, 21 Nov 2019 00:50:34 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:47939 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725904AbfKUFue (ORCPT ); Thu, 21 Nov 2019 00:50:34 -0500 X-IronPort-AV: E=Sophos;i="5.69,224,1571673600"; d="scan'208";a="78831327" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Nov 2019 13:50:32 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 6F4CC4CE1BED; Thu, 21 Nov 2019 13:42:11 +0800 (CST) Received: from [10.167.226.60] (10.167.226.60) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 21 Nov 2019 13:50:26 +0800 Subject: Re: [PATCH] fuse: Fix the return code of fuse_direct_IO() to deal with the error for aio To: Masayoshi Mizuma , Miklos Szeredi , CC: Masayoshi Mizuma , , References: <20191118022410.21023-1-msys.mizuma@gmail.com> From: Cao jin Message-ID: Date: Thu, 21 Nov 2019 13:51:31 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191118022410.21023-1-msys.mizuma@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.226.60] X-ClientProxiedBy: G08CNEXCHPEKD06.g08.fujitsu.local (10.167.33.205) To G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) X-yoursite-MailScanner-ID: 6F4CC4CE1BED.AB5CD X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: caoj.fnst@cn.fujitsu.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/18/19 10:24 AM, Masayoshi Mizuma wrote: > From: Masayoshi Mizuma > > exit_aio() is sometimes stuck in wait_for_completion() after aio is issued > with direct IO and the task receives a signal. > > That is because kioctx in mm->ioctx_table is in use by aio_kiocb. > aio_kiocb->ki_refcnt is 1 at that time. That means iocb_put() isn't > called correctly. > > fuse_get_req() returns as -EINTR when it's blocked and receives a signal. > fuse_direct_IO() deals with the -EINTER as -EIOCBQUEUED and returns as > -EIOCBQUEUED even though the aio isn't queued. > As the result, aio_rw_done() doesn't handle the error, so iocb_put() isn't > called via aio_complete_rw(), which is the callback. > > The flow is something like as: > > io_submit > aio_get_req > refcount_set(&req->ki_refcnt, 2) > __io_submit_one > aio_read > ... > fuse_direct_IO # return as -EIOCBQUEUED > __fuse_direct_read > ... > fuse_get_req # return as -EINTR > aio_rw_done > # Nothing to do because ret is -EIOCBQUEUED... > iocb_put > refcount_dec_and_test(&iocb->ki_refcnt) # 2->1 > > Return as the error code of fuse_direct_io() or __fuse_direct_read() in > fuse_direct_IO() so that aio_rw_done() can handle the error and call > iocb_put(). > > This issue is trucked as a virtio-fs issue: > https://gitlab.com/virtio-fs/qemu/issues/14 > I didn't reproduce this issue on kernel v5.4-rc7, but did on 5.4-rc8. And verified this patch fixed the case in issue 14 on v5.4-rc8 and virtiofsd (virtio-fs-dev 5f068fa9). Tested-by: Cao jin -- Sincerely, Cao jin