From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8DB34C96; Tue, 13 May 2025 06:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747117934; cv=none; b=I2tORv/823uKW9HPY2G//OmV5epP8Dtc7D6vMZloJeXfSDKzabDfLJjfHSqS099qQG45wzIU/FmMaBRvTyN83aHGNTh1C6Y+Wh0+RLLUE5ZCwDt/B6LHIl57abBz4HW5PWo9vEp5gHCRPfUlCH7unnThRJKeAt1/40DxwcvhmbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747117934; c=relaxed/simple; bh=3yotUE15OjKyTjOt8m0Lp6s6pl4db2xWWDxfsxZI3Vw=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=dkkXN41NLgdB/HE/Nf68Nd0ax/l91RCj85FpNMlsw+v6aqLIw08S4u2VnS3FwX8c1O3ckHTTwffduGGNAPZVQR8ASDen4+BLVO8VnXY5bMCJTzEx6jlsDjx5gLfv9iUFyhWscyezoG+AgfzvajGfZKfAgcWqARJrk4aUpk3L5c4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=none smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4ZxRTB1M16z4f3jXL; Tue, 13 May 2025 14:31:42 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id E14291A0359; Tue, 13 May 2025 14:32:06 +0800 (CST) Received: from [10.174.179.143] (unknown [10.174.179.143]) by APP4 (Coremail) with SMTP id gCh0CgCH619k5yJoKIEPMQ--.1039S3; Tue, 13 May 2025 14:32:06 +0800 (CST) Subject: Re: [PATCH RFC md-6.16 v3 15/19] md/md-llbitmap: implement APIs to dirty bits and clear bits To: Yu Kuai , Christoph Hellwig Cc: xni@redhat.com, colyli@kernel.org, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, song@kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-raid@vger.kernel.org, yi.zhang@huawei.com, yangerkun@huawei.com, johnny.chenyi@huawei.com, "yukuai (C)" References: <20250512011927.2809400-1-yukuai1@huaweicloud.com> <20250512011927.2809400-16-yukuai1@huaweicloud.com> <20250512051722.GA1667@lst.de> <0de7efeb-6d4a-2fa5-ed14-e2c0bec0257b@huaweicloud.com> <20250512132641.GC31781@lst.de> <20250512133048.GA32562@lst.de> <69dc5ab6-542d-dcc2-f4ec-0a6a8e49b937@huaweicloud.com> From: Yu Kuai Message-ID: <03f64fc7-4e57-2f32-bffc-04836a9df790@huaweicloud.com> Date: Tue, 13 May 2025 14:32:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <69dc5ab6-542d-dcc2-f4ec-0a6a8e49b937@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:gCh0CgCH619k5yJoKIEPMQ--.1039S3 X-Coremail-Antispam: 1UD129KBjvJXoWxCFW8XFyDGFyUuw4Dtw43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i, 在 2025/05/12 21:36, Yu Kuai 写道: > Hi, > > 在 2025/05/12 21:30, Christoph Hellwig 写道: >> On Mon, May 12, 2025 at 03:26:41PM +0200, Christoph Hellwig wrote: >>>> 1) bitmap bio must be done before this bio can be issued; >>>> 2) bitmap bio will be added to current->bio_list, and wait for this bio >>>> to be issued; >>>> >>>> Do you have a better sulution to this problem? >>> >>> A bew block layer API that bypasses bio_list maybe?  I.e. export >>> __submit_bio with a better name and a kerneldoc detailing the narrow >>> use case. >> >> That won't work as we'd miss a lot of checks, cgroup handling, etc. >> >> But maybe a flag to skip the recursion avoidance? > > I think this can work, and this can also improve performance. I'll look > into this. So, I did a quick test with old internal bitmap and make sure following patch can work. However, for bitmap file case, bio is issued from submit_bh(), I'll have to change buffer_head code and I'm not sure if we want to do that. Thanks, Kuai diff --git a/block/blk-core.c b/block/blk-core.c index b862c66018f2..66ced5769694 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -745,7 +745,7 @@ void submit_bio_noacct_nocheck(struct bio *bio) * to collect a list of requests submited by a ->submit_bio method while * it is active, and then process them after it returned. */ - if (current->bio_list) + if (current->bio_list && !bio_flagged(bio, BIO_STACKED_META)) bio_list_add(¤t->bio_list[0], bio); else if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO)) __submit_bio_noacct_mq(bio); diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 431a3ab2e449..e0cb210a4ea4 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c @@ -1257,35 +1257,6 @@ static void __bitmap_unplug(struct bitmap *bitmap) md_bitmap_file_kick(bitmap); } -struct bitmap_unplug_work { - struct work_struct work; - struct bitmap *bitmap; - struct completion *done; -}; - -static void md_bitmap_unplug_fn(struct work_struct *work) -{ - struct bitmap_unplug_work *unplug_work = - container_of(work, struct bitmap_unplug_work, work); - - __bitmap_unplug(unplug_work->bitmap); - complete(unplug_work->done); -} - -static void bitmap_unplug_async(struct bitmap *bitmap) -{ - DECLARE_COMPLETION_ONSTACK(done); - struct bitmap_unplug_work unplug_work; - - INIT_WORK_ONSTACK(&unplug_work.work, md_bitmap_unplug_fn); - unplug_work.bitmap = bitmap; - unplug_work.done = &done; - - queue_work(md_bitmap_wq, &unplug_work.work); - wait_for_completion(&done); - destroy_work_on_stack(&unplug_work.work); -} - static void bitmap_unplug(struct mddev *mddev, bool sync) { struct bitmap *bitmap = mddev->bitmap; @@ -1293,10 +1264,7 @@ static void bitmap_unplug(struct mddev *mddev, bool sync) if (!bitmap) return; - if (sync) - __bitmap_unplug(bitmap); - else - bitmap_unplug_async(bitmap); + __bitmap_unplug(bitmap); } static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed); diff --git a/drivers/md/md.c b/drivers/md/md.c index 32b997dfe6f4..179eabd6e038 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1050,6 +1050,7 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev, __bio_add_page(bio, page, size, 0); bio->bi_private = rdev; bio->bi_end_io = super_written; + bio_set_flag(bio, BIO_STACKED_META); if (test_bit(MD_FAILFAST_SUPPORTED, &mddev->flags) && test_bit(FailFast, &rdev->flags) && diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index f38425338c3f..88164cdae6aa 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -300,6 +300,7 @@ enum { BIO_REMAPPED, BIO_ZONE_WRITE_PLUGGING, /* bio handled through zone write plugging */ BIO_EMULATES_ZONE_APPEND, /* bio emulates a zone append operation */ + BIO_STACKED_META, /* bio is metadata from stacked device */ BIO_FLAG_LAST }; > > Thanks, > Kuai > >> >> . >> > > . >