From patchwork Thu Mar 16 16:12: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: 9628845 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 5CD4B60244 for ; Thu, 16 Mar 2017 16:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D19A283F9 for ; Thu, 16 Mar 2017 16:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41AEE2841E; Thu, 16 Mar 2017 16:14:53 +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 18DE7283F9 for ; Thu, 16 Mar 2017 16:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755158AbdCPQOu (ORCPT ); Thu, 16 Mar 2017 12:14:50 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:34278 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755151AbdCPQOs (ORCPT ); Thu, 16 Mar 2017 12:14:48 -0400 Received: by mail-pg0-f66.google.com with SMTP id b5so6608159pgg.1; Thu, 16 Mar 2017 09:14:47 -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=ZH9xpxRWCwqdhMYNF9mCWqyaFDsB8tCfTrfwQBEoHis=; b=RGAjf86P7Cwjuc8ZNg8cAYqMEpKpp2urkT8BFGJ5WABdXXl3vkt20I+DbVJS0QCVRi ZaPPgHjmguQKKFRwzm8zURNr7xDlDPAGb+XnxVWKDw7HX5V8JZ1VI4EH8U0qGto6iL1l u3Rz8AOfK02q7m8vFne1lC+r60RWPidDqbfrxlIzetoQf7p3uhLPNGXF4u+kq+eawt41 g+EAfH9FBw5EdAtUHn8uYTMXvPNKBvqMkHc6BTWSeP1X5r6P3QD4mAgjqymbQBfSjByj Smtd87305oXAqHLeMM7R9QBiJhIHBA5/2uJl4esPFNvMadZxVZSzkMmtqXCfO54OJv4P gm4Q== 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=ZH9xpxRWCwqdhMYNF9mCWqyaFDsB8tCfTrfwQBEoHis=; b=iel08giv1AH/zNpaK5BjneBptr5OP5rxIF3Ec2yKHavb8HTalBpx4L+ZHtBNnfDasF 04Ow3PDrcHFh9C94nLH0QCMFSToNzj24JC2V/VGF5QJzYnT9pzX4ookdk/OPmZj8iYWT 8Cve0kyo6G2+/RPuSZwmFeYFFylffzXaT0CDwAjpXwO3pozjN8mAdmnzlVCqd7r1+QK0 qjgd5woEpio/iTNe8YoBfqLJT8b1OdVtDI5ZyQdqh4bT3ugH/7vUgVieCJZbdoJjjfa6 CC0cQbnEkKTYHU211fIfYrH2jZmE5Vbba6wIDbiLBu7nbMGRIk0rNhy6M76bAL+zY5EK AzbQ== X-Gm-Message-State: AFeK/H28S+BjQbm6dfBQs6lqKhM1nlrhC82+Keq06lHGyoN4NJ4iCoj0V6TGDpYgHSuKTw== X-Received: by 10.99.149.6 with SMTP id p6mr10702656pgd.122.1489680881684; Thu, 16 Mar 2017 09:14:41 -0700 (PDT) Received: from localhost ([103.192.224.52]) by smtp.gmail.com with ESMTPSA id l29sm1658293pfb.118.2017.03.16.09.14.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 16 Mar 2017 09:14:40 -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 11/14] md: raid10: refactor code of read reshape's .bi_end_io Date: Fri, 17 Mar 2017 00:12:32 +0800 Message-Id: <20170316161235.27110-12-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 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 2b40420299e3..98e53f39b66e 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1909,17 +1909,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); @@ -1943,6 +1935,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; @@ -4466,7 +4474,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;