|
|
Log in / Subscribe / Register

Fixing sector_div

Fixing sector_div

Posted May 26, 2015 19:32 UTC (Tue) by bcopeland (subscriber, #51750)
In reply to: Fixing sector_div by ncm
Parent article: A tale of two data-corruption bugs

> There never was an excuse for this macro as written.

My guess, without having looked at history, is that sector_div() is that way because of do_div(), but even it has been recognized as a trap for the unwary going back quite a while (see e.g.: http://lkml.iu.edu/hypermail/linux/kernel/0308.0/0617.html)


to post comments

Fixing sector_div

Posted May 26, 2015 23:42 UTC (Tue) by cesarb (subscriber, #6266) [Link]

> Not very many people should use "do_div()" directly (and a quick grep shows that not very many people do). It's generally a mistake to do so, I suspect. The thing was originally written explicitly for "printk()" and nothing else.

That might explain why it's that way. The printk() family of functions is used in a lot of places.

And yeah, sector_div() is do_div() if CONFIG_LBDAF (large block devices) is set, otherwise it's a normal rem/div pair.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds