Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2302095ybc; Sun, 17 Nov 2019 18:26:05 -0800 (PST) X-Google-Smtp-Source: APXvYqw/cZCkzAXqFFal2VD1bpZxhH07c7XnTnr/x8Bc2ZNMeiWDduyzZSgeF114ax7b2fu/bBDL X-Received: by 2002:a17:906:3ec2:: with SMTP id d2mr23615792ejj.251.1574043965881; Sun, 17 Nov 2019 18:26:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574043965; cv=none; d=google.com; s=arc-20160816; b=h8PsxjqdI4ZdgfRGFigqeTcP1+Y8Cf5Jk7/SaGsW5ckarrEOFDdsjdPbaQfX2IIsAN OBV6O7m+x6fE6zxLTw+id/nmRu3a52EeBIzM6Ba68hNHAEjmNLkcwIOivKFO+EjUfflV lq9N2LWdjYSbeW78TCzNPv5Ddp8aLP91HgY8IK+HPyY7hqlAbFDlzXc7WmHMx4HPlmSX m2oU8RwtIoelYMPnGOOSWHEqd1Q0Vypc1+dY4UGUM9X6jacPdENy/OlzyYfYwX4Q28Hw TbvewF7Kyzu22iM+8OIbj6v/ANjOCoeBEgXzpFR3rUW2H5XV8Udp0EjwQ1jvu0IM6IdM 8oYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=0PODx413zWYXfSobH+0+CB4Ms3JTa4kjwkVV1cKBF0I=; b=OSgFxUje2QMSaLh4QS9x+i+zVM473hj2GWF4GfjsL3fgYVZIFoBm0hIo6H+QRRaY1Z Jhud/xnIzqIRpfQNUeIgJMNCJjQRmNI+UPPASXaUFrYgdHNtv35MyoYiqi9i6o2HWl+f UQBafZwYP/iyO65z4YY08EJYXZ8kl3etjRgFwzBeWRkYiTUm1Kx/dm5Rt2d0CwCJQKIS y6kHhr9Ve2x0r7ifoR2tmgvpx9CrXwP7Q9AMhWPkiMySadp7OHCV8ZMlfdDchhywYLzI 8ZdIDxJE7RovQUmycr4pEJo9X6UhIUY2fPDeIgHSb/+jHFy4mAddOWvNcgLVk+0lBIdO E2xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rmjEArZt; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si13325681edn.202.2019.11.17.18.25.40; Sun, 17 Nov 2019 18:26:05 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rmjEArZt; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726325AbfKRCYo (ORCPT + 99 others); Sun, 17 Nov 2019 21:24:44 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:33672 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725905AbfKRCYo (ORCPT ); Sun, 17 Nov 2019 21:24:44 -0500 Received: by mail-qk1-f194.google.com with SMTP id 71so13141347qkl.0; Sun, 17 Nov 2019 18:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=0PODx413zWYXfSobH+0+CB4Ms3JTa4kjwkVV1cKBF0I=; b=rmjEArZt+40+6whHrw6ndvflf4Colo6cGXVekvJlkeRrMjkUod5apJCONqqT4UVuey KJHpoxmAd2B/w6sVOUPRXpmHgQQSh2FsaQ28m6shiAZ7OKPzEhS/0Ilq3/1NEEhVC29k zbTYIPnDmR4GKiYbWR/73N1wgIrjxq77uMlJ+7LNVmYLSfY3XW7CiK0ke66ner0HGenJ 0LuVUcu5jgnsLsEDYwCgL9Bi6qwDZZ49awAZahqJarg0niTRKSw0x0hu63HgmNeix3oZ wbYcmFMFlDXC5Fu84M+oQbKneXjPl3JXfAuEVX5ktGKLobIoyZuT+X/qfByP7FMKlH3V Rf6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0PODx413zWYXfSobH+0+CB4Ms3JTa4kjwkVV1cKBF0I=; b=g/jv/OrVDJH5GXpcrEj5KwV3M3/autmmPPgBPYR6xmk2VubGFGpoBEqyzycGqYOl1K Hw9UxENL58bPb0U4LsCGAcqChRhTBcN+h/yUWz1U3wF1Ks9BlD7xu0LKyfJFk3kttXnq doJDbX82t3zpsNeldPRTWMz6y9EHFWivw4OajjAGdqjeYNONuWjPg/EJRprBYfib+wZ2 cDsHUeBfDn7uZdSwOhr/deiR/Q4nsoMzdbOrzUnIY79FqbD8Fbb92uZHgI/UscYGAvAD WlMzmBAvx1Z/Tyd/kr8yAwLsR7PUGyXjqKk2VIklELHXoKHiUwnTG5N+mUz/ImeMmyMq drNg== X-Gm-Message-State: APjAAAUp1t0xBXTyTdd65mUFyS93jAX1Rlq1MNnHsb1PC56zHaKpk3dA y1na+9Kz1yltjNG8ZBaU6g== X-Received: by 2002:a05:620a:159c:: with SMTP id d28mr21918417qkk.466.1574043882984; Sun, 17 Nov 2019 18:24:42 -0800 (PST) Received: from gabell.redhat.com (209-6-122-159.s2973.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [209.6.122.159]) by smtp.gmail.com with ESMTPSA id w15sm9687938qtk.43.2019.11.17.18.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Nov 2019 18:24:42 -0800 (PST) From: Masayoshi Mizuma To: Miklos Szeredi , linux-fsdevel@vger.kernel.org Cc: Masayoshi Mizuma , Masayoshi Mizuma , linux-kernel@vger.kernel.org, virtio-fs@redhat.com Subject: [PATCH] fuse: Fix the return code of fuse_direct_IO() to deal with the error for aio Date: Sun, 17 Nov 2019 21:24:10 -0500 Message-Id: <20191118022410.21023-1-msys.mizuma@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Masayoshi Mizuma --- fs/fuse/file.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index db48a5cf8620..87b151aec8f2 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -3115,8 +3115,12 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter) fuse_aio_complete(io, ret < 0 ? ret : 0, -1); /* we have a non-extending, async request, so return */ - if (!blocking) - return -EIOCBQUEUED; + if (!blocking) { + if (ret >= 0) + return -EIOCBQUEUED; + else + return ret; + } wait_for_completion(&wait); ret = fuse_get_res_by_io(io); -- 2.18.1