From patchwork Mon Oct 3 12:48:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 1685542 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SoVj2Pn2; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mh0yY1yh1z1yqm for ; Mon, 3 Oct 2022 23:49:08 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 349B93C7FBA for ; Mon, 3 Oct 2022 14:49:03 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id B4B9D3C4F4A for ; Mon, 3 Oct 2022 14:49:00 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id C56676008E7 for ; Mon, 3 Oct 2022 14:48:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664801338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MZDlk+YQk3Dc6fyjxS2YdjzFGJ6ixzCLtbB+hQV8hM4=; b=SoVj2Pn2RdtJ6chhNKuSYgKVwe5nxrUAaJrC0PUKJuio7ZnTxiRWzq8qHHHdSZOKnVh4Jo YAU5Xj90fHMVjDW8VGZqUruWW7wbpmqILk9gcp3uW8x7eFuadcXmszdq+AE2hvdjO+kLFI 1KOt9OV/apq4R5cH3v1G+7F8gMamiH8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-637-xyciRLpYPiOF7dcmpg0c3Q-1; Mon, 03 Oct 2022 08:48:56 -0400 X-MC-Unique: xyciRLpYPiOF7dcmpg0c3Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A2A33185A794 for ; Mon, 3 Oct 2022 12:48:56 +0000 (UTC) Received: from janakin.usersys.redhat.com (unknown [10.40.193.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 333F6492B04 for ; Mon, 3 Oct 2022 12:48:56 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Mon, 3 Oct 2022 14:48:46 +0200 Message-Id: <43d65409eb3290b09e1c3a21cb0dc079c5f4849c.1664801307.git.jstancek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 1/3] lib: introduce safe_write_fully() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" In case there is a short (but otherwise successful) write(), safe_write_fully() repeats write() and attempts to resume with the remainder of the buffer. Signed-off-by: Jan Stancek --- include/tst_safe_macros.h | 5 +++++ lib/tst_safe_macros.c | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index 81c4b0844267..caee0e9cf842 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -645,4 +645,9 @@ int safe_sysinfo(const char *file, const int lineno, struct sysinfo *info); #define SAFE_SYSINFO(info) \ safe_sysinfo(__FILE__, __LINE__, (info)) +ssize_t safe_write_fully(const char *file, const int lineno, + int fildes, const void *buf, size_t nbyte); +#define SAFE_WRITE_FULLY(fildes, buf, nbyte) \ + safe_write_fully(__FILE__, __LINE__, (fildes), (buf), (nbyte)) + #endif /* SAFE_MACROS_H__ */ diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c index c4cdc87e7346..e4d4ef4269a4 100644 --- a/lib/tst_safe_macros.c +++ b/lib/tst_safe_macros.c @@ -591,3 +591,22 @@ void safe_cmd(const char *file, const int lineno, const char *const argv[], tst_brk_(file, lineno, TBROK, "%s failed (%d)", argv[0], rval); } } + +ssize_t safe_write_fully(const char *file, const int lineno, + int fildes, const void *buf, size_t nbyte) +{ + ssize_t rval; + size_t len = nbyte; + + do { + rval = write(fildes, buf, len); + if (rval == -1) { + tst_brk_(file, lineno, TBROK | TERRNO, + "write(%d,%p,%zu) failed", fildes, buf, len); + } + buf += rval; + len -= rval; + } while (len > 0); + + return nbyte; +} From patchwork Mon Oct 3 12:48:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 1685543 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GY3eaQAM; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mh0yh591Wz23jM for ; Mon, 3 Oct 2022 23:49:16 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B961E3C8965 for ; Mon, 3 Oct 2022 14:49:13 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 098B73C4F4A for ; Mon, 3 Oct 2022 14:49:00 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 609F71401104 for ; Mon, 3 Oct 2022 14:49:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664801339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+QjRrQCPzolcfs/QoUrVUnkjagslGthAJgErX8kd/u8=; b=GY3eaQAMNMTLHfT2iHYPcuu1PEmYMAlcoUVEaHbTQpU8Te3cdvwxTHlopJSLRAZ9Fp+/no k50ZPiaJetQEtCmNotDmZaQhi8bLMng8Cc4N9uZ1123R2VtRwbeAdSJMtcyJEPJF4VUfXx Er8+YLaJgZnAOVk0ysV6HwxPMQlpS5Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-PankEwWPPuKCvygJ_HjBcQ-1; Mon, 03 Oct 2022 08:48:57 -0400 X-MC-Unique: PankEwWPPuKCvygJ_HjBcQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6664D185A79C for ; Mon, 3 Oct 2022 12:48:57 +0000 (UTC) Received: from janakin.usersys.redhat.com (unknown [10.40.193.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8BD0492B04 for ; Mon, 3 Oct 2022 12:48:56 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Mon, 3 Oct 2022 14:48:47 +0200 Message-Id: In-Reply-To: <43d65409eb3290b09e1c3a21cb0dc079c5f4849c.1664801307.git.jstancek@redhat.com> References: <43d65409eb3290b09e1c3a21cb0dc079c5f4849c.1664801307.git.jstancek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 2/3] syscalls/preadv203: don't treat short write() as failure X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Test is sporadically running into TBROK in setup() due to short write: tst_test.c:1064: TINFO: Formatting /dev/loop0 with xfs opts='' extra opts='' preadv203.c:257: TBROK: write(501,0x3fff4ef7d15,4123) failed: SUCCESS (0) Switch to SAFE_WRITE_FULLY(). Signed-off-by: Jan Stancek --- testcases/kernel/syscalls/preadv2/preadv203.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/preadv2/preadv203.c b/testcases/kernel/syscalls/preadv2/preadv203.c index 60dc4a882f16..f3e3ef438de2 100644 --- a/testcases/kernel/syscalls/preadv2/preadv203.c +++ b/testcases/kernel/syscalls/preadv2/preadv203.c @@ -254,7 +254,7 @@ static void setup(void) for (j = 0; j < CHUNKS; j++) { memset(buf, '0' + j, sizeof(buf)); - SAFE_WRITE(1, fds[i], buf, sizeof(buf)); + SAFE_WRITE_FULLY(fds[i], buf, sizeof(buf)); } } } From patchwork Mon Oct 3 12:48:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 1685544 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=PYnLa9bN; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mh0yv0pxbz1yqm for ; Mon, 3 Oct 2022 23:49:27 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 351EC3C9181 for ; Mon, 3 Oct 2022 14:49:24 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 925893C4F4A for ; Mon, 3 Oct 2022 14:49:01 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 0DB911A010FF for ; Mon, 3 Oct 2022 14:49:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664801339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QKDsAGIClEBQAvkuNpZ/QzugW3Ttj9kw5QqSSwKcnes=; b=PYnLa9bNn49QDAmCFLYq9ePWH+n4ARa+enbDQOMybelB4QbDN3OGbqtJUc69KiYSGN5kQD qx8vNoNp5o0obOtF7EJgsy8z9kwqGutcFfVK4vtbCujOOzRVbq3TlXTyfb0fMAJylCAzgV LqHjHvunjaerg7/gIFZxNITlAnDbOY8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-623-TY0uvsWvOl-EDy6vrGJajw-1; Mon, 03 Oct 2022 08:48:58 -0400 X-MC-Unique: TY0uvsWvOl-EDy6vrGJajw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 29FA11019C89 for ; Mon, 3 Oct 2022 12:48:58 +0000 (UTC) Received: from janakin.usersys.redhat.com (unknown [10.40.193.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9882492B04 for ; Mon, 3 Oct 2022 12:48:57 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Mon, 3 Oct 2022 14:48:48 +0200 Message-Id: <7627543d016c078db2bf4e7df7f242dca99843ed.1664801307.git.jstancek@redhat.com> In-Reply-To: <43d65409eb3290b09e1c3a21cb0dc079c5f4849c.1664801307.git.jstancek@redhat.com> References: <43d65409eb3290b09e1c3a21cb0dc079c5f4849c.1664801307.git.jstancek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH 3/3] mmapstress04: use SAFE_WRITE_FULLY from LTP library X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Jan Stancek --- testcases/kernel/mem/mmapstress/mmapstress04.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/testcases/kernel/mem/mmapstress/mmapstress04.c b/testcases/kernel/mem/mmapstress/mmapstress04.c index ceede7eaa860..2b421890a461 100644 --- a/testcases/kernel/mem/mmapstress/mmapstress04.c +++ b/testcases/kernel/mem/mmapstress/mmapstress04.c @@ -32,17 +32,6 @@ static void setup(void) MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); } -static void write_fully(int fd, void *buf, int len) -{ - int ret; - - do { - ret = SAFE_WRITE(0, fd, buf, len); - buf += ret; - len -= ret; - } while (len > 0); -} - static void mmapstress04(void) { int i, j, rofd, rwfd; @@ -85,7 +74,7 @@ static void mmapstress04(void) buf = SAFE_MALLOC(page_size); memset(buf, 'a', page_size); for (i = 0; i < 6 * 64; i++) - write_fully(rwfd, buf, page_size); + SAFE_WRITE_FULLY(rwfd, buf, page_size); free(buf); SAFE_CLOSE(rwfd);