int dbMount(struct inode *ipbmap)
{
struct bmap *bmp;
- struct dbmap *dbmp_le;
+ struct dbmap_disk *dbmp_le;
struct metapage *mp;
int i;
}
/* copy the on-disk bmap descriptor to its in-memory version. */
- dbmp_le = (struct dbmap *) mp->data;
+ dbmp_le = (struct dbmap_disk *) mp->data;
bmp->db_mapsize = le64_to_cpu(dbmp_le->dn_mapsize);
bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
*/
int dbSync(struct inode *ipbmap)
{
- struct dbmap *dbmp_le;
+ struct dbmap_disk *dbmp_le;
struct bmap *bmp = JFS_SBI(ipbmap->i_sb)->bmap;
struct metapage *mp;
int i;
return -EIO;
}
/* copy the in-memory version of the bmap to the on-disk version */
- dbmp_le = (struct dbmap *) mp->data;
+ dbmp_le = (struct dbmap_disk *) mp->data;
dbmp_le->dn_mapsize = cpu_to_le64(bmp->db_mapsize);
dbmp_le->dn_nfree = cpu_to_le64(bmp->db_nfree);
dbmp_le->dn_l2nbperpage = cpu_to_le32(bmp->db_l2nbperpage);
struct metapage *mp;
struct jfs_log *log;
int lsn, difft, diffp;
+ unsigned long flags;
/* the blocks better be within the mapsize. */
if (blkno + nblocks > bmp->db_mapsize) {
0);
if (mp == NULL)
return -EIO;
+ metapage_wait_for_io(mp);
}
dp = (struct dmap *) mp->data;
if (mp->lsn != 0) {
/* inherit older/smaller lsn */
logdiff(diffp, mp->lsn, log);
+ LOGSYNC_LOCK(log, flags);
if (difft < diffp) {
mp->lsn = lsn;
/* move bp after tblock in logsync list */
- LOGSYNC_LOCK(log);
list_move(&mp->synclist, &tblk->synclist);
- LOGSYNC_UNLOCK(log);
}
/* inherit younger/larger clsn */
- LOGSYNC_LOCK(log);
logdiff(difft, tblk->clsn, log);
logdiff(diffp, mp->clsn, log);
if (difft > diffp)
mp->clsn = tblk->clsn;
- LOGSYNC_UNLOCK(log);
+ LOGSYNC_UNLOCK(log, flags);
} else {
mp->log = log;
mp->lsn = lsn;
/* insert bp after tblock in logsync list */
- LOGSYNC_LOCK(log);
+ LOGSYNC_LOCK(log, flags);
log->count++;
list_add(&mp->synclist, &tblk->synclist);
mp->clsn = tblk->clsn;
- LOGSYNC_UNLOCK(log);
+ LOGSYNC_UNLOCK(log, flags);
}
}
s8 *leaf;
u32 mask;
+ if (dp->tree.leafidx != cpu_to_le32(LEAFIND)) {
+ jfs_error(bmp->db_ipbmap->i_sb,
+ "dbAllocNext: Corrupt dmap page");
+ return -EIO;
+ }
+
/* pick up a pointer to the leaves of the dmap tree.
*/
leaf = dp->tree.stree + le32_to_cpu(dp->tree.leafidx);
struct dmap * dp, s64 blkno, int nblocks, int l2nb, s64 * results)
{
int word, lword, rc;
- s8 *leaf = dp->tree.stree + le32_to_cpu(dp->tree.leafidx);
+ s8 *leaf;
+
+ if (dp->tree.leafidx != cpu_to_le32(LEAFIND)) {
+ jfs_error(bmp->db_ipbmap->i_sb,
+ "dbAllocNear: Corrupt dmap page");
+ return -EIO;
+ }
+
+ leaf = dp->tree.stree + le32_to_cpu(dp->tree.leafidx);
/* determine the word within the dmap that holds the hint
* (i.e. blkno). also, determine the last word in the dmap
dcp = (struct dmapctl *) mp->data;
budmin = dcp->budmin;
+ if (dcp->leafidx != cpu_to_le32(CTLLEAFIND)) {
+ jfs_error(bmp->db_ipbmap->i_sb,
+ "dbAllocAG: Corrupt dmapctl page");
+ release_metapage(mp);
+ return -EIO;
+ }
+
/* search the subtree(s) of the dmap control page that describes
* the allocation group, looking for sufficient free space. to begin,
* determine how many allocation groups are represented in a dmap
dcp = (struct dmapctl *) mp->data;
budmin = dcp->budmin;
+ if (dcp->leafidx != cpu_to_le32(CTLLEAFIND)) {
+ jfs_error(bmp->db_ipbmap->i_sb,
+ "dbFindCtl: Corrupt dmapctl page");
+ release_metapage(mp);
+ return -EIO;
+ }
+
/* search the tree within the dmap control page for
* sufficent free space. if sufficient free space is found,
* dbFindLeaf() returns the index of the leaf at which
return -EIO;
dcp = (struct dmapctl *) mp->data;
+ if (dcp->leafidx != cpu_to_le32(CTLLEAFIND)) {
+ jfs_error(bmp->db_ipbmap->i_sb,
+ "dbAdjCtl: Corrupt dmapctl page");
+ release_metapage(mp);
+ return -EIO;
+ }
+
/* determine the leaf number corresponding to the block and
* the index within the dmap control tree.
*/
/* set the rest of the words in the page to allocated (ONES) */
for (i = w; i < LPERDMAP; i++)
- dp->pmap[i] = dp->wmap[i] = ONES;
+ dp->pmap[i] = dp->wmap[i] = cpu_to_le32(ONES);
/*
* init tree