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

Fix i586 size_t compiler error. #609

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gonzoleeman
Copy link
Contributor

This fix silences a compiler complaint on i586 (32-bit)
in handle_writesame(). A similar fix is done in handle_format_unit(),
since the code is very similar.

Changes since v1:

  • removed git merges from commit
  • added fix in handle_format_unit()

Original-fix-by: David Disseldorp ddiss@suse.de

This fix silences a compiler complaint on i586 (32-bit)
in handle_writesame(). A similar fix is done in handle_format_unit(),
since the code is very similar.

Original-fix-by: David Disseldorp <ddiss@suse.de>
@gonzoleeman
Copy link
Contributor Author

Try 2.

@@ -712,7 +712,7 @@ static int handle_writesame(struct tcmu_device *dev, struct tcmulib_cmd *cmd)
uint32_t block_size = tcmu_dev_get_block_size(dev);
uint64_t start_lba = tcmu_cdb_get_lba(cdb);
uint64_t write_lbas;
size_t max_xfer_length, length = 1024 * 1024;
uint64_t max_xfer_length, length = 1024 * 1024;
Copy link
Collaborator

Choose a reason for hiding this comment

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

A couple lines below this we do:

length = round_up(length, max_xfer_length);

then pass length to tcmur_cmd_state_init which wants a size_t. Will you get another error about passing a unin64_t to a size_t now?

@mikechristie
Copy link
Collaborator

This PR is also trying to fix the same issue:

#603

@gonzoleeman
Copy link
Contributor Author

This PR is also trying to fix the same issue:

#603

Honestly, I kind of like that better. The size mismatches in the code (e.g. going to/from int/uint64_t/size_t) are numerous and kind of a can of worms to start fixing IMHO.

@ddiss what do you think (since you initiated the fix I submitted)?

@mikechristie
Copy link
Collaborator

Honestly, I kind of like that better. The size mismatches in the code (e.g. going to/from int/uint64_t/size_t) are numerous and kind of a can of worms to start fixing IMHO.

I didn't merge that patch, because I wanted to fix it properly.

However, it seems like the only time these get reported are just for builds and not actual users of 32 bit setups.

Are you guys seeing 32 bit tcmu runner users? We had one a long while back and they hit a issue with the device size:

#360

@gonzoleeman
Copy link
Contributor Author

Honestly, I kind of like that better. The size mismatches in the code (e.g. going to/from int/uint64_t/size_t) are numerous and kind of a can of worms to start fixing IMHO.

I didn't merge that patch, because I wanted to fix it properly.

IMHO that would take a bit of work, and for what? For 32-bit? Not sure it's worth it.

However, it seems like the only time these get reported are just for builds and not actual users of 32 bit setups.

Are you guys seeing 32 bit tcmu runner users? We had one a long while back and they hit a issue with the device size:

#360

No. We actually have never had a 32-bit issue. This came up as a build issue for our Factory build (Tumbleweed), and frankly I doubt anyone loads that on a 32-bit system. I actually just let the 32-bit build fail for quite a while, and David was the one that suggested fixing it.

@ddiss
Copy link
Contributor

ddiss commented Jan 4, 2020

Honestly, I kind of like that better. The size mismatches in the code (e.g. going to/from int/uint64_t/size_t) are numerous and kind of a can of worms to start fixing IMHO.

tcmu_dev_get_max_xfer_len() returns a uint32_t and tcmu_lba_to_byte() returns a uint64_t, so I think using a uint64_t makes more sense than casting to size_t for min() here.

I didn't merge that patch, because I wanted to fix it properly.

IMHO that would take a bit of work, and for what? For 32-bit? Not sure it's worth it.

However, it seems like the only time these get reported are just for builds and not actual users of 32 bit setups.
Are you guys seeing 32 bit tcmu runner users? We had one a long while back and they hit a issue with the device size:
#360

No. We actually have never had a 32-bit issue. This came up as a build issue for our Factory build (Tumbleweed), and frankly I doubt anyone loads that on a 32-bit system. I actually just let the 32-bit build fail for quite a while, and David was the one that suggested fixing it.

This was just a build regression, I agree that we probably don't have many 32-bit users, but keep in mind that openSUSE carries ARMv7 ports, in addition to i586.

@mikechristie
Copy link
Collaborator

Honestly, I kind of like that better. The size mismatches in the code (e.g. going to/from int/uint64_t/size_t) are numerous and kind of a can of worms to start fixing IMHO.

I didn't merge that patch, because I wanted to fix it properly.

IMHO that would take a bit of work, and for what? For 32-bit? Not sure it's worth it.

Maybe we are talking about different things. From my perspective if we are not supporting it then why even waste time on these build issues? If we are supporting it then we could end up having a user and if we prevent a data corruption, then it's worth it for me.

I'm not sure it's that bad. For example, for the WS case, lba_cnt can be up to 32 bits but we then use bytes internally so that gets multiplied so that is why we used u64 in some places. Maybe for 32 bit setups we need to at least set VPD_MAX_WRITE_SAME_LENGTH lower so we will always be within a 32bit value after the byte conversion. Then add a check that the incoming command obeys the reported limit.

@mikechristie
Copy link
Collaborator

I'm not sure it's that bad.

Doh. I think to support 32bit setups we probably need a lot of other fixes. Due to some other 32 bit setup bug that limits the device size we currently do not need stuff like the lowered WS size and limit check since we could never have a device that is large enough.

So I guess my concern is more general and do we want to even support 32 bit setups or just add something so it does not build.

This was referenced Jul 7, 2021
@lxbsz lxbsz changed the base branch from master to main August 10, 2022 00:21
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