From patchwork Thu May 18 07:59:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khorenko X-Patchwork-Id: 1783054 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=) 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QMMp7030kz20dv for ; Thu, 18 May 2023 17:59:59 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CACAE3CB37E for ; Thu, 18 May 2023 09:59:56 +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 [217.194.8.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 AF5A43CB28E for ; Thu, 18 May 2023 09:59:33 +0200 (CEST) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (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 in-3.smtp.seeweb.it (Postfix) with ESMTPS id 137581A00099 for ; Thu, 18 May 2023 09:59:32 +0200 (CEST) Received: from [172.29.16.86] (helo=finist-vl9.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1pzYWe-00BNpU-1V; Thu, 18 May 2023 09:59:31 +0200 To: ltp@lists.linux.it Date: Thu, 18 May 2023 10:59:30 +0300 Message-Id: <20230518075931.1344979-2-khorenko@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230518075931.1344979-1-khorenko@virtuozzo.com> References: <20230518075931.1344979-1-khorenko@virtuozzo.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 v2 1/2] scsi_debug/tlibio/lio_write_buffer: Always return total amount of written bytes 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: , X-Patchwork-Original-From: Konstantin Khorenko via ltp From: Konstantin Khorenko Reply-To: Konstantin Khorenko Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Sometimes we got failures like: growfiles(gf217): 65884 growfiles.c/2262: 104203 tlibio.c/744 write(3, buf, 5000) returned=2288 growfiles(gf217): 65884 growfiles.c/1765: 104203 Hit max errors value of 1 gf217 1 TFAIL : growfiles.c:134: Test failed Which looked strange as partial write is something usual and valid. It turned out that lio_write_buffer() has the code cycle writes in case of a partial write happens, but it anyway returns the amount of bytes written by the LAST write. And upper growfile() consider the returned amount from lio_write_buffer() to be less than it tried to write and fails the testcase. Fix lio_write_buffer() to always return total bytes written, even in case partial writes. Signed-off-by: Konstantin Khorenko Reviewed-by: Petr Vorel --- lib/tlibio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tlibio.c b/lib/tlibio.c index 79883913a..b029e5883 100644 --- a/lib/tlibio.c +++ b/lib/tlibio.c @@ -539,6 +539,10 @@ int lio_write_buffer(int fd, /* open file descriptor */ long wrd) /* to allow future features, use zero for now */ { int ret = 0; /* syscall return or used to get random method */ + /* as we cycle writes in case of partial writes, we have to report up + * total bytes written + */ + int totally_written = 0; char *io_type; /* Holds string of type of io */ int omethod = method; int listio_cmd; /* Holds the listio/lio_listio cmd */ @@ -745,13 +749,14 @@ int lio_write_buffer(int fd, /* open file descriptor */ fd, size, ret); size -= ret; buffer += ret; + totally_written += ret; } else { if (Debug_level > 1) printf ("DEBUG %s/%d: write completed without error (ret %d)\n", __FILE__, __LINE__, ret); - return ret; + return totally_written + ret; } } wait4sync_io(fd, 0); From patchwork Thu May 18 07:59:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khorenko X-Patchwork-Id: 1783052 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=) 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QMMnj07kqz20dv for ; Thu, 18 May 2023 17:59:36 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 88E353CD428 for ; Thu, 18 May 2023 09:59:34 +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 50C703CB28E for ; Thu, 18 May 2023 09:59:33 +0200 (CEST) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (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 in-6.smtp.seeweb.it (Postfix) with ESMTPS id AA5E514002C5 for ; Thu, 18 May 2023 09:59:32 +0200 (CEST) Received: from [172.29.16.86] (helo=finist-vl9.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1pzYWe-00BNpU-1f; Thu, 18 May 2023 09:59:31 +0200 To: ltp@lists.linux.it Date: Thu, 18 May 2023 10:59:31 +0300 Message-Id: <20230518075931.1344979-3-khorenko@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230518075931.1344979-1-khorenko@virtuozzo.com> References: <20230518075931.1344979-1-khorenko@virtuozzo.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 v2 2/2] scsi_debug/tlibio/lio_read_buffer: Always return total amount of read bytes 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: , X-Patchwork-Original-From: Konstantin Khorenko via ltp From: Konstantin Khorenko Reply-To: Konstantin Khorenko Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This issue behind this patch is noticed while fixing the lio_write_buffer(). Here in lio_read_buffer() we have similar situation: in case of a partial read, we cycle, but lio_read_buffer() returns back the amount of bytes read during the last read() call while it's expected to return the whole amount of read bytes. Signed-off-by: Konstantin Khorenko Reviewed-by: Petr Vorel --- lib/tlibio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tlibio.c b/lib/tlibio.c index b029e5883..2ecdbb42a 100644 --- a/lib/tlibio.c +++ b/lib/tlibio.c @@ -1114,6 +1114,10 @@ int lio_read_buffer(int fd, /* open file descriptor */ long wrd) /* to allow future features, use zero for now */ { int ret = 0; /* syscall return or used to get random method */ + /* as we cycle reads in case of partial reads, we have to report up + * total bytes read + */ + int totally_read = 0; char *io_type; /* Holds string of type of io */ int listio_cmd; /* Holds the listio/lio_listio cmd */ int omethod = method; @@ -1325,13 +1329,14 @@ int lio_read_buffer(int fd, /* open file descriptor */ fd, size, ret); size -= ret; buffer += ret; + totally_read += ret; } else { if (Debug_level > 1) printf ("DEBUG %s/%d: read completed without error (ret %d)\n", __FILE__, __LINE__, ret); - return ret; + return totally_read + ret; } } wait4sync_io(fd, 1);