From patchwork Tue Apr 5 12:07:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8750961 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C848B9F36E for ; Tue, 5 Apr 2016 12:11:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0C7F20117 for ; Tue, 5 Apr 2016 12:11:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C16E2012B for ; Tue, 5 Apr 2016 12:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758109AbcDEMIM (ORCPT ); Tue, 5 Apr 2016 08:08:12 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34845 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755133AbcDEMIJ (ORCPT ); Tue, 5 Apr 2016 08:08:09 -0400 Received: by mail-pf0-f196.google.com with SMTP id r187so1187614pfr.2; Tue, 05 Apr 2016 05:08:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PcoiDhXblNFtBNeyjbC0UvRqoDNKUD4YA72djBiGT4U=; b=GFw7AoZ9X2pGQlJRQ6gOrhwFhLNKTvZ804GGHmCizwaslXITmSfB4lfnlRftjAS163 OyBFv6f2eUCS8EL6AaWD8vFQ0OW3mqdutkQpfYyhu0IqjLdXFQQx/oY0X0itPw/JckHD MO0t3Are8c1C+4AVS5M+2d+Fjmg3xKPTLaq4t+qBbe4xGz0XsThO1TA0dEUtDBaSORfB ZF7db/10jmrPTa91gagoNf9qNK9szTrzNdvcO5Rv0fLyjxMKzW/hQ9darJ3EVms8bpCa LvUQIWbaLakgi1Q/h1aQAp0x9VKTTVGrzUAZzTxxkp/BzGIEKrbdwwgINMZFb6D64pve Uehg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PcoiDhXblNFtBNeyjbC0UvRqoDNKUD4YA72djBiGT4U=; b=iSoSaLMXhaDYejIOA7Tq28fK2lvoRZtlEFb4/Z+vYGVXJysddJMjY/6zAReSFrcf1Z u8KxEssQoGvzOjpQZC7KBmfMUdlV44wWe619yd0OsaPrVUQTQdj9O72JIvCZJMXTcEPx yfV5LxpN4rRiMX598Aaxpt/+sKJWLBoXja8jfjNzwq0RAsepebXg3G+H25eLr02qv4pW lUxrtm1uImsjYowgxLrVPtOUPPs/F77xRQjXVFFjSqrYZH4Y2nOhiR/OnDh8zChA1cm3 A9o202Oqndr+XqoCQxH4Qg0t6BiipUQV68w6gAdMygV7wcJ62YOTjvLDZE389sWFagzC P4Ig== X-Gm-Message-State: AD7BkJJB0bwCJxqas+gFnNex6S/SfJi9jjTxEfHiZ4klUhfUCRfjDVsId9dRnQDqF8ctpg== X-Received: by 10.98.72.83 with SMTP id v80mr29084211pfa.113.1459858088799; Tue, 05 Apr 2016 05:08:08 -0700 (PDT) Received: from localhost (56.34.213.162.lcy-01.canonistack.canonical.com. [162.213.34.56]) by smtp.gmail.com with ESMTPSA id z2sm32673917pfa.90.2016.04.05.05.08.01 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 05 Apr 2016 05:08:08 -0700 (PDT) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Boaz Harrosh , Ming Lei , Kent Overstreet , Shaohua Li , 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 16/27] bcache: super: use bio_get_base_vec Date: Tue, 5 Apr 2016 20:07:31 +0800 Message-Id: <1459858062-21075-2-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459858062-21075-1-git-send-email-tom.leiming@gmail.com> References: <1459858062-21075-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-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ming Lei --- drivers/md/bcache/super.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 3f649c9..56ad797 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -208,7 +208,12 @@ static void write_bdev_super_endio(struct bio *bio) static void __write_super(struct cache_sb *sb, struct bio *bio) { - struct cache_sb *out = page_address(bio->bi_io_vec[0].bv_page); + /* + * For accessing page pointed to by the 1st bvec, it + * works too after multipage bvecs. + */ + struct bio_vec *bvec = bio_get_base_vec(bio); + struct cache_sb *out = page_address(bvec->bv_page); unsigned i; bio->bi_iter.bi_sector = SB_SECTOR; @@ -1145,6 +1150,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page, char name[BDEVNAME_SIZE]; const char *err = "cannot allocate memory"; struct cache_set *c; + struct bio_vec *bvec; memcpy(&dc->sb, sb, sizeof(struct cache_sb)); dc->bdev = bdev; @@ -1152,7 +1158,8 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page, bio_init(&dc->sb_bio); bio_set_vec_table(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1); - dc->sb_bio.bi_io_vec[0].bv_page = sb_page; + bvec = bio_get_base_vec(&dc->sb_bio); + bvec->bv_page = sb_page; get_page(sb_page); if (cached_dev_init(dc, sb->block_size << 9)) @@ -1776,6 +1783,7 @@ void bch_cache_release(struct kobject *kobj) { struct cache *ca = container_of(kobj, struct cache, kobj); unsigned i; + struct bio_vec *bvec = bio_get_base_vec(&ca->sb_bio); if (ca->set) { BUG_ON(ca->set->cache[ca->sb.nr_this_dev] != ca); @@ -1793,7 +1801,7 @@ void bch_cache_release(struct kobject *kobj) free_fifo(&ca->free[i]); if (ca->sb_bio.bi_inline_vecs[0].bv_page) - put_page(ca->sb_bio.bi_io_vec[0].bv_page); + put_page(bvec->bv_page); if (!IS_ERR_OR_NULL(ca->bdev)) blkdev_put(ca->bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL); @@ -1843,6 +1851,7 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page, char name[BDEVNAME_SIZE]; const char *err = NULL; int ret = 0; + struct bio_vec *bvec; memcpy(&ca->sb, sb, sizeof(struct cache_sb)); ca->bdev = bdev; @@ -1850,7 +1859,8 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page, bio_init(&ca->sb_bio); bio_set_vec_table(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1); - ca->sb_bio.bi_io_vec[0].bv_page = sb_page; + bvec = bio_get_base_vec(&ca->sb_bio); + bvec->bv_page = sb_page; get_page(sb_page); if (blk_queue_discard(bdev_get_queue(ca->bdev)))