From patchwork Sat Feb 24 01:17:23 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: 205760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp934624dyb; Fri, 23 Feb 2024 17:18:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW0+Zb7y15UdsWKZ63NGYf30hLFEc0H13EREFz1ysFs7dZ1/FUCNhbbz+4QvuM/6pNa26wAxlHTWWChT0xx4iERi0aE2A== X-Google-Smtp-Source: AGHT+IGDImxfnXESe6WGyBpJnktnELvmiqL1Uivg6dModpPsDe83zgz9u3TciJkEBHf8Zi/1aIgH X-Received: by 2002:a05:6358:6f86:b0:17b:6f52:79d3 with SMTP id s6-20020a0563586f8600b0017b6f5279d3mr1600877rwn.16.1708737519756; Fri, 23 Feb 2024 17:18:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708737519; cv=pass; d=google.com; s=arc-20160816; b=Znabt77V7aX73/sWgF+RsI6XLKdc5yeiQd6hy4dBogVfJTf4W/RlBw1nRHhjBLfNFN aAg2WaAY/lwlu+nAvGh4SVNXcc6kDnZg4NeLpc74BXyCq4Rl7zPZZTXoCyjNuSMowFFf 2EPA/93A7Asq/OzlHS5PiCXZBYy/X7NJDM/2i7PX4qmEvQCgUzz/jl1wjCxTBBMxaHJu gu8URX+zeZ0aGwSC+HCNAMQdLwZkaYf+RzjMEw5OCp78IzANTA49ECXd2WfX1tlOZI/X LKsG8naTHfxRCyqJigqo9IKohtNR2JwypW3NMIYwJXWlCZHs2pEWS/e/bnM4e7KLT0ty D4/w== 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=a1rJW3Lr+iPJ+Ur0SLD/bxxfK0CNMm4wPtBgpv4AOe4=; fh=eGotrG2wUAPCtJbO4MhMKF1jcndrbQy7pSZLLDRnPjs=; b=PZXE7c8qFF7kRv456RCUfZHWrwZUoyXbLDrrxHk9uYoYMtInMXbyuIZ6ukhB+InkFZ 31CNNDOhx0KVhTqYyrpjq/MBqEF7NnjJdK5rdmW75h+pX//FR3w4KkhG0dlm9WQ+xLlE 27ZgETuEQCyZQPVAVX8n2jd/dGZZR71tnnGuLlY8QGRqSHh8e52zeKA5nIRn6sOV919N xiefFN7IoUQGw26ZpGT/gXl2QSokY+jhv31pv9LUITGWwETY3nYshXuCLfUx99SGDI8Z G1vruVqicmc9747q3jpZen16cIgvZDlIk/wSKXK2DV36MfgN5q//UO4W5IBjazcK+qm3 BbSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wqb8uP3n; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79417-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79417-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. [147.75.199.223]) by mx.google.com with ESMTPS id j2-20020a05620a146200b00787ad2ff7d7si122712qkl.482.2024.02.23.17.18.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 17:18:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79417-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wqb8uP3n; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-79417-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79417-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 87DA51C2316D for ; Sat, 24 Feb 2024 01:18:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1E85ABA2D; Sat, 24 Feb 2024 01:17:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wqb8uP3n" 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 6E9C69473; Sat, 24 Feb 2024 01:17:24 +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=1708737444; cv=none; b=GXo4ngTHdJpPt1VO2/UAoOn7ypaHEaJNQ1ka7ic/J1TVbg624wJZSHfiWx/dn90W2ogCu2AWCwLW9tBbQrKudr33UEihKNYzHzMyuAOKPsIdDo9jCcA8JC1gTKnD51Xk+HUiwYe6+u8lCKPOaczw+maKJ4pikYac5/ZAxHcZqXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708737444; c=relaxed/simple; bh=6IgKAnRC9HZ1+DMx6qKSJXO282zOxYj2aK6NUSak7mk=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Bq/VMMMuRs9xZmKZhIQe8Hfal8qItvoPubbCmNpu+fLbiqKc7m45EvrYgxPiHKpNd7S/37z3EvzAGnYsJohP7JphZQHE5kMYUgTVaqiNnCKDfbwxKPKnToz5YGwX9B6kZnrpzndMQpnCXChYiLEWk0rf0SCh7rbECUdH1H2adGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wqb8uP3n; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D53E1C433F1; Sat, 24 Feb 2024 01:17:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708737443; bh=6IgKAnRC9HZ1+DMx6qKSJXO282zOxYj2aK6NUSak7mk=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Wqb8uP3nEts44NoynAnfg3U+0J8HQh8VOOnAhIr1TugjJfxfrXA4qaUNKp6BfS9C+ teqcKULtwbzl9POLu3eBa8zacMjWL2Z765IgRu4xsVflxDfJ8I+U2yk5NKrOYCiyXT u03WSOHXd/QjYtdMgaiadMd8czDYBng7K1GbFy9F7p7OMyYgqKU08aFQrdjTbNLEaN MQ6odQ2KA8zSf3nK/v/LCi5gcPRt34ZSRlEcy5LN/lNIOW4E0Nk0RIcEr73buYuG4i j33ovb8qtry7TvaJtMwv09qnLwjW7i5el2WsDrWnMA5irxrFJ+FgqcN9DiEt0LWX+7 0YmX5v/KpCYQg== Date: Fri, 23 Feb 2024 17:17:23 -0800 Subject: [PATCH 4/5] thread_with_file: allow ioctls against these files 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: <170873669465.1861696.18118008706761741778.stgit@frogsfrogsfrogs> In-Reply-To: <170873669390.1861696.14195299906744951144.stgit@frogsfrogsfrogs> References: <170873669390.1861696.14195299906744951144.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: 1791741153500077590 X-GMAIL-MSGID: 1791741153500077590 From: Darrick J. Wong Make it so that a thread_with_stdio user can handle ioctls against the file descriptor. Signed-off-by: Darrick J. Wong Signed-off-by: Kent Overstreet --- include/linux/thread_with_file.h | 1 + lib/thread_with_file.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/linux/thread_with_file.h b/include/linux/thread_with_file.h index 445b1b12a0bd6..33770938d5d9a 100644 --- a/include/linux/thread_with_file.h +++ b/include/linux/thread_with_file.h @@ -57,6 +57,7 @@ struct thread_with_stdio; struct thread_with_stdio_ops { void (*exit)(struct thread_with_stdio *); void (*fn)(struct thread_with_stdio *); + long (*unlocked_ioctl)(struct thread_with_stdio *, unsigned int, unsigned long); }; struct thread_with_stdio { diff --git a/lib/thread_with_file.c b/lib/thread_with_file.c index 2edf33c3e7dc5..8b129744a48a3 100644 --- a/lib/thread_with_file.c +++ b/lib/thread_with_file.c @@ -379,12 +379,23 @@ static __poll_t thread_with_stdout_poll(struct file *file, struct poll_table_str return mask; } +static long thread_with_stdio_ioctl(struct file *file, unsigned int cmd, unsigned long p) +{ + struct thread_with_stdio *thr = + container_of(file->private_data, struct thread_with_stdio, thr); + + if (thr->ops->unlocked_ioctl) + return thr->ops->unlocked_ioctl(thr, cmd, p); + return -ENOTTY; +} + static const struct file_operations thread_with_stdio_fops = { .llseek = no_llseek, .read = thread_with_stdio_read, .write = thread_with_stdio_write, .poll = thread_with_stdio_poll, .release = thread_with_stdio_release, + .unlocked_ioctl = thread_with_stdio_ioctl, }; static const struct file_operations thread_with_stdout_fops = { @@ -392,6 +403,7 @@ static const struct file_operations thread_with_stdout_fops = { .read = thread_with_stdio_read, .poll = thread_with_stdout_poll, .release = thread_with_stdio_release, + .unlocked_ioctl = thread_with_stdio_ioctl, }; static int thread_with_stdio_fn(void *arg)