aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/suballoc.c
diff options
context:
space:
mode:
authorMark Fasheh <mark.fasheh@oracle.com>2007-09-16 23:10:16 -0400
committerMark Fasheh <mark.fasheh@oracle.com>2007-09-20 18:06:09 -0400
commit415cb800375cc4e89fb5a6a454e484bd4adbffb4 (patch)
tree816021a5279047702d5fa8180783b1c710f31746 /fs/ocfs2/suballoc.c
parent6d0b842d3bf0cc027dcff57a89fb8a6b1fd610e1 (diff)
ocfs2: Allow smaller allocations during large writes
The ocfs2 write code loops through a page much like the block code, except that ocfs2 allocation units can be any size, including larger than page size. Typically it's equal to or larger than page size - most kernels run 4k pages, the minimum ocfs2 allocation (cluster) size. Some changes introduced during 2.6.23 changed the way writes to pages are handled, and inadvertantly broke support for > 4k page size. Instead of just writing one cluster at a time, we now handle the whole page in one pass. This means that multiple (small) seperate allocations might happen in the same pass. The allocation code howver typically optimizes by getting the maximum which was reserved. This triggered a BUG_ON in the extend code where it'd ask for a single bit (for one part of a > 4k page) and get back more than it asked for. Fix this by providing a variant of the high level allocation function which allows the caller to specify a maximum. The traditional function remains and just calls the new one with a maximum determined from the initial reservation. Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/suballoc.c')
-rw-r--r--fs/ocfs2/suballoc.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index d9c5c9fcb30f..8f09f5235e3a 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -1486,21 +1486,21 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode,
1486 * contig. allocation, set to '1' to indicate we can deal with extents 1486 * contig. allocation, set to '1' to indicate we can deal with extents
1487 * of any size. 1487 * of any size.
1488 */ 1488 */
1489int ocfs2_claim_clusters(struct ocfs2_super *osb, 1489int __ocfs2_claim_clusters(struct ocfs2_super *osb,
1490 handle_t *handle, 1490 handle_t *handle,
1491 struct ocfs2_alloc_context *ac, 1491 struct ocfs2_alloc_context *ac,
1492 u32 min_clusters, 1492 u32 min_clusters,
1493 u32 *cluster_start, 1493 u32 max_clusters,
1494 u32 *num_clusters) 1494 u32 *cluster_start,
1495 u32 *num_clusters)
1495{ 1496{
1496 int status; 1497 int status;
1497 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; 1498 unsigned int bits_wanted = max_clusters;
1498 u64 bg_blkno = 0; 1499 u64 bg_blkno = 0;
1499 u16 bg_bit_off; 1500 u16 bg_bit_off;
1500 1501
1501 mlog_entry_void(); 1502 mlog_entry_void();
1502 1503
1503 BUG_ON(!ac);
1504 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); 1504 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted);
1505 1505
1506 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL 1506 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL
@@ -1557,6 +1557,19 @@ bail:
1557 return status; 1557 return status;
1558} 1558}
1559 1559
1560int ocfs2_claim_clusters(struct ocfs2_super *osb,
1561 handle_t *handle,
1562 struct ocfs2_alloc_context *ac,
1563 u32 min_clusters,
1564 u32 *cluster_start,
1565 u32 *num_clusters)
1566{
1567 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given;
1568
1569 return __ocfs2_claim_clusters(osb, handle, ac, min_clusters,
1570 bits_wanted, cluster_start, num_clusters);
1571}
1572
1560static inline int ocfs2_block_group_clear_bits(handle_t *handle, 1573static inline int ocfs2_block_group_clear_bits(handle_t *handle,
1561 struct inode *alloc_inode, 1574 struct inode *alloc_inode,
1562 struct ocfs2_group_desc *bg, 1575 struct ocfs2_group_desc *bg,