18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 48c2ecf20Sopenharmony_ci * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __INODE_DOT_H__ 88c2ecf20Sopenharmony_ci#define __INODE_DOT_H__ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/fs.h> 118c2ecf20Sopenharmony_ci#include <linux/buffer_head.h> 128c2ecf20Sopenharmony_ci#include <linux/mm.h> 138c2ecf20Sopenharmony_ci#include "util.h" 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciextern int gfs2_releasepage(struct page *page, gfp_t gfp_mask); 168c2ecf20Sopenharmony_ciextern int gfs2_internal_read(struct gfs2_inode *ip, 178c2ecf20Sopenharmony_ci char *buf, loff_t *pos, unsigned size); 188c2ecf20Sopenharmony_ciextern void gfs2_set_aops(struct inode *inode); 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_cistatic inline int gfs2_is_stuffed(const struct gfs2_inode *ip) 218c2ecf20Sopenharmony_ci{ 228c2ecf20Sopenharmony_ci return !ip->i_height; 238c2ecf20Sopenharmony_ci} 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistatic inline int gfs2_is_jdata(const struct gfs2_inode *ip) 268c2ecf20Sopenharmony_ci{ 278c2ecf20Sopenharmony_ci return ip->i_diskflags & GFS2_DIF_JDATA; 288c2ecf20Sopenharmony_ci} 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic inline bool gfs2_is_ordered(const struct gfs2_sbd *sdp) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci return sdp->sd_args.ar_data == GFS2_DATA_ORDERED; 338c2ecf20Sopenharmony_ci} 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cistatic inline bool gfs2_is_writeback(const struct gfs2_sbd *sdp) 368c2ecf20Sopenharmony_ci{ 378c2ecf20Sopenharmony_ci return sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK; 388c2ecf20Sopenharmony_ci} 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistatic inline int gfs2_is_dir(const struct gfs2_inode *ip) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci return S_ISDIR(ip->i_inode.i_mode); 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic inline void gfs2_set_inode_blocks(struct inode *inode, u64 blocks) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci inode->i_blocks = blocks << 488c2ecf20Sopenharmony_ci (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT); 498c2ecf20Sopenharmony_ci} 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_cistatic inline u64 gfs2_get_inode_blocks(const struct inode *inode) 528c2ecf20Sopenharmony_ci{ 538c2ecf20Sopenharmony_ci return inode->i_blocks >> 548c2ecf20Sopenharmony_ci (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT); 558c2ecf20Sopenharmony_ci} 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistatic inline void gfs2_add_inode_blocks(struct inode *inode, s64 change) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci change <<= inode->i_blkbits - GFS2_BASIC_BLOCK_SHIFT; 608c2ecf20Sopenharmony_ci gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks >= -change)); 618c2ecf20Sopenharmony_ci inode->i_blocks += change; 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistatic inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr, 658c2ecf20Sopenharmony_ci u64 no_formal_ino) 668c2ecf20Sopenharmony_ci{ 678c2ecf20Sopenharmony_ci return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino; 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline void gfs2_inum_out(const struct gfs2_inode *ip, 718c2ecf20Sopenharmony_ci struct gfs2_dirent *dent) 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); 748c2ecf20Sopenharmony_ci dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr); 758c2ecf20Sopenharmony_ci} 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistatic inline int gfs2_check_internal_file_size(struct inode *inode, 788c2ecf20Sopenharmony_ci u64 minsize, u64 maxsize) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci u64 size = i_size_read(inode); 818c2ecf20Sopenharmony_ci if (size < minsize || size > maxsize) 828c2ecf20Sopenharmony_ci goto err; 838c2ecf20Sopenharmony_ci if (size & (BIT(inode->i_blkbits) - 1)) 848c2ecf20Sopenharmony_ci goto err; 858c2ecf20Sopenharmony_ci return 0; 868c2ecf20Sopenharmony_cierr: 878c2ecf20Sopenharmony_ci gfs2_consist_inode(GFS2_I(inode)); 888c2ecf20Sopenharmony_ci return -EIO; 898c2ecf20Sopenharmony_ci} 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ciextern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type, 928c2ecf20Sopenharmony_ci u64 no_addr, u64 no_formal_ino, 938c2ecf20Sopenharmony_ci unsigned int blktype); 948c2ecf20Sopenharmony_ciextern struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr, 958c2ecf20Sopenharmony_ci u64 no_formal_ino, 968c2ecf20Sopenharmony_ci unsigned int blktype); 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ciextern int gfs2_inode_refresh(struct gfs2_inode *ip); 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciextern struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, 1018c2ecf20Sopenharmony_ci int is_root); 1028c2ecf20Sopenharmony_ciextern int gfs2_permission(struct inode *inode, int mask); 1038c2ecf20Sopenharmony_ciextern int gfs2_setattr_simple(struct inode *inode, struct iattr *attr); 1048c2ecf20Sopenharmony_ciextern struct inode *gfs2_lookup_simple(struct inode *dip, const char *name); 1058c2ecf20Sopenharmony_ciextern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf); 1068c2ecf20Sopenharmony_ciextern int gfs2_open_common(struct inode *inode, struct file *file); 1078c2ecf20Sopenharmony_ciextern loff_t gfs2_seek_data(struct file *file, loff_t offset); 1088c2ecf20Sopenharmony_ciextern loff_t gfs2_seek_hole(struct file *file, loff_t offset); 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ciextern const struct inode_operations gfs2_file_iops; 1118c2ecf20Sopenharmony_ciextern const struct inode_operations gfs2_dir_iops; 1128c2ecf20Sopenharmony_ciextern const struct inode_operations gfs2_symlink_iops; 1138c2ecf20Sopenharmony_ciextern const struct file_operations gfs2_file_fops_nolock; 1148c2ecf20Sopenharmony_ciextern const struct file_operations gfs2_dir_fops_nolock; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciextern void gfs2_set_inode_flags(struct inode *inode); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#ifdef CONFIG_GFS2_FS_LOCKING_DLM 1198c2ecf20Sopenharmony_ciextern const struct file_operations gfs2_file_fops; 1208c2ecf20Sopenharmony_ciextern const struct file_operations gfs2_dir_fops; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistatic inline int gfs2_localflocks(const struct gfs2_sbd *sdp) 1238c2ecf20Sopenharmony_ci{ 1248c2ecf20Sopenharmony_ci return sdp->sd_args.ar_localflocks; 1258c2ecf20Sopenharmony_ci} 1268c2ecf20Sopenharmony_ci#else /* Single node only */ 1278c2ecf20Sopenharmony_ci#define gfs2_file_fops gfs2_file_fops_nolock 1288c2ecf20Sopenharmony_ci#define gfs2_dir_fops gfs2_dir_fops_nolock 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cistatic inline int gfs2_localflocks(const struct gfs2_sbd *sdp) 1318c2ecf20Sopenharmony_ci{ 1328c2ecf20Sopenharmony_ci return 1; 1338c2ecf20Sopenharmony_ci} 1348c2ecf20Sopenharmony_ci#endif /* CONFIG_GFS2_FS_LOCKING_DLM */ 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci#endif /* __INODE_DOT_H__ */ 1378c2ecf20Sopenharmony_ci 138