Message ID | 20231008094801.354312-2-shikemeng@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1177018vqo; Sat, 7 Oct 2023 18:48:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOp7Jgt4gykt43oeDYVj+29x8CQQugGukB48OWfxWrOeoI+VSo3RD508NQbn0vefZVkRbj X-Received: by 2002:a17:90a:b015:b0:26b:c5b:bb44 with SMTP id x21-20020a17090ab01500b0026b0c5bbb44mr11401242pjq.13.1696729711722; Sat, 07 Oct 2023 18:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696729711; cv=none; d=google.com; s=arc-20160816; b=HGgqPtequ0Poh5SYAM7+WC7B/TpiFO2pU77Djq/s1t2AhUQOQ7RU6in31cDQMR3CW5 rGSc4n+i9kghkQAYy4Bk/r29/UZXO9qrozORlOm166kRYfSCB0vulTTdr+SzuEBEEzcv znEcwW7o132FK3EeUGcjrWTahosFnsKISXzgk4iDUfUxGwqcKqD8p7cvzfbC3wDI3XNQ puEkutYmWppDKRmVv61jAw5WDyeIPbmyLXDg2vtjHVPemlbTqQp2G5RCloz6cbMXjPsb KX6kfrxszFaydZOl8tqODeB31Jzrzs7rJTVvv/QYLw5NHNXcuVoYQ3iGCreuQiuHNHhP hjYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HPXRe2ci5bibplOuMtpQ+mvHTUIvpWj4ufHHQ182qEc=; fh=sVO6dZaz2MjOMYYQUXK0Jk+arht08gyUXlIvEKWSH7U=; b=0dQb2JAZl2a76Z2DonaOt2nW4dsPpdioYKYUS0OxQ/JLFvcjX+l8mlE1O/6XsBFo7A ti2HfrkEcT01+uW5PVssl99uRbChWVL3cdffT/9u4hLmVD/c/3bCP0BwXcCXqF4fCgBs WOZUQx2yc5+w27JhVPNIBvW2AHBNREcUj2qxBdJtKqDt3Wkvus5smvsVSXSR25/EjVdb aKzvDrwPXMHnQPNCF27JewFDaqBEM+MnKXSu2ALMxVESGttg/yYKd93+gEWj883QDUcg oEBAOWd1T2R8/Cz4jkZ5iWQo5TNNVZ454r04H2RepAXhJ+SohL7CmAyY3MkttlqUoNcR 8/lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ha22-20020a17090af3d600b0027b123fbe9dsi6847349pjb.156.2023.10.07.18.48.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 18:48:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0419A803201B; Sat, 7 Oct 2023 18:48:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344328AbjJHBsT (ORCPT <rfc822;pusanteemu@gmail.com> + 17 others); Sat, 7 Oct 2023 21:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344267AbjJHBsP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 7 Oct 2023 21:48:15 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AEF3B6; Sat, 7 Oct 2023 18:48:14 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4S34n20knsz4f3khf; Sun, 8 Oct 2023 09:48:06 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgBH0bFZCiJl7zQbCQ--.22902S3; Sun, 08 Oct 2023 09:48:11 +0800 (CST) From: Kemeng Shi <shikemeng@huaweicloud.com> To: viro@zeniv.linux.org.uk, brauner@kernel.org, dhowells@redhat.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] pipe: remove pipe_full check with wrong head in pipe_write Date: Sun, 8 Oct 2023 17:48:00 +0800 Message-Id: <20231008094801.354312-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231008094801.354312-1-shikemeng@huaweicloud.com> References: <20231008094801.354312-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgBH0bFZCiJl7zQbCQ--.22902S3 X-Coremail-Antispam: 1UD129KBjvdXoWruF13Cw1xAr45GF1xurWDXFb_yoWkKFgEka 97CFn3ur43Jr48Jw17CFnakryxW34Uur1UZrW5Ar9xJF1kWr98u3s5W34DC34UZ3Z8tF9x C392van2vr1fWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbf8YFVCjjxCrM7AC8VAFwI0_Gr0_Xr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_JFv_Gryl82 xGYIkIc2x26280x7IE14v26r18M28IrcIa0xkI8VCY1x0267AKxVWUXVWUCwA2ocxC64kI II0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7 xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2 z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4 xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v2 6r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwI xGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480 Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7 IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k2 6cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxV AFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU0a0PDUUUUU== X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, KHOP_HELO_FCRDNS,MAY_BE_FORGED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sat, 07 Oct 2023 18:48:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779150054595115817 X-GMAIL-MSGID: 1779150054595115817 |
Series |
Two cleanups to pipe
|
|
Commit Message
Kemeng Shi
Oct. 8, 2023, 9:48 a.m. UTC
In pipe_write we have:
head = pipe->head;
if (!pipe_full(head, pipe->tail, pipe->max_usage))
pipe->head = head + 1;
/* write data to buffer at head */
/* supposed to check if pipe is full after write */
if (!pipe_full(head, pipe->tail, pipe->max_usage))
continue
The second pipe_full expects head after write but head before write is
used. Luckily, we will call pipe_full with correct reloaded pipe->head
in new loop cycle and stop writing correctly. Remove wrong pipe_full
check and simply continue to first pipe_full check after write done to
avoid unnecessary check.
Fixes: a194dfe6e6f6 ("pipe: Rearrange sequence in pipe_write() to preallocate slot")
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
fs/pipe.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/fs/pipe.c b/fs/pipe.c index 2d88f73f585a..b19875720ff1 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -542,10 +542,9 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) if (!iov_iter_count(from)) break; - } - if (!pipe_full(head, pipe->tail, pipe->max_usage)) continue; + } /* Wait for buffer space to become available. */ if ((filp->f_flags & O_NONBLOCK) ||