-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GIT PULL] Add ftruncate #1004
[GIT PULL] Add ftruncate #1004
Conversation
a098ef9
to
627c71e
Compare
d4f6968
to
aed55d3
Compare
d555e2f
to
8f0c5c6
Compare
Two minor things:
|
f51b164
to
fd1bd0e
Compare
I think this looks fine, but one problem is that if you run this test case on an older kernel, then the test will fail. If you get -EINVAL for the first ftruncate you try, just assume the kernel doesn't support it and return T_EXIT_SKIP for that and skip the other tests. That way it'll just skip the test case on older kernels, but test it on newer kernels. See other test cases that do this very thing, usually with a |
It already runs |
test/truncate.c
Outdated
if (ret < 0) { | ||
if (ret == -EBADF || ret == -EINVAL) { | ||
fprintf(stdout, "Ftruncate not supported, skipping\n"); | ||
goto out; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be a break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is a break, it will go to test truncate with path failing, no reason to test that if ftruncate is unsupported I think
} | ||
} | ||
|
||
out: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should return T_EXIT_PASS for success, T_EXIT_SKIP if the test is skipped, and T_EXIT_FAIL if the test case failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
It does, but it doesn't return T_EXIT_SKIPPED. I think you should also distinguish between "we got EBADF/EINVAL on the first test, it's probably not supported, T_EXIT_SKIPPED" rather than just have any of the test cases returning EINVAL leading to a skipped test where it probably should've been a failure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing Signed-off-by tag.
src/liburing-ffi.map
Outdated
@@ -191,4 +191,5 @@ LIBURING_2.6 { | |||
global: | |||
io_uring_prep_fixed_fd_install; | |||
io_uring_buf_ring_available; | |||
io_uring_prep_ftruncate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use tabs as indentation; don't use spaces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
test/truncate.c
Outdated
goto err; | ||
} | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same indentation issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
test/truncate.c
Outdated
ret = cqe->res; | ||
io_uring_cqe_seen(ring, cqe); | ||
if (cqe->res != -EINVAL) { | ||
fprintf(stderr, "unexpected truncate res %d\n", cqe->res); | ||
goto err; | ||
} | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this assignment, ret = cqe->res,
the ret
value is not used. Shouldn't it be returned?
Also, goto err
is return 1
while your caller checking is:
ret = test_truncate(&ring, fd);
if (ret < 0)
goto err;
So test_truncate()
will always be assumed as a success because it never returns a negative value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Tony Solomonik <tony.solomonik@gmail.com>
test/truncate.c
Outdated
} | ||
ret = cqe->res; | ||
io_uring_cqe_seen(ring, cqe); | ||
if (cqe->res != -EINVAL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't matter too much here, but you cannot use the cqe after calling io_uring_cqe_seen() as it could've been overwritten by a new cqe. You assign 'ret' here anyway, so please just use ret. Would be a shame if people copied an error like that for their app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
Signed-off-by: Tony Solomonik <tony.solomonik@gmail.com>
Signed-off-by: Tony Solomonik <tony.solomonik@gmail.com>
Signed-off-by: Tony Solomonik <tony.solomonik@gmail.com>
sqe = io_uring_get_sqe(ring); | ||
if (!sqe) { | ||
fprintf(stderr, "get sqe failed\n"); | ||
goto err; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto err;
contains return ret,
but ret
is uninitialized; stop using goto
if you don't have any cleanup. Just return -1;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, it turns out return 1;
Not return ret
.
ret = io_uring_submit(ring); | ||
if (ret <= 0) { | ||
fprintf(stderr, "sqe submit failed: %d\n", ret); | ||
goto err; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we assume io_uring_submit()
returns 0 is failed, then you must override it with return -1
because return 0
is okay from the caller prespective.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the noise, I probably read the old code before you force pushed.
err: | ||
return 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return 1 is not an error as you have this in the caller:
ret = test_ftruncate(&ring, fd, test_sizes[i]);
if (ret < 0) {
// fail
}
Must be return -1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah no, it has an else if, my mistake again...
Introduces `opcode::Ftruncate` to support the ftruncate which got supported since Linux 6.9. Also updates the libc to the latest version to get the new sys::IORING_OP_FTRUNCATE flag from libc. See - `IORING_OP_FTRUNCATE` commit: torvalds/linux@b4bb190 - liburing PR: axboe/liburing#1004
To accompany the patches I sent for adding ftruncate, here are the changes for usermode.
git request-pull output:
Click to show/hide pull request guidelines
Pull Request Guidelines
notification, use
[GIT PULL]
as a prefix in your PR title.Commit message format rules:
Signed-off-by
tag with your real name and email. For example:The description should be word-wrapped at 72 chars. Some things should
not be word-wrapped. They may be some kind of quoted text - long
compiler error messages, oops reports, Link, etc. (things that have a
certain specific format).
Note that all of this goes in the commit message, not in the pull
request text. The pull request text should introduce what this pull
request does, and each commit message should explain the rationale for
why that particular change was made. The git tree is canonical source
of truth, not github.
Each patch should do one thing, and one thing only. If you find yourself
writing an explanation for why a patch is fixing multiple issues, that's
a good indication that the change should be split into separate patches.
If the commit is a fix for an issue, add a
Fixes
tag with the issueURL.
Don't use GitHub anonymous email like this as the commit author:
Use a real email address!
Commit message example:
By submitting this pull request, I acknowledge that: