From patchwork Fri Feb 24 15:42:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9590623 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 BC9C16020A for ; Fri, 24 Feb 2017 15:49:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B220B22BF1 for ; Fri, 24 Feb 2017 15:49:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7170286CC; Fri, 24 Feb 2017 15:49:05 +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=unavailable 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 648A122BF1 for ; Fri, 24 Feb 2017 15:49:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751481AbdBXPoJ (ORCPT ); Fri, 24 Feb 2017 10:44:09 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33162 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751291AbdBXPnv (ORCPT ); Fri, 24 Feb 2017 10:43:51 -0500 Received: by mail-pg0-f67.google.com with SMTP id 5so3466946pgj.0; Fri, 24 Feb 2017 07:43:51 -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=13xgk4XQa4pF5xqcr0bLr5udUnZ09M5/BnklglC39DA=; b=iDdRFfdPsua9wY28oPRW4Qelsk8EWGkB5HrpykclwOcc6VZqZddtFgOJD2b/1AoqTz Aj+QLvYrQA6V2NkMEpKWiT8jymAf0Q7qHYqVLurhfmsRH1jmwl6LryqugBEwhxB74s1C NCrOpLEQxafPdCsq1Dg6cFEat7earw/wGtLF+iRPjWiwscHyhvLf94B+wMUAMhaR4fyg 5lo0ADAA6FE537GWpZj1lV8g5y9NW7gXKlevBcaW9nLIUDbwZno8cgN6VdrzhdCGYpKs V8a5202ObnqIpiZ/fmnMKZzK6AHw/j2WM1S6wFPP6RIKzLCiu35bQuIgyvxs9UKx4PMi jh3w== 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=13xgk4XQa4pF5xqcr0bLr5udUnZ09M5/BnklglC39DA=; b=nCK2fKP+6khigqXauGpzvqxO8efnBfbly9UQQYdh+9qDfN0RCAczFzWkCUGfhqLq1h tshkSNjXaPChy6abwR45j/u0WpUftLICoPB2useaVnTKFwYrdmo5dTudGDI9gJ2qktFw nVH+GEC3lPNTtsRnf8r2YLSdY0UNmf578mm0FJiEGhAGGj9qBNosFfg59s6GsfcoVEYX rCPXR8i+otbjQKrbaMRa1USHCCxrrAoZRDB/ZHjSkF0G5AsZnDktyLNKVA07D8qQUtU+ uxpdyljpS/YAcHTiq8zAxcRJmP0yJOJzkyh2VqGm1h6n6kfHm2b+97LlhAXaF/gT285q P1AA== X-Gm-Message-State: AMke39n7h8Ez3bdwHN7IxkQiF8NZuMgR0klgtuYSdAUvaLiN85dTK3hHUq/0Flo9Jw98Pg== X-Received: by 10.99.3.206 with SMTP id 197mr4294068pgd.150.1487951030640; Fri, 24 Feb 2017 07:43:50 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id q64sm15954699pga.0.2017.02.24.07.43.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 07:43:50 -0800 (PST) From: Ming Lei To: Shaohua Li , Jens Axboe , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig Cc: Ming Lei Subject: [PATCH v1 11/14] md: raid10: refactor code of read reshape's .bi_end_io Date: Fri, 24 Feb 2017 23:42:48 +0800 Message-Id: <1487950971-1131-12-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487950971-1131-1-git-send-email-tom.leiming@gmail.com> References: <1487950971-1131-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 reshape read request is a bit special and requires one extra bio which isn't allocated from r10buf_pool. Refactor the .bi_end_io for read reshape, so that we can use raid10's resync page mangement approach easily in the following patches. Signed-off-by: Ming Lei --- drivers/md/raid10.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 227dd6ad7716..c76e08ea4b92 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1907,17 +1907,9 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev) return err; } -static void end_sync_read(struct bio *bio) +static void __end_sync_read(struct r10bio *r10_bio, struct bio *bio, int d) { - struct r10bio *r10_bio = bio->bi_private; struct r10conf *conf = r10_bio->mddev->private; - int d; - - if (bio == r10_bio->master_bio) { - /* this is a reshape read */ - d = r10_bio->read_slot; /* really the read dev */ - } else - d = find_bio_disk(conf, r10_bio, bio, NULL, NULL); if (!bio->bi_error) set_bit(R10BIO_Uptodate, &r10_bio->state); @@ -1941,6 +1933,22 @@ static void end_sync_read(struct bio *bio) } } +static void end_sync_read(struct bio *bio) +{ + struct r10bio *r10_bio = bio->bi_private; + struct r10conf *conf = r10_bio->mddev->private; + int d = find_bio_disk(conf, r10_bio, bio, NULL, NULL); + + __end_sync_read(r10_bio, bio, d); +} + +static void end_reshape_read(struct bio *bio) +{ + struct r10bio *r10_bio = bio->bi_private; + + __end_sync_read(r10_bio, bio, r10_bio->read_slot); +} + static void end_sync_request(struct r10bio *r10_bio) { struct mddev *mddev = r10_bio->mddev; @@ -4474,7 +4482,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, read_bio->bi_iter.bi_sector = (r10_bio->devs[r10_bio->read_slot].addr + rdev->data_offset); read_bio->bi_private = r10_bio; - read_bio->bi_end_io = end_sync_read; + read_bio->bi_end_io = end_reshape_read; bio_set_op_attrs(read_bio, REQ_OP_READ, 0); read_bio->bi_flags &= (~0UL << BIO_RESET_BITS); read_bio->bi_error = 0;