Skip to content

Commit 2f6ebd4

Browse files
author
Chandan Babu R
committed
Merge tag 'inode-refactor-6.11_2024-07-02' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.11-mergeB
xfs: hoist inode operations to libxfs This series hoists inode creation, renaming, and deletion operations to libxfs in anticipation of the metadata inode directory feature, which maintains a directory tree of metadata inodes. This will be necessary for further enhancements to the realtime feature, subvolume support. There aren't supposed to be any functional changes in this intense refactoring -- we just split the functions into pieces that are generic and pieces that are specific to libxfs clients. As a bonus, we can remove various open-coded pieces of mkfs.xfs and xfs_repair when this series gets to xfsprogs. Signed-off-by: Darrick J. Wong <[email protected]> Signed-off-by: Chandan Babu R <[email protected]> * tag 'inode-refactor-6.11_2024-07-02' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux: xfs: don't use the incore struct xfs_sb for offsets into struct xfs_dsb xfs: get rid of trivial rename helpers xfs: move dirent update hooks to xfs_dir2.c xfs: create libxfs helper to rename two directory entries xfs: create libxfs helper to exchange two directory entries xfs: create libxfs helper to remove an existing inode/name from a directory xfs: hoist inode free function to libxfs xfs: create libxfs helper to link an existing inode into a directory xfs: create libxfs helper to link a new inode into a directory xfs: separate the icreate logic around INIT_XATTRS xfs: hoist xfs_{bump,drop}link to libxfs xfs: hoist xfs_iunlink to libxfs xfs: wrap inode creation dqalloc calls xfs: push xfs_icreate_args creation out of xfs_create* xfs: hoist new inode initialization functions to libxfs xfs: split new inode creation into two pieces xfs: use xfs_trans_ichgtime to set times when allocating inode xfs: implement atime updates in xfs_trans_ichgtime xfs: pack icreate initialization parameters into a separate structure xfs: hoist project id get/set functions to libxfs xfs: hoist inode flag conversion functions to libxfs xfs: hoist extent size helpers to libxfs xfs: move inode copy-on-write predicates to xfs_inode.[ch] xfs: use consistent uid/gid when grabbing dquots for inodes xfs: verify buffer, inode, and dquot items every tx commit
2 parents 3ba3ab1 + ac3a027 commit 2f6ebd4

28 files changed

+1957
-1554
lines changed

fs/xfs/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ config XFS_DEBUG
217217

218218
Say N unless you are an XFS developer, or you play one on TV.
219219

220+
config XFS_DEBUG_EXPENSIVE
221+
bool "XFS expensive debugging checks"
222+
depends on XFS_FS && XFS_DEBUG
223+
help
224+
Say Y here to get an XFS build with expensive debugging checks
225+
enabled. These checks may affect performance significantly.
226+
227+
Note that the resulting code will be HUGER and SLOWER, and probably
228+
not useful unless you are debugging a particular problem.
229+
230+
Say N unless you are an XFS developer, or you play one on TV.
231+
220232
config XFS_ASSERT_FATAL
221233
bool "XFS fatal asserts"
222234
default y

fs/xfs/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ xfs-y += $(addprefix libxfs/, \
4040
xfs_iext_tree.o \
4141
xfs_inode_fork.o \
4242
xfs_inode_buf.o \
43+
xfs_inode_util.o \
4344
xfs_log_rlimit.o \
4445
xfs_ag_resv.o \
4546
xfs_parent.o \

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "xfs_health.h"
4040
#include "xfs_bmap_item.h"
4141
#include "xfs_symlink_remote.h"
42+
#include "xfs_inode_util.h"
4243

4344
struct kmem_cache *xfs_bmap_intent_cache;
4445

@@ -6454,3 +6455,45 @@ xfs_bmap_query_all(
64546455

64556456
return xfs_btree_query_all(cur, xfs_bmap_query_range_helper, &query);
64566457
}
6458+
6459+
/* Helper function to extract extent size hint from inode */
6460+
xfs_extlen_t
6461+
xfs_get_extsz_hint(
6462+
struct xfs_inode *ip)
6463+
{
6464+
/*
6465+
* No point in aligning allocations if we need to COW to actually
6466+
* write to them.
6467+
*/
6468+
if (xfs_is_always_cow_inode(ip))
6469+
return 0;
6470+
if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize)
6471+
return ip->i_extsize;
6472+
if (XFS_IS_REALTIME_INODE(ip) &&
6473+
ip->i_mount->m_sb.sb_rextsize > 1)
6474+
return ip->i_mount->m_sb.sb_rextsize;
6475+
return 0;
6476+
}
6477+
6478+
/*
6479+
* Helper function to extract CoW extent size hint from inode.
6480+
* Between the extent size hint and the CoW extent size hint, we
6481+
* return the greater of the two. If the value is zero (automatic),
6482+
* use the default size.
6483+
*/
6484+
xfs_extlen_t
6485+
xfs_get_cowextsz_hint(
6486+
struct xfs_inode *ip)
6487+
{
6488+
xfs_extlen_t a, b;
6489+
6490+
a = 0;
6491+
if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE)
6492+
a = ip->i_cowextsize;
6493+
b = xfs_get_extsz_hint(ip);
6494+
6495+
a = max(a, b);
6496+
if (a == 0)
6497+
return XFS_DEFAULT_COWEXTSZ_HINT;
6498+
return a;
6499+
}

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,4 +296,7 @@ typedef int (*xfs_bmap_query_range_fn)(
296296
int xfs_bmap_query_all(struct xfs_btree_cur *cur, xfs_bmap_query_range_fn fn,
297297
void *priv);
298298

299+
xfs_extlen_t xfs_get_extsz_hint(struct xfs_inode *ip);
300+
xfs_extlen_t xfs_get_cowextsz_hint(struct xfs_inode *ip);
301+
299302
#endif /* __XFS_BMAP_H__ */

0 commit comments

Comments
 (0)