xref: /linux/fs/gfs2/inode.h (revision a569c711f63995ad80c23918525111e0cdb0bc73)
1b3b94faaSDavid Teigland /*
2b3b94faaSDavid Teigland  * Copyright (C) Sistina Software, Inc.  1997-2003 All rights reserved.
33a8a9a10SSteven Whitehouse  * Copyright (C) 2004-2006 Red Hat, Inc.  All rights reserved.
4b3b94faaSDavid Teigland  *
5b3b94faaSDavid Teigland  * This copyrighted material is made available to anyone wishing to use,
6b3b94faaSDavid Teigland  * modify, copy, or redistribute it subject to the terms and conditions
7e9fc2aa0SSteven Whitehouse  * of the GNU General Public License version 2.
8b3b94faaSDavid Teigland  */
9b3b94faaSDavid Teigland 
10b3b94faaSDavid Teigland #ifndef __INODE_DOT_H__
11b3b94faaSDavid Teigland #define __INODE_DOT_H__
12b3b94faaSDavid Teigland 
1377658aadSSteven Whitehouse #include "util.h"
1477658aadSSteven Whitehouse 
15dbb7cae2SSteven Whitehouse static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
16b3b94faaSDavid Teigland {
17ecc30c79SSteven Whitehouse 	return !ip->i_height;
18b3b94faaSDavid Teigland }
19b3b94faaSDavid Teigland 
20dbb7cae2SSteven Whitehouse static inline int gfs2_is_jdata(const struct gfs2_inode *ip)
21b3b94faaSDavid Teigland {
22b3b94faaSDavid Teigland 	return ip->i_di.di_flags & GFS2_DIF_JDATA;
23b3b94faaSDavid Teigland }
24b3b94faaSDavid Teigland 
25bf36a713SSteven Whitehouse static inline int gfs2_is_writeback(const struct gfs2_inode *ip)
26bf36a713SSteven Whitehouse {
27bf36a713SSteven Whitehouse 	const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
28bf36a713SSteven Whitehouse 	return (sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK) && !gfs2_is_jdata(ip);
29bf36a713SSteven Whitehouse }
30bf36a713SSteven Whitehouse 
315561093eSSteven Whitehouse static inline int gfs2_is_ordered(const struct gfs2_inode *ip)
325561093eSSteven Whitehouse {
335561093eSSteven Whitehouse 	const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
345561093eSSteven Whitehouse 	return (sdp->sd_args.ar_data == GFS2_DATA_ORDERED) && !gfs2_is_jdata(ip);
355561093eSSteven Whitehouse }
365561093eSSteven Whitehouse 
37dbb7cae2SSteven Whitehouse static inline int gfs2_is_dir(const struct gfs2_inode *ip)
3818ec7d5cSSteven Whitehouse {
39b60623c2SSteven Whitehouse 	return S_ISDIR(ip->i_inode.i_mode);
4018ec7d5cSSteven Whitehouse }
4118ec7d5cSSteven Whitehouse 
4277658aadSSteven Whitehouse static inline void gfs2_set_inode_blocks(struct inode *inode, u64 blocks)
439e2dbdacSSteven Whitehouse {
4477658aadSSteven Whitehouse 	inode->i_blocks = blocks <<
459e2dbdacSSteven Whitehouse 		(GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
469e2dbdacSSteven Whitehouse }
479e2dbdacSSteven Whitehouse 
4877658aadSSteven Whitehouse static inline u64 gfs2_get_inode_blocks(const struct inode *inode)
4977658aadSSteven Whitehouse {
5077658aadSSteven Whitehouse 	return inode->i_blocks >>
5177658aadSSteven Whitehouse 		(GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
5277658aadSSteven Whitehouse }
5377658aadSSteven Whitehouse 
5477658aadSSteven Whitehouse static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change)
5577658aadSSteven Whitehouse {
5677658aadSSteven Whitehouse 	gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks > -change));
5777658aadSSteven Whitehouse 	change *= (GFS2_SB(inode)->sd_sb.sb_bsize/GFS2_BASIC_BLOCK);
5877658aadSSteven Whitehouse 	inode->i_blocks += change;
5977658aadSSteven Whitehouse }
6077658aadSSteven Whitehouse 
61dbb7cae2SSteven Whitehouse static inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr,
62dbb7cae2SSteven Whitehouse 				  u64 no_formal_ino)
63dbb7cae2SSteven Whitehouse {
64dbb7cae2SSteven Whitehouse 	return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino;
65dbb7cae2SSteven Whitehouse }
66dbb7cae2SSteven Whitehouse 
67bb8d8a6fSSteven Whitehouse static inline void gfs2_inum_out(const struct gfs2_inode *ip,
68bb8d8a6fSSteven Whitehouse 				 struct gfs2_dirent *dent)
69bb8d8a6fSSteven Whitehouse {
70bb8d8a6fSSteven Whitehouse 	dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
71bb8d8a6fSSteven Whitehouse 	dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr);
72bb8d8a6fSSteven Whitehouse }
73bb8d8a6fSSteven Whitehouse 
74bb8d8a6fSSteven Whitehouse 
7535dcc52eSWendy Cheng void gfs2_set_iop(struct inode *inode);
76bb9bcf06SWendy Cheng struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
777a9f53b3SBenjamin Marzinski 				u64 no_addr, u64 no_formal_ino,
787a9f53b3SBenjamin Marzinski 				int skip_freeing);
79dbb7cae2SSteven Whitehouse struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr);
80b3b94faaSDavid Teigland 
81b3b94faaSDavid Teigland int gfs2_inode_refresh(struct gfs2_inode *ip);
82b3b94faaSDavid Teigland 
83feaa7bbaSSteven Whitehouse int gfs2_dinode_dealloc(struct gfs2_inode *inode);
84b3b94faaSDavid Teigland int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
85feaa7bbaSSteven Whitehouse struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
86*a569c711SAl Viro 			   int is_root);
87feaa7bbaSSteven Whitehouse struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
88e7f14f4dSSteven Whitehouse 			   unsigned int mode, dev_t dev);
89feaa7bbaSSteven Whitehouse int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
90feaa7bbaSSteven Whitehouse 		struct gfs2_inode *ip);
91feaa7bbaSSteven Whitehouse int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
92dbb7cae2SSteven Whitehouse 		   const struct gfs2_inode *ip);
93f58ba889SMiklos Szeredi int gfs2_permission(struct inode *inode, int mask);
94b3b94faaSDavid Teigland int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to);
95b3b94faaSDavid Teigland int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
96b3b94faaSDavid Teigland int gfs2_glock_nq_atime(struct gfs2_holder *gh);
97b3b94faaSDavid Teigland int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
98c752666cSSteven Whitehouse struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
99bb8d8a6fSSteven Whitehouse void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
100bb8d8a6fSSteven Whitehouse void gfs2_dinode_print(const struct gfs2_inode *ip);
101b3b94faaSDavid Teigland 
102b3b94faaSDavid Teigland #endif /* __INODE_DOT_H__ */
103b3b94faaSDavid Teigland 
104