On 6/18/19 11:41 AM, Guoqing Jiang wrote:
+static int check_and_add_wb(struct md_rdev *rdev, sector_t lo,
sector_t hi)
+{
+ struct wb_info *wi;
+ unsigned long flags;
+ int ret = 0;
+ struct mddev *mddev = rdev->mddev;
+
+ wi = mempool_alloc(mddev->wb_info_pool, GFP_NOIO);
+
+ spin_lock_irqsave(&rdev->wb_list_lock, flags);
+ list_for_each_entry(wi, &rdev->wb_list, list) {
This doesn't look right. We should allocate wi from mempool after
the list_for_each_entry(), right?
Good catch, I will use an temp variable in the iteration since
mempool_alloc
could sleep.
After a second thought, I think it should be fine since wi is either
reused to record the sector range or freed after the iteration.
Could you elaborate your concern? Thanks.
Guoqing