Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *   Copyright (C) International Business Machines Corp., 2000-2004
0004  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
0005  */
0006 #ifndef _H_JFS_INCORE
0007 #define _H_JFS_INCORE
0008 
0009 #include <linux/mutex.h>
0010 #include <linux/rwsem.h>
0011 #include <linux/slab.h>
0012 #include <linux/bitops.h>
0013 #include <linux/uuid.h>
0014 
0015 #include "jfs_types.h"
0016 #include "jfs_xtree.h"
0017 #include "jfs_dtree.h"
0018 
0019 /*
0020  * JFS magic number
0021  */
0022 #define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
0023 
0024 /*
0025  * JFS-private inode information
0026  */
0027 struct jfs_inode_info {
0028     int fileset;    /* fileset number (always 16)*/
0029     uint    mode2;      /* jfs-specific mode        */
0030     kuid_t  saved_uid;  /* saved for uid mount option */
0031     kgid_t  saved_gid;  /* saved for gid mount option */
0032     pxd_t   ixpxd;      /* inode extent descriptor  */
0033     dxd_t   acl;        /* dxd describing acl   */
0034     dxd_t   ea;     /* dxd describing ea    */
0035     time64_t otime;     /* time created */
0036     uint    next_index; /* next available directory entry index */
0037     int acltype;    /* Type of ACL  */
0038     short   btorder;    /* access order */
0039     short   btindex;    /* btpage entry index*/
0040     struct inode *ipimap;   /* inode map            */
0041     unsigned long cflag;    /* commit flags     */
0042     u64 agstart;    /* agstart of the containing IAG */
0043     u16 bxflag;     /* xflag of pseudo buffer?  */
0044     unchar  pad;
0045     signed char active_ag;  /* ag currently allocating from */
0046     lid_t   blid;       /* lid of pseudo buffer?    */
0047     lid_t   atlhead;    /* anonymous tlock list head    */
0048     lid_t   atltail;    /* anonymous tlock list tail    */
0049     spinlock_t ag_lock; /* protects active_ag       */
0050     struct list_head anon_inode_list; /* inodes having anonymous txns */
0051     /*
0052      * rdwrlock serializes xtree between reads & writes and synchronizes
0053      * changes to special inodes.  It's use would be redundant on
0054      * directories since the i_mutex taken in the VFS is sufficient.
0055      */
0056     struct rw_semaphore rdwrlock;
0057     /*
0058      * commit_mutex serializes transaction processing on an inode.
0059      * It must be taken after beginning a transaction (txBegin), since
0060      * dirty inodes may be committed while a new transaction on the
0061      * inode is blocked in txBegin or TxBeginAnon
0062      */
0063     struct mutex commit_mutex;
0064     /* xattr_sem allows us to access the xattrs without taking i_mutex */
0065     struct rw_semaphore xattr_sem;
0066     lid_t   xtlid;      /* lid of xtree lock on directory */
0067     union {
0068         struct {
0069             xtpage_t _xtroot;   /* 288: xtree root */
0070             struct inomap *_imap;   /* 4: inode map header  */
0071         } file;
0072         struct {
0073             struct dir_table_slot _table[12]; /* 96: dir index */
0074             dtroot_t _dtroot;   /* 288: dtree root */
0075         } dir;
0076         struct {
0077             unchar _unused[16]; /* 16: */
0078             dxd_t _dxd;     /* 16: */
0079             /* _inline may overflow into _inline_ea when needed */
0080             /* _inline_ea may overlay the last part of
0081              * file._xtroot if maxentry = XTROOTINITSLOT
0082              */
0083             union {
0084                 struct {
0085                     /* 128: inline symlink */
0086                     unchar _inline[128];
0087                     /* 128: inline extended attr */
0088                     unchar _inline_ea[128];
0089                 };
0090                 unchar _inline_all[256];
0091             };
0092         } link;
0093     } u;
0094 #ifdef CONFIG_QUOTA
0095     struct dquot *i_dquot[MAXQUOTAS];
0096 #endif
0097     u32 dev;    /* will die when we get wide dev_t */
0098     struct inode    vfs_inode;
0099 };
0100 #define i_xtroot u.file._xtroot
0101 #define i_imap u.file._imap
0102 #define i_dirtable u.dir._table
0103 #define i_dtroot u.dir._dtroot
0104 #define i_inline u.link._inline
0105 #define i_inline_ea u.link._inline_ea
0106 #define i_inline_all u.link._inline_all
0107 
0108 #define IREAD_LOCK(ip, subclass) \
0109     down_read_nested(&JFS_IP(ip)->rdwrlock, subclass)
0110 #define IREAD_UNLOCK(ip)    up_read(&JFS_IP(ip)->rdwrlock)
0111 #define IWRITE_LOCK(ip, subclass) \
0112     down_write_nested(&JFS_IP(ip)->rdwrlock, subclass)
0113 #define IWRITE_UNLOCK(ip)   up_write(&JFS_IP(ip)->rdwrlock)
0114 
0115 /*
0116  * cflag
0117  */
0118 enum cflags {
0119     COMMIT_Nolink,      /* inode committed with zero link count */
0120     COMMIT_Inlineea,    /* commit inode inline EA */
0121     COMMIT_Freewmap,    /* free WMAP at iClose() */
0122     COMMIT_Dirty,       /* Inode is really dirty */
0123     COMMIT_Dirtable,    /* commit changes to di_dirtable */
0124     COMMIT_Stale,       /* data extent is no longer valid */
0125     COMMIT_Synclist,    /* metadata pages on group commit synclist */
0126 };
0127 
0128 /*
0129  * commit_mutex nesting subclasses:
0130  */
0131 enum commit_mutex_class
0132 {
0133     COMMIT_MUTEX_PARENT,
0134     COMMIT_MUTEX_CHILD,
0135     COMMIT_MUTEX_SECOND_PARENT, /* Renaming */
0136     COMMIT_MUTEX_VICTIM     /* Inode being unlinked due to rename */
0137 };
0138 
0139 /*
0140  * rdwrlock subclasses:
0141  * The dmap inode may be locked while a normal inode or the imap inode are
0142  * locked.
0143  */
0144 enum rdwrlock_class
0145 {
0146     RDWRLOCK_NORMAL,
0147     RDWRLOCK_IMAP,
0148     RDWRLOCK_DMAP
0149 };
0150 
0151 #define set_cflag(flag, ip) set_bit(flag, &(JFS_IP(ip)->cflag))
0152 #define clear_cflag(flag, ip)   clear_bit(flag, &(JFS_IP(ip)->cflag))
0153 #define test_cflag(flag, ip)    test_bit(flag, &(JFS_IP(ip)->cflag))
0154 #define test_and_clear_cflag(flag, ip) \
0155     test_and_clear_bit(flag, &(JFS_IP(ip)->cflag))
0156 /*
0157  * JFS-private superblock information.
0158  */
0159 struct jfs_sb_info {
0160     struct super_block *sb;     /* Point back to vfs super block */
0161     unsigned long   mntflag;    /* aggregate attributes */
0162     struct inode    *ipbmap;    /* block map inode      */
0163     struct inode    *ipaimap;   /* aggregate inode map inode    */
0164     struct inode    *ipaimap2;  /* secondary aimap inode    */
0165     struct inode    *ipimap;    /* aggregate inode map inode    */
0166     struct jfs_log  *log;       /* log          */
0167     struct list_head log_list;  /* volumes associated with a journal */
0168     short       bsize;      /* logical block size   */
0169     short       l2bsize;    /* log2 logical block size  */
0170     short       nbperpage;  /* blocks per page      */
0171     short       l2nbperpage;    /* log2 blocks per page */
0172     short       l2niperblk; /* log2 inodes per page */
0173     dev_t       logdev;     /* external log device  */
0174     uint        aggregate;  /* volume identifier in log record */
0175     pxd_t       logpxd;     /* pxd describing log   */
0176     pxd_t       fsckpxd;    /* pxd describing fsck wkspc */
0177     pxd_t       ait2;       /* pxd describing AIT copy  */
0178     uuid_t      uuid;       /* 128-bit uuid for volume  */
0179     uuid_t      loguuid;    /* 128-bit uuid for log */
0180     /*
0181      * commit_state is used for synchronization of the jfs_commit
0182      * threads.  It is protected by LAZY_LOCK().
0183      */
0184     int     commit_state;   /* commit state */
0185     /* Formerly in ipimap */
0186     uint        gengen;     /* inode generation generator*/
0187     uint        inostamp;   /* shows inode belongs to fileset*/
0188 
0189     /* Formerly in ipbmap */
0190     struct bmap *bmap;      /* incore bmap descriptor   */
0191     struct nls_table *nls_tab;  /* current codepage     */
0192     struct inode *direct_inode; /* metadata inode */
0193     uint        state;      /* mount/recovery state */
0194     unsigned long   flag;       /* mount time flags */
0195     uint        p_state;    /* state prior to going no integrity */
0196     kuid_t      uid;        /* uid to override on-disk uid */
0197     kgid_t      gid;        /* gid to override on-disk gid */
0198     uint        umask;      /* umask to override on-disk umask */
0199     uint        minblks_trim;   /* minimum blocks, for online trim */
0200 };
0201 
0202 /* jfs_sb_info commit_state */
0203 #define IN_LAZYCOMMIT 1
0204 
0205 static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
0206 {
0207     return container_of(inode, struct jfs_inode_info, vfs_inode);
0208 }
0209 
0210 static inline int jfs_dirtable_inline(struct inode *inode)
0211 {
0212     return (JFS_IP(inode)->next_index <= (MAX_INLINE_DIRTABLE_ENTRY + 1));
0213 }
0214 
0215 static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb)
0216 {
0217     return sb->s_fs_info;
0218 }
0219 
0220 static inline int isReadOnly(struct inode *inode)
0221 {
0222     if (JFS_SBI(inode->i_sb)->log)
0223         return 0;
0224     return 1;
0225 }
0226 #endif /* _H_JFS_INCORE */