0001
0002
0003
0004
0005
0006
0007 #ifndef __INODE_DOT_H__
0008 #define __INODE_DOT_H__
0009
0010 #include <linux/fs.h>
0011 #include <linux/buffer_head.h>
0012 #include <linux/mm.h>
0013 #include "util.h"
0014
0015 bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask);
0016 extern int gfs2_internal_read(struct gfs2_inode *ip,
0017 char *buf, loff_t *pos, unsigned size);
0018 extern void gfs2_set_aops(struct inode *inode);
0019
0020 static inline int gfs2_is_stuffed(const struct gfs2_inode *ip)
0021 {
0022 return !ip->i_height;
0023 }
0024
0025 static inline int gfs2_is_jdata(const struct gfs2_inode *ip)
0026 {
0027 return ip->i_diskflags & GFS2_DIF_JDATA;
0028 }
0029
0030 static inline bool gfs2_is_ordered(const struct gfs2_sbd *sdp)
0031 {
0032 return sdp->sd_args.ar_data == GFS2_DATA_ORDERED;
0033 }
0034
0035 static inline bool gfs2_is_writeback(const struct gfs2_sbd *sdp)
0036 {
0037 return sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK;
0038 }
0039
0040 static inline int gfs2_is_dir(const struct gfs2_inode *ip)
0041 {
0042 return S_ISDIR(ip->i_inode.i_mode);
0043 }
0044
0045 static inline void gfs2_set_inode_blocks(struct inode *inode, u64 blocks)
0046 {
0047 inode->i_blocks = blocks <<
0048 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
0049 }
0050
0051 static inline u64 gfs2_get_inode_blocks(const struct inode *inode)
0052 {
0053 return inode->i_blocks >>
0054 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
0055 }
0056
0057 static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change)
0058 {
0059 change <<= inode->i_blkbits - GFS2_BASIC_BLOCK_SHIFT;
0060 gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks >= -change));
0061 inode->i_blocks += change;
0062 }
0063
0064 static inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr,
0065 u64 no_formal_ino)
0066 {
0067 return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino;
0068 }
0069
0070 static inline void gfs2_inum_out(const struct gfs2_inode *ip,
0071 struct gfs2_dirent *dent)
0072 {
0073 dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
0074 dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr);
0075 }
0076
0077 static inline int gfs2_check_internal_file_size(struct inode *inode,
0078 u64 minsize, u64 maxsize)
0079 {
0080 u64 size = i_size_read(inode);
0081 if (size < minsize || size > maxsize)
0082 goto err;
0083 if (size & (BIT(inode->i_blkbits) - 1))
0084 goto err;
0085 return 0;
0086 err:
0087 gfs2_consist_inode(GFS2_I(inode));
0088 return -EIO;
0089 }
0090
0091 extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
0092 u64 no_addr, u64 no_formal_ino,
0093 unsigned int blktype);
0094 extern struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
0095 u64 no_formal_ino,
0096 unsigned int blktype);
0097
0098 extern int gfs2_inode_refresh(struct gfs2_inode *ip);
0099
0100 extern struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
0101 int is_root);
0102 extern int gfs2_permission(struct user_namespace *mnt_userns,
0103 struct inode *inode, int mask);
0104 extern struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
0105 extern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
0106 extern int gfs2_open_common(struct inode *inode, struct file *file);
0107 extern loff_t gfs2_seek_data(struct file *file, loff_t offset);
0108 extern loff_t gfs2_seek_hole(struct file *file, loff_t offset);
0109
0110 extern const struct file_operations gfs2_file_fops_nolock;
0111 extern const struct file_operations gfs2_dir_fops_nolock;
0112
0113 extern int gfs2_fileattr_get(struct dentry *dentry, struct fileattr *fa);
0114 extern int gfs2_fileattr_set(struct user_namespace *mnt_userns,
0115 struct dentry *dentry, struct fileattr *fa);
0116 extern void gfs2_set_inode_flags(struct inode *inode);
0117
0118 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
0119 extern const struct file_operations gfs2_file_fops;
0120 extern const struct file_operations gfs2_dir_fops;
0121
0122 static inline int gfs2_localflocks(const struct gfs2_sbd *sdp)
0123 {
0124 return sdp->sd_args.ar_localflocks;
0125 }
0126 #else
0127 #define gfs2_file_fops gfs2_file_fops_nolock
0128 #define gfs2_dir_fops gfs2_dir_fops_nolock
0129
0130 static inline int gfs2_localflocks(const struct gfs2_sbd *sdp)
0131 {
0132 return 1;
0133 }
0134 #endif
0135
0136 #endif
0137