original comment: +Wilson03172004,marked due to this pci host does not support MWI
[linux-2.4.git] / fs / jfs / jfs_imap.h
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
21 #include "jfs_txnmgr.h"
22
23 /*
24  *      jfs_imap.h: disk inode manager
25  */
26
27 #define EXTSPERIAG      128     /* number of disk inode extent per iag  */
28 #define IMAPBLKNO       0       /* lblkno of dinomap within inode map   */
29 #define SMAPSZ          4       /* number of words per summary map      */
30 #define EXTSPERSUM      32      /* number of extents per summary map entry */
31 #define L2EXTSPERSUM    5       /* l2 number of extents per summary map */
32 #define PGSPERIEXT      4       /* number of 4K pages per dinode extent */
33 #define MAXIAGS         ((1<<20)-1)     /* maximum number of iags       */
34 #define MAXAG           128     /* maximum number of allocation groups  */
35
36 #define AMAPSIZE      512       /* bytes in the IAG allocation maps */
37 #define SMAPSIZE      16        /* bytes in the IAG summary maps */
38
39 /* convert inode number to iag number */
40 #define INOTOIAG(ino)   ((ino) >> L2INOSPERIAG)
41
42 /* convert iag number to logical block number of the iag page */
43 #define IAGTOLBLK(iagno,l2nbperpg)      (((iagno) + 1) << (l2nbperpg))
44
45 /* get the starting block number of the 4K page of an inode extent
46  * that contains ino.
47  */
48 #define INOPBLK(pxd,ino,l2nbperpg)      (addressPXD((pxd)) +            \
49         ((((ino) & (INOSPEREXT-1)) >> L2INOSPERPAGE) << (l2nbperpg)))
50
51 /*
52  *      inode allocation map:
53  * 
54  * inode allocation map consists of 
55  * . the inode map control page and
56  * . inode allocation group pages (per 4096 inodes)
57  * which are addressed by standard JFS xtree.
58  */
59 /*
60  *      inode allocation group page (per 4096 inodes of an AG)
61  */
62 struct iag {
63         s64 agstart;            /* 8: starting block of ag              */
64         s32 iagnum;             /* 4: inode allocation group number     */
65         s32 inofreefwd;         /* 4: ag inode free list forward        */
66         s32 inofreeback;        /* 4: ag inode free list back           */
67         s32 extfreefwd;         /* 4: ag inode extent free list forward */
68         s32 extfreeback;        /* 4: ag inode extent free list back    */
69         s32 iagfree;            /* 4: iag free list                     */
70
71         /* summary map: 1 bit per inode extent */
72         s32 inosmap[SMAPSZ];    /* 16: sum map of mapwords w/ free inodes;
73                                  *      note: this indicates free and backed
74                                  *      inodes, if the extent is not backed the
75                                  *      value will be 1.  if the extent is
76                                  *      backed but all inodes are being used the
77                                  *      value will be 1.  if the extent is
78                                  *      backed but at least one of the inodes is
79                                  *      free the value will be 0.
80                                  */
81         s32 extsmap[SMAPSZ];    /* 16: sum map of mapwords w/ free extents */
82         s32 nfreeinos;          /* 4: number of free inodes             */
83         s32 nfreeexts;          /* 4: number of free extents            */
84         /* (72) */
85         u8 pad[1976];           /* 1976: pad to 2048 bytes */
86         /* allocation bit map: 1 bit per inode (0 - free, 1 - allocated) */
87         u32 wmap[EXTSPERIAG];   /* 512: working allocation map  */
88         u32 pmap[EXTSPERIAG];   /* 512: persistent allocation map */
89         pxd_t inoext[EXTSPERIAG];       /* 1024: inode extent addresses */
90 };                              /* (4096) */
91
92 /*
93  *      per AG control information (in inode map control page)
94  */
95 struct iagctl {
96         s32 inofree;            /* 4: free inode list anchor            */
97         s32 extfree;            /* 4: free extent list anchor           */
98         s32 numinos;            /* 4: number of backed inodes           */
99         s32 numfree;            /* 4: number of free inodes             */
100 };                              /* (16) */
101
102 /*
103  *      per fileset/aggregate inode map control page
104  */
105 struct dinomap {
106         s32 in_freeiag;         /* 4: free iag list anchor     */
107         s32 in_nextiag;         /* 4: next free iag number     */
108         s32 in_numinos;         /* 4: num of backed inodes */
109         s32 in_numfree;         /* 4: num of free backed inodes */
110         s32 in_nbperiext;       /* 4: num of blocks per inode extent */
111         s32 in_l2nbperiext;     /* 4: l2 of in_nbperiext */
112         s32 in_diskblock;       /* 4: for standalone test driver  */
113         s32 in_maxag;           /* 4: for standalone test driver  */
114         u8 pad[2016];           /* 2016: pad to 2048 */
115         struct iagctl in_agctl[MAXAG];  /* 2048: AG control information */
116 };                              /* (4096) */
117
118
119 /*
120  *      In-core inode map control page
121  */
122 struct inomap {
123         struct dinomap im_imap;         /* 4096: inode allocation control */
124         struct inode *im_ipimap;        /* 4: ptr to inode for imap   */
125         struct semaphore im_freelock;   /* 4: iag free list lock      */
126         struct semaphore im_aglock[MAXAG];      /* 512: per AG locks          */
127         u32 *im_DBGdimap;
128         atomic_t im_numinos;    /* num of backed inodes */
129         atomic_t im_numfree;    /* num of free backed inodes */
130 };
131
132 #define im_freeiag      im_imap.in_freeiag
133 #define im_nextiag      im_imap.in_nextiag
134 #define im_agctl        im_imap.in_agctl
135 #define im_nbperiext    im_imap.in_nbperiext
136 #define im_l2nbperiext  im_imap.in_l2nbperiext
137
138 /* for standalone testdriver
139  */
140 #define im_diskblock    im_imap.in_diskblock
141 #define im_maxag        im_imap.in_maxag
142
143 extern int diFree(struct inode *);
144 extern int diAlloc(struct inode *, boolean_t, struct inode *);
145 extern int diSync(struct inode *);
146 /* external references */
147 extern int diUpdatePMap(struct inode *ipimap, unsigned long inum,
148                         boolean_t is_free, struct tblock * tblk);
149 extern int diExtendFS(struct inode *ipimap, struct inode *ipbmap);
150 extern int diMount(struct inode *);
151 extern int diUnmount(struct inode *, int);
152 extern int diRead(struct inode *);
153 extern struct inode *diReadSpecial(struct super_block *, ino_t, int);
154 extern void diWriteSpecial(struct inode *, int);
155 extern void diFreeSpecial(struct inode *);
156 extern int diWrite(tid_t tid, struct inode *);
157 #endif                          /* _H_JFS_IMAP */