From patchwork Tue Feb 28 15:41:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9596073 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 386FC601D7 for ; Tue, 28 Feb 2017 15:43:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2934F2853A for ; Tue, 28 Feb 2017 15:43:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E2842853D; Tue, 28 Feb 2017 15:43:11 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 B52F62853A for ; Tue, 28 Feb 2017 15:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751768AbdB1PnK (ORCPT ); Tue, 28 Feb 2017 10:43:10 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34459 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbdB1PmU (ORCPT ); Tue, 28 Feb 2017 10:42:20 -0500 Received: by mail-pg0-f68.google.com with SMTP id s67so1990085pgb.1; Tue, 28 Feb 2017 07:42:11 -0800 (PST) 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=GFCOJ+U8l+mvSy/taozNmqSWERF2VFN78iwNuSuEQSE=; b=o0XP9SnZO3SmMWexdtr+57sI2o6v0+IQ45XcnJkGnDtsfb23n8GeQbNru8vSzY0fZN WQB+mybw9nmVMnLLiCYInMNWCkP5fPNnCvetcqSMp34PdpLRXJFzO3rP7kCIu7pxTtqV GQ34lKUWhAzjJFNNhUjo4RpSyjImxcJPJNo6JJumB26G6DP+IVmTU+2XWwA1tqtz2VTE 6GoOVMteCf3Gh5H6H2TFV2RQu2p3So6qDqPWcXzgh84eEW1xmz0NCVTU2QH0IX8rBCX4 gWP3Yvz5bM8CfDcdUcw3Jr2C/eVCOSqU0QJ/r2L9NnTTif5jRMCh88E7wF7pOpUTOnu6 Cn8g== 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=GFCOJ+U8l+mvSy/taozNmqSWERF2VFN78iwNuSuEQSE=; b=betvfjdEVKWWzG7Pc5GRku7Cfr6jTOnwqBGvxrCG3277yw0nETcnVkhigxxR/tNIJk iyMhtP47KB55k8T9CGkFXuyMiAyRmZdeLkHU6mb0u8c5zmdrJVpBGLI6W85z4hQkY6Fo 4tCbNMBr9OexId5Nf+J0Jm67yzjLbOQmsgd6jqYutgw8CmKEAXy4Py5MgHCK9V5UdLeE pr7QM9995rqJzgoG6AccQjVyg1Tf3uLNExS1SUemjOI1owmavfB+haVyBYX7ATzFr6/N iGxbTWutdmNSdHaSn7i+SmYnEjnJ5UolDSN28CCY0S+3qcWbYF/GgYLdI+eGS6CZSKO+ 5j+w== X-Gm-Message-State: AMke39nHdbo1LLLF7FdXr/WScBV/eh15oXxxtrA3cpDjkikkDX6+Nx6CQpaBWKg74BKTlg== X-Received: by 10.84.197.1 with SMTP id m1mr3889167pld.123.1488296530609; Tue, 28 Feb 2017 07:42:10 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id n8sm5107189pgc.16.2017.02.28.07.42.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Feb 2017 07:42:09 -0800 (PST) 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 v2 02/13] md: raid1/raid10: don't handle failure of bio_add_page() Date: Tue, 28 Feb 2017 23:41:32 +0800 Message-Id: <1488296503-4987-3-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488296503-4987-1-git-send-email-tom.leiming@gmail.com> References: <1488296503-4987-1-git-send-email-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 --- 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 0628c07dd16d..b3021355c7e2 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -2903,21 +2903,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 33f6a535dc1f..ceb3acc793cf 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3435,27 +3435,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) { @@ -4528,25 +4517,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;