Commit c119a81d authored by Dave Kleikamp's avatar Dave Kleikamp

JFS: cleanup dbAlloc

Reduces number of return paths to two.  This is a preparation for
quota support.

Submitted by Christoph Hellwig
parent ca980f75
...@@ -782,8 +782,7 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) ...@@ -782,8 +782,7 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
nblocks); nblocks);
} }
IWRITE_UNLOCK(ipbmap); goto write_unlock;
return (rc);
} }
/* we would like to allocate close to the hint. adjust the /* we would like to allocate close to the hint. adjust the
...@@ -829,12 +828,12 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) ...@@ -829,12 +828,12 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
/* get the buffer for the dmap containing the hint. /* get the buffer for the dmap containing the hint.
*/ */
rc = EIO;
lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage); lblkno = BLKTODMAP(blkno, bmp->db_l2nbperpage);
mp = read_metapage(ipbmap, lblkno, PSIZE, 0); mp = read_metapage(ipbmap, lblkno, PSIZE, 0);
if (mp == NULL) { if (mp == NULL)
IREAD_UNLOCK(ipbmap); goto read_unlock;
return (EIO);
}
dp = (dmap_t *) mp->data; dp = (dmap_t *) mp->data;
/* first, try to satisfy the allocation request with the /* first, try to satisfy the allocation request with the
...@@ -847,14 +846,11 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) ...@@ -847,14 +846,11 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
*results = blkno; *results = blkno;
DBALLOC(bmp->db_DBmap, bmp->db_mapsize, DBALLOC(bmp->db_DBmap, bmp->db_mapsize,
*results, nblocks); *results, nblocks);
write_metapage(mp); mark_metapage_dirty(mp);
} else {
assert(rc == EIO);
release_metapage(mp);
} }
IREAD_UNLOCK(ipbmap); release_metapage(mp);
return (rc); goto read_unlock;
} }
/* next, try to satisfy the allocation request with blocks /* next, try to satisfy the allocation request with blocks
...@@ -869,10 +865,9 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) ...@@ -869,10 +865,9 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
*results, nblocks); *results, nblocks);
mark_metapage_dirty(mp); mark_metapage_dirty(mp);
} }
release_metapage(mp);
IREAD_UNLOCK(ipbmap); release_metapage(mp);
return (rc); goto read_unlock;
} }
/* try to satisfy the allocation request with blocks within /* try to satisfy the allocation request with blocks within
...@@ -886,10 +881,9 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) ...@@ -886,10 +881,9 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
*results, nblocks); *results, nblocks);
mark_metapage_dirty(mp); mark_metapage_dirty(mp);
} }
release_metapage(mp);
IREAD_UNLOCK(ipbmap); release_metapage(mp);
return (rc); goto read_unlock;
} }
release_metapage(mp); release_metapage(mp);
...@@ -910,8 +904,14 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) ...@@ -910,8 +904,14 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results, nblocks); DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results, nblocks);
} }
write_unlock:
IWRITE_UNLOCK(ipbmap); IWRITE_UNLOCK(ipbmap);
return (rc);
read_unlock:
IREAD_UNLOCK(ipbmap);
return (rc); return (rc);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment