#ifndef _H_JFS_IMAP
#define _H_JFS_IMAP
#include "jfs_txnmgr.h"
#define EXTSPERIAG 128 /* number of disk inode extent per iag */
#define IMAPBLKNO 0 /* lblkno of dinomap within inode map */
#define SMAPSZ 4 /* number of words per summary map */
#define EXTSPERSUM 32 /* number of extents per summary map entry */
#define L2EXTSPERSUM 5 /* l2 number of extents per summary map */
#define PGSPERIEXT 4 /* number of 4K pages per dinode extent */
#define MAXIAGS ((1<<20)-1) /* maximum number of iags */
#define MAXAG 128 /* maximum number of allocation groups */
#define AMAPSIZE 512 /* bytes in the IAG allocation maps */
#define SMAPSIZE 16 /* bytes in the IAG summary maps */
#define INOTOIAG(ino) ((ino) >> L2INOSPERIAG)
#define IAGTOLBLK(iagno,l2nbperpg) (((iagno) + 1) << (l2nbperpg))
#define INOPBLK(pxd,ino,l2nbperpg) (addressPXD((pxd)) + \
((((ino) & (INOSPEREXT-1)) >> L2INOSPERPAGE) << (l2nbperpg)))
struct iag {
__le64 agstart;
__le32 iagnum;
__le32 inofreefwd;
__le32 inofreeback;
__le32 extfreefwd;
__le32 extfreeback;
__le32 iagfree;
__le32 inosmap[SMAPSZ];
__le32 extsmap[SMAPSZ];
__le32 nfreeinos;
__le32 nfreeexts;
u8 pad[1976];
__le32 wmap[EXTSPERIAG];
__le32 pmap[EXTSPERIAG];
pxd_t inoext[EXTSPERIAG];
};
struct iagctl_disk {
__le32 inofree;
__le32 extfree;
__le32 numinos;
__le32 numfree;
};
struct iagctl {
int inofree;
int extfree;
int numinos;
int numfree;
};
struct dinomap_disk {
__le32 in_freeiag;
__le32 in_nextiag;
__le32 in_numinos;
__le32 in_numfree;
__le32 in_nbperiext;
__le32 in_l2nbperiext;
__le32 in_diskblock;
__le32 in_maxag;
u8 pad[2016];
struct iagctl_disk in_agctl[MAXAG];
};
struct dinomap {
int in_freeiag;
int in_nextiag;
int in_numinos;
int in_numfree;
int in_nbperiext;
int in_l2nbperiext;
int in_diskblock;
int in_maxag;
struct iagctl in_agctl[MAXAG];
};
struct inomap {
struct dinomap im_imap;
struct inode *im_ipimap;
struct mutex im_freelock;
struct mutex im_aglock[MAXAG];
u32 *im_DBGdimap;
atomic_t im_numinos;
atomic_t im_numfree;
};
#define im_freeiag im_imap.in_freeiag
#define im_nextiag im_imap.in_nextiag
#define im_agctl im_imap.in_agctl
#define im_nbperiext im_imap.in_nbperiext
#define im_l2nbperiext im_imap.in_l2nbperiext
#define im_diskblock im_imap.in_diskblock
#define im_maxag im_imap.in_maxag
extern int diFree(struct inode *);
extern int diAlloc(struct inode *, bool, struct inode *);
extern int diSync(struct inode *);
extern int diUpdatePMap(struct inode *ipimap, unsigned long inum,
bool is_free, struct tblock * tblk);
extern int diExtendFS(struct inode *ipimap, struct inode *ipbmap);
extern int diMount(struct inode *);
extern int diUnmount(struct inode *, int);
extern int diRead(struct inode *);
extern struct inode *diReadSpecial(struct super_block *, ino_t, int);
extern void diWriteSpecial(struct inode *, int);
extern void diFreeSpecial(struct inode *);
extern int diWrite(tid_t tid, struct inode *);
#endif /* _H_JFS_IMAP */