From patchwork Sat Feb 24 01:15:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 205755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp934071dyb; Fri, 23 Feb 2024 17:16:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUQldOQGf5XLGj9uFol4XGBkoj/HSbzJ/dsukTan9aq5SAXbtmBabOBG5qTL7v5yvjvkjLGsgJECv9LK2WjHA3JaMleNA== X-Google-Smtp-Source: AGHT+IH6UJ55c8efCaUTYhAxpJA6KZWQh5ToFtBmVCsdyQVt5DJ6G152Z2a79zb1xNlfkDRKByna X-Received: by 2002:a05:6808:3989:b0:3c1:803b:4520 with SMTP id gq9-20020a056808398900b003c1803b4520mr2310158oib.57.1708737419401; Fri, 23 Feb 2024 17:16:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708737419; cv=pass; d=google.com; s=arc-20160816; b=rpllaQ5V3Xrvz6VjYLrxzl3PpKSjkGs45bdwlUwEsELoQEEcJ1cIsIHo5vkPAiAH83 hIGoeD9jMLb5wtNCoRlc1Ci7I+q8PnkavnUznga0NPTGV5JAJiezfNLu3eS2mzgVCgrN d543teIC+2wp9X4LtH/T2M5Pa3/X4+JytVScwt45fvkfOeu5GB6LmSF2F/5Ko5b/IeNT WhXmB7zsETnUE1D+VZ1UDg8nPyZFTBdr8b+CN+SZaGPbilZpTlFtTrw4MCpdUYIH4ZYx l24XGvlbLr3vNK37AoVHI/PAh2pXcAhuRchnnDePlZGpBAENjUxTVf9LmhIkOamO4aoU DCMQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:cc:to:from:subject:date:dkim-signature; bh=N8SCtHB22VlwXhS3KOG0Cg+Fb1MWCjRzEbSLPtZMbIQ=; fh=eGotrG2wUAPCtJbO4MhMKF1jcndrbQy7pSZLLDRnPjs=; b=qot7MLU9RjTSzzWNgli5sLN705s2F9Lo2/85UHQxvFHMpatgYSsmA02y+0AYt3hJXu vG7ntVFkpbbbjgeQviysK2FP88/cdjtnLzKgNbCF9GJCQVrAsBAQVdxEjq2mF8gkDFXE YWX98PHPKxQHvbX0SN3MvHM8c+mc+hoRGldTi+mxfkDYOTzKbtsT/DC1z5Fm7KSplnC2 FjsBf6WLSdvdvOCI5HzbvQbyQheaK7cozRHSe6NeVNfZm3HvSAfeOO3peK8Ku8muu/lo +g+iTab413Jvo/b7bSh7UnBUJS4XANfH6S11pvf8+J1qJI8nHgIgMIGU/3HJFDb5BP8R qRdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C9afMtX6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79411-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79411-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u10-20020ac858ca000000b0042c2e1586a4si186367qta.767.2024.02.23.17.16.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 17:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79411-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C9afMtX6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79411-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79411-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 097AF1C22333 for ; Sat, 24 Feb 2024 01:16:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 343F06FD2; Sat, 24 Feb 2024 01:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C9afMtX6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C6D7625; Sat, 24 Feb 2024 01:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708737350; cv=none; b=ffcG17frEOdWLwvP1TWpSC5xEcfuBZDNgGie9FwxzHnpE4y6jyaWBwKYJqDLb8WgZjTj/8G7dgWntOEMvSlQVF7+x5rzAKj50VOmkK6yO2tcl8lyI6NUCyKYy2ry6La6My1qBFHFqijAn0wX/W4EarIKtEJJp10qkl70uPmfr90= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708737350; c=relaxed/simple; bh=SqW/eE4ssRbXCZM7r2fVia0zdNVyh9xWEqJ5//VHBpk=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t+cIjOpmQILHLzDeYe+umwdbRXAKjNL0+lg9D3kV9CNBXPp5rLCWyvj4Iyu3KdUG+BUJNP57mUsMhODdlcdhWKdB7+5aTje7A2H1bIwLZF+AMI7tUih2o6WGrmji3R3N4eZ3hdng2S9wiNkVVW0u2cgKC54fPW0OflU7wErVj08= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C9afMtX6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16619C433C7; Sat, 24 Feb 2024 01:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708737350; bh=SqW/eE4ssRbXCZM7r2fVia0zdNVyh9xWEqJ5//VHBpk=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=C9afMtX6n6yz2v4DMQFskWpvmgaS8RYnt/l5D7tY1Tm/wOJBz5T4JI+62sEFGpmd5 HLvHZvCF8x1mTG0RmjZIKSJs3P1ycDsLdnZtkf41EImNCVvneaDDHKrVos3EYzWmku kd0EPO1U15z7uF/5Xhf7FJuRdbtAuXzPXc0Q+h3p8GM9lCENk8HnQmzyIP0ZsXWJ1J j3/LiKmmzR2nUkcb2+DDxKyNvFR6yPJvHwcXGENM3JjKRq56Ww8lPr/iZuPYiaOZDl vo3+J1fS1cJ4Efh03Bd5pbwe4SY0qay+r1u7cOwHc8LTV27qg985MRzBsz6XUFc9Hi ewT6meZI3/ORg== Date: Fri, 23 Feb 2024 17:15:49 -0800 Subject: [PATCH 08/10] thread_with_stdio: Mark completed in ->release() From: "Darrick J. Wong" To: akpm@linux-foundation.org, daniel@gluo.nz, kent.overstreet@linux.dev, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <170873669018.1861398.16986816951760275853.stgit@frogsfrogsfrogs> In-Reply-To: <170873668859.1861398.2367011381778949840.stgit@frogsfrogsfrogs> References: <170873668859.1861398.2367011381778949840.stgit@frogsfrogsfrogs> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791741048481229642 X-GMAIL-MSGID: 1791741048481229642 From: Kent Overstreet This fixes stdio_redirect_read() getting stuck, not noticing that the pipe has been closed. Signed-off-by: Kent Overstreet Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- lib/thread_with_file.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/thread_with_file.c b/lib/thread_with_file.c index 092996ca43fe7..f4946a437332a 100644 --- a/lib/thread_with_file.c +++ b/lib/thread_with_file.c @@ -201,6 +201,14 @@ EXPORT_SYMBOL_GPL(run_thread_with_file); /* thread_with_stdio */ +static void thread_with_stdio_done(struct thread_with_stdio *thr) +{ + thr->thr.done = true; + thr->stdio.done = true; + wake_up(&thr->stdio.input.wait); + wake_up(&thr->stdio.output.wait); +} + static ssize_t thread_with_stdio_read(struct file *file, char __user *ubuf, size_t len, loff_t *ppos) { @@ -315,6 +323,7 @@ static int thread_with_stdio_release(struct inode *inode, struct file *file) struct thread_with_stdio *thr = container_of(file->private_data, struct thread_with_stdio, thr); + thread_with_stdio_done(thr); thread_with_file_exit(&thr->thr); darray_exit(&thr->stdio.input.buf); darray_exit(&thr->stdio.output.buf); @@ -336,10 +345,7 @@ static int thread_with_stdio_fn(void *arg) thr->fn(thr); - thr->thr.done = true; - thr->stdio.done = true; - wake_up(&thr->stdio.input.wait); - wake_up(&thr->stdio.output.wait); + thread_with_stdio_done(thr); return 0; }