Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp78652imu; Wed, 2 Jan 2019 02:41:41 -0800 (PST) X-Google-Smtp-Source: ALg8bN49C7UdGQpe446EYUTPcK9eqjEfmhewgvOsOXqzfK7PdNqjBYZZ3bVshgbqz0altQ8imxEm X-Received: by 2002:a17:902:bd92:: with SMTP id q18mr43198701pls.167.1546425701620; Wed, 02 Jan 2019 02:41:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546425701; cv=none; d=google.com; s=arc-20160816; b=nNmRCrFiy18iy1sCBCF2kGTwXGpphGMNmx6WTMjo42st7MSo8tV/GhBqBS2/iKWQNh L7Vgn9SOTozXWQSu9oG4re6gA7SjPKgm/fshUUEmJssjgUXuffxdVkiin0O/qX0KrbbD 51zR05SbeTIsz+T7JXy5BYoRR8Yyvyz/y0vOxldKr0qUmxK7tLqnq8krhdhvvqQyVE6d uzfiStnVdGqkZfgt/brXy6hFSpT1d3TUlUccbiQX/RshYhKGlGfxLsUJXhWDJS4+6R8w FbTy3vRHvvzoF6Qz+08OVhE9ged8Z81YdIkAQUpvBHac702X2OE43yqg7SGF8jUhzgHU nxfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=hxH9j4y5iBkY64kOJmlubsa6Zl0z8PdX0T1gbqGOkFQ=; b=fM4X2Kt0SpBw462y8LkifIUI1SsIWngOCvFwo0YbvdWdYTWfE9f1vjI5MFV8ZX0tGU WuHvIIM17ZpwdDGzgARHbJr/2ZT2cKGBC0b6+jMMpP93mSozg0Fq04wewOtiKM288Sbq 2l6chGppAGzi7rU1aE0OjaEWegiVFRgmbfYWUJAPRrj1VbUz2FS2kGkxGDgpAojp4oel KPCD5BUB/L8I+mYoCSUjOz5XT9jHM+rqcTC/woW8NqLSgyZBHetF9bb9TIOwqYZOWIxW WVNohp46xsO+wSgSyC4OaWjbbOFI4XeB/7okkVBnl0bvDj4uSqhdlr9jp8eBNMcEl1UF a9UQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si50376714pgj.199.2019.01.02.02.41.12; Wed, 02 Jan 2019 02:41:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729092AbfABJIw (ORCPT + 99 others); Wed, 2 Jan 2019 04:08:52 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:53731 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729067AbfABJIv (ORCPT ); Wed, 2 Jan 2019 04:08:51 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 816504E0D64F2; Wed, 2 Jan 2019 17:08:47 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.408.0; Wed, 2 Jan 2019 17:08:40 +0800 From: sunqiuyang To: , , CC: Subject: [PATCH 2/2] fs: support direct IO in a multi-device FS Date: Wed, 2 Jan 2019 17:07:18 +0800 Message-ID: <20190102090718.8115-1-sunqiuyang@huawei.com> X-Mailer: git-send-email 2.14.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiuyang Sun Don't use the bdev pointer in struct buffer_head for dio_bio_alloc(), since it may have been changed to another device in the FS in get_more_blocks(). Signed-off-by: Qiuyang Sun --- fs/direct-io.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index 722d17c..6cd6029 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -99,6 +99,7 @@ struct dio_submit { unsigned cur_page_offset; /* Offset into it, in bytes */ unsigned cur_page_len; /* Nr of bytes at cur_page_offset */ sector_t cur_page_block; /* Where it starts */ + struct block_device *cur_page_dev; loff_t cur_page_fs_offset; /* Offset in file */ struct iov_iter *iter; @@ -729,7 +730,7 @@ static int get_more_blocks(struct dio *dio, struct dio_submit *sdio, * There is no bio. Make one now. */ static inline int dio_new_bio(struct dio *dio, struct dio_submit *sdio, - sector_t start_sector, struct buffer_head *map_bh) + sector_t start_sector) { sector_t sector; int ret, nr_pages; @@ -740,7 +741,7 @@ static inline int dio_new_bio(struct dio *dio, struct dio_submit *sdio, sector = start_sector << (sdio->blkbits - 9); nr_pages = min(sdio->pages_in_io, BIO_MAX_PAGES); BUG_ON(nr_pages <= 0); - dio_bio_alloc(dio, sdio, map_bh->b_bdev, sector, nr_pages); + dio_bio_alloc(dio, sdio, sdio->cur_page_dev, sector, nr_pages); sdio->boundary = 0; out: return ret; @@ -785,8 +786,7 @@ static inline int dio_bio_add_page(struct dio_submit *sdio) * The caller of this function is responsible for removing cur_page from the * dio, and for dropping the refcount which came from that presence. */ -static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio, - struct buffer_head *map_bh) +static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio) { int ret = 0; @@ -815,14 +815,14 @@ static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio, } if (sdio->bio == NULL) { - ret = dio_new_bio(dio, sdio, sdio->cur_page_block, map_bh); + ret = dio_new_bio(dio, sdio, sdio->cur_page_block); if (ret) goto out; } if (dio_bio_add_page(sdio) != 0) { dio_bio_submit(dio, sdio); - ret = dio_new_bio(dio, sdio, sdio->cur_page_block, map_bh); + ret = dio_new_bio(dio, sdio, sdio->cur_page_block); if (ret == 0) { ret = dio_bio_add_page(sdio); BUG_ON(ret != 0); @@ -878,7 +878,7 @@ static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio, * If there's a deferred page already there then send it. */ if (sdio->cur_page) { - ret = dio_send_cur_page(dio, sdio, map_bh); + ret = dio_send_cur_page(dio, sdio); put_page(sdio->cur_page); sdio->cur_page = NULL; if (ret) @@ -890,6 +890,7 @@ static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio, sdio->cur_page_offset = offset; sdio->cur_page_len = len; sdio->cur_page_block = blocknr; + sdio->cur_page_dev = map_bh->b_bdev; sdio->cur_page_fs_offset = sdio->block_in_file << sdio->blkbits; out: /* @@ -897,7 +898,7 @@ static inline int dio_send_cur_page(struct dio *dio, struct dio_submit *sdio, * avoid metadata seeks. */ if (sdio->boundary) { - ret = dio_send_cur_page(dio, sdio, map_bh); + ret = dio_send_cur_page(dio, sdio); if (sdio->bio) dio_bio_submit(dio, sdio); put_page(sdio->cur_page); @@ -1348,7 +1349,7 @@ static inline int drop_refcount(struct dio *dio) if (sdio.cur_page) { ssize_t ret2; - ret2 = dio_send_cur_page(dio, &sdio, &map_bh); + ret2 = dio_send_cur_page(dio, &sdio); if (retval == 0) retval = ret2; put_page(sdio.cur_page); -- 1.8.3.1