Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2817513ybc; Wed, 20 Nov 2019 21:52:38 -0800 (PST) X-Google-Smtp-Source: APXvYqx5QjxlBqEGmdcKrLTmwsJeJPhFR/shRauppejQQFdKbw5l5og0Xzj2aKhFc7j6zHT9AGto X-Received: by 2002:a17:906:1503:: with SMTP id b3mr10775561ejd.78.1574315558456; Wed, 20 Nov 2019 21:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574315558; cv=none; d=google.com; s=arc-20160816; b=OZkeIv6z6qVXulcPrRT3yNuDSERq2RsgbjfJzauanPz/YEKW32yZVyf2biip/5UzPD QDwVy+Yc6sCn/uysk1jGPZ2JsUx5jRsmHAyfrV0KUVWjpMntiNPcW++rVpZtPeF2qOLT DIG+faLcRL0toi2i3sH6pnYVtRBzMXSOV1BzKOXJkhKNlLhFZ8yx5bI/tUHa45rIvTIj i5sk9r63QfSCp5VCBTRdwfhURxN0Bc1f9U+bQDmKMHPPIMsXLzLOQV1sTXtz4RBSMxy2 2+3Capud4NBORCt1bathvDFNQBnRq9hLBAYTbHba42TsvXpTu1XwBnbRABFXFtNGiGrF eeiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=5/jmLAS+dSzy2HwJ8VDHs3P7PBfAVInCqSPw+NM3Woo=; b=CKUlah7W1el3RvxGZHXU4fPq7UgzAENdo+q4yhMfuVGgpez3Y/vGqDMy9oGmIv2eEf hOw2GsALWmyX7rdg9Lc8Zm1xv7LmMSWfGkO5dJuQl9X0bVDo0lT7AAUwWJozt5MdIobi pSWW4w+ShVzTrpBVzu8BevaSyJiyBUBWWhdvpC9WalazdElZqrZoRQUW+FvNYGQXeVna 6XiJZYKelixNOqhgWL1iUTCWQilJfezAYhI8ApXLdKZg3Hwxz4Cdu4GIKmKe6HzLxjtG cOsipNUGIwTPgDAOckrWrPfruw37F6TQPBs7oo4+yrwzHXpAQmB67FOOm+teRPtVw2ui plrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z37si1327982edz.281.2019.11.20.21.52.01; Wed, 20 Nov 2019 21:52:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbfKUFue (ORCPT + 99 others); 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 X-Spam-Status: No 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