From nobody Thu Feb 12 22:39:47 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 2771E195FEC for ; Wed, 5 Feb 2025 15:34:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738769650; cv=none; b=tHenT8yp7GMZ/Q9mfDcfw2JF32msxkEppkTF9CGfb8HXkOkxXiV6JuhQ2HUOPEQ14shgVFhnaXiRa/PtPX6iJXUAuVFwRacl8A8WWvi1UipYtCjjfxAVmipAKy+OZwqkIRNwfIgenFTyAiEcpJxClL9mP1UGZxT+AQHODBiThoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738769650; c=relaxed/simple; bh=CH4T9+TF1MUD6mj1IRko7WEeyjBYMqNwdCkEifawIK0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=quxOCv2E9oCd+fR0t4hwfRHMKiZ4OtroLYyU+xgNl/+INR19S0J+Qk3nxJHgyXBHI0+sms9GBOWNF17qEA5Qob6kSa4dWrNkGSZxSguCvWVEtAClkNEGw8NJ2byx68lyavxwP5q/NvEbXUKJoKiyfj+v8wOV1VLDdDey8gaQEgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=X8YtVjqC; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="X8YtVjqC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738769648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Xfr2SzfrB4u2rCpY5Ho60tM6BgqInZ+FNLekjkmhEVw=; b=X8YtVjqCqK/u0BGWT6A6roWdD2C5O/NUuKclqMSHkVnWYItUqnGPVssWcY+1tvB3M+9Ozo ZJ2H93XKXhA7qoWGPxoA8nIo90jOOlApbtskN2H5R/3uk9jnz0T8rGPYWSGD6ZPSYrrIV9 Ruq/OcMV0F58ct1lWRHBfEnvfYInb6U= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-k8IT80GsNs2bJ6s1qdC2Mg-1; Wed, 05 Feb 2025 10:34:04 -0500 X-MC-Unique: k8IT80GsNs2bJ6s1qdC2Mg-1 X-Mimecast-MFC-AGG-ID: k8IT80GsNs2bJ6s1qdC2Mg Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5430919560AA; Wed, 5 Feb 2025 15:34:02 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.224.10]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 94B89300018D; Wed, 5 Feb 2025 15:33:57 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 5 Feb 2025 16:33:35 +0100 (CET) Date: Wed, 5 Feb 2025 16:33:29 +0100 From: Oleg Nesterov To: Christian Brauner , Jeff Layton , Linus Torvalds Cc: David Howells , "Gautham R. Shenoy" , K Prateek Nayak , Mateusz Guzik , Neeraj Upadhyay , Oliver Sang , Swapnil Sapkal , WangYuli , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] pipe: introduce struct file_operations pipeanon_fops Message-ID: <20250205153329.GA2255@redhat.com> References: <20250205153302.GA2216@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250205153302.GA2216@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" So that fifos and anonymous pipes could have different f_op methods. Preparation to simplify the next patch. Signed-off-by: Oleg Nesterov --- fs/internal.h | 1 + fs/pipe.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index e7f02ae1e098..dfdc2b2cf2f5 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -229,6 +229,7 @@ extern void d_genocide(struct dentry *); * pipe.c */ extern const struct file_operations pipefifo_fops; +extern const struct file_operations pipeanon_fops; =20 /* * fs_pin.c diff --git a/fs/pipe.c b/fs/pipe.c index 94b59045ab44..b05cded28d9b 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -895,7 +895,7 @@ static struct inode * get_pipe_inode(void) inode->i_pipe =3D pipe; pipe->files =3D 2; pipe->readers =3D pipe->writers =3D 1; - inode->i_fop =3D &pipefifo_fops; + inode->i_fop =3D &pipeanon_fops; =20 /* * Mark the inode dirty from the very beginning, @@ -938,7 +938,7 @@ int create_pipe_files(struct file **res, int flags) =20 f =3D alloc_file_pseudo(inode, pipe_mnt, "", O_WRONLY | (flags & (O_NONBLOCK | O_DIRECT)), - &pipefifo_fops); + &pipeanon_fops); if (IS_ERR(f)) { free_pipe_info(inode->i_pipe); iput(inode); @@ -949,7 +949,7 @@ int create_pipe_files(struct file **res, int flags) f->f_pipe =3D 0; =20 res[0] =3D alloc_file_clone(f, O_RDONLY | (flags & O_NONBLOCK), - &pipefifo_fops); + &pipeanon_fops); if (IS_ERR(res[0])) { put_pipe_info(inode, inode->i_pipe); fput(f); @@ -1107,8 +1107,8 @@ static void wake_up_partner(struct pipe_inode_info *p= ipe) =20 static int fifo_open(struct inode *inode, struct file *filp) { + bool is_pipe =3D inode->i_fop =3D=3D &pipeanon_fops; struct pipe_inode_info *pipe; - bool is_pipe =3D inode->i_sb->s_magic =3D=3D PIPEFS_MAGIC; int ret; =20 filp->f_pipe =3D 0; @@ -1241,6 +1241,17 @@ const struct file_operations pipefifo_fops =3D { .splice_write =3D iter_file_splice_write, }; =20 +const struct file_operations pipeanon_fops =3D { + .open =3D fifo_open, + .read_iter =3D pipe_read, + .write_iter =3D pipe_write, + .poll =3D pipe_poll, + .unlocked_ioctl =3D pipe_ioctl, + .release =3D pipe_release, + .fasync =3D pipe_fasync, + .splice_write =3D iter_file_splice_write, +}; + /* * Currently we rely on the pipe array holding a power-of-2 number * of pages. Returns 0 on error. @@ -1388,7 +1399,9 @@ struct pipe_inode_info *get_pipe_info(struct file *fi= le, bool for_splice) { struct pipe_inode_info *pipe =3D file->private_data; =20 - if (file->f_op !=3D &pipefifo_fops || !pipe) + if (!pipe) + return NULL; + if (file->f_op !=3D &pipefifo_fops && file->f_op !=3D &pipeanon_fops) return NULL; if (for_splice && pipe_has_watch_queue(pipe)) return NULL; --=20 2.25.1.362.g51ebf55