aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dir.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-08-20 22:36:33 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 19:57:05 -0400
commitf99b9b7ccf6a691f653cec45f36bfdd1e94769c7 (patch)
tree1c6ff6ea1fa1bb86b70f1fd78dd725b559c729e4 /fs/ocfs2/dir.c
parent1e61ee79e2a96f62c007486677319814ce621c3c (diff)
ocfs2: Make ocfs2_extent_tree the first-class representation of a tree.
We now have three different kinds of extent trees in ocfs2: inode data (dinode), extended attributes (xattr_tree), and extended attribute values (xattr_value). There is a nice abstraction for them, ocfs2_extent_tree, but it is hidden in alloc.c. All the calling functions have to pick amongst a varied API and pass in type bits and often extraneous pointers. A better way is to make ocfs2_extent_tree a first-class object. Everyone converts their object to an ocfs2_extent_tree() via the ocfs2_get_*_extent_tree() calls, then uses the ocfs2_extent_tree for all tree calls to alloc.c. This simplifies a lot of callers, making for readability. It also provides an easy way to add additional extent tree types, as they only need to be defined in alloc.c with a ocfs2_get_<new>_extent_tree() function. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/dir.c')
-rw-r--r--fs/ocfs2/dir.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 5426a02c12bb..2cdc55390348 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -1192,6 +1192,9 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1192 struct buffer_head *dirdata_bh = NULL; 1192 struct buffer_head *dirdata_bh = NULL;
1193 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; 1193 struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
1194 handle_t *handle; 1194 handle_t *handle;
1195 struct ocfs2_extent_tree et;
1196
1197 ocfs2_get_dinode_extent_tree(&et, dir, di_bh);
1195 1198
1196 alloc = ocfs2_clusters_for_bytes(sb, bytes); 1199 alloc = ocfs2_clusters_for_bytes(sb, bytes);
1197 1200
@@ -1305,8 +1308,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1305 * This should never fail as our extent list is empty and all 1308 * This should never fail as our extent list is empty and all
1306 * related blocks have been journaled already. 1309 * related blocks have been journaled already.
1307 */ 1310 */
1308 ret = ocfs2_dinode_insert_extent(osb, handle, dir, di_bh, 0, blkno, 1311 ret = ocfs2_insert_extent(osb, handle, dir, &et, 0, blkno, len,
1309 len, 0, NULL); 1312 0, NULL);
1310 if (ret) { 1313 if (ret) {
1311 mlog_errno(ret); 1314 mlog_errno(ret);
1312 goto out_commit; 1315 goto out_commit;
@@ -1337,8 +1340,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1337 } 1340 }
1338 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off); 1341 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
1339 1342
1340 ret = ocfs2_dinode_insert_extent(osb, handle, dir, di_bh, 1, 1343 ret = ocfs2_insert_extent(osb, handle, dir, &et, 1,
1341 blkno, len, 0, NULL); 1344 blkno, len, 0, NULL);
1342 if (ret) { 1345 if (ret) {
1343 mlog_errno(ret); 1346 mlog_errno(ret);
1344 goto out_commit; 1347 goto out_commit;
@@ -1360,6 +1363,7 @@ out:
1360 1363
1361 brelse(dirdata_bh); 1364 brelse(dirdata_bh);
1362 1365
1366 ocfs2_put_extent_tree(&et);
1363 return ret; 1367 return ret;
1364} 1368}
1365 1369
@@ -1437,6 +1441,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
1437 struct buffer_head *new_bh = NULL; 1441 struct buffer_head *new_bh = NULL;
1438 struct ocfs2_dir_entry * de; 1442 struct ocfs2_dir_entry * de;
1439 struct super_block *sb = osb->sb; 1443 struct super_block *sb = osb->sb;
1444 struct ocfs2_extent_tree et;
1440 1445
1441 mlog_entry_void(); 1446 mlog_entry_void();
1442 1447
@@ -1480,10 +1485,9 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb,
1480 spin_lock(&OCFS2_I(dir)->ip_lock); 1485 spin_lock(&OCFS2_I(dir)->ip_lock);
1481 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { 1486 if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) {
1482 spin_unlock(&OCFS2_I(dir)->ip_lock); 1487 spin_unlock(&OCFS2_I(dir)->ip_lock);
1483 num_free_extents = ocfs2_num_free_extents(osb, dir, 1488 ocfs2_get_dinode_extent_tree(&et, dir, parent_fe_bh);
1484 parent_fe_bh, 1489 num_free_extents = ocfs2_num_free_extents(osb, dir, &et);
1485 OCFS2_DINODE_EXTENT, 1490 ocfs2_put_extent_tree(&et);
1486 NULL);
1487 if (num_free_extents < 0) { 1491 if (num_free_extents < 0) {
1488 status = num_free_extents; 1492 status = num_free_extents;
1489 mlog_errno(status); 1493 mlog_errno(status);