blob: bfd2afc0c906a1887db60f631b05cde66f2ed6af [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Steven Whitehouse3a8a9a12006-05-18 15:09:15 -04003 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
9
10#ifndef __INODE_DOT_H__
11#define __INODE_DOT_H__
12
Steven Whitehouse77658aa2008-02-12 14:17:27 +000013#include "util.h"
14
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010015static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
David Teiglandb3b94fa2006-01-16 16:50:04 +000016{
Steven Whitehouseecc30c72008-01-28 10:37:35 +000017 return !ip->i_height;
David Teiglandb3b94fa2006-01-16 16:50:04 +000018}
19
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010020static inline int gfs2_is_jdata(const struct gfs2_inode *ip)
David Teiglandb3b94fa2006-01-16 16:50:04 +000021{
22 return ip->i_di.di_flags & GFS2_DIF_JDATA;
23}
24
Steven Whitehousebf36a712007-10-17 08:35:19 +010025static inline int gfs2_is_writeback(const struct gfs2_inode *ip)
26{
27 const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
28 return (sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK) && !gfs2_is_jdata(ip);
29}
30
Steven Whitehouse55610932007-10-17 08:47:38 +010031static inline int gfs2_is_ordered(const struct gfs2_inode *ip)
32{
33 const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
34 return (sdp->sd_args.ar_data == GFS2_DATA_ORDERED) && !gfs2_is_jdata(ip);
35}
36
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010037static inline int gfs2_is_dir(const struct gfs2_inode *ip)
Steven Whitehouse18ec7d52006-02-08 11:50:51 +000038{
Steven Whitehouseb60623c2006-11-01 12:22:46 -050039 return S_ISDIR(ip->i_inode.i_mode);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +000040}
41
Steven Whitehouse77658aa2008-02-12 14:17:27 +000042static inline void gfs2_set_inode_blocks(struct inode *inode, u64 blocks)
Steven Whitehouse9e2dbda2006-11-08 15:45:46 -050043{
Steven Whitehouse77658aa2008-02-12 14:17:27 +000044 inode->i_blocks = blocks <<
Steven Whitehouse9e2dbda2006-11-08 15:45:46 -050045 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
46}
47
Steven Whitehouse77658aa2008-02-12 14:17:27 +000048static inline u64 gfs2_get_inode_blocks(const struct inode *inode)
49{
50 return inode->i_blocks >>
51 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
52}
53
54static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change)
55{
56 gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks > -change));
57 change *= (GFS2_SB(inode)->sd_sb.sb_bsize/GFS2_BASIC_BLOCK);
58 inode->i_blocks += change;
59}
60
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010061static inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr,
62 u64 no_formal_ino)
63{
64 return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino;
65}
66
Steven Whitehousebb8d8a62007-06-01 14:11:58 +010067static inline void gfs2_inum_out(const struct gfs2_inode *ip,
68 struct gfs2_dirent *dent)
69{
70 dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
71 dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr);
72}
73
74
Wendy Cheng35dcc522007-06-27 17:07:53 -040075void gfs2_set_iop(struct inode *inode);
Wendy Chengbb9bcf02007-06-27 17:07:08 -040076struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
Benjamin Marzinski7a9f53b2007-09-18 13:33:18 -050077 u64 no_addr, u64 no_formal_ino,
78 int skip_freeing);
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010079struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr);
David Teiglandb3b94fa2006-01-16 16:50:04 +000080
David Teiglandb3b94fa2006-01-16 16:50:04 +000081int gfs2_inode_refresh(struct gfs2_inode *ip);
82
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040083int gfs2_dinode_dealloc(struct gfs2_inode *inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +000084int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
Steven Whitehouse907b9bc2006-09-25 09:26:04 -040085struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
Al Viroa569c712008-07-23 14:42:05 -040086 int is_root);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040087struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
Steven Whitehousee7f14f42006-10-31 21:45:08 -050088 unsigned int mode, dev_t dev);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040089int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
90 struct gfs2_inode *ip);
91int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010092 const struct gfs2_inode *ip);
Miklos Szeredif58ba882008-07-02 21:12:01 +020093int gfs2_permission(struct inode *inode, int mask);
David Teiglandb3b94fa2006-01-16 16:50:04 +000094int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
David Teiglandb3b94fa2006-01-16 16:50:04 +000095int gfs2_glock_nq_atime(struct gfs2_holder *gh);
David Teiglandb3b94fa2006-01-16 16:50:04 +000096int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
Steven Whitehousec7526662006-03-20 12:30:04 -050097struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
Steven Whitehousebb8d8a62007-06-01 14:11:58 +010098void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
99void gfs2_dinode_print(const struct gfs2_inode *ip);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000100
101#endif /* __INODE_DOT_H__ */
102