linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Shan Hai <shan.hai@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH RFC 3/8] xfs: convert inode from extents to local format
Date: Thu, 5 Jul 2018 20:47:37 -0700	[thread overview]
Message-ID: <20180706034737.GR32415@magnolia> (raw)
In-Reply-To: <1530846750-6686-4-git-send-email-shan.hai@oracle.com>

On Fri, Jul 06, 2018 at 11:12:24AM +0800, Shan Hai wrote:
> Introduce a function to convert an inode from extents to local
> format. The conversion happens at writeback time, this avoids
> interfering with the delayed allocation and page cache vs
> xfs_buf operations, the will be inlined data is directly got
> from the page which was read and modified by the iomap write actor.
> 
> Signed-off-by: Shan Hai <shan.hai@oracle.com>
> ---
>  fs/xfs/xfs_aops.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
> 
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index 8eb3ba3d4d00..ac5a7695f363 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -9,6 +9,7 @@
>  #include "xfs_log_format.h"
>  #include "xfs_trans_resv.h"
>  #include "xfs_mount.h"
> +#include "xfs_defer.h"
>  #include "xfs_inode.h"
>  #include "xfs_trans.h"
>  #include "xfs_inode_item.h"
> @@ -887,6 +888,55 @@ xfs_map_cow(
>  	return 0;
>  }
>  
> +static int
> +xfs_inode_extents_to_local(
> +	xfs_inode_t		*ip,
> +	int			whichfork,
> +	struct page		*page)
> +{
> +	struct xfs_mount	*mp = ip->i_mount;
> +	struct xfs_trans	*tp;
> +	struct xfs_defer_ops	dfops;
> +	xfs_fsblock_t		first_block;
> +	int			logflags;
> +	int			error = 0;
> +
> +	if (i_size_read(VFS_I(ip)) > XFS_IFORK_DSIZE(ip))
> +		return 0;

If it's too big to fit in local format, then isn't this an error?

--D

> +	error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
> +	if (error)
> +		return error;
> +
> +	xfs_ilock(ip, XFS_ILOCK_EXCL);
> +	xfs_trans_ijoin(tp, ip, 0);
> +
> +	xfs_defer_init(&dfops, &first_block);
> +
> +	logflags = 0;
> +	error = xfs_bmap_extents_to_local(tp, ip, &dfops, &logflags,
> +			XFS_DATA_FORK, page);
> +	if (error)
> +		goto trans_cancel;
> +
> +	xfs_trans_log_inode(tp, ip, logflags);
> +	error = xfs_defer_finish(&tp, &dfops);
> +	if (error)
> +		goto trans_cancel;
> +	error = xfs_trans_commit(tp);
> +	if (error)
> +		goto error0;
> +	xfs_iunlock(ip, XFS_ILOCK_EXCL);
> +
> +	return 0;
> +
> +trans_cancel:
> +	xfs_defer_cancel(&dfops);
> +	xfs_trans_cancel(tp);
> +error0:
> +	xfs_iunlock(ip, XFS_ILOCK_EXCL);
> +	return error;
> +}
>  /*
>   * We implement an immediate ioend submission policy here to avoid needing to
>   * chain multiple ioends and hence nest mempool allocations which can violate
> @@ -920,6 +970,8 @@ xfs_writepage_map(
>  	int			count = 0;
>  	int			uptodate = 1;
>  	unsigned int		new_type;
> +	xfs_inode_t		*ip = XFS_I(inode);
> +	struct xfs_mount	*mp = ip->i_mount;
>  
>  	bh = head = page_buffers(page);
>  	offset = page_offset(page);
> @@ -1044,6 +1096,14 @@ xfs_writepage_map(
>  		end_page_writeback(page);
>  	}
>  
> +	if (!error) {
> +		if (xfs_sb_version_hasinlinedata(&mp->m_sb) &&
> +				i_size_read(inode) <= XFS_IFORK_DSIZE(ip)) {
> +			error = xfs_inode_extents_to_local(ip, XFS_DATA_FORK,
> +								page);
> +		}
> +	}
> +
>  	mapping_set_error(page->mapping, error);
>  	return error;
>  }
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2018-07-06  3:47 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06  3:12 [PATCH RFC 0/8] xfs: introduce inode data inline feature Shan Hai
2018-07-06  3:12 ` [PATCH RFC 1/8] xfs: introduce inline data superblock feature bit Shan Hai
2018-07-06  3:34   ` Darrick J. Wong
2018-07-06  4:06     ` Shan Hai
2018-07-06  3:12 ` [PATCH RFC 2/8] xfs: introduce extents to local conversion helper Shan Hai
2018-07-06  3:45   ` Darrick J. Wong
2018-07-06  4:15     ` Shan Hai
2018-07-08 15:42   ` Christoph Hellwig
2018-07-09  1:58     ` Shan Hai
2018-07-06  3:12 ` [PATCH RFC 3/8] xfs: convert inode from extents to local format Shan Hai
2018-07-06  3:47   ` Darrick J. Wong [this message]
2018-07-06  4:24     ` Shan Hai
2018-07-06  3:12 ` [PATCH RFC 4/8] xfs: implement inline data read write code Shan Hai
2018-07-06  3:33   ` Darrick J. Wong
2018-07-06  4:05     ` Shan Hai
2018-07-08 15:45   ` Christoph Hellwig
2018-07-09  2:08     ` Shan Hai
2018-07-06  3:12 ` [PATCH RFC 5/8] xfs: consider the local format inode in misc operations Shan Hai
2018-07-06  3:40   ` Darrick J. Wong
2018-07-06  4:40     ` Shan Hai
2018-07-08 15:51   ` Christoph Hellwig
2018-07-09  3:06     ` Shan Hai
2018-07-06  3:12 ` [PATCH RFC 6/8] xfs: fix imbalanced locking Shan Hai
2018-07-08 15:53   ` Christoph Hellwig
2018-07-09  3:07     ` Shan Hai
2018-07-06  3:12 ` [PATCH RFC 7/8] xfs: return non-zero blocks for inline data Shan Hai
2018-07-08 15:54   ` Christoph Hellwig
2018-07-11 13:08   ` Carlos Maiolino
2018-07-12  1:03     ` Shan Hai
2018-07-12  1:13       ` Shan Hai
2018-07-12  1:31         ` Darrick J. Wong
2018-07-12  1:46           ` Shan Hai
2018-07-12  9:08             ` Carlos Maiolino
2018-07-12 10:48               ` Shan Hai
2018-07-13 12:39                 ` Carlos Maiolino
2018-07-17 13:57                   ` Christoph Hellwig
2018-07-18 15:03                     ` Carlos Maiolino
2018-07-06  3:12 ` [PATCH RFC 8/8] xfs: skip local format inode for reflinking Shan Hai
2018-07-06  3:26   ` Darrick J. Wong
2018-07-06  3:54     ` Shan Hai
2018-07-08 16:00     ` Christoph Hellwig
2018-07-06  3:12 ` [PATCH RFC 1/1] xfsprogs: add inode inline data support Shan Hai
2018-07-06  3:35   ` Darrick J. Wong
2018-07-06 19:14     ` Eric Sandeen
2018-07-06  3:51 ` [PATCH RFC 0/8] xfs: introduce inode data inline feature Darrick J. Wong
2018-07-06  4:09   ` Shan Hai
2018-07-06  5:42 ` Dave Chinner
2018-07-06  6:39   ` Shan Hai
2018-07-06  7:11     ` Shan Hai
2018-07-08 15:58   ` Christoph Hellwig

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=20180706034737.GR32415@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=shan.hai@oracle.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).