From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10C42C33CA1 for ; Mon, 20 Jan 2020 09:37:48 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B96272073D for ; Mon, 20 Jan 2020 09:37:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.ozlabs.org header.i=@lists.ozlabs.org header.b="LJQ5UTlW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=aol.com header.i=@aol.com header.b="LS7aP323" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B96272073D Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=lists.ozlabs.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 481RRF3yBDzDqgZ for ; Mon, 20 Jan 2020 20:37:45 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.ozlabs.org; s=201707; t=1579513065; bh=7l3xBcxOX/YqHCs+ibOr9NKM0bU9tzQAVvLpmR4Z6OY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LJQ5UTlW8zOBx+HOx6NWMogwBq3W4NXGOgTtWyj5CZpqo41RrGKqCnlOqbYYzyFgK 4c3EHU0xqA53b+5jD0Cv65Z6P2ANsJEzQIWptvLiIipaZhpxZ6cmSjBJo/psZpzEi4 cWjBQmjuug+HVSuYBOpnqLZF7u6WCHs4n2MAkQed3HUeXajtIN/WCGK+OnmGoGGWVE neaPhs+Nxi/JB6mjnNlqngguul88Rd/bjMPmcGvTbN7yUYJDs7UaYupjyCzONk3IY6 sWSYXCnn1xK6/czlBONrN/ITjwkx9/GYzAuLazPqKIIntwaHxN9LVUafhlUM1n1b+X zmPJYHlJbkY8w== Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aol.com (client-ip=98.137.69.84; helo=sonic314-21.consmr.mail.gq1.yahoo.com; envelope-from=hsiangkao@aol.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=aol.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aol.com header.i=@aol.com header.a=rsa-sha256 header.s=a2048 header.b=LS7aP323; dkim-atps=neutral Received: from sonic314-21.consmr.mail.gq1.yahoo.com (sonic314-21.consmr.mail.gq1.yahoo.com [98.137.69.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 481QXt4h58zDqdD for ; Mon, 20 Jan 2020 19:57:32 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1579510648; bh=0owMYed7lR2DbHghd/A0BDOJYE+mtYR+fvCs9yHxrQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject; b=LS7aP323gaVps7fxkD5ZjDJM+xK9eEr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4xG8bQmf3dgQ02zmEVZWQ7YDodg8K0hd_jOAuwoeVcQO1Bb3k4LUOgPViGCtsaePg0F1XCZF GDe2iOfoA.b0dUQDGEZkmCqVrj8Pj8d_6hXBarnWyFuDcs2DypGmppo9FQdWTNDXV9wU6FjrSNMJ aqSv5wcYCzFk97J0AZ2b7H.S5BPpN41b2Q5EJkOU8dAYfkNScTzrbGxUgcJv_0YMqiMAG2uKusFa u4pz0kcRfQUrl9FghqRbUJumlvnn9XZITrn8bxZSk3JRZhzsEh.5eCHO3Twvloh_Mky1RSjRhjFh MgYhmGOXaxAuZ9jVjN_.RPXI.0c3mv1VZHX6402Jzzt3VuQErbA1IQJUl5HOL5EDqsiTpZN4RW7e nzmDNEE0bngJLjkwqeCHBj3mCHLIuRTvNJ4jzNLgPRQMK7UQ2uz0vZ1oarl402sJHRmaOsQvNaWU NF4StMKmrL86lBSJiYK2qKDm7ARyewRHSUJa1baoM4uKKKhT6zejTe.EjfWbXB2Amz6HimrUa_Hy qVJywQLGQYO9p0WLBgH5RJzDWc6GT4H.C0qmASFXdeeT_9EN2WBRotdARBhYUDHYwar736ptdmni sicNNjNzXkoV7UPyYV4XbHdSSlRybVTIr9lT1l0TYwW0ezCDNvwbNmS.EqscX6MRo6Sf6AY3aXHS jn31ZlQ_VFU3ot8T5dHDb2H7xcRM- Received: from sonic.gate.mail.ne1.yahoo.com by sonic314.consmr.mail.gq1.yahoo.com with HTTP; Mon, 20 Jan 2020 08:57:28 +0000 Received: by smtp411.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 108e935cc9711f548eb3f10aaf32bbda; Mon, 20 Jan 2020 08:57:28 +0000 (UTC) To: Chao Yu Subject: [PATCH 2/2] erofs: clean up z_erofs_submit_queue() Date: Mon, 20 Jan 2020 16:57:09 +0800 Message-Id: <20200120085709.10320-2-hsiangkao@aol.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200120085709.10320-1-hsiangkao@aol.com> References: <20200120085709.10320-1-hsiangkao@aol.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Gao Xiang via Linux-erofs Reply-To: Gao Xiang Cc: Miao Xie , linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" From: Gao Xiang A label and extra variables will be eliminated, which is more cleaner. Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 95 ++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 6ee5153801b2..9a84609b6d1b 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -1148,7 +1148,7 @@ static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl, qtail[JQ_BYPASS] = &pcl->next; } -static bool z_erofs_submit_queue(struct super_block *sb, +static void z_erofs_submit_queue(struct super_block *sb, z_erofs_next_pcluster_t owned_head, struct list_head *pagepool, struct z_erofs_decompressqueue *fgq, @@ -1157,19 +1157,12 @@ static bool z_erofs_submit_queue(struct super_block *sb, struct erofs_sb_info *const sbi = EROFS_SB(sb); z_erofs_next_pcluster_t qtail[NR_JOBQUEUES]; struct z_erofs_decompressqueue *q[NR_JOBQUEUES]; - struct bio *bio; void *bi_private; /* since bio will be NULL, no need to initialize last_index */ pgoff_t uninitialized_var(last_index); - bool force_submit = false; - unsigned int nr_bios; + unsigned int nr_bios = 0; + struct bio *bio = NULL; - if (owned_head == Z_EROFS_PCLUSTER_TAIL) - return false; - - force_submit = false; - bio = NULL; - nr_bios = 0; bi_private = jobqueueset_init(sb, q, fgq, force_fg); qtail[JQ_BYPASS] = &q[JQ_BYPASS]->head; qtail[JQ_SUBMIT] = &q[JQ_SUBMIT]->head; @@ -1179,11 +1172,9 @@ static bool z_erofs_submit_queue(struct super_block *sb, do { struct z_erofs_pcluster *pcl; - unsigned int clusterpages; - pgoff_t first_index; - struct page *page; - unsigned int i = 0, bypass = 0; - int err; + pgoff_t cur, end; + unsigned int i = 0; + bool bypass = true; /* no possible 'owned_head' equals the following */ DBG_BUGON(owned_head == Z_EROFS_PCLUSTER_TAIL_CLOSED); @@ -1191,55 +1182,50 @@ static bool z_erofs_submit_queue(struct super_block *sb, pcl = container_of(owned_head, struct z_erofs_pcluster, next); - clusterpages = BIT(pcl->clusterbits); + cur = pcl->obj.index; + end = cur + BIT(pcl->clusterbits); /* close the main owned chain at first */ owned_head = cmpxchg(&pcl->next, Z_EROFS_PCLUSTER_TAIL, Z_EROFS_PCLUSTER_TAIL_CLOSED); - first_index = pcl->obj.index; - force_submit |= (first_index != last_index + 1); + do { + struct page *page; + int err; -repeat: - page = pickup_page_for_submission(pcl, i, pagepool, - MNGD_MAPPING(sbi), - GFP_NOFS); - if (!page) { - force_submit = true; - ++bypass; - goto skippage; - } + page = pickup_page_for_submission(pcl, i++, pagepool, + MNGD_MAPPING(sbi), + GFP_NOFS); + if (!page) + continue; - if (bio && force_submit) { + if (bio && cur != last_index + 1) { submit_bio_retry: - submit_bio(bio); - bio = NULL; - } - - if (!bio) { - bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); + submit_bio(bio); + bio = NULL; + } - bio->bi_end_io = z_erofs_decompressqueue_endio; - bio_set_dev(bio, sb->s_bdev); - bio->bi_iter.bi_sector = (sector_t)(first_index + i) << - LOG_SECTORS_PER_BLOCK; - bio->bi_private = bi_private; - bio->bi_opf = REQ_OP_READ; + if (!bio) { + bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); - ++nr_bios; - } + bio->bi_end_io = z_erofs_decompressqueue_endio; + bio_set_dev(bio, sb->s_bdev); + bio->bi_iter.bi_sector = (sector_t)cur << + LOG_SECTORS_PER_BLOCK; + bio->bi_private = bi_private; + bio->bi_opf = REQ_OP_READ; + ++nr_bios; + } - err = bio_add_page(bio, page, PAGE_SIZE, 0); - if (err < PAGE_SIZE) - goto submit_bio_retry; + err = bio_add_page(bio, page, PAGE_SIZE, 0); + if (err < PAGE_SIZE) + goto submit_bio_retry; - force_submit = false; - last_index = first_index + i; -skippage: - if (++i < clusterpages) - goto repeat; + last_index = cur; + bypass = false; + } while (++cur < end); - if (bypass < clusterpages) + if (!bypass) qtail[JQ_SUBMIT] = &pcl->next; else move_to_bypass_jobqueue(pcl, qtail, owned_head); @@ -1254,10 +1240,9 @@ static bool z_erofs_submit_queue(struct super_block *sb, */ if (!force_fg && !nr_bios) { kvfree(q[JQ_SUBMIT]); - return true; + return; } z_erofs_decompress_kickoff(q[JQ_SUBMIT], *force_fg, nr_bios); - return true; } static void z_erofs_runqueue(struct super_block *sb, @@ -1266,9 +1251,9 @@ static void z_erofs_runqueue(struct super_block *sb, { struct z_erofs_decompressqueue io[NR_JOBQUEUES]; - if (!z_erofs_submit_queue(sb, clt->owned_head, - pagepool, io, &force_fg)) + if (clt->owned_head == Z_EROFS_PCLUSTER_TAIL) return; + z_erofs_submit_queue(sb, clt->owned_head, pagepool, io, &force_fg); /* handle bypass queue (no i/o pclusters) immediately */ z_erofs_decompress_queue(&io[JQ_BYPASS], pagepool); -- 2.20.1