diff options
author | Tao Ma <tao.ma@oracle.com> | 2008-08-18 05:38:42 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2008-10-13 16:57:58 -0400 |
commit | 231b87d10920e024efaf0f9e86e1bab7bced1620 (patch) | |
tree | 00283dfb9e4a7054576be8a073635dc51bdc4e22 | |
parent | 9a8ff578fb430a8816dfbc73c77e5e09c6d9c343 (diff) |
ocfs2: Modify ocfs2_num_free_extents for future xattr usage.
ocfs2_num_free_extents() is used to find the number of free extent records
in an inode btree. Hence, it takes an "ocfs2_dinode" parameter. We want to
use this for extended attribute trees in the future, so genericize the
interface the take a buffer head. A future patch will allow that buffer_head
to contain any structure rooting an ocfs2 btree.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r-- | fs/ocfs2/alloc.c | 3 | ||||
-rw-r--r-- | fs/ocfs2/alloc.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/aops.c | 5 | ||||
-rw-r--r-- | fs/ocfs2/dir.c | 3 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 11 | ||||
-rw-r--r-- | fs/ocfs2/file.h | 2 |
6 files changed, 15 insertions, 11 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 29ff57ec5d1f..377acb24f67b 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -368,12 +368,13 @@ struct ocfs2_merge_ctxt { | |||
368 | */ | 368 | */ |
369 | int ocfs2_num_free_extents(struct ocfs2_super *osb, | 369 | int ocfs2_num_free_extents(struct ocfs2_super *osb, |
370 | struct inode *inode, | 370 | struct inode *inode, |
371 | struct ocfs2_dinode *fe) | 371 | struct buffer_head *bh) |
372 | { | 372 | { |
373 | int retval; | 373 | int retval; |
374 | struct ocfs2_extent_list *el; | 374 | struct ocfs2_extent_list *el; |
375 | struct ocfs2_extent_block *eb; | 375 | struct ocfs2_extent_block *eb; |
376 | struct buffer_head *eb_bh = NULL; | 376 | struct buffer_head *eb_bh = NULL; |
377 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *)bh->b_data; | ||
377 | 378 | ||
378 | mlog_entry_void(); | 379 | mlog_entry_void(); |
379 | 380 | ||
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index 60cd3d59230c..5c0f764b59ec 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h | |||
@@ -47,7 +47,7 @@ int ocfs2_remove_extent(struct inode *inode, struct buffer_head *di_bh, | |||
47 | struct ocfs2_cached_dealloc_ctxt *dealloc); | 47 | struct ocfs2_cached_dealloc_ctxt *dealloc); |
48 | int ocfs2_num_free_extents(struct ocfs2_super *osb, | 48 | int ocfs2_num_free_extents(struct ocfs2_super *osb, |
49 | struct inode *inode, | 49 | struct inode *inode, |
50 | struct ocfs2_dinode *fe); | 50 | struct buffer_head *bh); |
51 | /* how many new metadata chunks would an allocation need at maximum? */ | 51 | /* how many new metadata chunks would an allocation need at maximum? */ |
52 | static inline int ocfs2_extend_meta_needed(struct ocfs2_dinode *fe) | 52 | static inline int ocfs2_extend_meta_needed(struct ocfs2_dinode *fe) |
53 | { | 53 | { |
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index a53da1466277..e2008dcec753 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -1712,8 +1712,9 @@ int ocfs2_write_begin_nolock(struct address_space *mapping, | |||
1712 | * ocfs2_lock_allocators(). It greatly over-estimates | 1712 | * ocfs2_lock_allocators(). It greatly over-estimates |
1713 | * the work to be done. | 1713 | * the work to be done. |
1714 | */ | 1714 | */ |
1715 | ret = ocfs2_lock_allocators(inode, di, clusters_to_alloc, | 1715 | ret = ocfs2_lock_allocators(inode, wc->w_di_bh, |
1716 | extents_to_split, &data_ac, &meta_ac); | 1716 | clusters_to_alloc, extents_to_split, |
1717 | &data_ac, &meta_ac); | ||
1717 | if (ret) { | 1718 | if (ret) { |
1718 | mlog_errno(ret); | 1719 | mlog_errno(ret); |
1719 | goto out; | 1720 | goto out; |
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 9cce563fd627..fda09c32a5f2 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -1479,7 +1479,8 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
1479 | spin_lock(&OCFS2_I(dir)->ip_lock); | 1479 | spin_lock(&OCFS2_I(dir)->ip_lock); |
1480 | if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { | 1480 | if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { |
1481 | spin_unlock(&OCFS2_I(dir)->ip_lock); | 1481 | spin_unlock(&OCFS2_I(dir)->ip_lock); |
1482 | num_free_extents = ocfs2_num_free_extents(osb, dir, fe); | 1482 | num_free_extents = ocfs2_num_free_extents(osb, dir, |
1483 | parent_fe_bh); | ||
1483 | if (num_free_extents < 0) { | 1484 | if (num_free_extents < 0) { |
1484 | status = num_free_extents; | 1485 | status = num_free_extents; |
1485 | mlog_errno(status); | 1486 | mlog_errno(status); |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 1015ef16a8bf..b6c483dfe615 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -521,7 +521,7 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb, | |||
521 | if (mark_unwritten) | 521 | if (mark_unwritten) |
522 | flags = OCFS2_EXT_UNWRITTEN; | 522 | flags = OCFS2_EXT_UNWRITTEN; |
523 | 523 | ||
524 | free_extents = ocfs2_num_free_extents(osb, inode, fe); | 524 | free_extents = ocfs2_num_free_extents(osb, inode, fe_bh); |
525 | if (free_extents < 0) { | 525 | if (free_extents < 0) { |
526 | status = free_extents; | 526 | status = free_extents; |
527 | mlog_errno(status); | 527 | mlog_errno(status); |
@@ -609,7 +609,7 @@ leave: | |||
609 | * File systems which don't support holes call this from | 609 | * File systems which don't support holes call this from |
610 | * ocfs2_extend_allocation(). | 610 | * ocfs2_extend_allocation(). |
611 | */ | 611 | */ |
612 | int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di, | 612 | int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *di_bh, |
613 | u32 clusters_to_add, u32 extents_to_split, | 613 | u32 clusters_to_add, u32 extents_to_split, |
614 | struct ocfs2_alloc_context **data_ac, | 614 | struct ocfs2_alloc_context **data_ac, |
615 | struct ocfs2_alloc_context **meta_ac) | 615 | struct ocfs2_alloc_context **meta_ac) |
@@ -617,6 +617,7 @@ int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di, | |||
617 | int ret = 0, num_free_extents; | 617 | int ret = 0, num_free_extents; |
618 | unsigned int max_recs_needed = clusters_to_add + 2 * extents_to_split; | 618 | unsigned int max_recs_needed = clusters_to_add + 2 * extents_to_split; |
619 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 619 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
620 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | ||
620 | 621 | ||
621 | *meta_ac = NULL; | 622 | *meta_ac = NULL; |
622 | if (data_ac) | 623 | if (data_ac) |
@@ -629,7 +630,7 @@ int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di, | |||
629 | (unsigned long long)OCFS2_I(inode)->ip_blkno, (long long)i_size_read(inode), | 630 | (unsigned long long)OCFS2_I(inode)->ip_blkno, (long long)i_size_read(inode), |
630 | le32_to_cpu(di->i_clusters), clusters_to_add, extents_to_split); | 631 | le32_to_cpu(di->i_clusters), clusters_to_add, extents_to_split); |
631 | 632 | ||
632 | num_free_extents = ocfs2_num_free_extents(osb, inode, di); | 633 | num_free_extents = ocfs2_num_free_extents(osb, inode, di_bh); |
633 | if (num_free_extents < 0) { | 634 | if (num_free_extents < 0) { |
634 | ret = num_free_extents; | 635 | ret = num_free_extents; |
635 | mlog_errno(ret); | 636 | mlog_errno(ret); |
@@ -724,7 +725,7 @@ static int __ocfs2_extend_allocation(struct inode *inode, u32 logical_start, | |||
724 | restart_all: | 725 | restart_all: |
725 | BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); | 726 | BUG_ON(le32_to_cpu(fe->i_clusters) != OCFS2_I(inode)->ip_clusters); |
726 | 727 | ||
727 | status = ocfs2_lock_allocators(inode, fe, clusters_to_add, 0, &data_ac, | 728 | status = ocfs2_lock_allocators(inode, bh, clusters_to_add, 0, &data_ac, |
728 | &meta_ac); | 729 | &meta_ac); |
729 | if (status) { | 730 | if (status) { |
730 | mlog_errno(status); | 731 | mlog_errno(status); |
@@ -1395,7 +1396,7 @@ static int __ocfs2_remove_inode_range(struct inode *inode, | |||
1395 | struct ocfs2_alloc_context *meta_ac = NULL; | 1396 | struct ocfs2_alloc_context *meta_ac = NULL; |
1396 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; | 1397 | struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data; |
1397 | 1398 | ||
1398 | ret = ocfs2_lock_allocators(inode, di, 0, 1, NULL, &meta_ac); | 1399 | ret = ocfs2_lock_allocators(inode, di_bh, 0, 1, NULL, &meta_ac); |
1399 | if (ret) { | 1400 | if (ret) { |
1400 | mlog_errno(ret); | 1401 | mlog_errno(ret); |
1401 | return ret; | 1402 | return ret; |
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h index 5a6d3e48e4ba..c96b8054fbe7 100644 --- a/fs/ocfs2/file.h +++ b/fs/ocfs2/file.h | |||
@@ -57,7 +57,7 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb, | |||
57 | enum ocfs2_alloc_restarted *reason_ret); | 57 | enum ocfs2_alloc_restarted *reason_ret); |
58 | int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size, | 58 | int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size, |
59 | u64 zero_to); | 59 | u64 zero_to); |
60 | int ocfs2_lock_allocators(struct inode *inode, struct ocfs2_dinode *di, | 60 | int ocfs2_lock_allocators(struct inode *inode, struct buffer_head *fe, |
61 | u32 clusters_to_add, u32 extents_to_split, | 61 | u32 clusters_to_add, u32 extents_to_split, |
62 | struct ocfs2_alloc_context **data_ac, | 62 | struct ocfs2_alloc_context **data_ac, |
63 | struct ocfs2_alloc_context **meta_ac); | 63 | struct ocfs2_alloc_context **meta_ac); |