From mboxrd@z Thu Jan 1 00:00:00 1970 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 (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8DFC606A322 for ; Sat, 5 Dec 2026 13:37:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=lists.linux.it header.i=@lists.linux.it header.a=rsa-sha256 header.s=picard header.b=UQZyPDQ4; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=oeItG4W6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it; i=@lists.linux.it; q=dns/txt; s=picard; t=1796477857; h=date : mime-version : message-id : to : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : from : reply-to : cc : content-type : content-transfer-encoding : sender : from; bh=qxndu6DsOrt4R+Wg3crJssIEyGQHT6VqzDA+zr/Ay38=; b=UQZyPDQ4ce+T3WkZud+011kd5oDns13MxwW2NaKo3/t8GuDa1HyHtz4h0cGNcIReui1GU 9tas/k3ceJnn897HL1r5xvnPbBiSCCgBA64jNSOb7nremhYjVV/BrD8EoKjz751WPv44lPK rbONsGNRhC5h7l2sI2xFChj/QqOaKTc= Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id F0A793EA6EE for ; Sat, 5 Dec 2026 14:37:36 +0100 (CET) Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id BDD243E6EA4 for ; Sat, 5 Dec 2026 14:37:10 +0100 (CET) Received: from mail-pf1-x445.google.com (mail-pf1-x445.google.com [IPv6:2607:f8b0:4864:20::445]) (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-5.smtp.seeweb.it (Postfix) with ESMTPS id 5099560055D for ; Sat, 5 Dec 2026 14:37:10 +0100 (CET) Received: by mail-pf1-x445.google.com with SMTP id d2e1a72fcca58-8a05b68f851so2298895b3a.1 for ; Sat, 05 Dec 2026 05:37:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796477829; x=1797082629; darn=lists.linux.it; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ReiXCgpBtGVdceJmX+KS9GaXmh41CkAOyyGq+PLKNkA=; b=oeItG4W6awf+ttnI484Yj6lkpz62nJoEhAvVERfKEEaHycuPaZd0wKEWibNA7qLaf0 11RL9NwdpIEBUX7gIggdFIgESIG9s2ZYndPVYHbF6zlS5iOOzGh//XsVkrq65J/ebQrn RpH553WIzMn4+PiSQ5UFPov4+liHnnsbpTwu6oWrrK2/qkrPx0Q0czWsV+duyJsZhJyG k79wA+hyX8IZdwYBaKpXMqX9p87C3RIW1rQF0m+Xz/7v4IQn6DgfCKZgOHC/INp/5jmj HL34uJ99/m7+9yfpTNMCK4uwlH+ApHYZ6P7//5R0mfBZAcMKG5TdyxAJjalG0Q+/3oLD ECnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796477829; x=1797082629; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=ReiXCgpBtGVdceJmX+KS9GaXmh41CkAOyyGq+PLKNkA=; b=qI8MxXPhftq5coJt0+GOS7Sy0S4SnKhn8n9/NQmhot4AXKFMJ+EgQdYbHvYNmtWNtw qFpeb5bvz7frwSC/wsJweMD5dJPN4xttb5fdIrUDe6u5ssrQG6zvRAQl3W4JBBwli6aF mbFKqBCjrd1Yp5rhoMG6PWP3EpIdwDjQdy3FmvsVRKfqF8B0G1c4NzIKH2p0p45xmPdy eqYiSGeGRPYSpl7XayeseliNkGOza8EPuYFGPhesDRYMqk3P7PXXyIGjdKGKH99Euguy B0hpJsULdoPemcwLyRnw+O2OwdQ1DipzbD1mTeOySUFJ4WjQYh3ItxYjJRJ3jvsDPhpK qFqw== X-Gm-Message-State: AB4q+uFtxWoMqWoojBRNZn9nB204JOXlwiLYqxe8Arc1/iJyiq/QjGjz 0juayVXFB90WokhHUyvtWf4rhtF8qweCrDLO3cKsd7JjbfWwd3CxR2r2Ed0yFM9f6pFmXmT6bAj b4WB77yt81dZKrp51ywZdpgFOvUvsBB+LrT7MCJkWL8gzjrjHGtdoDxLjnPOEh5DlbdncoAF5Sf odp9PMzu2TR4WmVxEKsz0Y5tW0VA== X-Received: from pgmp25.prod.google.com ([2002:a63:1e59:0:b0:cd8:c321:70]) (user=wakel job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5708:b0:3ac:b6eb:e0cd with SMTP id 98e67ed59e1d1-3b5cbd19c2cmr6072199a91.48.1796477828222; Sat, 05 Dec 2026 05:37:08 -0800 (PST) Date: Sat, 5 Dec 2026 13:37:05 +0000 X-Archived-By: Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261205133705.1004549-1-wakel@google.com> To: ltp@lists.linux.it X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Virus-Scanned: clamav-milter 1.0.9 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH] ioctl_loop05: Account for backing file STATX_DIOALIGN X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Archive: List-Post: List-Help: List-Subscribe: , From: Wake Liu via ltp Reply-To: Wake Liu Cc: Wake Liu Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "ltp" Since Linux commit f4774e92aab8 ("loop: take the file system minimum dio alignment into account"), the loop driver queries STATX_DIOALIGN on the backing file in loop_update_dio_alignment() and requires both the loop logical block size and lo_offset to satisfy stx_dio_offset_align before LOOP_SET_DIRECT_IO can be enabled. When the temporary directory resides on a filesystem whose block size exceeds the underlying block device's logical block size (for example, a 16KB f2fs filesystem over a 4KB dm block device), querying only BLKSSZGET yields 4096 while stx_dio_offset_align is 16384. Setting LOOP_SET_BLOCK_SIZE to 4096 then causes LOOP_SET_DIRECT_IO to fail with EINVAL. Query STATX_DIOALIGN on the backing file via statx() and use the larger of BLKSSZGET and stx_dio_offset_align when configuring the loop block size and offset test cases. If LOOP_SET_BLOCK_SIZE fails with EINVAL, report TCONF instead of proceeding with an unconfigured block size. Signed-off-by: Wake Liu --- .../kernel/syscalls/ioctl/ioctl_loop05.c | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop05.c b/testcases/kernel/syscalls/ioctl/ioctl_loop05.c index 11952af0a..9ff013d7f 100644 --- a/testcases/kernel/syscalls/ioctl/ioctl_loop05.c +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop05.c @@ -24,13 +24,16 @@ * success with non-zero offset. */ +#define _GNU_SOURCE #include #include #include #include #include -#include "lapi/loop.h" #include "tst_test.h" +#include "lapi/fcntl.h" +#include "lapi/loop.h" +#include "lapi/stat.h" #define DIO_MESSAGE "In dio mode" #define NON_DIO_MESSAGE "In non dio mode" @@ -101,6 +104,7 @@ static void verify_ioctl_loop(void) static void setup(void) { char bd_path[100]; + struct ltp_statx stx; dev_num = tst_find_free_loopdev(dev_path, sizeof(dev_path)); if (dev_num < 0) @@ -117,11 +121,11 @@ static void setup(void) tst_brk(TCONF, "LOOP_SET_DIRECT_IO is not supported"); /* - * from __loop_update_dio(): - * We support direct I/O only if lo_offset is aligned with the - * logical I/O size of backing device, and the logical block - * size of loop is bigger than the backing device's and the loop - * needn't transform transfer. + * From loop_update_dio_alignment() / lo_can_use_dio(): + * Direct I/O requires the loop logical block size and lo_offset to + * be at least and aligned with the backing file's minimum DIO + * alignment (STATX_DIOALIGN when reported by the filesystem, or the + * backing block device's logical block size otherwise). */ backing_file_path = tst_tmpdir_genpath("test.img"); tst_find_backing_dev(backing_file_path, bd_path, sizeof(bd_path)); @@ -129,8 +133,27 @@ static void setup(void) SAFE_IOCTL(block_devfd, BLKSSZGET, &logical_block_size); tst_res(TINFO, "backing dev(%s) logical_block_size is %d", bd_path, logical_block_size); SAFE_CLOSE(block_devfd); - if (logical_block_size > 512) - TST_RETRY_FUNC(ioctl(dev_fd, LOOP_SET_BLOCK_SIZE, logical_block_size), TST_RETVAL_EQ0); + + memset(&stx, 0, sizeof(stx)); + if (!statx(AT_FDCWD, "test.img", 0, STATX_DIOALIGN, &stx.buff) && + (stx.data.stx_mask & STATX_DIOALIGN) && + stx.data.stx_dio_mem_align && stx.data.stx_dio_offset_align) { + tst_res(TINFO, "backing file stx_dio_offset_align is %u", + stx.data.stx_dio_offset_align); + if (logical_block_size < 0 || + stx.data.stx_dio_offset_align > (uint32_t)logical_block_size) + logical_block_size = stx.data.stx_dio_offset_align; + } + + if (logical_block_size > 512 && + TST_RETRY_FUNC(ioctl(dev_fd, LOOP_SET_BLOCK_SIZE, logical_block_size), + TST_RETVAL_EQ0)) { + if (errno == EINVAL) + tst_brk(TCONF, "LOOP_SET_BLOCK_SIZE(%d) not supported", + logical_block_size); + tst_brk(TBROK | TERRNO, "LOOP_SET_BLOCK_SIZE(%d) failed", + logical_block_size); + } } static void cleanup(void) -- 2.56.1.915.g69d5ec7298-goog -- Mailing list info: https://lists.linux.it/listinfo/ltp