| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 2 | *   Copyright (C) International Business Machines Corp., 2000-2002 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | 
| Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 6 | *   the Free Software Foundation; either version 2 of the License, or | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | *   (at your option) any later version. | 
| Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 8 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | 
| Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 15 | *   along with this program;  if not, write to the Free Software | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 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	*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 33 | #define	MAXIAGS		((1<<20)-1)	/* maximum number of iags	*/ | 
|  | 34 | #define	MAXAG		128	/* maximum number of allocation groups	*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 |  | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 36 | #define AMAPSIZE	512	/* bytes in the IAG allocation maps */ | 
|  | 37 | #define SMAPSIZE	16	/* bytes in the IAG summary maps */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | */ | 
| Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 48 | #define INOPBLK(pxd,ino,l2nbperpg)	(addressPXD((pxd)) +		\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | ((((ino) & (INOSPEREXT-1)) >> L2INOSPERPAGE) << (l2nbperpg))) | 
|  | 50 |  | 
|  | 51 | /* | 
|  | 52 | *	inode allocation map: | 
| Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 53 | * | 
|  | 54 | * inode allocation map consists of | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 { | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 63 | __le64 agstart;		/* 8: starting block of ag		*/ | 
|  | 64 | __le32 iagnum;		/* 4: inode allocation group number	*/ | 
|  | 65 | __le32 inofreefwd;	/* 4: ag inode free list forward	*/ | 
|  | 66 | __le32 inofreeback;	/* 4: ag inode free list back		*/ | 
|  | 67 | __le32 extfreefwd;	/* 4: ag inode extent free list forward	*/ | 
|  | 68 | __le32 extfreeback;	/* 4: ag inode extent free list back	*/ | 
|  | 69 | __le32 iagfree;		/* 4: iag free list			*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 |  | 
|  | 71 | /* summary map: 1 bit per inode extent */ | 
|  | 72 | __le32 inosmap[SMAPSZ];	/* 16: sum map of mapwords w/ free inodes; | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 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. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | */ | 
|  | 81 | __le32 extsmap[SMAPSZ];	/* 16: sum map of mapwords w/ free extents */ | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 82 | __le32 nfreeinos;	/* 4: number of free inodes		*/ | 
|  | 83 | __le32 nfreeexts;	/* 4: number of free extents		*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | /* (72) */ | 
|  | 85 | u8 pad[1976];		/* 1976: pad to 2048 bytes */ | 
|  | 86 | /* allocation bit map: 1 bit per inode (0 - free, 1 - allocated) */ | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 87 | __le32 wmap[EXTSPERIAG];	/* 512: working allocation map */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | __le32 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_disk { | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 96 | __le32 inofree;		/* 4: free inode list anchor		*/ | 
|  | 97 | __le32 extfree;		/* 4: free extent list anchor		*/ | 
|  | 98 | __le32 numinos;		/* 4: number of backed inodes		*/ | 
|  | 99 | __le32 numfree;		/* 4: number of free inodes		*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | };				/* (16) */ | 
|  | 101 |  | 
|  | 102 | struct iagctl { | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 103 | int inofree;		/* free inode list anchor		*/ | 
|  | 104 | int extfree;		/* free extent list anchor		*/ | 
|  | 105 | int numinos;		/* number of backed inodes		*/ | 
|  | 106 | int numfree;		/* number of free inodes		*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | }; | 
|  | 108 |  | 
|  | 109 | /* | 
|  | 110 | *	per fileset/aggregate inode map control page | 
|  | 111 | */ | 
|  | 112 | struct dinomap_disk { | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 113 | __le32 in_freeiag;	/* 4: free iag list anchor	*/ | 
|  | 114 | __le32 in_nextiag;	/* 4: next free iag number	*/ | 
|  | 115 | __le32 in_numinos;	/* 4: num of backed inodes	*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | __le32 in_numfree;	/* 4: num of free backed inodes */ | 
|  | 117 | __le32 in_nbperiext;	/* 4: num of blocks per inode extent */ | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 118 | __le32 in_l2nbperiext;	/* 4: l2 of in_nbperiext	*/ | 
|  | 119 | __le32 in_diskblock;	/* 4: for standalone test driver */ | 
|  | 120 | __le32 in_maxag;	/* 4: for standalone test driver */ | 
|  | 121 | u8 pad[2016];		/* 2016: pad to 2048		*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | struct iagctl_disk in_agctl[MAXAG]; /* 2048: AG control information */ | 
|  | 123 | };				/* (4096) */ | 
|  | 124 |  | 
|  | 125 | struct dinomap { | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 126 | int in_freeiag;		/* free iag list anchor		*/ | 
|  | 127 | int in_nextiag;		/* next free iag number		*/ | 
|  | 128 | int in_numinos;		/* num of backed inodes		*/ | 
|  | 129 | int in_numfree;		/* num of free backed inodes	*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | int in_nbperiext;	/* num of blocks per inode extent */ | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 131 | int in_l2nbperiext;	/* l2 of in_nbperiext		*/ | 
|  | 132 | int in_diskblock;	/* for standalone test driver	*/ | 
|  | 133 | int in_maxag;		/* for standalone test driver	*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | struct iagctl in_agctl[MAXAG];	/* AG control information */ | 
|  | 135 | }; | 
|  | 136 |  | 
|  | 137 | /* | 
|  | 138 | *	In-core inode map control page | 
|  | 139 | */ | 
|  | 140 | struct inomap { | 
|  | 141 | struct dinomap im_imap;		/* 4096: inode allocation control */ | 
| Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 142 | struct inode *im_ipimap;	/* 4: ptr to inode for imap	*/ | 
|  | 143 | struct mutex im_freelock;	/* 4: iag free list lock	*/ | 
|  | 144 | struct mutex im_aglock[MAXAG];	/* 512: per AG locks		*/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | u32 *im_DBGdimap; | 
|  | 146 | atomic_t im_numinos;	/* num of backed inodes */ | 
|  | 147 | atomic_t im_numfree;	/* num of free backed inodes */ | 
|  | 148 | }; | 
|  | 149 |  | 
|  | 150 | #define	im_freeiag	im_imap.in_freeiag | 
|  | 151 | #define	im_nextiag	im_imap.in_nextiag | 
|  | 152 | #define	im_agctl	im_imap.in_agctl | 
|  | 153 | #define	im_nbperiext	im_imap.in_nbperiext | 
|  | 154 | #define	im_l2nbperiext	im_imap.in_l2nbperiext | 
|  | 155 |  | 
|  | 156 | /* for standalone testdriver | 
|  | 157 | */ | 
|  | 158 | #define	im_diskblock	im_imap.in_diskblock | 
|  | 159 | #define	im_maxag	im_imap.in_maxag | 
|  | 160 |  | 
|  | 161 | extern int diFree(struct inode *); | 
| Richard Knutsson | 4d81715 | 2006-09-30 23:27:14 -0700 | [diff] [blame] | 162 | extern int diAlloc(struct inode *, bool, struct inode *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | extern int diSync(struct inode *); | 
|  | 164 | /* external references */ | 
|  | 165 | extern int diUpdatePMap(struct inode *ipimap, unsigned long inum, | 
| Richard Knutsson | 4d81715 | 2006-09-30 23:27:14 -0700 | [diff] [blame] | 166 | bool is_free, struct tblock * tblk); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | extern int diExtendFS(struct inode *ipimap, struct inode *ipbmap); | 
|  | 168 | extern int diMount(struct inode *); | 
|  | 169 | extern int diUnmount(struct inode *, int); | 
|  | 170 | extern int diRead(struct inode *); | 
|  | 171 | extern struct inode *diReadSpecial(struct super_block *, ino_t, int); | 
|  | 172 | extern void diWriteSpecial(struct inode *, int); | 
|  | 173 | extern void diFreeSpecial(struct inode *); | 
|  | 174 | extern int diWrite(tid_t tid, struct inode *); | 
|  | 175 | #endif				/* _H_JFS_IMAP */ |