1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2018-2024 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <djwong@kernel.org>
8 #include "xfs_shared.h"
9 #include "xfs_format.h"
10 #include "xfs_log_format.h"
11 #include "xfs_trans_resv.h"
14 #include "xfs_mount.h"
15 #include "xfs_defer.h"
16 #include "xfs_trans.h"
17 #include "xfs_metafile.h"
18 #include "xfs_trace.h"
19 #include "xfs_inode.h"
21 /* Set up an inode to be recognized as a metadata directory inode. */
23 xfs_metafile_set_iflag(
26 enum xfs_metafile_type metafile_type
)
28 VFS_I(ip
)->i_mode
&= ~0777;
29 VFS_I(ip
)->i_uid
= GLOBAL_ROOT_UID
;
30 VFS_I(ip
)->i_gid
= GLOBAL_ROOT_GID
;
31 if (S_ISDIR(VFS_I(ip
)->i_mode
))
32 ip
->i_diflags
|= XFS_METADIR_DIFLAGS
;
34 ip
->i_diflags
|= XFS_METAFILE_DIFLAGS
;
35 ip
->i_diflags2
&= ~XFS_DIFLAG2_DAX
;
36 ip
->i_diflags2
|= XFS_DIFLAG2_METADATA
;
37 ip
->i_metatype
= metafile_type
;
38 xfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);
41 /* Clear the metadata directory inode flag. */
43 xfs_metafile_clear_iflag(
47 ASSERT(xfs_is_metadir_inode(ip
));
48 ASSERT(VFS_I(ip
)->i_nlink
== 0);
50 ip
->i_diflags2
&= ~XFS_DIFLAG2_METADATA
;
51 xfs_trans_log_inode(tp
, ip
, XFS_ILOG_CORE
);