All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shiyang Ruan <ruansy.fnst@cn.fujitsu.com>
To: linux-xfs@vger.kernel.org, linux-nvdimm@lists.01.org
Subject: [RFC PATCH 2/4] fs/xfs: iomap: add handle for reflink in fsdax mode
Date: Wed, 17 Apr 2019 09:27:13 +0800	[thread overview]
Message-ID: <20190417012715.8287-3-ruansy.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com>

xfs_file_iomap_begin() is supposed to allocate new extents for reflinked
inode and pass the source blocks' start address to the actor functions.

Signed-off-by: Shiyang Ruan <ruansy.fnst@cn.fujitsu.com>
---
 fs/xfs/xfs_iomap.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 63d323916bba..a45b4e5a1d87 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -255,7 +255,11 @@ xfs_iomap_write_direct(
 	 * left but we need to do unwritten extent conversion.
 	 */
 	if (IS_DAX(VFS_I(ip))) {
-		bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO;
+		if (xfs_is_cow_inode(ip))
+			/* we need to allocate new extents for reflink */
+			bmapi_flags = XFS_BMAPI_COWFORK;
+		else
+			bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO;
 		if (imap->br_state == XFS_EXT_UNWRITTEN) {
 			tflags |= XFS_TRANS_RESERVE;
 			resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0) << 1;
@@ -983,7 +987,8 @@ xfs_file_iomap_begin(
 	 */
 	if (xfs_is_cow_inode(ip)) {
 		struct xfs_bmbt_irec	cmap;
-		bool			directio = (flags & IOMAP_DIRECT);
+		bool			convert = (flags & IOMAP_DIRECT)
+							|| IS_DAX(inode);
 
 		/* if zeroing doesn't need COW allocation, then we are done. */
 		if ((flags & IOMAP_ZERO) &&
@@ -993,10 +998,16 @@ xfs_file_iomap_begin(
 		/* may drop and re-acquire the ilock */
 		cmap = imap;
 		error = xfs_reflink_allocate_cow(ip, &cmap, &shared, &lockmode,
-				directio);
+				convert);
 		if (error)
 			goto out_unlock;
 
+		if (shared && IS_DAX(inode)) {
+			/* get source address and pass it to actor functions */
+			iomap->src_addr = BBTOB(xfs_fsb_to_db(ip,
+							imap.br_startblock));
+		}
+
 		/*
 		 * For buffered writes we need to report the address of the
 		 * previous block (if there was any) so that the higher level
@@ -1005,8 +1016,9 @@ xfs_file_iomap_begin(
 		 * I/O, which must be block aligned, we need to report the
 		 * newly allocated address.  If the data fork has a hole, copy
 		 * the COW fork mapping to avoid allocating to the data fork.
+		 * If is DAX, we need to allocate new address.
 		 */
-		if (directio || imap.br_startblock == HOLESTARTBLOCK)
+		if (convert || imap.br_startblock == HOLESTARTBLOCK)
 			imap = cmap;
 
 		end_fsb = imap.br_startoff + imap.br_blockcount;
-- 
2.17.0



_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

WARNING: multiple messages have this Message-ID (diff)
From: Shiyang Ruan <ruansy.fnst@cn.fujitsu.com>
To: linux-xfs@vger.kernel.org, linux-nvdimm@lists.01.org
Subject: [RFC PATCH 2/4] fs/xfs: iomap: add handle for reflink in fsdax mode
Date: Wed, 17 Apr 2019 09:27:13 +0800	[thread overview]
Message-ID: <20190417012715.8287-3-ruansy.fnst@cn.fujitsu.com> (raw)
In-Reply-To: <20190417012715.8287-1-ruansy.fnst@cn.fujitsu.com>

xfs_file_iomap_begin() is supposed to allocate new extents for reflinked
inode and pass the source blocks' start address to the actor functions.

Signed-off-by: Shiyang Ruan <ruansy.fnst@cn.fujitsu.com>
---
 fs/xfs/xfs_iomap.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 63d323916bba..a45b4e5a1d87 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -255,7 +255,11 @@ xfs_iomap_write_direct(
 	 * left but we need to do unwritten extent conversion.
 	 */
 	if (IS_DAX(VFS_I(ip))) {
-		bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO;
+		if (xfs_is_cow_inode(ip))
+			/* we need to allocate new extents for reflink */
+			bmapi_flags = XFS_BMAPI_COWFORK;
+		else
+			bmapi_flags = XFS_BMAPI_CONVERT | XFS_BMAPI_ZERO;
 		if (imap->br_state == XFS_EXT_UNWRITTEN) {
 			tflags |= XFS_TRANS_RESERVE;
 			resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0) << 1;
@@ -983,7 +987,8 @@ xfs_file_iomap_begin(
 	 */
 	if (xfs_is_cow_inode(ip)) {
 		struct xfs_bmbt_irec	cmap;
-		bool			directio = (flags & IOMAP_DIRECT);
+		bool			convert = (flags & IOMAP_DIRECT)
+							|| IS_DAX(inode);
 
 		/* if zeroing doesn't need COW allocation, then we are done. */
 		if ((flags & IOMAP_ZERO) &&
@@ -993,10 +998,16 @@ xfs_file_iomap_begin(
 		/* may drop and re-acquire the ilock */
 		cmap = imap;
 		error = xfs_reflink_allocate_cow(ip, &cmap, &shared, &lockmode,
-				directio);
+				convert);
 		if (error)
 			goto out_unlock;
 
+		if (shared && IS_DAX(inode)) {
+			/* get source address and pass it to actor functions */
+			iomap->src_addr = BBTOB(xfs_fsb_to_db(ip,
+							imap.br_startblock));
+		}
+
 		/*
 		 * For buffered writes we need to report the address of the
 		 * previous block (if there was any) so that the higher level
@@ -1005,8 +1016,9 @@ xfs_file_iomap_begin(
 		 * I/O, which must be block aligned, we need to report the
 		 * newly allocated address.  If the data fork has a hole, copy
 		 * the COW fork mapping to avoid allocating to the data fork.
+		 * If is DAX, we need to allocate new address.
 		 */
-		if (directio || imap.br_startblock == HOLESTARTBLOCK)
+		if (convert || imap.br_startblock == HOLESTARTBLOCK)
 			imap = cmap;
 
 		end_fsb = imap.br_startoff + imap.br_blockcount;
-- 
2.17.0

  parent reply	other threads:[~2019-04-17  1:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-17  1:27 [RFC PATCH 0/4] xfs: add handle for reflink in dax Shiyang Ruan
2019-04-17  1:27 ` Shiyang Ruan
2019-04-17  1:27 ` [RFC PATCH 1/4] fs/iomap: Introduce src_addr for COW in fsdax mode Shiyang Ruan
2019-04-17  1:27   ` Shiyang Ruan
2019-04-17  1:27 ` Shiyang Ruan [this message]
2019-04-17  1:27   ` [RFC PATCH 2/4] fs/xfs: iomap: add handle for reflink " Shiyang Ruan
2019-04-17  1:27 ` [RFC PATCH 3/4] fs/dax: copy source blocks before writing when COW Shiyang Ruan
2019-04-17  1:27   ` Shiyang Ruan
2019-04-17  1:27 ` [RFC PATCH 4/4] fs/xfs: iomap: update the extent list after a COW Shiyang Ruan
2019-04-17  1:27   ` Shiyang Ruan
     [not found] ` <20190417012715.8287-1-ruansy.fnst-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2019-04-17  1:34   ` [RFC PATCH 0/4] xfs: add handle for reflink in dax Darrick J. Wong
2019-04-17  1:34     ` Darrick J. Wong
2019-04-17  2:06     ` Shiyang Ruan
2019-04-17  2:06       ` Shiyang Ruan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190417012715.8287-3-ruansy.fnst@cn.fujitsu.com \
    --to=ruansy.fnst@cn.fujitsu.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.