From patchwork Wed Mar 8 03:10:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13165161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B790DC742A7 for ; Wed, 8 Mar 2023 03:10:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229785AbjCHDKp (ORCPT ); Tue, 7 Mar 2023 22:10:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbjCHDKj (ORCPT ); Tue, 7 Mar 2023 22:10:39 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAC6BA6BD7 for ; Tue, 7 Mar 2023 19:10:37 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id nn12so593991pjb.5 for ; Tue, 07 Mar 2023 19:10:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; t=1678245037; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FB0AlMXXyfbVB/DAeV/LMnWywE/8dZnz2/fFoG7xdHE=; b=SF75gIG+NWJnuHTSctHio4NqNZbahLtPmGtOfMudXUmkStMSOKugh7Ag20L69OeJa4 17yK6xGWC2pAx0Vw30Sgu2785XpsDWdzMCBaxg1MPOYhNxPKS6ZEqpDSsS16hlKqgT9A Lk9aMUF0FXnQa2gFaAEc6NMRpaZAMjpUho7Xmsa1E4BmiKmeECaHtojZcuCgrCsaj36a 4PuOoI9tqjzsg548d7t1W/YYaV+i7/+c1zWpjfLAwu7t9dI0lGjnSNg+GCIeUutEw/9D C48SipNDEJQvHbbqb2mxGveA0zWKzdS2wjLqL7rYNssnFrvcl1Gk8pkRPnpVwkD6CuQz 3pbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678245037; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FB0AlMXXyfbVB/DAeV/LMnWywE/8dZnz2/fFoG7xdHE=; b=ocJv9Kv41F+WLXGc9Sg70BRuMTDtA16ZHdMhWld8m1nACjF7GCJ5ACZ5NI7ZE/L0oY edr9J1aV1WZC1tKjJQOsEz62+9MuvDnb07hF0nOKF9oNWmKhYaCpOBvMoZHRQwOXps5I NqX39X5cuvV3u5bOdzUYeuEYwCOfQSjozbiHys5cO6GYp5BuEjvftuwdF7QsvW48dCAl 0svXQXfPKfJfPqLJJgItkYBG3itwKsnfFg2o5wGQg5Ba4rHIo2+cezoEHGTpAnhUyHdc eTE0r6xxLjcgBqMyBIr7hY6g++qBpxc/YwrpSyTfxmCw0AQlnFWnle5eelBqMRukAQzR Q2bQ== X-Gm-Message-State: AO0yUKXlD6pD4KU5Lq8k28U7dqDOhPLIHZsN5Br3SP2N4eG14TLdEPhF eDy48HfYlDXawhmMOIA3RWuf2Mlvx3FdFHxZjXg= X-Google-Smtp-Source: AK7set/o4+EhRBnpK7QuvDVJy4zTXRltjIkts8JDuPfLAYO1AwQc1dY0ZGqKId2Ebs+sELlpdRd64g== X-Received: by 2002:a17:90a:8d13:b0:234:b170:1f27 with SMTP id c19-20020a17090a8d1300b00234b1701f27mr12042521pjo.0.1678245037104; Tue, 07 Mar 2023 19:10:37 -0800 (PST) Received: from localhost.localdomain ([50.233.106.125]) by smtp.gmail.com with ESMTPSA id o44-20020a17090a0a2f00b0023440af7aafsm7995806pjo.9.2023.03.07.19.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 19:10:36 -0800 (PST) From: Jens Axboe To: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 1/3] fs: add 'nonblock' parameter to pipe_buf_confirm() and fops method Date: Tue, 7 Mar 2023 20:10:31 -0700 Message-Id: <20230308031033.155717-2-axboe@kernel.dk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230308031033.155717-1-axboe@kernel.dk> References: <20230308031033.155717-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In preparation for being able to do a nonblocking confirm attempt of a pipe buffer, plumb a parameter through the stack to indicate if this is a nonblocking attempt or not. Each caller is passing down 'false' right now, but the only confirm method in the tree, page_cache_pipe_buf_confirm(), is converted to do a trylock_page() if nonblock == true. Signed-off-by: Jens Axboe Reviewed-by: Christian Brauner --- fs/fuse/dev.c | 4 ++-- fs/pipe.c | 4 ++-- fs/splice.c | 11 +++++++---- include/linux/pipe_fs_i.h | 7 ++++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index eb4f88e3dc97..0bd1b0870f2d 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -700,7 +700,7 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) struct pipe_buffer *buf = cs->pipebufs; if (!cs->write) { - err = pipe_buf_confirm(cs->pipe, buf); + err = pipe_buf_confirm(cs->pipe, buf, false); if (err) return err; @@ -800,7 +800,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) fuse_copy_finish(cs); - err = pipe_buf_confirm(cs->pipe, buf); + err = pipe_buf_confirm(cs->pipe, buf, false); if (err) goto out_put_old; diff --git a/fs/pipe.c b/fs/pipe.c index 42c7ff41c2db..340f253913a2 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -297,7 +297,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) chars = total_len; } - error = pipe_buf_confirm(pipe, buf); + error = pipe_buf_confirm(pipe, buf, false); if (error) { if (!ret) ret = error; @@ -461,7 +461,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) if ((buf->flags & PIPE_BUF_FLAG_CAN_MERGE) && offset + chars <= PAGE_SIZE) { - ret = pipe_buf_confirm(pipe, buf); + ret = pipe_buf_confirm(pipe, buf, false); if (ret) goto out; diff --git a/fs/splice.c b/fs/splice.c index 2e76dbb81a8f..5ae6b4a202df 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -100,13 +100,16 @@ static void page_cache_pipe_buf_release(struct pipe_inode_info *pipe, * is a page cache page, IO may be in flight. */ static int page_cache_pipe_buf_confirm(struct pipe_inode_info *pipe, - struct pipe_buffer *buf) + struct pipe_buffer *buf, bool nonblock) { struct page *page = buf->page; int err; if (!PageUptodate(page)) { - lock_page(page); + if (nonblock && !trylock_page(page)) + return -EAGAIN; + else + lock_page(page); /* * Page got truncated/unhashed. This will cause a 0-byte @@ -498,7 +501,7 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des if (sd->len > sd->total_len) sd->len = sd->total_len; - ret = pipe_buf_confirm(pipe, buf); + ret = pipe_buf_confirm(pipe, buf, false); if (unlikely(ret)) { if (ret == -ENODATA) ret = 0; @@ -761,7 +764,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out, continue; this_len = min(this_len, left); - ret = pipe_buf_confirm(pipe, buf); + ret = pipe_buf_confirm(pipe, buf, false); if (unlikely(ret)) { if (ret == -ENODATA) ret = 0; diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index d2c3f16cf6b1..d63278bb0797 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -100,7 +100,8 @@ struct pipe_buf_operations { * hook. Returns 0 for good, or a negative error value in case of * error. If not present all pages are considered good. */ - int (*confirm)(struct pipe_inode_info *, struct pipe_buffer *); + int (*confirm)(struct pipe_inode_info *, struct pipe_buffer *, + bool nonblock); /* * When the contents of this pipe buffer has been completely @@ -209,11 +210,11 @@ static inline void pipe_buf_release(struct pipe_inode_info *pipe, * @buf: the buffer to confirm */ static inline int pipe_buf_confirm(struct pipe_inode_info *pipe, - struct pipe_buffer *buf) + struct pipe_buffer *buf, bool nonblock) { if (!buf->ops->confirm) return 0; - return buf->ops->confirm(pipe, buf); + return buf->ops->confirm(pipe, buf, nonblock); } /** From patchwork Wed Mar 8 03:10:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13165159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADAF1C742A7 for ; Wed, 8 Mar 2023 03:10:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjCHDKl (ORCPT ); Tue, 7 Mar 2023 22:10:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjCHDKj (ORCPT ); Tue, 7 Mar 2023 22:10:39 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50F0A6BF5 for ; Tue, 7 Mar 2023 19:10:38 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id p3-20020a17090ad30300b0023a1cd5065fso754494pju.0 for ; Tue, 07 Mar 2023 19:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; t=1678245038; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kpOYI77LDBDSfPAfwwRt1IR4K3PYUasWejfFHEWKzrs=; b=28A1NjE30HTD+asdxPYf8DzArFMcDjuiPdxuZMzIxfeDsw7pDY5se8eryy8cWFVHfm jjwmTkIhTe2nCW+769jYilH2PSiDQZbhznHzbA20FqrCYz2sdSikQV8Uaml031aPa8tW 3bmyxFUpaZyVQ1GCWPiEJUn36QANvNy17SYBljOfW6f2k832AhkKg7gJ8udbx/34bBQD Jf1tTe+sUjRoupjef+6PO5eVImawNPAzfLOv4jOiShmfGz6fRFCIqp/GtO3pojm5IzXh oNYWnr3YxGhRMT7RRHJbo/8BokHhIUl/flLjVqd2J8fYKJ7OCYBvubrH+KGnGERYRNiO dixg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678245038; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kpOYI77LDBDSfPAfwwRt1IR4K3PYUasWejfFHEWKzrs=; b=5HZbdTDIccYE8f+NxzL3U7d1ecAwJIWUuOVHI+QDqBdnlM69ckw25tzMba3AeAJ1nw u6GGwklOneXZzzGuIVY8J3CECw4s9L0PS5OGZRY9AkoCLpsPOiiDrevHOr9ROoizw8AK LhjZmef3KHV9pGgZm/itHTmm8DIMSlhHQA3r6IyaiSUmKKgPoCHbYC+9Iinhq2awL7uO oHlm7LguHox9jyWYDMRtGVi9O1rAWwkPtpetuaT9g3oMHPYT/Q9jXWyKOjV8HR0W1Wmj bhJrDx0DWxBY/uzMbsXZEXlpXGkjmqmOeMHTwaysMsZa4Ui8L8zli7Fa7TQ4whnUAtmr oT1w== X-Gm-Message-State: AO0yUKV4UvLLeIbhutEQxqkPODp/xmktFyuyV1Ta/Lq4gk2TyZxNIPqc kYGxbZTvvXlM7QZoLyMImvHygw== X-Google-Smtp-Source: AK7set9P/NvInaGn9QDKHdaeF4xOJEM57oUTET3ZmNIBvpz6ZjXYEssRa+eP6vFHJhPaurfm6lvLJw== X-Received: by 2002:a17:90a:9805:b0:230:dc97:9da2 with SMTP id z5-20020a17090a980500b00230dc979da2mr12906048pjo.1.1678245038157; Tue, 07 Mar 2023 19:10:38 -0800 (PST) Received: from localhost.localdomain ([50.233.106.125]) by smtp.gmail.com with ESMTPSA id o44-20020a17090a0a2f00b0023440af7aafsm7995806pjo.9.2023.03.07.19.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 19:10:37 -0800 (PST) From: Jens Axboe To: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 2/3] pipe: enable handling of IOCB_NOWAIT Date: Tue, 7 Mar 2023 20:10:32 -0700 Message-Id: <20230308031033.155717-3-axboe@kernel.dk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230308031033.155717-1-axboe@kernel.dk> References: <20230308031033.155717-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In preparation for enabling FMODE_NOWAIT for pipes, ensure that the read and write path handle it correctly. This includes the pipe locking, page allocation for writes, and confirming pipe buffers. Signed-off-by: Jens Axboe --- fs/pipe.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 340f253913a2..10366a6cb5b6 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -108,6 +108,16 @@ static inline void __pipe_unlock(struct pipe_inode_info *pipe) mutex_unlock(&pipe->mutex); } +static inline bool __pipe_trylock(struct pipe_inode_info *pipe, bool nonblock) +{ + if (!nonblock) { + __pipe_lock(pipe); + return true; + } + + return mutex_trylock(&pipe->mutex); +} + void pipe_double_lock(struct pipe_inode_info *pipe1, struct pipe_inode_info *pipe2) { @@ -234,6 +244,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) struct file *filp = iocb->ki_filp; struct pipe_inode_info *pipe = filp->private_data; bool was_full, wake_next_reader = false; + const bool nonblock = iocb->ki_flags & IOCB_NOWAIT; ssize_t ret; /* Null read succeeds. */ @@ -241,7 +252,8 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) return 0; ret = 0; - __pipe_lock(pipe); + if (!__pipe_trylock(pipe, nonblock)) + return -EAGAIN; /* * We only wake up writers if the pipe was full when we started @@ -297,7 +309,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) chars = total_len; } - error = pipe_buf_confirm(pipe, buf, false); + error = pipe_buf_confirm(pipe, buf, nonblock); if (error) { if (!ret) ret = error; @@ -342,7 +354,7 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to) break; if (ret) break; - if (filp->f_flags & O_NONBLOCK) { + if (filp->f_flags & O_NONBLOCK || nonblock) { ret = -EAGAIN; break; } @@ -423,12 +435,14 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) ssize_t chars; bool was_empty = false; bool wake_next_writer = false; + const bool nonblock = iocb->ki_flags & IOCB_NOWAIT; /* Null write succeeds. */ if (unlikely(total_len == 0)) return 0; - __pipe_lock(pipe); + if (!__pipe_trylock(pipe, nonblock)) + return -EAGAIN; if (!pipe->readers) { send_sig(SIGPIPE, current, 0); @@ -461,7 +475,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) if ((buf->flags & PIPE_BUF_FLAG_CAN_MERGE) && offset + chars <= PAGE_SIZE) { - ret = pipe_buf_confirm(pipe, buf, false); + ret = pipe_buf_confirm(pipe, buf, nonblock); if (ret) goto out; @@ -493,9 +507,13 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) int copied; if (!page) { - page = alloc_page(GFP_HIGHUSER | __GFP_ACCOUNT); + gfp_t gfp = __GFP_HIGHMEM | __GFP_ACCOUNT; + + if (!nonblock) + gfp |= GFP_USER; + page = alloc_page(gfp); if (unlikely(!page)) { - ret = ret ? : -ENOMEM; + ret = ret ? : nonblock ? -EAGAIN : -ENOMEM; break; } pipe->tmp_page = page; @@ -547,7 +565,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) continue; /* Wait for buffer space to become available. */ - if (filp->f_flags & O_NONBLOCK) { + if (filp->f_flags & O_NONBLOCK || nonblock) { if (!ret) ret = -EAGAIN; break; From patchwork Wed Mar 8 03:10:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13165160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FD0FC678D5 for ; Wed, 8 Mar 2023 03:10:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbjCHDKn (ORCPT ); Tue, 7 Mar 2023 22:10:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjCHDKk (ORCPT ); Tue, 7 Mar 2023 22:10:40 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A08EFA6BEA for ; Tue, 7 Mar 2023 19:10:39 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id qa18-20020a17090b4fd200b0023750b675f5so917334pjb.3 for ; Tue, 07 Mar 2023 19:10:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; t=1678245039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5mu++duLa1HYXQoRgD8CJqzoZQ47PM9+K5ZhAEIOsBg=; b=t5MN5n7flANBYusBMPHvSi5UTma9LxmdEzfB5UIPRgjv5UWMPr5ZDk53ddKJLuIAtw Ou5IgUxYkSII/HL/91pnnv+QAfBgghSTfymF2almtDsRgcIy2cQm4jTqxGko1Aj2AkTQ CAKeRmbK5SxP7gV7C5P0+AGBtRBwtGDRRFCujj8OnnBiaV2UO5RmB3uGasv0+ejdE+X1 UwOKh4rYsD3QoBORHoAftlk91QjWt0rTNIqOz65Q9Gc40kEUPrfC/UyX5GzdmwRdTGcK S0S1SUxF6b7IzTn7rTC/hrwEjm8+cnRUxu4Fk1yeEcrqSUjCC0z117xetTn27GKTN1K2 7C3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678245039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5mu++duLa1HYXQoRgD8CJqzoZQ47PM9+K5ZhAEIOsBg=; b=WQgTuellAvaWx59IoI0GQnssoPw85pTwQS51QENoMdX3L+wLUatlP4Aky1imMpUyin k7KzhT5uZ1VwUUM3vcr1i9Z8ylg1wv6yHz5lfH1+n08xuoH5rNN6tmsrQd3fndmXyEWm h298agGXxcz0wB1ybAz9o+QzfKRuTZdjDZ0seF1HFxY/Y0hfQ8wUwqX93U27gEapWqM8 chKXeqHuzQqCkf5ivRzsnjLwXvWWuDZA59MI8MpThKhYwbq/kNY2ZIWuHafEBj3h68VH 6sjwv3YWOn3jEtEM5ySLowM24cB0x/1IMr/I1kSATLH1h/oLxs5hqUu3fpA4K1SF6lvs nUjw== X-Gm-Message-State: AO0yUKW1XYMkhChqkQiya5v7BICVhw0VHrnfUE15IX05tUkehw+24xOY AUYqE06s76WRtVTH7ixe42Af4wfQSheXiVit0KM= X-Google-Smtp-Source: AK7set8M2ScOuiqCNSCuBPsWpJDEEIvkejGDWgouRr3gzVyj9Y3Lq/WSxoivIRhwTIh17X3FhAu+hg== X-Received: by 2002:a17:90a:f111:b0:237:779d:7022 with SMTP id cc17-20020a17090af11100b00237779d7022mr1308675pjb.3.1678245039062; Tue, 07 Mar 2023 19:10:39 -0800 (PST) Received: from localhost.localdomain ([50.233.106.125]) by smtp.gmail.com with ESMTPSA id o44-20020a17090a0a2f00b0023440af7aafsm7995806pjo.9.2023.03.07.19.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 19:10:38 -0800 (PST) From: Jens Axboe To: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 3/3] pipe: set FMODE_NOWAIT on pipes Date: Tue, 7 Mar 2023 20:10:33 -0700 Message-Id: <20230308031033.155717-4-axboe@kernel.dk> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230308031033.155717-1-axboe@kernel.dk> References: <20230308031033.155717-1-axboe@kernel.dk> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The read/write path is now prepared to deal with IOCB_NOWAIT, hence enable support for that via setting FMODE_NOWAIT on new pipes. Signed-off-by: Jens Axboe Reviewed-by: Christian Brauner --- fs/pipe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/pipe.c b/fs/pipe.c index 10366a6cb5b6..9db274f9baa5 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -994,6 +994,9 @@ static int __do_pipe_flags(int *fd, struct file **files, int flags) audit_fd_pair(fdr, fdw); fd[0] = fdr; fd[1] = fdw; + /* pipe groks IOCB_NOWAIT */ + files[0]->f_mode |= FMODE_NOWAIT; + files[1]->f_mode |= FMODE_NOWAIT; return 0; err_fdr: