blob: c30be2b66580f9740cfa07f65abc1b45c2ad8181 [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 Whitehouseb2760582008-10-14 16:05:55 +010013#include <linux/fs.h>
Steven Whitehouse77658aa2008-02-12 14:17:27 +000014#include "util.h"
15
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010016static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
David Teiglandb3b94fa2006-01-16 16:50:04 +000017{
Steven Whitehouseecc30c72008-01-28 10:37:35 +000018 return !ip->i_height;
David Teiglandb3b94fa2006-01-16 16:50:04 +000019}
20
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010021static inline int gfs2_is_jdata(const struct gfs2_inode *ip)
David Teiglandb3b94fa2006-01-16 16:50:04 +000022{
Steven Whitehouse383f01f2008-11-04 10:05:22 +000023 return ip->i_diskflags & GFS2_DIF_JDATA;
David Teiglandb3b94fa2006-01-16 16:50:04 +000024}
25
Steven Whitehousebf36a712007-10-17 08:35:19 +010026static inline int gfs2_is_writeback(const struct gfs2_inode *ip)
27{
28 const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
29 return (sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK) && !gfs2_is_jdata(ip);
30}
31
Steven Whitehouse55610932007-10-17 08:47:38 +010032static inline int gfs2_is_ordered(const struct gfs2_inode *ip)
33{
34 const struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
35 return (sdp->sd_args.ar_data == GFS2_DATA_ORDERED) && !gfs2_is_jdata(ip);
36}
37
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010038static inline int gfs2_is_dir(const struct gfs2_inode *ip)
Steven Whitehouse18ec7d52006-02-08 11:50:51 +000039{
Steven Whitehouseb60623c2006-11-01 12:22:46 -050040 return S_ISDIR(ip->i_inode.i_mode);
Steven Whitehouse18ec7d52006-02-08 11:50:51 +000041}
42
Steven Whitehouse77658aa2008-02-12 14:17:27 +000043static inline void gfs2_set_inode_blocks(struct inode *inode, u64 blocks)
Steven Whitehouse9e2dbda2006-11-08 15:45:46 -050044{
Steven Whitehouse77658aa2008-02-12 14:17:27 +000045 inode->i_blocks = blocks <<
Steven Whitehouse9e2dbda2006-11-08 15:45:46 -050046 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
47}
48
Steven Whitehouse77658aa2008-02-12 14:17:27 +000049static inline u64 gfs2_get_inode_blocks(const struct inode *inode)
50{
51 return inode->i_blocks >>
52 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
53}
54
55static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change)
56{
57 gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks > -change));
58 change *= (GFS2_SB(inode)->sd_sb.sb_bsize/GFS2_BASIC_BLOCK);
59 inode->i_blocks += change;
60}
61
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010062static inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr,
63 u64 no_formal_ino)
64{
65 return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino;
66}
67
Steven Whitehousebb8d8a62007-06-01 14:11:58 +010068static inline void gfs2_inum_out(const struct gfs2_inode *ip,
69 struct gfs2_dirent *dent)
70{
71 dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
72 dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr);
73}
74
75
Wendy Cheng35dcc522007-06-27 17:07:53 -040076void gfs2_set_iop(struct inode *inode);
Wendy Chengbb9bcf02007-06-27 17:07:08 -040077struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
Benjamin Marzinski7a9f53b2007-09-18 13:33:18 -050078 u64 no_addr, u64 no_formal_ino,
79 int skip_freeing);
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010080struct inode *gfs2_ilookup(struct super_block *sb, u64 no_addr);
David Teiglandb3b94fa2006-01-16 16:50:04 +000081
David Teiglandb3b94fa2006-01-16 16:50:04 +000082int gfs2_inode_refresh(struct gfs2_inode *ip);
83
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040084int gfs2_dinode_dealloc(struct gfs2_inode *inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +000085int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
Steven Whitehouse907b9bc2006-09-25 09:26:04 -040086struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
Al Viroa569c712008-07-23 14:42:05 -040087 int is_root);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040088struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
Steven Whitehousee7f14f42006-10-31 21:45:08 -050089 unsigned int mode, dev_t dev);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040090int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
91 struct gfs2_inode *ip);
92int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
Steven Whitehousedbb7cae2007-05-15 15:37:50 +010093 const struct gfs2_inode *ip);
Miklos Szeredif58ba882008-07-02 21:12:01 +020094int gfs2_permission(struct inode *inode, int mask);
David Teiglandb3b94fa2006-01-16 16:50:04 +000095int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
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
Steven Whitehouseb2760582008-10-14 16:05:55 +0100101extern const struct inode_operations gfs2_file_iops;
102extern const struct inode_operations gfs2_dir_iops;
103extern const struct inode_operations gfs2_symlink_iops;
Christoph Hellwig10d21982009-04-07 19:42:17 +0200104extern const struct file_operations gfs2_file_fops_nolock;
105extern const struct file_operations gfs2_dir_fops_nolock;
Steven Whitehouseb2760582008-10-14 16:05:55 +0100106
107extern void gfs2_set_inode_flags(struct inode *inode);
Steven Whitehousef057f6c2009-01-12 10:43:39 +0000108
109#ifdef CONFIG_GFS2_FS_LOCKING_DLM
Christoph Hellwig10d21982009-04-07 19:42:17 +0200110extern const struct file_operations gfs2_file_fops;
111extern const struct file_operations gfs2_dir_fops;
112
Steven Whitehousef057f6c2009-01-12 10:43:39 +0000113static inline int gfs2_localflocks(const struct gfs2_sbd *sdp)
114{
115 return sdp->sd_args.ar_localflocks;
116}
117#else /* Single node only */
Christoph Hellwig10d21982009-04-07 19:42:17 +0200118#define gfs2_file_fops gfs2_file_fops_nolock
119#define gfs2_dir_fops gfs2_dir_fops_nolock
120
Steven Whitehousef057f6c2009-01-12 10:43:39 +0000121static inline int gfs2_localflocks(const struct gfs2_sbd *sdp)
122{
123 return 1;
124}
125#endif /* CONFIG_GFS2_FS_LOCKING_DLM */
Steven Whitehouseb2760582008-10-14 16:05:55 +0100126
David Teiglandb3b94fa2006-01-16 16:50:04 +0000127#endif /* __INODE_DOT_H__ */
128