1 /* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
6 * metadata alloc and free
7 * Inspired by ext3 block groups.
9 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public
22 * License along with this program; if not, write to the
23 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 021110-1307, USA.
28 #include <linux/types.h>
29 #include <linux/slab.h>
30 #include <linux/highmem.h>
32 #define MLOG_MASK_PREFIX ML_DISK_ALLOC
33 #include <cluster/masklog.h>
41 #include "localalloc.h"
47 #include "buffer_head_io.h"
49 static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg);
50 static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe);
51 static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl);
52 static int ocfs2_block_group_fill(handle_t *handle,
53 struct inode *alloc_inode,
54 struct buffer_head *bg_bh,
57 struct ocfs2_chain_list *cl);
58 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
59 struct inode *alloc_inode,
60 struct buffer_head *bh);
62 static int ocfs2_cluster_group_search(struct inode *inode,
63 struct buffer_head *group_bh,
64 u32 bits_wanted, u32 min_bits,
65 u16 *bit_off, u16 *bits_found);
66 static int ocfs2_block_group_search(struct inode *inode,
67 struct buffer_head *group_bh,
68 u32 bits_wanted, u32 min_bits,
69 u16 *bit_off, u16 *bits_found);
70 static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
71 struct ocfs2_alloc_context *ac,
76 unsigned int *num_bits,
78 static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
80 static inline int ocfs2_block_group_set_bits(handle_t *handle,
81 struct inode *alloc_inode,
82 struct ocfs2_group_desc *bg,
83 struct buffer_head *group_bh,
85 unsigned int num_bits);
86 static inline int ocfs2_block_group_clear_bits(handle_t *handle,
87 struct inode *alloc_inode,
88 struct ocfs2_group_desc *bg,
89 struct buffer_head *group_bh,
91 unsigned int num_bits);
93 static int ocfs2_relink_block_group(handle_t *handle,
94 struct inode *alloc_inode,
95 struct buffer_head *fe_bh,
96 struct buffer_head *bg_bh,
97 struct buffer_head *prev_bg_bh,
99 static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg,
101 static inline u32 ocfs2_desc_bitmap_to_cluster_off(struct inode *inode,
104 static inline u64 ocfs2_which_cluster_group(struct inode *inode,
106 static inline void ocfs2_block_to_cluster_group(struct inode *inode,
111 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)
113 struct inode *inode = ac->ac_inode;
116 if (ac->ac_which != OCFS2_AC_USE_LOCAL)
117 ocfs2_meta_unlock(inode, 1);
119 mutex_unlock(&inode->i_mutex);
128 static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
130 return (u32)le16_to_cpu(cl->cl_cpg) * (u32)le16_to_cpu(cl->cl_bpc);
133 /* somewhat more expensive than our other checks, so use sparingly. */
134 static int ocfs2_check_group_descriptor(struct super_block *sb,
135 struct ocfs2_dinode *di,
136 struct ocfs2_group_desc *gd)
138 unsigned int max_bits;
140 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) {
141 OCFS2_RO_ON_INVALID_GROUP_DESC(sb, gd);
145 if (di->i_blkno != gd->bg_parent_dinode) {
146 ocfs2_error(sb, "Group descriptor # %llu has bad parent "
147 "pointer (%llu, expected %llu)",
148 (unsigned long long)le64_to_cpu(gd->bg_blkno),
149 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
150 (unsigned long long)le64_to_cpu(di->i_blkno));
154 max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc);
155 if (le16_to_cpu(gd->bg_bits) > max_bits) {
156 ocfs2_error(sb, "Group descriptor # %llu has bit count of %u",
157 (unsigned long long)le64_to_cpu(gd->bg_blkno),
158 le16_to_cpu(gd->bg_bits));
162 if (le16_to_cpu(gd->bg_chain) >=
163 le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
164 ocfs2_error(sb, "Group descriptor # %llu has bad chain %u",
165 (unsigned long long)le64_to_cpu(gd->bg_blkno),
166 le16_to_cpu(gd->bg_chain));
170 if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits)) {
171 ocfs2_error(sb, "Group descriptor # %llu has bit count %u but "
172 "claims that %u are free",
173 (unsigned long long)le64_to_cpu(gd->bg_blkno),
174 le16_to_cpu(gd->bg_bits),
175 le16_to_cpu(gd->bg_free_bits_count));
179 if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size))) {
180 ocfs2_error(sb, "Group descriptor # %llu has bit count %u but "
181 "max bitmap bits of %u",
182 (unsigned long long)le64_to_cpu(gd->bg_blkno),
183 le16_to_cpu(gd->bg_bits),
184 8 * le16_to_cpu(gd->bg_size));
191 static int ocfs2_block_group_fill(handle_t *handle,
192 struct inode *alloc_inode,
193 struct buffer_head *bg_bh,
196 struct ocfs2_chain_list *cl)
199 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
200 struct super_block * sb = alloc_inode->i_sb;
204 if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) {
205 ocfs2_error(alloc_inode->i_sb, "group block (%llu) != "
207 (unsigned long long)group_blkno,
208 (unsigned long long) bg_bh->b_blocknr);
213 status = ocfs2_journal_access(handle,
216 OCFS2_JOURNAL_ACCESS_CREATE);
222 memset(bg, 0, sb->s_blocksize);
223 strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE);
224 bg->bg_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation);
225 bg->bg_size = cpu_to_le16(ocfs2_group_bitmap_size(sb));
226 bg->bg_bits = cpu_to_le16(ocfs2_bits_per_group(cl));
227 bg->bg_chain = cpu_to_le16(my_chain);
228 bg->bg_next_group = cl->cl_recs[my_chain].c_blkno;
229 bg->bg_parent_dinode = cpu_to_le64(OCFS2_I(alloc_inode)->ip_blkno);
230 bg->bg_blkno = cpu_to_le64(group_blkno);
231 /* set the 1st bit in the bitmap to account for the descriptor block */
232 ocfs2_set_bit(0, (unsigned long *)bg->bg_bitmap);
233 bg->bg_free_bits_count = cpu_to_le16(le16_to_cpu(bg->bg_bits) - 1);
235 status = ocfs2_journal_dirty(handle, bg_bh);
239 /* There is no need to zero out or otherwise initialize the
240 * other blocks in a group - All valid FS metadata in a block
241 * group stores the superblock fs_generation value at
242 * allocation time. */
249 static inline u16 ocfs2_find_smallest_chain(struct ocfs2_chain_list *cl)
254 while (curr < le16_to_cpu(cl->cl_count)) {
255 if (le32_to_cpu(cl->cl_recs[best].c_total) >
256 le32_to_cpu(cl->cl_recs[curr].c_total))
264 * We expect the block group allocator to already be locked.
266 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
267 struct inode *alloc_inode,
268 struct buffer_head *bh)
271 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
272 struct ocfs2_chain_list *cl;
273 struct ocfs2_alloc_context *ac = NULL;
274 handle_t *handle = NULL;
275 u32 bit_off, num_bits;
278 struct buffer_head *bg_bh = NULL;
279 struct ocfs2_group_desc *bg;
281 BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode));
285 cl = &fe->id2.i_chain;
286 status = ocfs2_reserve_clusters(osb,
287 le16_to_cpu(cl->cl_cpg),
290 if (status != -ENOSPC)
295 credits = ocfs2_calc_group_alloc_credits(osb->sb,
296 le16_to_cpu(cl->cl_cpg));
297 handle = ocfs2_start_trans(osb, credits);
298 if (IS_ERR(handle)) {
299 status = PTR_ERR(handle);
305 status = ocfs2_claim_clusters(osb,
308 le16_to_cpu(cl->cl_cpg),
312 if (status != -ENOSPC)
317 alloc_rec = ocfs2_find_smallest_chain(cl);
319 /* setup the group */
320 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off);
321 mlog(0, "new descriptor, record %u, at block %llu\n",
322 alloc_rec, (unsigned long long)bg_blkno);
324 bg_bh = sb_getblk(osb->sb, bg_blkno);
330 ocfs2_set_new_buffer_uptodate(alloc_inode, bg_bh);
332 status = ocfs2_block_group_fill(handle,
343 bg = (struct ocfs2_group_desc *) bg_bh->b_data;
345 status = ocfs2_journal_access(handle, alloc_inode,
346 bh, OCFS2_JOURNAL_ACCESS_WRITE);
352 le32_add_cpu(&cl->cl_recs[alloc_rec].c_free,
353 le16_to_cpu(bg->bg_free_bits_count));
354 le32_add_cpu(&cl->cl_recs[alloc_rec].c_total, le16_to_cpu(bg->bg_bits));
355 cl->cl_recs[alloc_rec].c_blkno = cpu_to_le64(bg_blkno);
356 if (le16_to_cpu(cl->cl_next_free_rec) < le16_to_cpu(cl->cl_count))
357 le16_add_cpu(&cl->cl_next_free_rec, 1);
359 le32_add_cpu(&fe->id1.bitmap1.i_used, le16_to_cpu(bg->bg_bits) -
360 le16_to_cpu(bg->bg_free_bits_count));
361 le32_add_cpu(&fe->id1.bitmap1.i_total, le16_to_cpu(bg->bg_bits));
362 le32_add_cpu(&fe->i_clusters, le16_to_cpu(cl->cl_cpg));
364 status = ocfs2_journal_dirty(handle, bh);
370 spin_lock(&OCFS2_I(alloc_inode)->ip_lock);
371 OCFS2_I(alloc_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
372 fe->i_size = cpu_to_le64(ocfs2_clusters_to_bytes(alloc_inode->i_sb,
373 le32_to_cpu(fe->i_clusters)));
374 spin_unlock(&OCFS2_I(alloc_inode)->ip_lock);
375 i_size_write(alloc_inode, le64_to_cpu(fe->i_size));
376 alloc_inode->i_blocks = ocfs2_inode_sector_count(alloc_inode);
381 ocfs2_commit_trans(osb, handle);
384 ocfs2_free_alloc_context(ac);
393 static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
394 struct ocfs2_alloc_context *ac,
399 u32 bits_wanted = ac->ac_bits_wanted;
400 struct inode *alloc_inode;
401 struct buffer_head *bh = NULL;
402 struct ocfs2_dinode *fe;
407 alloc_inode = ocfs2_get_system_file_inode(osb, type, slot);
413 mutex_lock(&alloc_inode->i_mutex);
415 status = ocfs2_meta_lock(alloc_inode, &bh, 1);
417 mutex_unlock(&alloc_inode->i_mutex);
424 ac->ac_inode = alloc_inode;
426 fe = (struct ocfs2_dinode *) bh->b_data;
427 if (!OCFS2_IS_VALID_DINODE(fe)) {
428 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
432 if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) {
433 ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator %llu",
434 (unsigned long long)le64_to_cpu(fe->i_blkno));
439 free_bits = le32_to_cpu(fe->id1.bitmap1.i_total) -
440 le32_to_cpu(fe->id1.bitmap1.i_used);
442 if (bits_wanted > free_bits) {
443 /* cluster bitmap never grows */
444 if (ocfs2_is_cluster_bitmap(alloc_inode)) {
445 mlog(0, "Disk Full: wanted=%u, free_bits=%u\n",
446 bits_wanted, free_bits);
451 status = ocfs2_block_group_alloc(osb, alloc_inode, bh);
453 if (status != -ENOSPC)
457 atomic_inc(&osb->alloc_stats.bg_extends);
459 /* You should never ask for this much metadata */
461 (le32_to_cpu(fe->id1.bitmap1.i_total)
462 - le32_to_cpu(fe->id1.bitmap1.i_used)));
475 int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
476 struct ocfs2_dinode *fe,
477 struct ocfs2_alloc_context **ac)
482 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
489 (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe);
490 (*ac)->ac_which = OCFS2_AC_USE_META;
492 #ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS
495 slot = osb->slot_num;
498 (*ac)->ac_group_search = ocfs2_block_group_search;
500 status = ocfs2_reserve_suballoc_bits(osb, (*ac),
501 EXTENT_ALLOC_SYSTEM_INODE, slot);
503 if (status != -ENOSPC)
510 if ((status < 0) && *ac) {
511 ocfs2_free_alloc_context(*ac);
519 int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
520 struct ocfs2_alloc_context **ac)
524 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
531 (*ac)->ac_bits_wanted = 1;
532 (*ac)->ac_which = OCFS2_AC_USE_INODE;
534 (*ac)->ac_group_search = ocfs2_block_group_search;
536 status = ocfs2_reserve_suballoc_bits(osb, *ac,
537 INODE_ALLOC_SYSTEM_INODE,
540 if (status != -ENOSPC)
547 if ((status < 0) && *ac) {
548 ocfs2_free_alloc_context(*ac);
556 /* local alloc code has to do the same thing, so rather than do this
558 int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb,
559 struct ocfs2_alloc_context *ac)
563 ac->ac_which = OCFS2_AC_USE_MAIN;
564 ac->ac_group_search = ocfs2_cluster_group_search;
566 status = ocfs2_reserve_suballoc_bits(osb, ac,
567 GLOBAL_BITMAP_SYSTEM_INODE,
569 if (status < 0 && status != -ENOSPC) {
578 /* Callers don't need to care which bitmap (local alloc or main) to
579 * use so we figure it out for them, but unfortunately this clutters
581 int ocfs2_reserve_clusters(struct ocfs2_super *osb,
583 struct ocfs2_alloc_context **ac)
589 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
596 (*ac)->ac_bits_wanted = bits_wanted;
599 if (ocfs2_alloc_should_use_local(osb, bits_wanted)) {
600 status = ocfs2_reserve_local_alloc_bits(osb,
603 if ((status < 0) && (status != -ENOSPC)) {
606 } else if (status == -ENOSPC) {
607 /* reserve_local_bits will return enospc with
608 * the local alloc inode still locked, so we
609 * can change this safely here. */
610 mlog(0, "Disabling local alloc\n");
611 /* We set to OCFS2_LA_DISABLED so that umount
612 * can clean up what's left of the local
614 osb->local_alloc_state = OCFS2_LA_DISABLED;
618 if (status == -ENOSPC) {
619 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
621 if (status != -ENOSPC)
629 if ((status < 0) && *ac) {
630 ocfs2_free_alloc_context(*ac);
639 * More or less lifted from ext3. I'll leave their description below:
641 * "For ext3 allocations, we must not reuse any blocks which are
642 * allocated in the bitmap buffer's "last committed data" copy. This
643 * prevents deletes from freeing up the page for reuse until we have
644 * committed the delete transaction.
646 * If we didn't do this, then deleting something and reallocating it as
647 * data would allow the old block to be overwritten before the
648 * transaction committed (because we force data to disk before commit).
649 * This would lead to corruption if we crashed between overwriting the
650 * data and committing the delete.
652 * @@@ We may want to make this allocation behaviour conditional on
653 * data-writes at some point, and disable it for metadata allocations or
656 * Note: OCFS2 already does this differently for metadata vs data
657 * allocations, as those bitmaps are seperate and undo access is never
658 * called on a metadata group descriptor.
660 static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
663 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
665 if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
667 if (!buffer_jbd(bg_bh) || !bh2jh(bg_bh)->b_committed_data)
670 bg = (struct ocfs2_group_desc *) bh2jh(bg_bh)->b_committed_data;
671 return !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
674 static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
675 struct buffer_head *bg_bh,
676 unsigned int bits_wanted,
677 unsigned int total_bits,
682 u16 best_offset, best_size;
683 int offset, start, found, status = 0;
684 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
686 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
687 OCFS2_RO_ON_INVALID_GROUP_DESC(osb->sb, bg);
691 found = start = best_offset = best_size = 0;
692 bitmap = bg->bg_bitmap;
694 while((offset = ocfs2_find_next_zero_bit(bitmap, total_bits, start)) != -1) {
695 if (offset == total_bits)
698 if (!ocfs2_test_bg_bit_allocatable(bg_bh, offset)) {
699 /* We found a zero, but we can't use it as it
700 * hasn't been put to disk yet! */
703 } else if (offset == start) {
704 /* we found a zero */
706 /* move start to the next bit to test */
709 /* got a zero after some ones */
713 if (found > best_size) {
715 best_offset = start - found;
717 /* we got everything we needed */
718 if (found == bits_wanted) {
719 /* mlog(0, "Found it all!\n"); */
724 /* XXX: I think the first clause is equivalent to the second
726 if (found == bits_wanted) {
727 *bit_off = start - found;
729 } else if (best_size) {
730 *bit_off = best_offset;
731 *bits_found = best_size;
734 /* No error log here -- see the comment above
735 * ocfs2_test_bg_bit_allocatable */
741 static inline int ocfs2_block_group_set_bits(handle_t *handle,
742 struct inode *alloc_inode,
743 struct ocfs2_group_desc *bg,
744 struct buffer_head *group_bh,
745 unsigned int bit_off,
746 unsigned int num_bits)
749 void *bitmap = bg->bg_bitmap;
750 int journal_type = OCFS2_JOURNAL_ACCESS_WRITE;
754 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
755 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg);
759 BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits);
761 mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off,
764 if (ocfs2_is_cluster_bitmap(alloc_inode))
765 journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
767 status = ocfs2_journal_access(handle,
776 le16_add_cpu(&bg->bg_free_bits_count, -num_bits);
779 ocfs2_set_bit(bit_off++, bitmap);
781 status = ocfs2_journal_dirty(handle,
793 /* find the one with the most empty bits */
794 static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl)
798 BUG_ON(!cl->cl_next_free_rec);
801 while (curr < le16_to_cpu(cl->cl_next_free_rec)) {
802 if (le32_to_cpu(cl->cl_recs[curr].c_free) >
803 le32_to_cpu(cl->cl_recs[best].c_free))
808 BUG_ON(best >= le16_to_cpu(cl->cl_next_free_rec));
812 static int ocfs2_relink_block_group(handle_t *handle,
813 struct inode *alloc_inode,
814 struct buffer_head *fe_bh,
815 struct buffer_head *bg_bh,
816 struct buffer_head *prev_bg_bh,
820 /* there is a really tiny chance the journal calls could fail,
821 * but we wouldn't want inconsistent blocks in *any* case. */
822 u64 fe_ptr, bg_ptr, prev_bg_ptr;
823 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
824 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
825 struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data;
827 if (!OCFS2_IS_VALID_DINODE(fe)) {
828 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
832 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
833 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg);
837 if (!OCFS2_IS_VALID_GROUP_DESC(prev_bg)) {
838 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, prev_bg);
843 mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n",
844 (unsigned long long)le64_to_cpu(fe->i_blkno), chain,
845 (unsigned long long)le64_to_cpu(bg->bg_blkno),
846 (unsigned long long)le64_to_cpu(prev_bg->bg_blkno));
848 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno);
849 bg_ptr = le64_to_cpu(bg->bg_next_group);
850 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group);
852 status = ocfs2_journal_access(handle, alloc_inode, prev_bg_bh,
853 OCFS2_JOURNAL_ACCESS_WRITE);
859 prev_bg->bg_next_group = bg->bg_next_group;
861 status = ocfs2_journal_dirty(handle, prev_bg_bh);
867 status = ocfs2_journal_access(handle, alloc_inode, bg_bh,
868 OCFS2_JOURNAL_ACCESS_WRITE);
874 bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;
876 status = ocfs2_journal_dirty(handle, bg_bh);
882 status = ocfs2_journal_access(handle, alloc_inode, fe_bh,
883 OCFS2_JOURNAL_ACCESS_WRITE);
889 fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;
891 status = ocfs2_journal_dirty(handle, fe_bh);
900 fe->id2.i_chain.cl_recs[chain].c_blkno = cpu_to_le64(fe_ptr);
901 bg->bg_next_group = cpu_to_le64(bg_ptr);
902 prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr);
909 static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg,
912 return le16_to_cpu(bg->bg_free_bits_count) > wanted;
915 /* return 0 on success, -ENOSPC to keep searching and any other < 0
917 static int ocfs2_cluster_group_search(struct inode *inode,
918 struct buffer_head *group_bh,
919 u32 bits_wanted, u32 min_bits,
920 u16 *bit_off, u16 *bits_found)
922 int search = -ENOSPC;
924 struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *) group_bh->b_data;
925 u16 tmp_off, tmp_found;
926 unsigned int max_bits, gd_cluster_off;
928 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
930 if (gd->bg_free_bits_count) {
931 max_bits = le16_to_cpu(gd->bg_bits);
933 /* Tail groups in cluster bitmaps which aren't cpg
934 * aligned are prone to partial extention by a failed
935 * fs resize. If the file system resize never got to
936 * update the dinode cluster count, then we don't want
937 * to trust any clusters past it, regardless of what
938 * the group descriptor says. */
939 gd_cluster_off = ocfs2_blocks_to_clusters(inode->i_sb,
940 le64_to_cpu(gd->bg_blkno));
941 if ((gd_cluster_off + max_bits) >
942 OCFS2_I(inode)->ip_clusters) {
943 max_bits = OCFS2_I(inode)->ip_clusters - gd_cluster_off;
944 mlog(0, "Desc %llu, bg_bits %u, clusters %u, use %u\n",
945 (unsigned long long)le64_to_cpu(gd->bg_blkno),
946 le16_to_cpu(gd->bg_bits),
947 OCFS2_I(inode)->ip_clusters, max_bits);
950 ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb),
951 group_bh, bits_wanted,
953 &tmp_off, &tmp_found);
957 /* ocfs2_block_group_find_clear_bits() might
958 * return success, but we still want to return
959 * -ENOSPC unless it found the minimum number
961 if (min_bits <= tmp_found) {
963 *bits_found = tmp_found;
964 search = 0; /* success */
971 static int ocfs2_block_group_search(struct inode *inode,
972 struct buffer_head *group_bh,
973 u32 bits_wanted, u32 min_bits,
974 u16 *bit_off, u16 *bits_found)
977 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) group_bh->b_data;
979 BUG_ON(min_bits != 1);
980 BUG_ON(ocfs2_is_cluster_bitmap(inode));
982 if (bg->bg_free_bits_count)
983 ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb),
984 group_bh, bits_wanted,
985 le16_to_cpu(bg->bg_bits),
986 bit_off, bits_found);
991 static int ocfs2_alloc_dinode_update_counts(struct inode *inode,
993 struct buffer_head *di_bh,
999 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
1000 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &di->id2.i_chain;
1002 ret = ocfs2_journal_access(handle, inode, di_bh,
1003 OCFS2_JOURNAL_ACCESS_WRITE);
1009 tmp_used = le32_to_cpu(di->id1.bitmap1.i_used);
1010 di->id1.bitmap1.i_used = cpu_to_le32(num_bits + tmp_used);
1011 le32_add_cpu(&cl->cl_recs[chain].c_free, -num_bits);
1013 ret = ocfs2_journal_dirty(handle, di_bh);
1021 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac,
1026 unsigned int *num_bits,
1032 struct buffer_head *group_bh = NULL;
1033 struct ocfs2_group_desc *gd;
1034 struct inode *alloc_inode = ac->ac_inode;
1036 ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno,
1037 &group_bh, OCFS2_BH_CACHED, alloc_inode);
1043 gd = (struct ocfs2_group_desc *) group_bh->b_data;
1044 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) {
1045 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, gd);
1050 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits,
1060 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh,
1062 le16_to_cpu(gd->bg_chain));
1068 ret = ocfs2_block_group_set_bits(handle, alloc_inode, gd, group_bh,
1069 *bit_off, *num_bits);
1073 *bits_left = le16_to_cpu(gd->bg_free_bits_count);
1081 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1086 unsigned int *num_bits,
1091 u16 chain, tmp_bits;
1094 struct inode *alloc_inode = ac->ac_inode;
1095 struct buffer_head *group_bh = NULL;
1096 struct buffer_head *prev_group_bh = NULL;
1097 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data;
1098 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &fe->id2.i_chain;
1099 struct ocfs2_group_desc *bg;
1101 chain = ac->ac_chain;
1102 mlog(0, "trying to alloc %u bits from chain %u, inode %llu\n",
1104 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno);
1106 status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb),
1107 le64_to_cpu(cl->cl_recs[chain].c_blkno),
1108 &group_bh, OCFS2_BH_CACHED, alloc_inode);
1113 bg = (struct ocfs2_group_desc *) group_bh->b_data;
1114 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, bg);
1121 /* for now, the chain search is a bit simplistic. We just use
1122 * the 1st group with any empty bits. */
1123 while ((status = ac->ac_group_search(alloc_inode, group_bh,
1124 bits_wanted, min_bits, bit_off,
1125 &tmp_bits)) == -ENOSPC) {
1126 if (!bg->bg_next_group)
1129 if (prev_group_bh) {
1130 brelse(prev_group_bh);
1131 prev_group_bh = NULL;
1133 next_group = le64_to_cpu(bg->bg_next_group);
1134 prev_group_bh = group_bh;
1136 status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb),
1137 next_group, &group_bh,
1138 OCFS2_BH_CACHED, alloc_inode);
1143 bg = (struct ocfs2_group_desc *) group_bh->b_data;
1144 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, bg);
1151 if (status != -ENOSPC)
1156 mlog(0, "alloc succeeds: we give %u bits from block group %llu\n",
1157 tmp_bits, (unsigned long long)le64_to_cpu(bg->bg_blkno));
1159 *num_bits = tmp_bits;
1161 BUG_ON(*num_bits == 0);
1164 * Keep track of previous block descriptor read. When
1165 * we find a target, if we have read more than X
1166 * number of descriptors, and the target is reasonably
1167 * empty, relink him to top of his chain.
1169 * We've read 0 extra blocks and only send one more to
1170 * the transaction, yet the next guy to search has a
1173 * Do this *after* figuring out how many bits we're taking out
1174 * of our target group.
1176 if (ac->ac_allow_chain_relink &&
1178 (ocfs2_block_group_reasonably_empty(bg, *num_bits))) {
1179 status = ocfs2_relink_block_group(handle, alloc_inode,
1180 ac->ac_bh, group_bh,
1181 prev_group_bh, chain);
1188 /* Ok, claim our bits now: set the info on dinode, chainlist
1189 * and then the group */
1190 status = ocfs2_journal_access(handle,
1193 OCFS2_JOURNAL_ACCESS_WRITE);
1199 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used);
1200 fe->id1.bitmap1.i_used = cpu_to_le32(*num_bits + tmp_used);
1201 le32_add_cpu(&cl->cl_recs[chain].c_free, -(*num_bits));
1203 status = ocfs2_journal_dirty(handle,
1210 status = ocfs2_block_group_set_bits(handle,
1221 mlog(0, "Allocated %u bits from suballocator %llu\n", *num_bits,
1222 (unsigned long long)le64_to_cpu(fe->i_blkno));
1224 *bg_blkno = le64_to_cpu(bg->bg_blkno);
1225 *bits_left = le16_to_cpu(bg->bg_free_bits_count);
1230 brelse(prev_group_bh);
1236 /* will give out up to bits_wanted contiguous bits. */
1237 static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1238 struct ocfs2_alloc_context *ac,
1243 unsigned int *num_bits,
1249 u64 hint_blkno = ac->ac_last_group;
1250 struct ocfs2_chain_list *cl;
1251 struct ocfs2_dinode *fe;
1255 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted);
1256 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given));
1259 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data;
1260 if (!OCFS2_IS_VALID_DINODE(fe)) {
1261 OCFS2_RO_ON_INVALID_DINODE(osb->sb, fe);
1265 if (le32_to_cpu(fe->id1.bitmap1.i_used) >=
1266 le32_to_cpu(fe->id1.bitmap1.i_total)) {
1267 ocfs2_error(osb->sb, "Chain allocator dinode %llu has %u used "
1268 "bits but only %u total.",
1269 (unsigned long long)le64_to_cpu(fe->i_blkno),
1270 le32_to_cpu(fe->id1.bitmap1.i_used),
1271 le32_to_cpu(fe->id1.bitmap1.i_total));
1277 /* Attempt to short-circuit the usual search mechanism
1278 * by jumping straight to the most recently used
1279 * allocation group. This helps us mantain some
1280 * contiguousness across allocations. */
1281 status = ocfs2_search_one_group(ac, handle, bits_wanted,
1282 min_bits, bit_off, num_bits,
1283 hint_blkno, &bits_left);
1285 /* Be careful to update *bg_blkno here as the
1286 * caller is expecting it to be filled in, and
1287 * ocfs2_search_one_group() won't do that for
1289 *bg_blkno = hint_blkno;
1292 if (status < 0 && status != -ENOSPC) {
1298 cl = (struct ocfs2_chain_list *) &fe->id2.i_chain;
1300 victim = ocfs2_find_victim_chain(cl);
1301 ac->ac_chain = victim;
1302 ac->ac_allow_chain_relink = 1;
1304 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, bit_off,
1305 num_bits, bg_blkno, &bits_left);
1308 if (status < 0 && status != -ENOSPC) {
1313 mlog(0, "Search of victim chain %u came up with nothing, "
1314 "trying all chains now.\n", victim);
1316 /* If we didn't pick a good victim, then just default to
1317 * searching each chain in order. Don't allow chain relinking
1318 * because we only calculate enough journal credits for one
1319 * relink per alloc. */
1320 ac->ac_allow_chain_relink = 0;
1321 for (i = 0; i < le16_to_cpu(cl->cl_next_free_rec); i ++) {
1324 if (!cl->cl_recs[i].c_free)
1328 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
1329 bit_off, num_bits, bg_blkno,
1333 if (status < 0 && status != -ENOSPC) {
1340 if (status != -ENOSPC) {
1341 /* If the next search of this group is not likely to
1342 * yield a suitable extent, then we reset the last
1343 * group hint so as to not waste a disk read */
1344 if (bits_left < min_bits)
1345 ac->ac_last_group = 0;
1347 ac->ac_last_group = *bg_blkno;
1355 int ocfs2_claim_metadata(struct ocfs2_super *osb,
1357 struct ocfs2_alloc_context *ac,
1359 u16 *suballoc_bit_start,
1360 unsigned int *num_bits,
1367 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted));
1368 BUG_ON(ac->ac_which != OCFS2_AC_USE_META);
1370 status = ocfs2_claim_suballoc_bits(osb,
1382 atomic_inc(&osb->alloc_stats.bg_allocs);
1384 *blkno_start = bg_blkno + (u64) *suballoc_bit_start;
1385 ac->ac_bits_given += (*num_bits);
1392 int ocfs2_claim_new_inode(struct ocfs2_super *osb,
1394 struct ocfs2_alloc_context *ac,
1399 unsigned int num_bits;
1405 BUG_ON(ac->ac_bits_given != 0);
1406 BUG_ON(ac->ac_bits_wanted != 1);
1407 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE);
1409 status = ocfs2_claim_suballoc_bits(osb,
1421 atomic_inc(&osb->alloc_stats.bg_allocs);
1423 BUG_ON(num_bits != 1);
1425 *fe_blkno = bg_blkno + (u64) (*suballoc_bit);
1426 ac->ac_bits_given++;
1433 /* translate a group desc. blkno and it's bitmap offset into
1434 * disk cluster offset. */
1435 static inline u32 ocfs2_desc_bitmap_to_cluster_off(struct inode *inode,
1439 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1442 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
1444 if (bg_blkno != osb->first_cluster_group_blkno)
1445 cluster = ocfs2_blocks_to_clusters(inode->i_sb, bg_blkno);
1446 cluster += (u32) bg_bit_off;
1450 /* given a cluster offset, calculate which block group it belongs to
1451 * and return that block offset. */
1452 static inline u64 ocfs2_which_cluster_group(struct inode *inode,
1455 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1458 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
1460 group_no = cluster / osb->bitmap_cpg;
1462 return osb->first_cluster_group_blkno;
1463 return ocfs2_clusters_to_blocks(inode->i_sb,
1464 group_no * osb->bitmap_cpg);
1467 /* given the block number of a cluster start, calculate which cluster
1468 * group and descriptor bitmap offset that corresponds to. */
1469 static inline void ocfs2_block_to_cluster_group(struct inode *inode,
1474 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1475 u32 data_cluster = ocfs2_blocks_to_clusters(osb->sb, data_blkno);
1477 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
1479 *bg_blkno = ocfs2_which_cluster_group(inode,
1482 if (*bg_blkno == osb->first_cluster_group_blkno)
1483 *bg_bit_off = (u16) data_cluster;
1485 *bg_bit_off = (u16) ocfs2_blocks_to_clusters(osb->sb,
1486 data_blkno - *bg_blkno);
1490 * min_bits - minimum contiguous chunk from this total allocation we
1491 * can handle. set to what we asked for originally for a full
1492 * contig. allocation, set to '1' to indicate we can deal with extents
1495 int ocfs2_claim_clusters(struct ocfs2_super *osb,
1497 struct ocfs2_alloc_context *ac,
1503 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given;
1510 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted);
1512 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL
1513 && ac->ac_which != OCFS2_AC_USE_MAIN);
1515 if (ac->ac_which == OCFS2_AC_USE_LOCAL) {
1516 status = ocfs2_claim_local_alloc_bits(osb,
1523 atomic_inc(&osb->alloc_stats.local_data);
1525 if (min_clusters > (osb->bitmap_cpg - 1)) {
1526 /* The only paths asking for contiguousness
1527 * should know about this already. */
1528 mlog(ML_ERROR, "minimum allocation requested exceeds "
1529 "group bitmap size!");
1533 /* clamp the current request down to a realistic size. */
1534 if (bits_wanted > (osb->bitmap_cpg - 1))
1535 bits_wanted = osb->bitmap_cpg - 1;
1537 status = ocfs2_claim_suballoc_bits(osb,
1547 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
1550 atomic_inc(&osb->alloc_stats.bitmap_data);
1554 if (status != -ENOSPC)
1559 ac->ac_bits_given += *num_clusters;
1566 static inline int ocfs2_block_group_clear_bits(handle_t *handle,
1567 struct inode *alloc_inode,
1568 struct ocfs2_group_desc *bg,
1569 struct buffer_head *group_bh,
1570 unsigned int bit_off,
1571 unsigned int num_bits)
1575 int journal_type = OCFS2_JOURNAL_ACCESS_WRITE;
1576 struct ocfs2_group_desc *undo_bg = NULL;
1580 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
1581 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg);
1586 mlog(0, "off = %u, num = %u\n", bit_off, num_bits);
1588 if (ocfs2_is_cluster_bitmap(alloc_inode))
1589 journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
1591 status = ocfs2_journal_access(handle, alloc_inode, group_bh,
1598 if (ocfs2_is_cluster_bitmap(alloc_inode))
1599 undo_bg = (struct ocfs2_group_desc *) bh2jh(group_bh)->b_committed_data;
1603 ocfs2_clear_bit((bit_off + tmp),
1604 (unsigned long *) bg->bg_bitmap);
1605 if (ocfs2_is_cluster_bitmap(alloc_inode))
1606 ocfs2_set_bit(bit_off + tmp,
1607 (unsigned long *) undo_bg->bg_bitmap);
1609 le16_add_cpu(&bg->bg_free_bits_count, num_bits);
1611 status = ocfs2_journal_dirty(handle, group_bh);
1619 * expects the suballoc inode to already be locked.
1621 int ocfs2_free_suballoc_bits(handle_t *handle,
1622 struct inode *alloc_inode,
1623 struct buffer_head *alloc_bh,
1624 unsigned int start_bit,
1630 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
1631 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) alloc_bh->b_data;
1632 struct ocfs2_chain_list *cl = &fe->id2.i_chain;
1633 struct buffer_head *group_bh = NULL;
1634 struct ocfs2_group_desc *group;
1638 if (!OCFS2_IS_VALID_DINODE(fe)) {
1639 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
1643 BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl));
1645 mlog(0, "%llu: freeing %u bits from group %llu, starting at %u\n",
1646 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count,
1647 (unsigned long long)bg_blkno, start_bit);
1649 status = ocfs2_read_block(osb, bg_blkno, &group_bh, OCFS2_BH_CACHED,
1656 group = (struct ocfs2_group_desc *) group_bh->b_data;
1657 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, group);
1662 BUG_ON((count + start_bit) > le16_to_cpu(group->bg_bits));
1664 status = ocfs2_block_group_clear_bits(handle, alloc_inode,
1672 status = ocfs2_journal_access(handle, alloc_inode, alloc_bh,
1673 OCFS2_JOURNAL_ACCESS_WRITE);
1679 le32_add_cpu(&cl->cl_recs[le16_to_cpu(group->bg_chain)].c_free,
1681 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used);
1682 fe->id1.bitmap1.i_used = cpu_to_le32(tmp_used - count);
1684 status = ocfs2_journal_dirty(handle, alloc_bh);
1698 int ocfs2_free_dinode(handle_t *handle,
1699 struct inode *inode_alloc_inode,
1700 struct buffer_head *inode_alloc_bh,
1701 struct ocfs2_dinode *di)
1703 u64 blk = le64_to_cpu(di->i_blkno);
1704 u16 bit = le16_to_cpu(di->i_suballoc_bit);
1705 u64 bg_blkno = ocfs2_which_suballoc_group(blk, bit);
1707 return ocfs2_free_suballoc_bits(handle, inode_alloc_inode,
1708 inode_alloc_bh, bit, bg_blkno, 1);
1711 int ocfs2_free_clusters(handle_t *handle,
1712 struct inode *bitmap_inode,
1713 struct buffer_head *bitmap_bh,
1715 unsigned int num_clusters)
1720 struct ocfs2_dinode *fe;
1722 /* You can't ever have a contiguous set of clusters
1723 * bigger than a block group bitmap so we never have to worry
1724 * about looping on them. */
1728 /* This is expensive. We can safely remove once this stuff has
1729 * gotten tested really well. */
1730 BUG_ON(start_blk != ocfs2_clusters_to_blocks(bitmap_inode->i_sb, ocfs2_blocks_to_clusters(bitmap_inode->i_sb, start_blk)));
1732 fe = (struct ocfs2_dinode *) bitmap_bh->b_data;
1734 ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno,
1737 mlog(0, "want to free %u clusters starting at block %llu\n",
1738 num_clusters, (unsigned long long)start_blk);
1739 mlog(0, "bg_blkno = %llu, bg_start_bit = %u\n",
1740 (unsigned long long)bg_blkno, bg_start_bit);
1742 status = ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh,
1743 bg_start_bit, bg_blkno,
1752 static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg)
1754 printk("Block Group:\n");
1755 printk("bg_signature: %s\n", bg->bg_signature);
1756 printk("bg_size: %u\n", bg->bg_size);
1757 printk("bg_bits: %u\n", bg->bg_bits);
1758 printk("bg_free_bits_count: %u\n", bg->bg_free_bits_count);
1759 printk("bg_chain: %u\n", bg->bg_chain);
1760 printk("bg_generation: %u\n", le32_to_cpu(bg->bg_generation));
1761 printk("bg_next_group: %llu\n",
1762 (unsigned long long)bg->bg_next_group);
1763 printk("bg_parent_dinode: %llu\n",
1764 (unsigned long long)bg->bg_parent_dinode);
1765 printk("bg_blkno: %llu\n",
1766 (unsigned long long)bg->bg_blkno);
1769 static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe)
1773 printk("Suballoc Inode %llu:\n", (unsigned long long)fe->i_blkno);
1774 printk("i_signature: %s\n", fe->i_signature);
1775 printk("i_size: %llu\n",
1776 (unsigned long long)fe->i_size);
1777 printk("i_clusters: %u\n", fe->i_clusters);
1778 printk("i_generation: %u\n",
1779 le32_to_cpu(fe->i_generation));
1780 printk("id1.bitmap1.i_used: %u\n",
1781 le32_to_cpu(fe->id1.bitmap1.i_used));
1782 printk("id1.bitmap1.i_total: %u\n",
1783 le32_to_cpu(fe->id1.bitmap1.i_total));
1784 printk("id2.i_chain.cl_cpg: %u\n", fe->id2.i_chain.cl_cpg);
1785 printk("id2.i_chain.cl_bpc: %u\n", fe->id2.i_chain.cl_bpc);
1786 printk("id2.i_chain.cl_count: %u\n", fe->id2.i_chain.cl_count);
1787 printk("id2.i_chain.cl_next_free_rec: %u\n",
1788 fe->id2.i_chain.cl_next_free_rec);
1789 for(i = 0; i < fe->id2.i_chain.cl_next_free_rec; i++) {
1790 printk("fe->id2.i_chain.cl_recs[%d].c_free: %u\n", i,
1791 fe->id2.i_chain.cl_recs[i].c_free);
1792 printk("fe->id2.i_chain.cl_recs[%d].c_total: %u\n", i,
1793 fe->id2.i_chain.cl_recs[i].c_total);
1794 printk("fe->id2.i_chain.cl_recs[%d].c_blkno: %llu\n", i,
1795 (unsigned long long)fe->id2.i_chain.cl_recs[i].c_blkno);