From patchwork Tue Dec 27 15:56:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489423 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 9523262AAD for ; Tue, 27 Dec 2016 16:02:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86986201BC for ; Tue, 27 Dec 2016 16:02:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A24C223B2; Tue, 27 Dec 2016 16:02:32 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 6D497201BC for ; Tue, 27 Dec 2016 16:02:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754160AbcL0QC3 (ORCPT ); Tue, 27 Dec 2016 11:02:29 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34724 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755691AbcL0QB3 (ORCPT ); Tue, 27 Dec 2016 11:01:29 -0500 Received: by mail-pg0-f68.google.com with SMTP id b1so12793732pgc.1; Tue, 27 Dec 2016 08:01:03 -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=VdE6P9145VJWuq73kJTj0d0jCahq4YAZRI3/JLOAJA4=; b=JLc6K78hMczgpSDfx3sxiCkj16i6Vnv/pU9w4IaKOKYJi22yQbGZKdO6JC6IUKr8d4 XRla8e2PHTMyAc77al2nGXfoOZafRIxXLZtOXWSVEZwe1pjhaykpjuatKHhamsGsCbYS 4F60n78s8l1QJ4tP5fnH4miB98ZYtnNStic5zUHa7+XqoRmVHLuidnEyNOsE2Q/aqDtc dTZceVjIzaMiYZU08AZL9G+U25G437v+ySBtOYj0hLrjprSRnA+qBNdPPrH8pP0levNX KAFf9gQ/FE9LULHu+w8OVcaSPnmeEb7pXNIG7Q9g8PTiC0VDuc2Lw2Q7MSI0aBBQUdbi mkjw== 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=VdE6P9145VJWuq73kJTj0d0jCahq4YAZRI3/JLOAJA4=; b=L8qMIZKclReAGKaNtno5BnCJhcVHOqFCUGo5uTTuu9TkAy7udH/b06p8TNixWCjv5p UQ/wLMYAMzSF7wzhFIkC4Pw7qr+LMoUtUZKNW6Rb1w/bBdgyEx0LMO3Wk57T8hNQWEc3 aAAoD2YuRQtNx8wNUCpmjMH6uGDnKgXfbVUg6hHqDvaf0yrPg0+kJ7p9txvii0XqmTds BHrLma7FJVpXK1kOJ67njSsPD0o5rusf3lEcvwX7Y1hCJvFMM93QBhC42JvR6DUk3eAr GL9z0SCG9zYdtWfRPG622R4ATZ4u5Ke+0lgtuvEU0O3mNE8ZDDOrq8E/Mc1zAvTO6rWO tFUw== X-Gm-Message-State: AIkVDXJtEPvTTIIPkSLEiQES0kCcvHRCO0cQ+FwDtun5h1z3PMrAyWI9++Sx9TvB3mlDaw== X-Received: by 10.84.139.67 with SMTP id 61mr66894250plq.65.1482854463029; Tue, 27 Dec 2016 08:01:03 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id e5sm90560042pfd.77.2016.12.27.08.01.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:01:01 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Ming Lei , Kent Overstreet , Shaohua Li , Mike Christie , Guoqing Jiang , linux-bcache@vger.kernel.org (open list:BCACHE (BLOCK LAYER CACHE)), linux-raid@vger.kernel.org (open list:SOFTWARE RAID (Multiple Disks) SUPPORT) Subject: [PATCH v1 23/54] bcache: handle bio_clone() & bvec updating for multipage bvecs Date: Tue, 27 Dec 2016 23:56:12 +0800 Message-Id: <1482854250-13481-24-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482854250-13481-1-git-send-email-tom.leiming@gmail.com> References: <1482854250-13481-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 The incoming bio may be too big to be cloned into one singlepage bvecs bio, so split the bio and check the splitted bio one by one. Signed-off-by: Ming Lei --- drivers/md/bcache/debug.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 48d03e8b3385..18b2d2d138e3 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c @@ -103,7 +103,7 @@ void bch_btree_verify(struct btree *b) up(&b->io_mutex); } -void bch_data_verify(struct cached_dev *dc, struct bio *bio) +static void __bch_data_verify(struct cached_dev *dc, struct bio *bio) { char name[BDEVNAME_SIZE]; struct bio *check; @@ -116,7 +116,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) * in the new cloned bio because each single page need * to assign to each bvec of the new bio. */ - check = bio_clone(bio, GFP_NOIO); + check = bio_clone_sp(bio, GFP_NOIO); if (!check) return; check->bi_opf = REQ_OP_READ; @@ -151,6 +151,26 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio) bio_put(check); } +void bch_data_verify(struct cached_dev *dc, struct bio *bio) +{ + struct request_queue *q = bdev_get_queue(bio->bi_bdev); + struct bio *clone = bio_clone_fast(bio, GFP_NOIO, q->bio_split); + unsigned sectors; + + while (!bio_can_convert_to_sp(clone, §ors)) { + struct bio *split = bio_split(clone, sectors, + GFP_NOIO, q->bio_split); + + __bch_data_verify(dc, split); + bio_put(split); + } + + if (bio_sectors(clone)) + __bch_data_verify(dc, clone); + + bio_put(clone); +} + #endif #ifdef CONFIG_DEBUG_FS