On 2019/4/18 下午8:27, Nikolay Borisov wrote:
> 
> 
> On 18.04.19 г. 14:54 ч., Qu Wenruo wrote:
> <snip>
> 
>>
>> Forgot to mention, for that method, I'll definitely keep the BUG_ON() on
>> @prealloc.
>>
>> Just make the allocation part fall back to use fs_info->last_chance[] to
>> grab a valid memory slot.
> 
> Before you go and re-invent the wheel I will suggest you take a look at
> the mempool api (include/linux/mempool.h). AFAIK it's purpose is to
> exactly ensure memory allocations from it will not fail (depending on
> how the pool is configured)

Know that before.
But should_fail_slab() will ignore GFP flags, thus it doesn't make sense
in error injection case.

Thanks,
Qu

> 
>>
>> Thanks,
>> Qu
>>
>>>
>>> The main reason I'm doing such error injection test is to ensure write
>>> time tree checker is not the cause of the lockup.
>>>
>>> Of course I can directly inject error into btrfs_check_leaf_full() and
>>> btrfs_check_node(), and filter the stack to ensure it only happen in
>>> write time, and that's already what I'm crafting, based on the bcc error
>>> inject example and kprobe return value overriding.
>>>
>>> But it will never be a bad idea to explore what can go wrong.
>>> And "always BUG_ON()" -> "good enough (TM)" already looks like a
>>> improvement to me.
>>>
>>> Thanks,
>>> Qu
>>>
>>

Reply via email to