From: Shan Hai <shan.hai@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH RFC 2/8] xfs: introduce extents to local conversion helper
Date: Fri, 6 Jul 2018 11:12:23 +0800 [thread overview]
Message-ID: <1530846750-6686-3-git-send-email-shan.hai@oracle.com> (raw)
In-Reply-To: <1530846750-6686-1-git-send-email-shan.hai@oracle.com>
Delete the extents from xfs inode, copy the data into the data fork,
convert the inode from extents to local format and specify log the
core and data fork of the inode.
Signed-off-by: Shan Hai <shan.hai@oracle.com>
---
fs/xfs/libxfs/xfs_bmap.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++-
fs/xfs/libxfs/xfs_bmap.h | 4 ++++
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 7205268b30bc..bea6dc254a7d 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2000-2006 Silicon Graphics, Inc.
+ * Copyright (c) 2018 Oracle.
* All Rights Reserved.
*/
#include "xfs.h"
@@ -213,7 +214,7 @@ xfs_default_attroffset(
* attribute fork from local to extent format - we reset it where
* possible to make space available for inline data fork extents.
*/
-STATIC void
+void
xfs_bmap_forkoff_reset(
xfs_inode_t *ip,
int whichfork)
@@ -5141,6 +5142,63 @@ xfs_bmap_del_extent_real(
}
/*
+ * Convert an inode from extents to the local format.
+ * Free all the extents of the inode and reset it to the local
+ * format. Copy the contents of the inode's blocks to the inode's
+ * literal area.
+ */
+int
+xfs_bmap_extents_to_local(
+ xfs_trans_t *tp,
+ xfs_inode_t *ip,
+ struct xfs_defer_ops *dfops,
+ int *logflagsp,
+ int whichfork,
+ struct page *page)
+{
+ xfs_ifork_t *ifp = XFS_IFORK_PTR(ip, whichfork);
+ xfs_fileoff_t isize = i_size_read(VFS_I(ip));
+ struct xfs_bmbt_irec got, del;
+ struct xfs_iext_cursor icur;
+ int error = 0;
+ int tmp_logflags;
+ char *kaddr = NULL;
+
+ ASSERT(whichfork != XFS_COW_FORK);
+ ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS);
+
+ if (xfs_iext_count(ifp) == 0)
+ goto init_local_fork;
+
+ for_each_xfs_iext(ifp, &icur, &got) {
+ del = got;
+ if (isnullstartblock(got.br_startblock)) {
+ error = xfs_bmap_del_extent_delay(ip,
+ whichfork, &icur, &got, &del);
+ if (error)
+ goto out;
+ } else {
+ error = xfs_bmap_del_extent_real(ip, tp, &icur, dfops,
+ NULL, &del, &tmp_logflags, whichfork, 0);
+ if (error)
+ goto out;
+ *logflagsp |= tmp_logflags;
+ }
+ }
+init_local_fork:
+ kaddr = kmap_atomic(page);
+ xfs_init_local_fork(ip, whichfork, kaddr, isize);
+ kunmap_atomic(kaddr);
+ ip->i_d.di_format = XFS_DINODE_FMT_LOCAL;
+ XFS_IFORK_NEXT_SET(ip, whichfork, 0);
+ ip->i_d.di_size = isize;
+ *logflagsp |= (XFS_ILOG_DDATA | XFS_ILOG_CORE);
+out:
+ return error;
+}
+
+
+/*
* Unmap (remove) blocks from a file.
* If nexts is nonzero then the number of extents to remove is limited to
* that value. If not all extents in the block range can be removed then
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 9b49ddf99c41..22cd2642f1cd 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -271,6 +271,10 @@ int xfs_bmap_map_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
struct xfs_inode *ip, struct xfs_bmbt_irec *imap);
int xfs_bmap_unmap_extent(struct xfs_mount *mp, struct xfs_defer_ops *dfops,
struct xfs_inode *ip, struct xfs_bmbt_irec *imap);
+int xfs_bmap_extents_to_local(struct xfs_trans *tp, struct xfs_inode *ip,
+ struct xfs_defer_ops *dfops, int *flags, int whichfork,
+ struct page *page);
+void xfs_bmap_forkoff_reset(struct xfs_inode *ip, int whichfork);
static inline int xfs_bmap_fork_to_state(int whichfork)
{
--
2.11.0
next prev parent reply other threads:[~2018-07-06 3:12 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 ` Shan Hai [this message]
2018-07-06 3:45 ` [PATCH RFC 2/8] xfs: introduce extents to local conversion helper 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
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=1530846750-6686-3-git-send-email-shan.hai@oracle.com \
--to=shan.hai@oracle.com \
--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 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).