xref: /openbmc/linux/fs/xfs/libxfs/xfs_inode_buf.h (revision 04301bf5)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6 #ifndef	__XFS_INODE_BUF_H__
7 #define	__XFS_INODE_BUF_H__
8 
9 struct xfs_inode;
10 struct xfs_dinode;
11 
12 /*
13  * In memory representation of the XFS inode. This is held in the in-core struct
14  * xfs_inode and represents the current on disk values but the structure is not
15  * in on-disk format.  That is, this structure is always translated to on-disk
16  * format specific structures at the appropriate time.
17  */
18 struct xfs_icdinode {
19 	uint16_t	di_flushiter;	/* incremented on flush */
20 	uint32_t	di_projid;	/* owner's project id */
21 	xfs_fsize_t	di_size;	/* number of bytes in file */
22 	xfs_rfsblock_t	di_nblocks;	/* # of direct & btree blocks used */
23 	xfs_extlen_t	di_extsize;	/* basic/minimum extent size for file */
24 	uint8_t		di_forkoff;	/* attr fork offs, <<3 for 64b align */
25 	uint32_t	di_dmevmask;	/* DMIG event mask */
26 	uint16_t	di_dmstate;	/* DMIG state info */
27 	uint16_t	di_flags;	/* random flags, XFS_DIFLAG_... */
28 
29 	uint64_t	di_flags2;	/* more random flags */
30 	uint32_t	di_cowextsize;	/* basic cow extent size for file */
31 
32 	struct timespec64 di_crtime;	/* time created */
33 };
34 
35 /*
36  * Inode location information.  Stored in the inode and passed to
37  * xfs_imap_to_bp() to get a buffer and dinode for a given inode.
38  */
39 struct xfs_imap {
40 	xfs_daddr_t	im_blkno;	/* starting BB of inode chunk */
41 	unsigned short	im_len;		/* length in BBs of inode chunk */
42 	unsigned short	im_boffset;	/* inode offset in block in bytes */
43 };
44 
45 int	xfs_imap_to_bp(struct xfs_mount *, struct xfs_trans *,
46 		       struct xfs_imap *, struct xfs_dinode **,
47 		       struct xfs_buf **, uint);
48 void	xfs_dinode_calc_crc(struct xfs_mount *, struct xfs_dinode *);
49 void	xfs_inode_to_disk(struct xfs_inode *ip, struct xfs_dinode *to,
50 			  xfs_lsn_t lsn);
51 int	xfs_inode_from_disk(struct xfs_inode *ip, struct xfs_dinode *from);
52 void	xfs_log_dinode_to_disk(struct xfs_log_dinode *from,
53 			       struct xfs_dinode *to);
54 
55 xfs_failaddr_t xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino,
56 			   struct xfs_dinode *dip);
57 xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp,
58 		uint32_t extsize, uint16_t mode, uint16_t flags);
59 xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp,
60 		uint32_t cowextsize, uint16_t mode, uint16_t flags,
61 		uint64_t flags2);
62 
63 #endif	/* __XFS_INODE_BUF_H__ */
64