From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Mingfangsen <mingfangsen@huawei.com>, Guiyao <guiyao@huawei.com>,
Louhongxiang <louhongxiang@huawei.com>
Subject: Re: [PATCH V4] brd: check and limit max_part par
Date: Tue, 4 Feb 2020 09:21:28 +0800 [thread overview]
Message-ID: <9d82e25c-c909-3180-e987-260f53de51a4@huawei.com> (raw)
In-Reply-To: <20200203122005.GB31450@ming.t460p>
On 2020/2/3 20:26, Ming Lei wrote:
> On Tue, Jan 21, 2020 at 12:04:41PM +0800, Zhiqiang Liu wrote:
>>
>> In brd_init func, rd_nr num of brd_device are firstly allocated
>> and add in brd_devices, then brd_devices are traversed to add each
>> brd_device by calling add_disk func. When allocating brd_device,
>> the disk->first_minor is set to i * max_part, if rd_nr * max_part
>> is larger than MINORMASK, two different brd_device may have the same
>> devt, then only one of them can be successfully added.
>> when rmmod brd.ko, it will cause oops when calling brd_exit.
>>
>> +static inline void brd_check_and_reset_par(void)
>> +{
>> + if (unlikely(!max_part))
>> + max_part = 1;
>> +
>> + if (max_part > DISK_MAX_PARTS) {
>> + pr_info("brd: max_part can't be larger than %d, reset max_part = %d.\n",
>> + DISK_MAX_PARTS, DISK_MAX_PARTS);
>> + max_part = DISK_MAX_PARTS;
>> + }
>> +
>> + /*
>> + * make sure 'max_part' can be divided exactly by (1U << MINORBITS),
>> + * otherwise, it is possiable to get same dev_t when adding partitions.
>> + */
>> + if ((1U << MINORBITS) % max_part != 0)
>> + max_part = 1UL << fls(max_part);
>> +}
>
> You should move the above change before capping it to DISK_MAX_PARTS
> since 1UL << fls() may increase 'max_part'.
>
Thanks for your suggestion. I will send the v5 patch.
prev parent reply other threads:[~2020-02-04 1:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-21 4:04 [PATCH V4] brd: check and limit max_part par Zhiqiang Liu
2020-02-03 1:53 ` Zhiqiang Liu
2020-02-03 12:36 ` Bob Liu
2020-02-03 12:26 ` Ming Lei
2020-02-04 1:21 ` Zhiqiang Liu [this message]
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=9d82e25c-c909-3180-e987-260f53de51a4@huawei.com \
--to=liuzhiqiang26@huawei.com \
--cc=axboe@kernel.dk \
--cc=guiyao@huawei.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=louhongxiang@huawei.com \
--cc=ming.lei@redhat.com \
--cc=mingfangsen@huawei.com \
/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