+ 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
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html