Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp67449imu; Wed, 2 Jan 2019 02:25:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ZblV7PQy1JcSW7Olp0CZCtzfSXozSFK01MOPxyMcgD97avZrOy9rZOq4leeBcob3G7kaS X-Received: by 2002:a17:902:e28e:: with SMTP id cf14mr43697973plb.311.1546424717303; Wed, 02 Jan 2019 02:25:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546424717; cv=none; d=google.com; s=arc-20160816; b=ddYMAX3D94RNTHsiClb22ZViw3GC8hO6Vl+MmJ60FAy7Bzz0A9frikTNXe80Rss7Y4 uQhGkAl9TyHt8c1M6zqFitCMZX5MJ/i64ppCf0zE4hnIWO9D7/AxS7u2lQ1cDNgVvgup CGRQ74rxwb5UpLL+FhBrOIFDIwSGc0AQILpc+AyFe2IQP6xQ2wYNHVA/zU/hMCr3uSbV qBsTEfaEZI+Jnsvt1OVjTsJrMDjysvDpy6WpDF59fNcQq176yAjH71hoOTSnJLpWUA4C btaLMqXxWdSKQ1T9TVWp6ZPOwNngqqkuCqEKFNjOEn3UQRwz7ZOyuFMT37XbFEfVg2Wk Q1lA== 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=dHl/vjGlOzuWu1+3kdkp8LYzdAzso7qVMCvCgFiygdY=; b=Q7Ev383GmrEMMchFTFayHnrUHrGOZUzzLww+c3jyuY7FVsurpziCyFgkHHehI8wHcY fSmcUbIZ3/aZtrMVnW8T0bozM/Xq1o3tWdOGktseu1ZbyRubatLpDhyTfa3B9+AWTdqQ CtxSA4J05XLOAo0GO62Q6tesVcQxfSNVhTyaMqewwcE8WDZfbBDqqgOzs283Aj4/BQpV 6fHuQWf3iEA8d4Bqnttgebk3KHV7DKgHb19277hTY4lnwjZ01FsOG2dubt85CbpcgZ95 HuHTRLuWEZP9vFK6A+2pAhnvUq1McYy3yUwHV6lKBPLleETsPssqq1HtuEJECinGvYEb OyKA== 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 x135si51011637pgx.579.2019.01.02.02.25.02; Wed, 02 Jan 2019 02:25:17 -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 S1729054AbfABJIm (ORCPT + 99 others); Wed, 2 Jan 2019 04:08:42 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:53672 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728994AbfABJIm (ORCPT ); Wed, 2 Jan 2019 04:08:42 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 7C99C51D4812F; Wed, 2 Jan 2019 17:08:37 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Wed, 2 Jan 2019 17:08:29 +0800 From: sunqiuyang To: , , CC: Subject: [PATCH 1/2] f2fs-dev: support multi-device direct IO Date: Wed, 2 Jan 2019 17:06:59 +0800 Message-ID: <20190102090659.7974-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 The physical blocks in struct f2fs_map_blocks must be in the same device. Signed-off-by: Qiuyang Sun --- fs/f2fs/data.c | 20 +++++++++++++++++++- fs/f2fs/f2fs.h | 2 -- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index e5cd3fd..7a6369e 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1076,6 +1076,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, struct extent_info ei = {0,0,0}; block_t blkaddr; unsigned int start_pgofs; + int devi; + block_t end_blk; if (!maxblocks) return 0; @@ -1207,8 +1209,15 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, map->m_pblk = blkaddr; map->m_len = 1; + + if (sbi->s_ndevs && blkaddr != NEW_ADDR && + blkaddr != NULL_ADDR) { + devi = f2fs_target_device_index(sbi, blkaddr); + end_blk = FDEV(devi).end_blk; + } } else if ((map->m_pblk != NEW_ADDR && - blkaddr == (map->m_pblk + ofs)) || + blkaddr == (map->m_pblk + ofs) && + (!sbi->s_ndevs || blkaddr <= end_blk)) || (map->m_pblk == NEW_ADDR && blkaddr == NEW_ADDR) || flag == F2FS_GET_BLOCK_PRE_DIO) { ofs++; @@ -1322,6 +1331,8 @@ static int __get_data_block(struct inode *inode, sector_t iblock, { struct f2fs_map_blocks map; int err; + struct f2fs_sb_info *sbi = F2FS_I_SB(inode); + int devi; map.m_lblk = iblock; map.m_len = bh->b_size >> inode->i_blkbits; @@ -1333,6 +1344,13 @@ static int __get_data_block(struct inode *inode, sector_t iblock, err = f2fs_map_blocks(inode, &map, create, flag); if (!err) { map_bh(bh, inode->i_sb, map.m_pblk); + if (sbi->s_ndevs) { + devi = f2fs_target_device_index(sbi, map.m_pblk); + if (devi) { + bh->b_bdev = FDEV(devi).bdev; + bh->b_blocknr -= FDEV(devi).start_blk; + } + } bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags; bh->b_size = (u64)map.m_len << inode->i_blkbits; } diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index eeede26..b311471 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3595,8 +3595,6 @@ static inline bool f2fs_force_buffered_io(struct inode *inode, if (f2fs_post_read_required(inode)) return true; - if (sbi->s_ndevs) - return true; /* * for blkzoned device, fallback direct IO to buffered IO, so * all IOs can be serialized by log-structured write. -- 1.8.3.1