jfs_imap.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (C) International Business Machines Corp., 2000-2002
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  12. * the GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef _H_JFS_IMAP
  19. #define _H_JFS_IMAP
  20. #include "jfs_txnmgr.h"
  21. /*
  22. * jfs_imap.h: disk inode manager
  23. */
  24. #define EXTSPERIAG 128 /* number of disk inode extent per iag */
  25. #define IMAPBLKNO 0 /* lblkno of dinomap within inode map */
  26. #define SMAPSZ 4 /* number of words per summary map */
  27. #define EXTSPERSUM 32 /* number of extents per summary map entry */
  28. #define L2EXTSPERSUM 5 /* l2 number of extents per summary map */
  29. #define PGSPERIEXT 4 /* number of 4K pages per dinode extent */
  30. #define MAXIAGS ((1<<20)-1) /* maximum number of iags */
  31. #define MAXAG 128 /* maximum number of allocation groups */
  32. #define AMAPSIZE 512 /* bytes in the IAG allocation maps */
  33. #define SMAPSIZE 16 /* bytes in the IAG summary maps */
  34. /* convert inode number to iag number */
  35. #define INOTOIAG(ino) ((ino) >> L2INOSPERIAG)
  36. /* convert iag number to logical block number of the iag page */
  37. #define IAGTOLBLK(iagno,l2nbperpg) (((iagno) + 1) << (l2nbperpg))
  38. /* get the starting block number of the 4K page of an inode extent
  39. * that contains ino.
  40. */
  41. #define INOPBLK(pxd,ino,l2nbperpg) (addressPXD((pxd)) + \
  42. ((((ino) & (INOSPEREXT-1)) >> L2INOSPERPAGE) << (l2nbperpg)))
  43. /*
  44. * inode allocation map:
  45. *
  46. * inode allocation map consists of
  47. * . the inode map control page and
  48. * . inode allocation group pages (per 4096 inodes)
  49. * which are addressed by standard JFS xtree.
  50. */
  51. /*
  52. * inode allocation group page (per 4096 inodes of an AG)
  53. */
  54. struct iag {
  55. __le64 agstart; /* 8: starting block of ag */
  56. __le32 iagnum; /* 4: inode allocation group number */
  57. __le32 inofreefwd; /* 4: ag inode free list forward */
  58. __le32 inofreeback; /* 4: ag inode free list back */
  59. __le32 extfreefwd; /* 4: ag inode extent free list forward */
  60. __le32 extfreeback; /* 4: ag inode extent free list back */
  61. __le32 iagfree; /* 4: iag free list */
  62. /* summary map: 1 bit per inode extent */
  63. __le32 inosmap[SMAPSZ]; /* 16: sum map of mapwords w/ free inodes;
  64. * note: this indicates free and backed
  65. * inodes, if the extent is not backed the
  66. * value will be 1. if the extent is
  67. * backed but all inodes are being used the
  68. * value will be 1. if the extent is
  69. * backed but at least one of the inodes is
  70. * free the value will be 0.
  71. */
  72. __le32 extsmap[SMAPSZ]; /* 16: sum map of mapwords w/ free extents */
  73. __le32 nfreeinos; /* 4: number of free inodes */
  74. __le32 nfreeexts; /* 4: number of free extents */
  75. /* (72) */
  76. u8 pad[1976]; /* 1976: pad to 2048 bytes */
  77. /* allocation bit map: 1 bit per inode (0 - free, 1 - allocated) */
  78. __le32 wmap[EXTSPERIAG]; /* 512: working allocation map */
  79. __le32 pmap[EXTSPERIAG]; /* 512: persistent allocation map */
  80. pxd_t inoext[EXTSPERIAG]; /* 1024: inode extent addresses */
  81. }; /* (4096) */
  82. /*
  83. * per AG control information (in inode map control page)
  84. */
  85. struct iagctl_disk {
  86. __le32 inofree; /* 4: free inode list anchor */
  87. __le32 extfree; /* 4: free extent list anchor */
  88. __le32 numinos; /* 4: number of backed inodes */
  89. __le32 numfree; /* 4: number of free inodes */
  90. }; /* (16) */
  91. struct iagctl {
  92. int inofree; /* free inode list anchor */
  93. int extfree; /* free extent list anchor */
  94. int numinos; /* number of backed inodes */
  95. int numfree; /* number of free inodes */
  96. };
  97. /*
  98. * per fileset/aggregate inode map control page
  99. */
  100. struct dinomap_disk {
  101. __le32 in_freeiag; /* 4: free iag list anchor */
  102. __le32 in_nextiag; /* 4: next free iag number */
  103. __le32 in_numinos; /* 4: num of backed inodes */
  104. __le32 in_numfree; /* 4: num of free backed inodes */
  105. __le32 in_nbperiext; /* 4: num of blocks per inode extent */
  106. __le32 in_l2nbperiext; /* 4: l2 of in_nbperiext */
  107. __le32 in_diskblock; /* 4: for standalone test driver */
  108. __le32 in_maxag; /* 4: for standalone test driver */
  109. u8 pad[2016]; /* 2016: pad to 2048 */
  110. struct iagctl_disk in_agctl[MAXAG]; /* 2048: AG control information */
  111. }; /* (4096) */
  112. struct dinomap {
  113. int in_freeiag; /* free iag list anchor */
  114. int in_nextiag; /* next free iag number */
  115. int in_numinos; /* num of backed inodes */
  116. int in_numfree; /* num of free backed inodes */
  117. int in_nbperiext; /* num of blocks per inode extent */
  118. int in_l2nbperiext; /* l2 of in_nbperiext */
  119. int in_diskblock; /* for standalone test driver */
  120. int in_maxag; /* for standalone test driver */
  121. struct iagctl in_agctl[MAXAG]; /* AG control information */
  122. };
  123. /*
  124. * In-core inode map control page
  125. */
  126. struct inomap {
  127. struct dinomap im_imap; /* 4096: inode allocation control */
  128. struct inode *im_ipimap; /* 4: ptr to inode for imap */
  129. struct mutex im_freelock; /* 4: iag free list lock */
  130. struct mutex im_aglock[MAXAG]; /* 512: per AG locks */
  131. u32 *im_DBGdimap;
  132. atomic_t im_numinos; /* num of backed inodes */
  133. atomic_t im_numfree; /* num of free backed inodes */
  134. };
  135. #define im_freeiag im_imap.in_freeiag
  136. #define im_nextiag im_imap.in_nextiag
  137. #define im_agctl im_imap.in_agctl
  138. #define im_nbperiext im_imap.in_nbperiext
  139. #define im_l2nbperiext im_imap.in_l2nbperiext
  140. /* for standalone testdriver
  141. */
  142. #define im_diskblock im_imap.in_diskblock
  143. #define im_maxag im_imap.in_maxag
  144. extern int diFree(struct inode *);
  145. extern int diAlloc(struct inode *, bool, struct inode *);
  146. extern int diSync(struct inode *);
  147. /* external references */
  148. extern int diUpdatePMap(struct inode *ipimap, unsigned long inum,
  149. bool is_free, struct tblock * tblk);
  150. extern int diExtendFS(struct inode *ipimap, struct inode *ipbmap);
  151. extern int diMount(struct inode *);
  152. extern int diUnmount(struct inode *, int);
  153. extern int diRead(struct inode *);
  154. extern struct inode *diReadSpecial(struct super_block *, ino_t, int);
  155. extern void diWriteSpecial(struct inode *, int);
  156. extern void diFreeSpecial(struct inode *);
  157. extern int diWrite(tid_t tid, struct inode *);
  158. #endif /* _H_JFS_IMAP */