public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH liburing 0/3] test/fixed-seg: Add data verification and
       [not found] <CGME20250423133628epcas5p2b4752a672a64bd2f1392f663a284f9f2@epcas5p2.samsung.com>
@ 2025-04-23 13:27 ` Nitesh Shetty
       [not found]   ` <CGME20250423133638epcas5p34a9cf20f13387f7f604d9c2e2bf6976a@epcas5p3.samsung.com>
                     ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Nitesh Shetty @ 2025-04-23 13:27 UTC (permalink / raw)
  To: io-uring; +Cc: gost.dev, nitheshshetty, Nitesh Shetty

Write data before issuing read and verify the data once read is
completed. This makes sure we are failing if nr_seg is passed wrong,
incase of offset is present.

At present test fails for block devices formatted with non 512 bytes.
This allows to test 4k block devices. Some of the corner cases such as
3584 offset test are not valid for 4k, hence skipped.

Nitesh Shetty (3):
  test/fixed-seg: Prep patch, rename the vec to rvec.
  test/fixed-seg: verify the data read
  test/fixed-seg: Support non 512 LBA format devices.

 test/fixed-seg.c | 51 +++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 40 insertions(+), 11 deletions(-)


base-commit: 353fc7dcc61e059ac8890916f41d39df10e5bfa5
-- 
2.43.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH liburing 1/3] test/fixed-seg: Prep patch, rename the vec to rvec.
       [not found]   ` <CGME20250423133638epcas5p34a9cf20f13387f7f604d9c2e2bf6976a@epcas5p3.samsung.com>
@ 2025-04-23 13:27     ` Nitesh Shetty
  0 siblings, 0 replies; 7+ messages in thread
From: Nitesh Shetty @ 2025-04-23 13:27 UTC (permalink / raw)
  To: io-uring; +Cc: gost.dev, nitheshshetty, Nitesh Shetty

No functional change introduced.

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
---
 test/fixed-seg.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/fixed-seg.c b/test/fixed-seg.c
index f908cad..83e4b13 100644
--- a/test/fixed-seg.c
+++ b/test/fixed-seg.c
@@ -12,7 +12,7 @@
 #include "liburing.h"
 #include "helpers.h"
 
-static struct iovec vec;
+static struct iovec rvec;
 
 static int read_it(struct io_uring *ring, int fd, int len, int off)
 {
@@ -21,7 +21,7 @@ static int read_it(struct io_uring *ring, int fd, int len, int off)
 	int ret;
 
 	sqe = io_uring_get_sqe(ring);
-	io_uring_prep_read_fixed(sqe, fd, vec.iov_base + off, len, 0, 0);
+	io_uring_prep_read_fixed(sqe, fd, rvec.iov_base + off, len, 0, 0);
 	sqe->user_data = 1;
 
 	io_uring_submit(ring);
@@ -45,7 +45,7 @@ static int read_it(struct io_uring *ring, int fd, int len, int off)
 
 static int test(struct io_uring *ring, int fd, int vec_off)
 {
-	struct iovec v = vec;
+	struct iovec v = rvec;
 	int ret;
 
 	v.iov_base += vec_off;
@@ -99,9 +99,9 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-	if (posix_memalign(&vec.iov_base, 4096, 512*1024))
+	if (posix_memalign(&rvec.iov_base, 4096, 512*1024))
 		goto err;
-	vec.iov_len = 512*1024;
+	rvec.iov_len = 512*1024;
 
 	ret = io_uring_queue_init(8, &ring, 0);
 	if (ret) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 2/3] test/fixed-seg: verify the data read
       [not found]   ` <CGME20250423133642epcas5p1bef7e3af23bd8561f359ccc16fdaf980@epcas5p1.samsung.com>
@ 2025-04-23 13:27     ` Nitesh Shetty
  0 siblings, 0 replies; 7+ messages in thread
From: Nitesh Shetty @ 2025-04-23 13:27 UTC (permalink / raw)
  To: io-uring; +Cc: gost.dev, nitheshshetty, Nitesh Shetty

Write before reading the data. This written data
will be used for comparision later to verification.
To avoid running test on block device in use by system (e.g, mounted),
O_EXCL is added while opening file.

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
---
 test/fixed-seg.c | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/test/fixed-seg.c b/test/fixed-seg.c
index 83e4b13..ab1d359 100644
--- a/test/fixed-seg.c
+++ b/test/fixed-seg.c
@@ -12,7 +12,7 @@
 #include "liburing.h"
 #include "helpers.h"
 
-static struct iovec rvec;
+static struct iovec rvec, wvec;
 
 static int read_it(struct io_uring *ring, int fd, int len, int off)
 {
@@ -40,6 +40,12 @@ static int read_it(struct io_uring *ring, int fd, int len, int off)
 		return 1;
 	}
 	io_uring_cqe_seen(ring, cqe);
+
+	if (memcmp(wvec.iov_base, rvec.iov_base + off, len)) {
+		fprintf(stderr, "%d %d verify failed\n", len, off);
+		return 1;
+	}
+
 	return 0;
 }
 
@@ -81,7 +87,7 @@ int main(int argc, char *argv[])
 	struct io_uring ring;
 	const char *fname;
 	char buf[256];
-	int fd, ret;
+	int fd, rnd_fd, ret;
 
 	if (argc > 1) {
 		fname = argv[1];
@@ -93,12 +99,34 @@ int main(int argc, char *argv[])
 		t_create_file(fname, 128*1024);
 	}
 
-	fd = open(fname, O_RDONLY | O_DIRECT);
+	fd = open(fname, O_RDWR | O_DIRECT | O_EXCL);
 	if (fd < 0) {
 		perror("open");
 		return 1;
 	}
 
+	rnd_fd = open("/dev/urandom", O_RDONLY);
+	if (fd < 0) {
+		perror("urandom: open");
+		goto err;
+	}
+
+	if (posix_memalign(&wvec.iov_base, 4096, 512*1024))
+		goto err;
+	wvec.iov_len = 512*1024;
+
+	ret = read(rnd_fd, wvec.iov_base, wvec.iov_len);
+	if (ret != wvec.iov_len) {
+		fprintf(stderr, "Precondition, urandom read failed, ret: %d\n", ret);
+		goto err;
+	}
+
+	ret = write(fd, wvec.iov_base, wvec.iov_len);
+	if (ret != wvec.iov_len) {
+		fprintf(stderr, "Precondition, write failed, ret: %d\n", ret);
+		goto err;
+	}
+
 	if (posix_memalign(&rvec.iov_base, 4096, 512*1024))
 		goto err;
 	rvec.iov_len = 512*1024;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH liburing 3/3] test/fixed-seg: Support non 512 LBA format devices.
       [not found]   ` <CGME20250423133646epcas5p2e67808b13c6c85444b8a9f28995fe70b@epcas5p2.samsung.com>
@ 2025-04-23 13:27     ` Nitesh Shetty
  2025-04-23 19:05       ` Anuj gupta
  0 siblings, 1 reply; 7+ messages in thread
From: Nitesh Shetty @ 2025-04-23 13:27 UTC (permalink / raw)
  To: io-uring; +Cc: gost.dev, nitheshshetty, Nitesh Shetty

At present test succeeds only for 512 LBA format device.
Now 4k LBA formatted device should also pass.

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
---
 test/fixed-seg.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/test/fixed-seg.c b/test/fixed-seg.c
index ab1d359..63b1cee 100644
--- a/test/fixed-seg.c
+++ b/test/fixed-seg.c
@@ -9,6 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/time.h>
+#include <sys/ioctl.h>
 #include "liburing.h"
 #include "helpers.h"
 
@@ -87,7 +88,7 @@ int main(int argc, char *argv[])
 	struct io_uring ring;
 	const char *fname;
 	char buf[256];
-	int fd, rnd_fd, ret;
+	int fd, rnd_fd, ret, vec_off = 512;
 
 	if (argc > 1) {
 		fname = argv[1];
@@ -104,6 +105,7 @@ int main(int argc, char *argv[])
 		perror("open");
 		return 1;
 	}
+	ioctl(fd, BLKSSZGET, &vec_off);
 
 	rnd_fd = open("/dev/urandom", O_RDONLY);
 	if (fd < 0) {
@@ -143,14 +145,13 @@ int main(int argc, char *argv[])
 		goto err;
 	}
 
-	ret = test(&ring, fd, 512);
+	ret = test(&ring, fd, vec_off);
 	if (ret) {
-		fprintf(stderr, "test 512 failed\n");
+		fprintf(stderr, "test %d failed\n", vec_off);
 		goto err;
 	}
 
-	ret = test(&ring, fd, 3584);
-	if (ret) {
+	if ((vec_off == 512) && test(&ring, fd, 3584)) {
 		fprintf(stderr, "test 3584 failed\n");
 		goto err;
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH liburing 3/3] test/fixed-seg: Support non 512 LBA format devices.
  2025-04-23 13:27     ` [PATCH liburing 3/3] test/fixed-seg: Support non 512 LBA format devices Nitesh Shetty
@ 2025-04-23 19:05       ` Anuj gupta
  2025-04-23 20:02         ` Jens Axboe
  0 siblings, 1 reply; 7+ messages in thread
From: Anuj gupta @ 2025-04-23 19:05 UTC (permalink / raw)
  To: Nitesh Shetty; +Cc: io-uring, gost.dev, nitheshshetty

> +       ioctl(fd, BLKSSZGET, &vec_off);

nit: vec_off might be better named as block_size or lba_size to better
reflect its use

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH liburing 3/3] test/fixed-seg: Support non 512 LBA format devices.
  2025-04-23 19:05       ` Anuj gupta
@ 2025-04-23 20:02         ` Jens Axboe
  0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2025-04-23 20:02 UTC (permalink / raw)
  To: Anuj gupta, Nitesh Shetty; +Cc: io-uring, gost.dev, nitheshshetty

On 4/23/25 1:05 PM, Anuj gupta wrote:
>> +       ioctl(fd, BLKSSZGET, &vec_off);
> 
> nit: vec_off might be better named as block_size or lba_size to better
> reflect its use

Agree, and would be nice to have an error check on ioctl as
well, just to be prudent.

I'll apply this series as-is, as it's mostly just nits.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH liburing 0/3] test/fixed-seg: Add data verification and
  2025-04-23 13:27 ` [PATCH liburing 0/3] test/fixed-seg: Add data verification and Nitesh Shetty
                     ` (2 preceding siblings ...)
       [not found]   ` <CGME20250423133646epcas5p2e67808b13c6c85444b8a9f28995fe70b@epcas5p2.samsung.com>
@ 2025-04-23 20:04   ` Jens Axboe
  3 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2025-04-23 20:04 UTC (permalink / raw)
  To: io-uring, Nitesh Shetty; +Cc: gost.dev, nitheshshetty


On Wed, 23 Apr 2025 18:57:49 +0530, Nitesh Shetty wrote:
> Write data before issuing read and verify the data once read is
> completed. This makes sure we are failing if nr_seg is passed wrong,
> incase of offset is present.
> 
> At present test fails for block devices formatted with non 512 bytes.
> This allows to test 4k block devices. Some of the corner cases such as
> 3584 offset test are not valid for 4k, hence skipped.
> 
> [...]

Applied, thanks!

[1/3] test/fixed-seg: Prep patch, rename the vec to rvec.
      commit: f9f133fd9edbdd8e47b06739e0a2e4fa8da9c721
[2/3] test/fixed-seg: verify the data read
      commit: fcf273bbae7082fb6413c87c21f1d982ee6b9140
[3/3] test/fixed-seg: Support non 512 LBA format devices.
      commit: be5f31287825eb1f81813a15a28989b27627ac10

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-04-23 20:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20250423133628epcas5p2b4752a672a64bd2f1392f663a284f9f2@epcas5p2.samsung.com>
2025-04-23 13:27 ` [PATCH liburing 0/3] test/fixed-seg: Add data verification and Nitesh Shetty
     [not found]   ` <CGME20250423133638epcas5p34a9cf20f13387f7f604d9c2e2bf6976a@epcas5p3.samsung.com>
2025-04-23 13:27     ` [PATCH liburing 1/3] test/fixed-seg: Prep patch, rename the vec to rvec Nitesh Shetty
     [not found]   ` <CGME20250423133642epcas5p1bef7e3af23bd8561f359ccc16fdaf980@epcas5p1.samsung.com>
2025-04-23 13:27     ` [PATCH liburing 2/3] test/fixed-seg: verify the data read Nitesh Shetty
     [not found]   ` <CGME20250423133646epcas5p2e67808b13c6c85444b8a9f28995fe70b@epcas5p2.samsung.com>
2025-04-23 13:27     ` [PATCH liburing 3/3] test/fixed-seg: Support non 512 LBA format devices Nitesh Shetty
2025-04-23 19:05       ` Anuj gupta
2025-04-23 20:02         ` Jens Axboe
2025-04-23 20:04   ` [PATCH liburing 0/3] test/fixed-seg: Add data verification and Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox