From patchwork Thu Mar 16 16:12:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9628839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B071D60244 for ; Thu, 16 Mar 2017 16:14:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A15F52841E for ; Thu, 16 Mar 2017 16:14:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95E402856B; Thu, 16 Mar 2017 16:14:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FD122841E for ; Thu, 16 Mar 2017 16:14:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753316AbdCPQOP (ORCPT ); Thu, 16 Mar 2017 12:14:15 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:34248 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752357AbdCPQOO (ORCPT ); Thu, 16 Mar 2017 12:14:14 -0400 Received: by mail-pf0-f194.google.com with SMTP id o126so6267628pfb.1; Thu, 16 Mar 2017 09:14:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1IpvTYJPGwKNL4SC19S7m+ka03jHwQWbWgVb0jwqHXw=; b=jDwGWOplgM42GrfMz5fKWGHBVsvP1QNysCKBwo4zLOQodXPfXF6iGGsltvTiJK34Mz oap/rOqjBroc4klFZ/OZ3RzpdVi/M/WavkEIotMdw9AZt5gAMvEyR3T6bCI37lmPvdq6 XRWcmv++shbSLQjCnCYNVilkfX0iNHLn0apsiG12IbdrjxzJ46DR2xzyinZARsAZB8uu 4KgDLH+rpfuUS77EKW9j+0Gh72lpG4fLMiCxyPQzQWUe505OgmEAPI1+lEBbskIUSA9C CoWrfLHYUTWbyG7LY2DiSzwvsBVcPzodb1olmnzfk4QSsHw1uCh3/+Do0gEW1Tsy/leC zZWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1IpvTYJPGwKNL4SC19S7m+ka03jHwQWbWgVb0jwqHXw=; b=JsH9GdbJsnSuixiWseyr7Qo/dgIA6QgZjOuQ2fnPFkygBx7enh1v9JmUmCsAyF05RA N9/JtsW7T7b35X6UR5P3KkS8aUhtu+HpyzGJe0dzLkRZ/C4fEVT8qdg9eAiJ0P6zLI0b nDfEbFdFsz/QTKadhRyyfU7MPVFwtm2S/tJkN9HuA6jMS1rkFmyNGnKCAvBbsEjpWn9J OJ/hGbW6ooLHoropgTasa9VZGNMKw8Jp8Fa9GdckBaB+MNEQLnhxlzWrOPZ/czES/Rpy CReeflAg9KjEyhEEQl69tRtdNbjEdQhXcnTStuJovM3s5fbDSsDR3NTEyFa/4cEeEwhB 7B6g== X-Gm-Message-State: AFeK/H037GjrLKsUoKNCZNd6UYgDte2JHDHDCTF2acgr8yk8S3XrLPYIvG3zik2UGcJ/4w== X-Received: by 10.99.42.78 with SMTP id q75mr10890878pgq.144.1489680852687; Thu, 16 Mar 2017 09:14:12 -0700 (PDT) Received: from localhost ([103.192.224.52]) by smtp.gmail.com with ESMTPSA id y6sm11614518pgc.1.2017.03.16.09.14.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Mar 2017 09:14:11 -0700 (PDT) From: Ming Lei To: Shaohua Li , Jens Axboe , linux-raid@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig Cc: Ming Lei Subject: [PATCH v3 01/14] md: raid1/raid10: don't handle failure of bio_add_page() Date: Fri, 17 Mar 2017 00:12:22 +0800 Message-Id: <20170316161235.27110-2-tom.leiming@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170316161235.27110-1-tom.leiming@gmail.com> References: <20170316161235.27110-1-tom.leiming@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP All bio_add_page() is for adding one page into resync bio, which is big enough to hold RESYNC_PAGES pages, and the current bio_add_page() doesn't check queue limit any more, so it won't fail at all. Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig --- drivers/md/raid1.c | 21 ++++++--------------- drivers/md/raid10.c | 41 ++++++++++------------------------------- 2 files changed, 16 insertions(+), 46 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index fbc2d7851b49..4a0b2ad5025e 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2917,21 +2917,12 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, bio = r1_bio->bios[i]; if (bio->bi_end_io) { page = bio->bi_io_vec[bio->bi_vcnt].bv_page; - if (bio_add_page(bio, page, len, 0) == 0) { - /* stop here */ - bio->bi_io_vec[bio->bi_vcnt].bv_page = page; - while (i > 0) { - i--; - bio = r1_bio->bios[i]; - if (bio->bi_end_io==NULL) - continue; - /* remove last page from this bio */ - bio->bi_vcnt--; - bio->bi_iter.bi_size -= len; - bio_clear_flag(bio, BIO_SEG_VALID); - } - goto bio_full; - } + + /* + * won't fail because the vec table is big + * enough to hold all these pages + */ + bio_add_page(bio, page, len, 0); } } nr_sectors += len>>9; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 0536658c9d40..b4a56a488668 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3437,27 +3437,16 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr, if (len == 0) break; for (bio= biolist ; bio ; bio=bio->bi_next) { - struct bio *bio2; page = bio->bi_io_vec[bio->bi_vcnt].bv_page; - if (bio_add_page(bio, page, len, 0)) - continue; - - /* stop here */ - bio->bi_io_vec[bio->bi_vcnt].bv_page = page; - for (bio2 = biolist; - bio2 && bio2 != bio; - bio2 = bio2->bi_next) { - /* remove last page from this bio */ - bio2->bi_vcnt--; - bio2->bi_iter.bi_size -= len; - bio_clear_flag(bio2, BIO_SEG_VALID); - } - goto bio_full; + /* + * won't fail because the vec table is big enough + * to hold all these pages + */ + bio_add_page(bio, page, len, 0); } nr_sectors += len>>9; sector_nr += len>>9; } while (biolist->bi_vcnt < RESYNC_PAGES); - bio_full: r10_bio->sectors = nr_sectors; while (biolist) { @@ -4530,25 +4519,15 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, if (len > PAGE_SIZE) len = PAGE_SIZE; for (bio = blist; bio ; bio = bio->bi_next) { - struct bio *bio2; - if (bio_add_page(bio, page, len, 0)) - continue; - - /* Didn't fit, must stop */ - for (bio2 = blist; - bio2 && bio2 != bio; - bio2 = bio2->bi_next) { - /* Remove last page from this bio */ - bio2->bi_vcnt--; - bio2->bi_iter.bi_size -= len; - bio_clear_flag(bio2, BIO_SEG_VALID); - } - goto bio_full; + /* + * won't fail because the vec table is big enough + * to hold all these pages + */ + bio_add_page(bio, page, len, 0); } sector_nr += len >> 9; nr_sectors += len >> 9; } -bio_full: rcu_read_unlock(); r10_bio->sectors = nr_sectors;