17336d0e6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2b3b94faaSDavid Teigland /* 3b3b94faaSDavid Teigland * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 43a8a9a10SSteven Whitehouse * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. 5b3b94faaSDavid Teigland */ 6b3b94faaSDavid Teigland 7b3b94faaSDavid Teigland #ifndef __INODE_DOT_H__ 8b3b94faaSDavid Teigland #define __INODE_DOT_H__ 9b3b94faaSDavid Teigland 10b2760583SSteven Whitehouse #include <linux/fs.h> 11b1e71b06SSteven Whitehouse #include <linux/buffer_head.h> 12b1e71b06SSteven Whitehouse #include <linux/mm.h> 1377658aadSSteven Whitehouse #include "util.h" 1477658aadSSteven Whitehouse 15*e45c20d1SMatthew Wilcox (Oracle) bool gfs2_release_folio(struct folio *folio, gfp_t gfp_mask); 16b1e71b06SSteven Whitehouse extern int gfs2_internal_read(struct gfs2_inode *ip, 17b1e71b06SSteven Whitehouse char *buf, loff_t *pos, unsigned size); 18b1e71b06SSteven Whitehouse extern void gfs2_set_aops(struct inode *inode); 19b1e71b06SSteven Whitehouse 20dbb7cae2SSteven Whitehouse static inline int gfs2_is_stuffed(const struct gfs2_inode *ip) 21b3b94faaSDavid Teigland { 22ecc30c79SSteven Whitehouse return !ip->i_height; 23b3b94faaSDavid Teigland } 24b3b94faaSDavid Teigland 25dbb7cae2SSteven Whitehouse static inline int gfs2_is_jdata(const struct gfs2_inode *ip) 26b3b94faaSDavid Teigland { 27383f01fbSSteven Whitehouse return ip->i_diskflags & GFS2_DIF_JDATA; 28b3b94faaSDavid Teigland } 29b3b94faaSDavid Teigland 30977767a7SAndreas Gruenbacher static inline bool gfs2_is_ordered(const struct gfs2_sbd *sdp) 31bf36a713SSteven Whitehouse { 32977767a7SAndreas Gruenbacher return sdp->sd_args.ar_data == GFS2_DATA_ORDERED; 33bf36a713SSteven Whitehouse } 34bf36a713SSteven Whitehouse 35977767a7SAndreas Gruenbacher static inline bool gfs2_is_writeback(const struct gfs2_sbd *sdp) 365561093eSSteven Whitehouse { 37977767a7SAndreas Gruenbacher return sdp->sd_args.ar_data == GFS2_DATA_WRITEBACK; 385561093eSSteven Whitehouse } 395561093eSSteven Whitehouse 40dbb7cae2SSteven Whitehouse static inline int gfs2_is_dir(const struct gfs2_inode *ip) 4118ec7d5cSSteven Whitehouse { 42b60623c2SSteven Whitehouse return S_ISDIR(ip->i_inode.i_mode); 4318ec7d5cSSteven Whitehouse } 4418ec7d5cSSteven Whitehouse 4577658aadSSteven Whitehouse static inline void gfs2_set_inode_blocks(struct inode *inode, u64 blocks) 469e2dbdacSSteven Whitehouse { 4777658aadSSteven Whitehouse inode->i_blocks = blocks << 489e2dbdacSSteven Whitehouse (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT); 499e2dbdacSSteven Whitehouse } 509e2dbdacSSteven Whitehouse 5177658aadSSteven Whitehouse static inline u64 gfs2_get_inode_blocks(const struct inode *inode) 5277658aadSSteven Whitehouse { 5377658aadSSteven Whitehouse return inode->i_blocks >> 5477658aadSSteven Whitehouse (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT); 5577658aadSSteven Whitehouse } 5677658aadSSteven Whitehouse 5777658aadSSteven Whitehouse static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change) 5877658aadSSteven Whitehouse { 597c03e756STim Smith change <<= inode->i_blkbits - GFS2_BASIC_BLOCK_SHIFT; 607c03e756STim Smith gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks >= -change)); 6177658aadSSteven Whitehouse inode->i_blocks += change; 6277658aadSSteven Whitehouse } 6377658aadSSteven Whitehouse 64dbb7cae2SSteven Whitehouse static inline int gfs2_check_inum(const struct gfs2_inode *ip, u64 no_addr, 65dbb7cae2SSteven Whitehouse u64 no_formal_ino) 66dbb7cae2SSteven Whitehouse { 67dbb7cae2SSteven Whitehouse return ip->i_no_addr == no_addr && ip->i_no_formal_ino == no_formal_ino; 68dbb7cae2SSteven Whitehouse } 69dbb7cae2SSteven Whitehouse 70bb8d8a6fSSteven Whitehouse static inline void gfs2_inum_out(const struct gfs2_inode *ip, 71bb8d8a6fSSteven Whitehouse struct gfs2_dirent *dent) 72bb8d8a6fSSteven Whitehouse { 73bb8d8a6fSSteven Whitehouse dent->de_inum.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino); 74bb8d8a6fSSteven Whitehouse dent->de_inum.no_addr = cpu_to_be64(ip->i_no_addr); 75bb8d8a6fSSteven Whitehouse } 76bb8d8a6fSSteven Whitehouse 77a2e0f799SSteven Whitehouse static inline int gfs2_check_internal_file_size(struct inode *inode, 78a2e0f799SSteven Whitehouse u64 minsize, u64 maxsize) 79a2e0f799SSteven Whitehouse { 80a2e0f799SSteven Whitehouse u64 size = i_size_read(inode); 81a2e0f799SSteven Whitehouse if (size < minsize || size > maxsize) 82a2e0f799SSteven Whitehouse goto err; 8347a9a527SFabian Frederick if (size & (BIT(inode->i_blkbits) - 1)) 84a2e0f799SSteven Whitehouse goto err; 85a2e0f799SSteven Whitehouse return 0; 86a2e0f799SSteven Whitehouse err: 87a2e0f799SSteven Whitehouse gfs2_consist_inode(GFS2_I(inode)); 88a2e0f799SSteven Whitehouse return -EIO; 89a2e0f799SSteven Whitehouse } 90bb8d8a6fSSteven Whitehouse 91b1e71b06SSteven Whitehouse extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type, 923ce37b2cSAndreas Gruenbacher u64 no_addr, u64 no_formal_ino, 933ce37b2cSAndreas Gruenbacher unsigned int blktype); 94044b9414SSteven Whitehouse extern struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr, 956bdcadeaSAndreas Gruenbacher u64 no_formal_ino, 96044b9414SSteven Whitehouse unsigned int blktype); 97b3b94faaSDavid Teigland 98b1e71b06SSteven Whitehouse extern int gfs2_inode_refresh(struct gfs2_inode *ip); 99b3b94faaSDavid Teigland 100b1e71b06SSteven Whitehouse extern struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, 101a569c711SAl Viro int is_root); 102549c7297SChristian Brauner extern int gfs2_permission(struct user_namespace *mnt_userns, 103549c7297SChristian Brauner struct inode *inode, int mask); 104b1e71b06SSteven Whitehouse extern struct inode *gfs2_lookup_simple(struct inode *dip, const char *name); 105b1e71b06SSteven Whitehouse extern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf); 1066d4ade98SSteven Whitehouse extern int gfs2_open_common(struct inode *inode, struct file *file); 1073a27411cSAndreas Gruenbacher extern loff_t gfs2_seek_data(struct file *file, loff_t offset); 1083a27411cSAndreas Gruenbacher extern loff_t gfs2_seek_hole(struct file *file, loff_t offset); 109b3b94faaSDavid Teigland 11010d21988SChristoph Hellwig extern const struct file_operations gfs2_file_fops_nolock; 11110d21988SChristoph Hellwig extern const struct file_operations gfs2_dir_fops_nolock; 112b2760583SSteven Whitehouse 11388b631cbSMiklos Szeredi extern int gfs2_fileattr_get(struct dentry *dentry, struct fileattr *fa); 11488b631cbSMiklos Szeredi extern int gfs2_fileattr_set(struct user_namespace *mnt_userns, 11588b631cbSMiklos Szeredi struct dentry *dentry, struct fileattr *fa); 116b2760583SSteven Whitehouse extern void gfs2_set_inode_flags(struct inode *inode); 117b2760583SSteven Whitehouse 118f057f6cdSSteven Whitehouse #ifdef CONFIG_GFS2_FS_LOCKING_DLM 11910d21988SChristoph Hellwig extern const struct file_operations gfs2_file_fops; 12010d21988SChristoph Hellwig extern const struct file_operations gfs2_dir_fops; 12110d21988SChristoph Hellwig 122f057f6cdSSteven Whitehouse static inline int gfs2_localflocks(const struct gfs2_sbd *sdp) 123f057f6cdSSteven Whitehouse { 124f057f6cdSSteven Whitehouse return sdp->sd_args.ar_localflocks; 125f057f6cdSSteven Whitehouse } 126f057f6cdSSteven Whitehouse #else /* Single node only */ 12710d21988SChristoph Hellwig #define gfs2_file_fops gfs2_file_fops_nolock 12810d21988SChristoph Hellwig #define gfs2_dir_fops gfs2_dir_fops_nolock 12910d21988SChristoph Hellwig 130f057f6cdSSteven Whitehouse static inline int gfs2_localflocks(const struct gfs2_sbd *sdp) 131f057f6cdSSteven Whitehouse { 132f057f6cdSSteven Whitehouse return 1; 133f057f6cdSSteven Whitehouse } 134f057f6cdSSteven Whitehouse #endif /* CONFIG_GFS2_FS_LOCKING_DLM */ 135f057f6cdSSteven Whitehouse 136b3b94faaSDavid Teigland #endif /* __INODE_DOT_H__ */ 137b3b94faaSDavid Teigland 138