• C
    bcache: remove incremental dirty sector counting for bch_sectors_dirty_init() · 1d53d3dd
    Coly Li 提交于
    mainline inclusion
    from v5.19-rc1
    commit 80db4e47
    category: bugfix
    bugzilla: https://gitee.com/openeuler/kernel/issues/I59A5L?from=project-issue
    CVE: N/A
    
    ----------------------------------------
    
    After making bch_sectors_dirty_init() being multithreaded, the existing
    incremental dirty sector counting in bch_root_node_dirty_init() doesn't
    release btree occupation after iterating 500000 (INIT_KEYS_EACH_TIME)
    bkeys. Because a read lock is added on btree root node to prevent the
    btree to be split during the dirty sectors counting, other I/O requester
    has no chance to gain the write lock even restart bcache_btree().
    
    That is to say, the incremental dirty sectors counting is incompatible
    to the multhreaded bch_sectors_dirty_init(). We have to choose one and
    drop another one.
    
    In my testing, with 512 bytes random writes, I generate 1.2T dirty data
    and a btree with 400K nodes. With single thread and incremental dirty
    sectors counting, it takes 30+ minites to register the backing device.
    And with multithreaded dirty sectors counting, the backing device
    registration can be accomplished within 2 minutes.
    
    The 30+ minutes V.S. 2- minutes difference makes me decide to keep
    multithreaded bch_sectors_dirty_init() and drop the incremental dirty
    sectors counting. This is what this patch does.
    
    But INIT_KEYS_EACH_TIME is kept, in sectors_dirty_init_fn() the CPU
    will be released by cond_resched() after every INIT_KEYS_EACH_TIME keys
    iterated. This is to avoid the watchdog reports a bogus soft lockup
    warning.
    
    Fixes: b144e45f ("bcache: make bch_sectors_dirty_init() to be multithreaded")
    Signed-off-by: NColy Li <colyli@suse.de>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220524102336.10684-4-colyli@suse.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
    Reviewed-by: NJason Yan <yanaijie@huawei.com>
    Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
    1d53d3dd
writeback.c 27.1 KB