Skip to content
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

fio: enable dataplacement(fdp) while replaying I/Os #1762

Merged
merged 2 commits into from
May 28, 2024

Conversation

parkvibes
Copy link
Contributor

@parkvibes parkvibes commented May 23, 2024

fio: enable dataplacement(fdp) while replaying I/Os

Add initialization and dataplacement logic to enable
dataplacement(fdp) while fio replays I/Os with read_iolog.

Signed-off-by: Hyunwoo Park [email protected]

t/nvmept_fdp: add a test(402)

A test(402) checks whether dataplacement(fdp) works fine while replaying iologs

Signed-off-by: Hyunwoo Park [email protected]

@vincentkfu
Copy link
Collaborator

Can you add a test case for this?

iolog.c Outdated
@@ -140,8 +140,13 @@ static int ipo_special(struct thread_data *td, struct io_piece *ipo)
break;
}
ret = td_io_open_file(td, f);
if (!ret)
if (!ret){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space between ) and {

iolog.c Outdated
if (!ret){
if (td->o.dp_type != FIO_DP_NONE) {
if (dp_init(td))
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we return 0 here this fails silently. Why not print out an error message and abort on error? See the td_verror() + return -1; construction below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the construction below, I'll update it.

@parkvibes
Copy link
Contributor Author

Can you add a test case for this?

Sure.
Did you intend the test case to be included in t/nvmep_fdp.py?

@vincentkfu
Copy link
Collaborator

Can you add a test case for this?

Sure. Did you intend the test case to be included in t/nvmep_fdp.py?

Yes that's fine.

@parkvibes parkvibes force-pushed the enable-dataplacement-while-replaying-io branch from 7456a87 to e6a96fa Compare May 27, 2024 05:27
@parkvibes parkvibes requested a review from vincentkfu May 27, 2024 05:30
Add initialization and dataplacement logic to enable
dataplacement(fdp) while fio replays I/Os with read_iolog.

Signed-off-by: Hyunwoo Park <[email protected]>
A test(402) checks whether dataplacement(fdp) works fine while replaying iologs

Signed-off-by: Hyunwoo Park <[email protected]>
@vincentkfu
Copy link
Collaborator

Looks good. Thanks.

@axboe axboe merged commit d5fbe84 into axboe:master May 28, 2024
10 checks passed
@vincentkfu
Copy link
Collaborator

@parkvibes The iolog changes triggered the issues below from Coverity. Could you take a look?

Hi,

Please find the latest report on new defect(s) introduced to axboe/fio found with Coverity Scan.

2 new defect(s) introduced to axboe/fio found with Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 2 of 2 defect(s)


** CID 494151:  Error handling issues  (NEGATIVE_RETURNS)
/iolog.c: 148 in ipo_special()


________________________________________________________________________________________________________
*** CID 494151:  Error handling issues  (NEGATIVE_RETURNS)
/iolog.c: 148 in ipo_special()
142     		ret = td_io_open_file(td, f);
143     		if (!ret) {
144     			if (td->o.dp_type != FIO_DP_NONE) {
145     				int dp_init_ret = dp_init(td);
146     
147     				if (dp_init_ret != 0) {
>>>     CID 494151:  Error handling issues  (NEGATIVE_RETURNS)
>>>     "dp_init_ret" is passed to a parameter that cannot be negative.
148     					td_verror(td, dp_init_ret, "dp_init");
149     					return -1;
150     				}
151     			}
152     			break;
153     		}

** CID 494150:  Null pointer dereferences  (FORWARD_NULL)


________________________________________________________________________________________________________
*** CID 494150:  Null pointer dereferences  (FORWARD_NULL)
/io_u.c: 1877 in get_io_u()
1871     		goto out;
1872     
1873     	/*
1874     	 * If using an iolog, grab next piece if any available.
1875     	 */
1876     	if (td->flags & TD_F_READ_IOLOG) {
>>>     CID 494150:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing "io_u" to "read_iolog_get", which dereferences null "io_u->file".
1877     		if (read_iolog_get(td, io_u))
1878     			goto err_put;
1879     	} else if (set_io_u_file(td, io_u)) {
1880     		ret = -EBUSY;
1881     		dprint(FD_IO, "io_u %p, setting file failed\n", io_u);
1882     		goto err_put;


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, https://u15810271.ct.sendgrid.net/ls/click?upn=u001.AxU2LYlgjL6eX23u9ErQy-2BKADyCpvUKOL6EWmZljiu4yVEXfoZtNI9aDIN5OOuYjE8SHJnwGeWwjfdVs9s-2BYB3ZEVB97u-2BLmRNT80zQw85Y-3Db7sa_8kI-2BKaI4kRTN8bowTGN-2FIv-2B5XERDW2ihNq7DYuDzDpmmvahLn3JajrxA3i5l5DGyDhhzLSTpTQ-2BJ2sl2nUUaOh87USSlaD9P5rFbqOiOAvnH6OSpFV-2Fc8BKi6mMESwLHUeXVPyb0HpmtEJ03mcYdYqmBXxlvj0UkBSWKzLtyQWImKUzg3AXuv07Yw-2BQDc5ZpFmoMO-2FrNuMNNecVzSxCC4A-3D-3D

@parkvibes
Copy link
Contributor Author

parkvibes commented May 29, 2024

@vincentkfu
Analyzing the issues, I indentified the causes that could be reasons of issue.

Here is my study.

CID 494150: Null pointer dereferences (FORWARD_NULL)

This issue seems to be not originated from my commits. But I guess that the code that checking whether io_u is null or not in read_iolog_get() can resolve the issue.

CID 494151: Error handling issues (NEGATIVE_RETURNS)

dp_init_ret(int) will be casted into unsigned int in __td_verror() macro.
To handle this issue, the declaration of dp_init() should be changed to return unsigned int. It seems like this change should come with changes of all functions in datplacement.c/h

But I wonder why similar cases below are not detected as issues.

  • td_verror() of line 154 in iolog.c
  • set_io_u_file() of line 1879 in io_u.c

As far as I know, these came from https://scan.coverity.com/projects/axboe-fio. After adding me to the project(I already requested), I can see the detail. (to view defects or help fix defects...)

@vincentkfu
Copy link
Collaborator

CID 494150: Null pointer dereferences (FORWARD_NULL)

Inspecting the code and Coverity's annotations suggest that there will be a null pointer dereference of io_u->file in dp_fill_dspec_data() when ipo->ddir == DDIR_WAIT . We know that io_u->file is NULL when read_iolog_get() is called, so when ipo->ddir == DDIR_WAIT we should not try to fill dspec data for this operation.

I can confirm that adding /dev/ng0n1 wait 100 100 to iolog for your new test case does result in a segfault.

One possible fix would be to put

		if (td->o.dp_type != FIO_DP_NONE)
			dp_fill_dspec_data(td, io_u);

inside the if (iop->ddir !+ DDIR_WAIT) { block.

CID 494151: Error handling issues (NEGATIVE_RETURNS)

It looks like td_verror() expects a positive errno as the second parameter but dp_init() returns a negative errno on error. For td_verror() on line 154 in iolog.c, td_io_open_file() only returns 0 or 1.

@parkvibes
Copy link
Contributor Author

Thanks for the cross check.

CID 494150: Null pointer dereferences (FORWARD_NULL)

Putting the codes related to dp_fill_dspec_data() inside if (iop->ddir !+ DDIR_WAIT) { block sounds good.

CID 494151: Error handling issues (NEGATIVE_RETURNS)

I'm willing to update dp_init() not to return negative value. Before carrying it out, I have some question.

  • Is there any special purpose to return a negative error number(not EINVAL but -EINVAL)? Inspecting fio codes overally, Some codes return error number itself but others do it adding -.
  • Would it be okay to change function prototype(intunsigned int) in dataplacement.c/h additionally?

@vincentkfu
Copy link
Collaborator

The least intrusive change to handle the return code of dp_init would be to leave the function unchanged but simply negate the return code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants