On 2020/5/15 12:19, Matthew Wilcox wrote:
> On Thu, May 07, 2020 at 03:50:57PM +0800, Zhen Lei wrote:
>> +++ b/block/blk-settings.c
>> @@ -150,7 +150,7 @@ void blk_queue_max_hw_sectors(struct request_queue *q,
>> unsigned int max_hw_secto
>> unsigned int max_sectors;
>>
>> if ((max_hw_sectors << 9) < PAGE_SIZE) {
>> - max_hw_sectors = 1 << (PAGE_SHIFT - 9);
>> + max_hw_sectors = PAGE_SECTORS;
>
> Surely this should be:
>
> if (max_hw_sectors < PAGE_SECTORS) {
> max_hw_sectors = PAGE_SECTORS;
>
> ... no?
I've noticed this place before. "(max_hw_sectors << 9) < PAGE_SIZE" can also
make sure
that max_hw_sectors is not too large, that means (max_hw_sectors << 9) may
overflow.
>
>> - page = read_mapping_page(mapping,
>> - (pgoff_t)(n >> (PAGE_SHIFT - 9)), NULL);
>> + page = read_mapping_page(mapping, (pgoff_t)sectors_to_npage(n), NULL);
>
> ... again, get the type right, and you won't need the cast.
OK, I'll consider it.
>
>
> .
>
--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel
- Re: [dm-devel] [PATCH v2 06/10] mm/swap: us... Leizhen (ThunderTown)
- Re: [dm-devel] [PATCH v2 06/10] mm/swap: use np... Matthew Wilcox
- Re: [dm-devel] [PATCH v2 06/10] mm/swap: us... Leizhen (ThunderTown)
- [dm-devel] [PATCH v2 08/10] md: use sectors_to_npage... Zhen Lei
- [dm-devel] [PATCH v2 02/10] zram: abolish macro SECT... Zhen Lei
- [dm-devel] [PATCH v2 01/10] block: move PAGE_SECTORS... Zhen Lei
- [dm-devel] [PATCH v2 09/10] md: use existing definit... Zhen Lei
- [dm-devel] [PATCH v2 05/10] block: abolish macro PAG... Zhen Lei
- [dm-devel] [PATCH v2 07/10] block: use sectors_to_np... Zhen Lei
- Re: [dm-devel] [PATCH v2 07/10] block: use sect... Matthew Wilcox
- Re: [dm-devel] [PATCH v2 07/10] block: use ... Leizhen (ThunderTown)
- [dm-devel] [PATCH v2 04/10] zram: abolish macro SECT... Zhen Lei
- [dm-devel] [PATCH v2 10/10] md: use PAGE_SECTORS to ... Zhen Lei
- [dm-devel] [PATCH v2 03/10] block: add sectors_to_np... Zhen Lei
- Re: [dm-devel] [PATCH v2 00/10] clean up SECTOR rela... Leizhen (ThunderTown)
