lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFx+gP1+ztJ+THoxLpXkpv83k9JRikG7nD7cY1xByOpCAw@mail.gmail.com>
Date:	Fri, 22 Jan 2016 10:43:59 -0800
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Ming Lei <tom.leiming@...il.com>
Cc:	Jens Axboe <axboe@...nel.dk>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	linux-block@...r.kernel.org,
	Stefan Haberland <sth@...ux.vnet.ibm.com>,
	Keith Busch <keith.busch@...el.com>
Subject: Re: [PATCH] block: fix bio splitting on max sectors

On Fri, Jan 22, 2016 at 10:29 AM, Ming Lei <tom.leiming@...il.com> wrote:
>
> This patch fixes the issue by making the max io size aligned
> to logical block size.

Looks better, thanks.

I'd suggest also moving the "max_sectors" variable into the
bio_for_each_segment() loop too just to keep variables with minimal
scope, but at least this is fairly legible.

Also:

> +static inline unsigned get_max_io_size(struct request_queue *q,
> +                                      struct bio *bio)
> +{
> +       unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector);
> +       unsigned mask = ~(queue_logical_block_size(q) - 1);
> +
> +       /* aligned to logical block size */
> +       sectors = ((sectors << 9) & mask) >> 9;

this could be written as

        unsigned mask = queue_logical_block_size(q) - 1;

        sectors = sectors & ~(mask >> 9);

avoiding the extra shift. That also avoids the possible overflow that
that extra left-shift introduces. Hmm?

                 Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ