1 /* SPDX-License-Identifier: GPL-2.0-or-later * 1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 2 /* 3 * Copyright (C) International Business Mach 3 * Copyright (C) International Business Machines Corp., 2000-2002 4 */ 4 */ 5 #ifndef _H_JFS_IMAP 5 #ifndef _H_JFS_IMAP 6 #define _H_JFS_IMAP 6 #define _H_JFS_IMAP 7 7 8 #include "jfs_txnmgr.h" 8 #include "jfs_txnmgr.h" 9 9 10 /* 10 /* 11 * jfs_imap.h: disk inode manager 11 * jfs_imap.h: disk inode manager 12 */ 12 */ 13 13 14 #define EXTSPERIAG 128 /* number of d 14 #define EXTSPERIAG 128 /* number of disk inode extent per iag */ 15 #define IMAPBLKNO 0 /* lblkno of d 15 #define IMAPBLKNO 0 /* lblkno of dinomap within inode map */ 16 #define SMAPSZ 4 /* number of w 16 #define SMAPSZ 4 /* number of words per summary map */ 17 #define EXTSPERSUM 32 /* number of e 17 #define EXTSPERSUM 32 /* number of extents per summary map entry */ 18 #define L2EXTSPERSUM 5 /* l2 number o 18 #define L2EXTSPERSUM 5 /* l2 number of extents per summary map */ 19 #define PGSPERIEXT 4 /* number of 4 19 #define PGSPERIEXT 4 /* number of 4K pages per dinode extent */ 20 #define MAXIAGS ((1<<20)-1) /* max 20 #define MAXIAGS ((1<<20)-1) /* maximum number of iags */ 21 #define MAXAG 128 /* maximum num 21 #define MAXAG 128 /* maximum number of allocation groups */ 22 22 23 #define AMAPSIZE 512 /* bytes in th 23 #define AMAPSIZE 512 /* bytes in the IAG allocation maps */ 24 #define SMAPSIZE 16 /* bytes in th 24 #define SMAPSIZE 16 /* bytes in the IAG summary maps */ 25 25 26 /* convert inode number to iag number */ 26 /* convert inode number to iag number */ 27 #define INOTOIAG(ino) ((ino) >> L2INOSPERIAG 27 #define INOTOIAG(ino) ((ino) >> L2INOSPERIAG) 28 28 29 /* convert iag number to logical block number 29 /* convert iag number to logical block number of the iag page */ 30 #define IAGTOLBLK(iagno,l2nbperpg) (((iag 30 #define IAGTOLBLK(iagno,l2nbperpg) (((iagno) + 1) << (l2nbperpg)) 31 31 32 /* get the starting block number of the 4K pag 32 /* get the starting block number of the 4K page of an inode extent 33 * that contains ino. 33 * that contains ino. 34 */ 34 */ 35 #define INOPBLK(pxd,ino,l2nbperpg) (addre 35 #define INOPBLK(pxd,ino,l2nbperpg) (addressPXD((pxd)) + \ 36 ((((ino) & (INOSPEREXT-1)) >> L2INOSPE 36 ((((ino) & (INOSPEREXT-1)) >> L2INOSPERPAGE) << (l2nbperpg))) 37 37 38 /* 38 /* 39 * inode allocation map: 39 * inode allocation map: 40 * 40 * 41 * inode allocation map consists of 41 * inode allocation map consists of 42 * . the inode map control page and 42 * . the inode map control page and 43 * . inode allocation group pages (per 4096 in 43 * . inode allocation group pages (per 4096 inodes) 44 * which are addressed by standard JFS xtree. 44 * which are addressed by standard JFS xtree. 45 */ 45 */ 46 /* 46 /* 47 * inode allocation group page (per 4096 47 * inode allocation group page (per 4096 inodes of an AG) 48 */ 48 */ 49 struct iag { 49 struct iag { 50 __le64 agstart; /* 8: starting 50 __le64 agstart; /* 8: starting block of ag */ 51 __le32 iagnum; /* 4: inode al 51 __le32 iagnum; /* 4: inode allocation group number */ 52 __le32 inofreefwd; /* 4: ag inode 52 __le32 inofreefwd; /* 4: ag inode free list forward */ 53 __le32 inofreeback; /* 4: ag inode 53 __le32 inofreeback; /* 4: ag inode free list back */ 54 __le32 extfreefwd; /* 4: ag inode 54 __le32 extfreefwd; /* 4: ag inode extent free list forward */ 55 __le32 extfreeback; /* 4: ag inode 55 __le32 extfreeback; /* 4: ag inode extent free list back */ 56 __le32 iagfree; /* 4: iag free 56 __le32 iagfree; /* 4: iag free list */ 57 57 58 /* summary map: 1 bit per inode extent 58 /* summary map: 1 bit per inode extent */ 59 __le32 inosmap[SMAPSZ]; /* 16: sum map 59 __le32 inosmap[SMAPSZ]; /* 16: sum map of mapwords w/ free inodes; 60 * note: 60 * note: this indicates free and backed 61 * inodes 61 * inodes, if the extent is not backed the 62 * value 62 * value will be 1. if the extent is 63 * backed 63 * backed but all inodes are being used the 64 * value 64 * value will be 1. if the extent is 65 * backed 65 * backed but at least one of the inodes is 66 * free t 66 * free the value will be 0. 67 */ 67 */ 68 __le32 extsmap[SMAPSZ]; /* 16: sum map 68 __le32 extsmap[SMAPSZ]; /* 16: sum map of mapwords w/ free extents */ 69 __le32 nfreeinos; /* 4: number o 69 __le32 nfreeinos; /* 4: number of free inodes */ 70 __le32 nfreeexts; /* 4: number o 70 __le32 nfreeexts; /* 4: number of free extents */ 71 /* (72) */ 71 /* (72) */ 72 u8 pad[1976]; /* 1976: pad t 72 u8 pad[1976]; /* 1976: pad to 2048 bytes */ 73 /* allocation bit map: 1 bit per inode 73 /* allocation bit map: 1 bit per inode (0 - free, 1 - allocated) */ 74 __le32 wmap[EXTSPERIAG]; /* 512 74 __le32 wmap[EXTSPERIAG]; /* 512: working allocation map */ 75 __le32 pmap[EXTSPERIAG]; /* 512 75 __le32 pmap[EXTSPERIAG]; /* 512: persistent allocation map */ 76 pxd_t inoext[EXTSPERIAG]; /* 102 76 pxd_t inoext[EXTSPERIAG]; /* 1024: inode extent addresses */ 77 }; /* (4096) */ 77 }; /* (4096) */ 78 78 79 /* 79 /* 80 * per AG control information (in inode m 80 * per AG control information (in inode map control page) 81 */ 81 */ 82 struct iagctl_disk { 82 struct iagctl_disk { 83 __le32 inofree; /* 4: free ino 83 __le32 inofree; /* 4: free inode list anchor */ 84 __le32 extfree; /* 4: free ext 84 __le32 extfree; /* 4: free extent list anchor */ 85 __le32 numinos; /* 4: number o 85 __le32 numinos; /* 4: number of backed inodes */ 86 __le32 numfree; /* 4: number o 86 __le32 numfree; /* 4: number of free inodes */ 87 }; /* (16) */ 87 }; /* (16) */ 88 88 89 struct iagctl { 89 struct iagctl { 90 int inofree; /* free inode 90 int inofree; /* free inode list anchor */ 91 int extfree; /* free extent 91 int extfree; /* free extent list anchor */ 92 int numinos; /* number of b 92 int numinos; /* number of backed inodes */ 93 int numfree; /* number of f 93 int numfree; /* number of free inodes */ 94 }; 94 }; 95 95 96 /* 96 /* 97 * per fileset/aggregate inode map contro 97 * per fileset/aggregate inode map control page 98 */ 98 */ 99 struct dinomap_disk { 99 struct dinomap_disk { 100 __le32 in_freeiag; /* 4: free iag 100 __le32 in_freeiag; /* 4: free iag list anchor */ 101 __le32 in_nextiag; /* 4: next fre 101 __le32 in_nextiag; /* 4: next free iag number */ 102 __le32 in_numinos; /* 4: num of b 102 __le32 in_numinos; /* 4: num of backed inodes */ 103 __le32 in_numfree; /* 4: num of f 103 __le32 in_numfree; /* 4: num of free backed inodes */ 104 __le32 in_nbperiext; /* 4: num of b 104 __le32 in_nbperiext; /* 4: num of blocks per inode extent */ 105 __le32 in_l2nbperiext; /* 4: l2 of in 105 __le32 in_l2nbperiext; /* 4: l2 of in_nbperiext */ 106 __le32 in_diskblock; /* 4: for stan 106 __le32 in_diskblock; /* 4: for standalone test driver */ 107 __le32 in_maxag; /* 4: for stan 107 __le32 in_maxag; /* 4: for standalone test driver */ 108 u8 pad[2016]; /* 2016: pad t 108 u8 pad[2016]; /* 2016: pad to 2048 */ 109 struct iagctl_disk in_agctl[MAXAG]; /* 109 struct iagctl_disk in_agctl[MAXAG]; /* 2048: AG control information */ 110 }; /* (4096) */ 110 }; /* (4096) */ 111 111 112 struct dinomap { 112 struct dinomap { 113 int in_freeiag; /* free iag li 113 int in_freeiag; /* free iag list anchor */ 114 int in_nextiag; /* next free i 114 int in_nextiag; /* next free iag number */ 115 int in_numinos; /* num of back 115 int in_numinos; /* num of backed inodes */ 116 int in_numfree; /* num of free 116 int in_numfree; /* num of free backed inodes */ 117 int in_nbperiext; /* num of bloc 117 int in_nbperiext; /* num of blocks per inode extent */ 118 int in_l2nbperiext; /* l2 of in_nb 118 int in_l2nbperiext; /* l2 of in_nbperiext */ 119 int in_diskblock; /* for standal 119 int in_diskblock; /* for standalone test driver */ 120 int in_maxag; /* for standal 120 int in_maxag; /* for standalone test driver */ 121 struct iagctl in_agctl[MAXAG]; /* AG 121 struct iagctl in_agctl[MAXAG]; /* AG control information */ 122 }; 122 }; 123 123 124 /* 124 /* 125 * In-core inode map control page 125 * In-core inode map control page 126 */ 126 */ 127 struct inomap { 127 struct inomap { 128 struct dinomap im_imap; /* 409 128 struct dinomap im_imap; /* 4096: inode allocation control */ 129 struct inode *im_ipimap; /* 4: 129 struct inode *im_ipimap; /* 4: ptr to inode for imap */ 130 struct mutex im_freelock; /* 4: 130 struct mutex im_freelock; /* 4: iag free list lock */ 131 struct mutex im_aglock[MAXAG]; /* 512 131 struct mutex im_aglock[MAXAG]; /* 512: per AG locks */ 132 u32 *im_DBGdimap; 132 u32 *im_DBGdimap; 133 atomic_t im_numinos; /* num of back 133 atomic_t im_numinos; /* num of backed inodes */ 134 atomic_t im_numfree; /* num of free 134 atomic_t im_numfree; /* num of free backed inodes */ 135 }; 135 }; 136 136 137 #define im_freeiag im_imap.in_freeiag 137 #define im_freeiag im_imap.in_freeiag 138 #define im_nextiag im_imap.in_nextiag 138 #define im_nextiag im_imap.in_nextiag 139 #define im_agctl im_imap.in_agctl 139 #define im_agctl im_imap.in_agctl 140 #define im_nbperiext im_imap.in_nbperiext 140 #define im_nbperiext im_imap.in_nbperiext 141 #define im_l2nbperiext im_imap.in_l2nbperiext 141 #define im_l2nbperiext im_imap.in_l2nbperiext 142 142 143 /* for standalone testdriver 143 /* for standalone testdriver 144 */ 144 */ 145 #define im_diskblock im_imap.in_diskblock 145 #define im_diskblock im_imap.in_diskblock 146 #define im_maxag im_imap.in_maxag 146 #define im_maxag im_imap.in_maxag 147 147 148 extern int diFree(struct inode *); 148 extern int diFree(struct inode *); 149 extern int diAlloc(struct inode *, bool, struc 149 extern int diAlloc(struct inode *, bool, struct inode *); 150 extern int diSync(struct inode *); 150 extern int diSync(struct inode *); 151 /* external references */ 151 /* external references */ 152 extern int diUpdatePMap(struct inode *ipimap, 152 extern int diUpdatePMap(struct inode *ipimap, unsigned long inum, 153 bool is_free, struct t 153 bool is_free, struct tblock * tblk); 154 extern int diExtendFS(struct inode *ipimap, st 154 extern int diExtendFS(struct inode *ipimap, struct inode *ipbmap); 155 extern int diMount(struct inode *); 155 extern int diMount(struct inode *); 156 extern int diUnmount(struct inode *, int); 156 extern int diUnmount(struct inode *, int); 157 extern int diRead(struct inode *); 157 extern int diRead(struct inode *); 158 extern struct inode *diReadSpecial(struct supe 158 extern struct inode *diReadSpecial(struct super_block *, ino_t, int); 159 extern void diWriteSpecial(struct inode *, int 159 extern void diWriteSpecial(struct inode *, int); 160 extern void diFreeSpecial(struct inode *); 160 extern void diFreeSpecial(struct inode *); 161 extern int diWrite(tid_t tid, struct inode *); 161 extern int diWrite(tid_t tid, struct inode *); 162 #endif /* _H_JFS_IMAP 162 #endif /* _H_JFS_IMAP */ 163 163
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.