On 11/1/19 3:22 PM, jgq516@xxxxxxxxx wrote:
From: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> Since raid1 had already used bucket based mechanism to reduce the conflict between write IO and resync IO, it is possible to speed up performance for io serialization with refer to the same mechanism. To align with the barrier bucket mechanism, we created arrays (with the same number of BARRIER_BUCKETS_NR) for spinlock, rb tree and waitqueue. Then we can reduce lock competition with multiple spinlocks, boost search performance with multiple rb trees and also reduce thundering herd problem with multiple waitqueues. Of course, we need to deal with below conditions: 1. Handle the failure of memory allocation since more memory are needed. So the two functions (rdev_uninit_serial and rdevs_uninit_serial) are introduced. 2. Free those allocated memory when serialization is disabled. Which means mddev_destroy_serial_pool is also need when backlog is cleared, write is stopped or bitmap is destroyed, so add is_suspend parameter to mddev_destroy_serial_pool to make it fits in all cases. Also no need to export mddev_create_serial_pool since it is only called in md-mod module.
[...]
/* @@ -160,13 +221,17 @@ void mddev_create_serial_pool(struct mddev *mddev, struct md_rdev *rdev,
[...]
noio_flag = memalloc_noio_save(); mddev->serial_info_pool = mempool_create_kmalloc_pool(NR_SERIAL_INFOS, @@ -175,6 +240,7 @@ void mddev_create_serial_pool(struct mddev *mddev, struct md_rdev *rdev, if (!mddev->serial_info_pool) pr_err("can't alloc memory pool for writemostly\n"); mddev->serialize_policy = true; +abort: if (!is_suspend) mddev_resume(mddev); } @@ -186,8 +252,8 @@ EXPORT_SYMBOL_GPL(mddev_create_serial_pool);
Hmm, I forgot to remove the EXPORT_SYMBOL_GPL per the patch header, will update the patch in next version. Thanks, Guoqing