From: Chen Gang <gang.chen.5i5j@gmail.com>
To: Hannes Reinecke <hare@suse.de>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
James Hogan <james.hogan@imgtec.com>,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Fengguang Wu <fengguang.wu@intel.com>
Subject: Re: [PATCH] drivers: target: target_core_mod: use div64_u64_rem() instead of operator '%' for u64
Date: Wed, 08 Jan 2014 22:40:24 +0800 [thread overview]
Message-ID: <52CD6358.7010706@gmail.com> (raw)
In-Reply-To: <52CCFF0C.7070704@suse.de>
On 01/08/2014 03:32 PM, Hannes Reinecke wrote:
> On 12/24/2013 04:35 AM, Chen Gang wrote:
>> On 12/23/2013 02:51 PM, Nicholas A. Bellinger wrote:
>>> On Sun, 2013-12-22 at 17:17 +0800, Chen Gang wrote:
>>>> On 12/22/2013 10:56 AM, Nicholas A. Bellinger wrote:
>>>>> Hi Chen,
>>>>>
>>>>> On Sat, 2013-12-21 at 10:08 +0800, Chen Gang wrote:
>>>>>> In kernel, need use div64_u64_rem() instead of operator '%' for u64, or
>>>>>> can not pass compiling (with allmodconfig under metag):
>>>>>>
>>>>>> MODPOST 2909 modules
>>>>>> ERROR: "__umoddi3" [drivers/target/target_core_mod.ko] undefined!
>>>>>>
>>>>>> Also need u64 type cast for u32 variable multiply u32 variable, or will
>>>>>> cause type overflow issue.
>>>>>>
>>>>>>
>>>>>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>>>>>> ---
>>>>>> drivers/target/target_core_alua.c | 3 ++-
>>>>>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>>>>>
>>>>>
>>>>> FYI, this unsigned long long division in core_alua_state_lba_dependent()
>>>>> was fixed for 32-bit in linux-next >= 12192013 code.
>>>>>
>>>>
>>>> OK, thanks.
>>>>
>>>> The related fix patch changed "start_lba = lba % ..." to "start_lba =
>>>> lba / ...", and also assumed "segment_size * segment_mult" is still
>>>> within u32 (can not cause type over flow).
>>>>
>>>> I guess the original author already knew about them, and intended to do
>>>> like that (if not, please let me know, thanks).
>>>>
>>>
>>> Sorry, your correct that the original code is using modulo division to
>>> calculate start_lba.
>>>
>>
>> Oh, that's all right, (in fact, don't need sorry), I am not quite
>> familiar with the details, so need related member help check it. :-)
>>
>>> Hannes, can you please double check this below..?
>>>
>>
>> Please help check when have time, thanks.
>>
> I would even convert segment_size and segment_mult to u64,
> to ensure no overflows occur:
>
> diff --git a/drivers/target/target_core_alua.c
> b/drivers/target/target_core_alua
> .c
> index 9b1856d..54b1e52 100644
> --- a/drivers/target/target_core_alua.c
> +++ b/drivers/target/target_core_alua.c
> @@ -477,8 +477,7 @@ static inline int core_alua_state_lba_dependent(
> u8 *alua_ascq)
> {
> struct se_device *dev = cmd->se_dev;
> - u32 segment_size, segment_mult, sectors;
> - u64 lba;
> + u64 segment_size, segment_mult, sectors, lba;
>
> /* Only need to check for cdb actually containing LBAs */
> if (!(cmd->se_cmd_flags & SCF_SCSI_DATA_CDB))
>
>
OK, thanks.
> Other than that the sector_div() patch is correct.
>
So we really need use '/' instead of original '%'?
Thanks
--
Chen Gang
Open, share and attitude like air, water and life which God blessed
next prev parent reply other threads:[~2014-01-08 14:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-21 2:08 [PATCH] drivers: target: target_core_mod: use div64_u64_rem() instead of operator '%' for u64 Chen Gang
2013-12-22 2:56 ` Nicholas A. Bellinger
2013-12-22 9:17 ` Chen Gang
2013-12-23 6:51 ` Nicholas A. Bellinger
2013-12-24 3:35 ` Chen Gang
2014-01-08 7:32 ` Hannes Reinecke
2014-01-08 14:40 ` Chen Gang [this message]
2014-01-08 23:18 ` Nicholas A. Bellinger
2014-01-09 10:17 ` Hannes Reinecke
2014-01-10 5:47 ` Nicholas A. Bellinger
2014-01-10 16:06 ` Chen Gang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52CD6358.7010706@gmail.com \
--to=gang.chen.5i5j@gmail.com \
--cc=fengguang.wu@intel.com \
--cc=hare@suse.de \
--cc=james.hogan@imgtec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nab@linux-iscsi.org \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).