Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp399272ybx; Tue, 29 Oct 2019 21:15:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxE45vyR2NipOnGKOJxLrwr36qbh9C1lqeE7Ezc3jZbdS2PHkLw2ZXBKdhs6Pqp2+V2gaKy X-Received: by 2002:aa7:d955:: with SMTP id l21mr29603353eds.179.1572408943528; Tue, 29 Oct 2019 21:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572408943; cv=none; d=google.com; s=arc-20160816; b=ZkYe8oVV80ZSFJ0tLXtPhfrQXf3sI2mQtqjs2qSGK+ul7YyXDD1/SXTZwCq25/y0LT igvQZcZmDBa3QjcED7fcJA5mHHpVUNtCVjgsS8h9WEYGakgmkn/fNM6cOKHYam2h7FQ4 1gJY6N/1uCvGIMH6nkeJdLbV/Zzf7MAoSfjxrVDbNfKJVXgi8Xkxe4eKtjE73gdTQd3r pIe+vWkng2mpkti6HcIY9Gv/Y+Ifa5iYyDJZUC0/N4izbEfO1xFTTW8eB0BxlvrQjXnV FWoohqq4L3t7/skxnahlWkRUMQaEDpWN4U/m9zkRSWNBYzOclJK5jEAOP9a05IPN+TF/ X5Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=tTbvbyhe8hWI7wJHj8CT8w9158uloEDPA1tdGAAOBMY=; b=HzQPeOAwQmwcSGsrxiYVVmjUtaaRkawp8gm1s1K2MZ+TCpJH0aTDgDfVBqD20YkuTh n9v+OIhG4lZFtexOGSFUEMPQJqnEWDVFLFvnNupF5TkW/RJ7NZDVKT6brdu0FN6xJAwp CWT12Lh8PQSyGYbD0EkUKQxVnKZlkXn6XBQOPnXgPTi7Y2IrZipj5APglM1TCxlqR88x E6SFBqjHoe+GyJYUk/ySuR9+KfGdffkeJBC/oVam5cFbnZHliwdG6MW6/hmDww4WPC1Q BsFEWpBpTeWrfFnAe8hNgL/rfDuLU37/OwYEHjNjYEH/l8l5WYYg/9JBtTcDdiCo66FE /GfQ== 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 p4si470907ejo.21.2019.10.29.21.15.20; Tue, 29 Oct 2019 21:15:43 -0700 (PDT) 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 S1727416AbfJ3EOb (ORCPT + 99 others); Wed, 30 Oct 2019 00:14:31 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:4010 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727344AbfJ3EOa (ORCPT ); Wed, 30 Oct 2019 00:14:30 -0400 X-IronPort-AV: E=Sophos;i="5.68,245,1569254400"; d="scan'208";a="77665121" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Oct 2019 12:14:26 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id E68F04B6EC86; Wed, 30 Oct 2019 12:06:26 +0800 (CST) Received: from localhost.localdomain (10.167.225.140) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 30 Oct 2019 12:14:34 +0800 From: Shiyang Ruan To: , , , , , CC: , , , , , Goldwyn Rodrigues Subject: [RFC PATCH v2 5/7] dax: memcpy before zeroing range Date: Wed, 30 Oct 2019 12:13:56 +0800 Message-ID: <20191030041358.14450-6-ruansy.fnst@cn.fujitsu.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20191030041358.14450-1-ruansy.fnst@cn.fujitsu.com> References: <20191030041358.14450-1-ruansy.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.167.225.140] X-yoursite-MailScanner-ID: E68F04B6EC86.A6A86 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: ruansy.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Goldwyn Rodrigues However, this needed more iomap fields, so it was easier to pass iomap and compute inside the function rather than passing a log of arguments. Note, there is subtle difference between iomap_sector and dax_iomap_sector(). Can we replace dax_iomap_sector with iomap_sector()? It would need pos & PAGE_MASK though or else bdev_dax_pgoff() return -EINVAL. Signed-off-by: Goldwyn Rodrigues --- fs/dax.c | 21 ++++++++++++++++----- fs/iomap/buffered-io.c | 8 ++++---- include/linux/dax.h | 12 ++++++------ 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index a4f90f3faddb..eab6bb256205 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1117,11 +1117,16 @@ static int dax_copy_edges(loff_t pos, loff_t length, struct iomap *srcmap, return ret; } -int __dax_zero_page_range(struct block_device *bdev, - struct dax_device *dax_dev, sector_t sector, - unsigned int offset, unsigned int size) +int __dax_zero_page_range(struct iomap *iomap, struct iomap *srcmap, loff_t pos, + unsigned int offset, unsigned int size) { - if (dax_range_is_aligned(bdev, offset, size)) { + sector_t sector = dax_iomap_sector(iomap, pos & PAGE_MASK); + struct block_device *bdev = iomap->bdev; + struct dax_device *dax_dev = iomap->dax_dev; + int ret = 0; + + if (iomap == srcmap && + dax_range_is_aligned(bdev, offset, size)) { sector_t start_sector = sector + (offset >> 9); return blkdev_issue_zeroout(bdev, start_sector, @@ -1141,11 +1146,17 @@ int __dax_zero_page_range(struct block_device *bdev, dax_read_unlock(id); return rc; } + if (iomap != srcmap) { + ret = dax_copy_edges(pos, size, srcmap, kaddr, false); + if (ret) + goto out_unlock; + } memset(kaddr + offset, 0, size); dax_flush(dax_dev, kaddr + offset, size); +out_unlock: dax_read_unlock(id); } - return 0; + return ret; } EXPORT_SYMBOL_GPL(__dax_zero_page_range); diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index c62e807956b6..3fa79389e4d0 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -960,10 +960,9 @@ static int iomap_zero(struct inode *inode, loff_t pos, unsigned offset, } static int iomap_dax_zero(loff_t pos, unsigned offset, unsigned bytes, - struct iomap *iomap) + struct iomap *iomap, struct iomap *srcmap) { - return __dax_zero_page_range(iomap->bdev, iomap->dax_dev, - iomap_sector(iomap, pos & PAGE_MASK), offset, bytes); + return __dax_zero_page_range(iomap, srcmap, pos, offset, bytes); } static loff_t @@ -985,7 +984,8 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count, bytes = min_t(loff_t, PAGE_SIZE - offset, count); if (IS_DAX(inode)) - status = iomap_dax_zero(pos, offset, bytes, iomap); + status = iomap_dax_zero(pos, offset, bytes, iomap, + srcmap); else status = iomap_zero(inode, pos, offset, bytes, iomap, srcmap); diff --git a/include/linux/dax.h b/include/linux/dax.h index 4533bfb99683..7adf3b9e1061 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -12,6 +12,7 @@ typedef unsigned long dax_entry_t; +struct iomap; struct iomap_ops; struct dax_device; struct dax_operations { @@ -226,13 +227,12 @@ int dax_file_range_compare(struct inode *src, loff_t srcoff, const struct iomap_ops *ops); #ifdef CONFIG_FS_DAX -int __dax_zero_page_range(struct block_device *bdev, - struct dax_device *dax_dev, sector_t sector, - unsigned int offset, unsigned int length); +int __dax_zero_page_range(struct iomap *iomap, struct iomap *srcmap, loff_t pos, + unsigned int offset, unsigned int size); #else -static inline int __dax_zero_page_range(struct block_device *bdev, - struct dax_device *dax_dev, sector_t sector, - unsigned int offset, unsigned int length) +static inline int __dax_zero_page_range(struct iomap *iomap, + struct iomap *srcmap, loff_t pos, + unsigned int offset, unsigned int size) { return -ENXIO; } -- 2.23.0