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 #define NOT_ALLOC_NEW_GROUP 0
50 #define ALLOC_NEW_GROUP 1
52 static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg);
53 static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe);
54 static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl);
55 static int ocfs2_block_group_fill(handle_t *handle,
56 struct inode *alloc_inode,
57 struct buffer_head *bg_bh,
60 struct ocfs2_chain_list *cl);
61 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
62 struct inode *alloc_inode,
63 struct buffer_head *bh);
65 static int ocfs2_cluster_group_search(struct inode *inode,
66 struct buffer_head *group_bh,
67 u32 bits_wanted, u32 min_bits,
68 u16 *bit_off, u16 *bits_found);
69 static int ocfs2_block_group_search(struct inode *inode,
70 struct buffer_head *group_bh,
71 u32 bits_wanted, u32 min_bits,
72 u16 *bit_off, u16 *bits_found);
73 static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
74 struct ocfs2_alloc_context *ac,
79 unsigned int *num_bits,
81 static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
83 static inline int ocfs2_block_group_set_bits(handle_t *handle,
84 struct inode *alloc_inode,
85 struct ocfs2_group_desc *bg,
86 struct buffer_head *group_bh,
88 unsigned int num_bits);
89 static inline int ocfs2_block_group_clear_bits(handle_t *handle,
90 struct inode *alloc_inode,
91 struct ocfs2_group_desc *bg,
92 struct buffer_head *group_bh,
94 unsigned int num_bits);
96 static int ocfs2_relink_block_group(handle_t *handle,
97 struct inode *alloc_inode,
98 struct buffer_head *fe_bh,
99 struct buffer_head *bg_bh,
100 struct buffer_head *prev_bg_bh,
102 static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg,
104 static inline u32 ocfs2_desc_bitmap_to_cluster_off(struct inode *inode,
107 static inline void ocfs2_block_to_cluster_group(struct inode *inode,
112 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac)
114 struct inode *inode = ac->ac_inode;
117 if (ac->ac_which != OCFS2_AC_USE_LOCAL)
118 ocfs2_inode_unlock(inode, 1);
120 mutex_unlock(&inode->i_mutex);
129 static u32 ocfs2_bits_per_group(struct ocfs2_chain_list *cl)
131 return (u32)le16_to_cpu(cl->cl_cpg) * (u32)le16_to_cpu(cl->cl_bpc);
134 /* somewhat more expensive than our other checks, so use sparingly. */
135 int ocfs2_check_group_descriptor(struct super_block *sb,
136 struct ocfs2_dinode *di,
137 struct ocfs2_group_desc *gd)
139 unsigned int max_bits;
141 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) {
142 OCFS2_RO_ON_INVALID_GROUP_DESC(sb, gd);
146 if (di->i_blkno != gd->bg_parent_dinode) {
147 ocfs2_error(sb, "Group descriptor # %llu has bad parent "
148 "pointer (%llu, expected %llu)",
149 (unsigned long long)le64_to_cpu(gd->bg_blkno),
150 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
151 (unsigned long long)le64_to_cpu(di->i_blkno));
155 max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) * le16_to_cpu(di->id2.i_chain.cl_bpc);
156 if (le16_to_cpu(gd->bg_bits) > max_bits) {
157 ocfs2_error(sb, "Group descriptor # %llu has bit count of %u",
158 (unsigned long long)le64_to_cpu(gd->bg_blkno),
159 le16_to_cpu(gd->bg_bits));
163 if (le16_to_cpu(gd->bg_chain) >=
164 le16_to_cpu(di->id2.i_chain.cl_next_free_rec)) {
165 ocfs2_error(sb, "Group descriptor # %llu has bad chain %u",
166 (unsigned long long)le64_to_cpu(gd->bg_blkno),
167 le16_to_cpu(gd->bg_chain));
171 if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits)) {
172 ocfs2_error(sb, "Group descriptor # %llu has bit count %u but "
173 "claims that %u are free",
174 (unsigned long long)le64_to_cpu(gd->bg_blkno),
175 le16_to_cpu(gd->bg_bits),
176 le16_to_cpu(gd->bg_free_bits_count));
180 if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size))) {
181 ocfs2_error(sb, "Group descriptor # %llu has bit count %u but "
182 "max bitmap bits of %u",
183 (unsigned long long)le64_to_cpu(gd->bg_blkno),
184 le16_to_cpu(gd->bg_bits),
185 8 * le16_to_cpu(gd->bg_size));
192 static int ocfs2_block_group_fill(handle_t *handle,
193 struct inode *alloc_inode,
194 struct buffer_head *bg_bh,
197 struct ocfs2_chain_list *cl)
200 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
201 struct super_block * sb = alloc_inode->i_sb;
205 if (((unsigned long long) bg_bh->b_blocknr) != group_blkno) {
206 ocfs2_error(alloc_inode->i_sb, "group block (%llu) != "
208 (unsigned long long)group_blkno,
209 (unsigned long long) bg_bh->b_blocknr);
214 status = ocfs2_journal_access(handle,
217 OCFS2_JOURNAL_ACCESS_CREATE);
223 memset(bg, 0, sb->s_blocksize);
224 strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE);
225 bg->bg_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation);
226 bg->bg_size = cpu_to_le16(ocfs2_group_bitmap_size(sb));
227 bg->bg_bits = cpu_to_le16(ocfs2_bits_per_group(cl));
228 bg->bg_chain = cpu_to_le16(my_chain);
229 bg->bg_next_group = cl->cl_recs[my_chain].c_blkno;
230 bg->bg_parent_dinode = cpu_to_le64(OCFS2_I(alloc_inode)->ip_blkno);
231 bg->bg_blkno = cpu_to_le64(group_blkno);
232 /* set the 1st bit in the bitmap to account for the descriptor block */
233 ocfs2_set_bit(0, (unsigned long *)bg->bg_bitmap);
234 bg->bg_free_bits_count = cpu_to_le16(le16_to_cpu(bg->bg_bits) - 1);
236 status = ocfs2_journal_dirty(handle, bg_bh);
240 /* There is no need to zero out or otherwise initialize the
241 * other blocks in a group - All valid FS metadata in a block
242 * group stores the superblock fs_generation value at
243 * allocation time. */
250 static inline u16 ocfs2_find_smallest_chain(struct ocfs2_chain_list *cl)
255 while (curr < le16_to_cpu(cl->cl_count)) {
256 if (le32_to_cpu(cl->cl_recs[best].c_total) >
257 le32_to_cpu(cl->cl_recs[curr].c_total))
265 * We expect the block group allocator to already be locked.
267 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
268 struct inode *alloc_inode,
269 struct buffer_head *bh)
272 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data;
273 struct ocfs2_chain_list *cl;
274 struct ocfs2_alloc_context *ac = NULL;
275 handle_t *handle = NULL;
276 u32 bit_off, num_bits;
279 struct buffer_head *bg_bh = NULL;
280 struct ocfs2_group_desc *bg;
282 BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode));
286 cl = &fe->id2.i_chain;
287 status = ocfs2_reserve_clusters(osb,
288 le16_to_cpu(cl->cl_cpg),
291 if (status != -ENOSPC)
296 credits = ocfs2_calc_group_alloc_credits(osb->sb,
297 le16_to_cpu(cl->cl_cpg));
298 handle = ocfs2_start_trans(osb, credits);
299 if (IS_ERR(handle)) {
300 status = PTR_ERR(handle);
306 status = ocfs2_claim_clusters(osb,
309 le16_to_cpu(cl->cl_cpg),
313 if (status != -ENOSPC)
318 alloc_rec = ocfs2_find_smallest_chain(cl);
320 /* setup the group */
321 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off);
322 mlog(0, "new descriptor, record %u, at block %llu\n",
323 alloc_rec, (unsigned long long)bg_blkno);
325 bg_bh = sb_getblk(osb->sb, bg_blkno);
331 ocfs2_set_new_buffer_uptodate(alloc_inode, bg_bh);
333 status = ocfs2_block_group_fill(handle,
344 bg = (struct ocfs2_group_desc *) bg_bh->b_data;
346 status = ocfs2_journal_access(handle, alloc_inode,
347 bh, OCFS2_JOURNAL_ACCESS_WRITE);
353 le32_add_cpu(&cl->cl_recs[alloc_rec].c_free,
354 le16_to_cpu(bg->bg_free_bits_count));
355 le32_add_cpu(&cl->cl_recs[alloc_rec].c_total, le16_to_cpu(bg->bg_bits));
356 cl->cl_recs[alloc_rec].c_blkno = cpu_to_le64(bg_blkno);
357 if (le16_to_cpu(cl->cl_next_free_rec) < le16_to_cpu(cl->cl_count))
358 le16_add_cpu(&cl->cl_next_free_rec, 1);
360 le32_add_cpu(&fe->id1.bitmap1.i_used, le16_to_cpu(bg->bg_bits) -
361 le16_to_cpu(bg->bg_free_bits_count));
362 le32_add_cpu(&fe->id1.bitmap1.i_total, le16_to_cpu(bg->bg_bits));
363 le32_add_cpu(&fe->i_clusters, le16_to_cpu(cl->cl_cpg));
365 status = ocfs2_journal_dirty(handle, bh);
371 spin_lock(&OCFS2_I(alloc_inode)->ip_lock);
372 OCFS2_I(alloc_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
373 fe->i_size = cpu_to_le64(ocfs2_clusters_to_bytes(alloc_inode->i_sb,
374 le32_to_cpu(fe->i_clusters)));
375 spin_unlock(&OCFS2_I(alloc_inode)->ip_lock);
376 i_size_write(alloc_inode, le64_to_cpu(fe->i_size));
377 alloc_inode->i_blocks = ocfs2_inode_sector_count(alloc_inode);
382 ocfs2_commit_trans(osb, handle);
385 ocfs2_free_alloc_context(ac);
394 static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
395 struct ocfs2_alloc_context *ac,
401 u32 bits_wanted = ac->ac_bits_wanted;
402 struct inode *alloc_inode;
403 struct buffer_head *bh = NULL;
404 struct ocfs2_dinode *fe;
409 alloc_inode = ocfs2_get_system_file_inode(osb, type, slot);
415 mutex_lock(&alloc_inode->i_mutex);
417 status = ocfs2_inode_lock(alloc_inode, &bh, 1);
419 mutex_unlock(&alloc_inode->i_mutex);
426 ac->ac_inode = alloc_inode;
427 ac->ac_alloc_slot = slot;
429 fe = (struct ocfs2_dinode *) bh->b_data;
430 if (!OCFS2_IS_VALID_DINODE(fe)) {
431 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
435 if (!(fe->i_flags & cpu_to_le32(OCFS2_CHAIN_FL))) {
436 ocfs2_error(alloc_inode->i_sb, "Invalid chain allocator %llu",
437 (unsigned long long)le64_to_cpu(fe->i_blkno));
442 free_bits = le32_to_cpu(fe->id1.bitmap1.i_total) -
443 le32_to_cpu(fe->id1.bitmap1.i_used);
445 if (bits_wanted > free_bits) {
446 /* cluster bitmap never grows */
447 if (ocfs2_is_cluster_bitmap(alloc_inode)) {
448 mlog(0, "Disk Full: wanted=%u, free_bits=%u\n",
449 bits_wanted, free_bits);
454 if (alloc_new_group != ALLOC_NEW_GROUP) {
455 mlog(0, "Alloc File %u Full: wanted=%u, free_bits=%u, "
456 "and we don't alloc a new group for it.\n",
457 slot, bits_wanted, free_bits);
462 status = ocfs2_block_group_alloc(osb, alloc_inode, bh);
464 if (status != -ENOSPC)
468 atomic_inc(&osb->alloc_stats.bg_extends);
470 /* You should never ask for this much metadata */
472 (le32_to_cpu(fe->id1.bitmap1.i_total)
473 - le32_to_cpu(fe->id1.bitmap1.i_used)));
486 int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
487 struct ocfs2_dinode *fe,
488 struct ocfs2_alloc_context **ac)
493 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
500 (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe);
501 (*ac)->ac_which = OCFS2_AC_USE_META;
502 slot = osb->slot_num;
503 (*ac)->ac_group_search = ocfs2_block_group_search;
505 status = ocfs2_reserve_suballoc_bits(osb, (*ac),
506 EXTENT_ALLOC_SYSTEM_INODE,
507 slot, ALLOC_NEW_GROUP);
509 if (status != -ENOSPC)
516 if ((status < 0) && *ac) {
517 ocfs2_free_alloc_context(*ac);
525 int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
526 struct ocfs2_alloc_context **ac)
530 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
537 (*ac)->ac_bits_wanted = 1;
538 (*ac)->ac_which = OCFS2_AC_USE_INODE;
540 (*ac)->ac_group_search = ocfs2_block_group_search;
542 status = ocfs2_reserve_suballoc_bits(osb, *ac,
543 INODE_ALLOC_SYSTEM_INODE,
544 osb->slot_num, ALLOC_NEW_GROUP);
546 if (status != -ENOSPC)
553 if ((status < 0) && *ac) {
554 ocfs2_free_alloc_context(*ac);
562 /* local alloc code has to do the same thing, so rather than do this
564 int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb,
565 struct ocfs2_alloc_context *ac)
569 ac->ac_which = OCFS2_AC_USE_MAIN;
570 ac->ac_group_search = ocfs2_cluster_group_search;
572 status = ocfs2_reserve_suballoc_bits(osb, ac,
573 GLOBAL_BITMAP_SYSTEM_INODE,
576 if (status < 0 && status != -ENOSPC) {
585 /* Callers don't need to care which bitmap (local alloc or main) to
586 * use so we figure it out for them, but unfortunately this clutters
588 int ocfs2_reserve_clusters(struct ocfs2_super *osb,
590 struct ocfs2_alloc_context **ac)
596 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL);
603 (*ac)->ac_bits_wanted = bits_wanted;
606 if (ocfs2_alloc_should_use_local(osb, bits_wanted)) {
607 status = ocfs2_reserve_local_alloc_bits(osb,
610 if ((status < 0) && (status != -ENOSPC)) {
613 } else if (status == -ENOSPC) {
614 /* reserve_local_bits will return enospc with
615 * the local alloc inode still locked, so we
616 * can change this safely here. */
617 mlog(0, "Disabling local alloc\n");
618 /* We set to OCFS2_LA_DISABLED so that umount
619 * can clean up what's left of the local
621 osb->local_alloc_state = OCFS2_LA_DISABLED;
625 if (status == -ENOSPC) {
626 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
628 if (status != -ENOSPC)
636 if ((status < 0) && *ac) {
637 ocfs2_free_alloc_context(*ac);
646 * More or less lifted from ext3. I'll leave their description below:
648 * "For ext3 allocations, we must not reuse any blocks which are
649 * allocated in the bitmap buffer's "last committed data" copy. This
650 * prevents deletes from freeing up the page for reuse until we have
651 * committed the delete transaction.
653 * If we didn't do this, then deleting something and reallocating it as
654 * data would allow the old block to be overwritten before the
655 * transaction committed (because we force data to disk before commit).
656 * This would lead to corruption if we crashed between overwriting the
657 * data and committing the delete.
659 * @@@ We may want to make this allocation behaviour conditional on
660 * data-writes at some point, and disable it for metadata allocations or
663 * Note: OCFS2 already does this differently for metadata vs data
664 * allocations, as those bitmaps are separate and undo access is never
665 * called on a metadata group descriptor.
667 static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh,
670 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
672 if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
674 if (!buffer_jbd(bg_bh) || !bh2jh(bg_bh)->b_committed_data)
677 bg = (struct ocfs2_group_desc *) bh2jh(bg_bh)->b_committed_data;
678 return !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
681 static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
682 struct buffer_head *bg_bh,
683 unsigned int bits_wanted,
684 unsigned int total_bits,
689 u16 best_offset, best_size;
690 int offset, start, found, status = 0;
691 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
693 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
694 OCFS2_RO_ON_INVALID_GROUP_DESC(osb->sb, bg);
698 found = start = best_offset = best_size = 0;
699 bitmap = bg->bg_bitmap;
701 while((offset = ocfs2_find_next_zero_bit(bitmap, total_bits, start)) != -1) {
702 if (offset == total_bits)
705 if (!ocfs2_test_bg_bit_allocatable(bg_bh, offset)) {
706 /* We found a zero, but we can't use it as it
707 * hasn't been put to disk yet! */
710 } else if (offset == start) {
711 /* we found a zero */
713 /* move start to the next bit to test */
716 /* got a zero after some ones */
720 if (found > best_size) {
722 best_offset = start - found;
724 /* we got everything we needed */
725 if (found == bits_wanted) {
726 /* mlog(0, "Found it all!\n"); */
731 /* XXX: I think the first clause is equivalent to the second
733 if (found == bits_wanted) {
734 *bit_off = start - found;
736 } else if (best_size) {
737 *bit_off = best_offset;
738 *bits_found = best_size;
741 /* No error log here -- see the comment above
742 * ocfs2_test_bg_bit_allocatable */
748 static inline int ocfs2_block_group_set_bits(handle_t *handle,
749 struct inode *alloc_inode,
750 struct ocfs2_group_desc *bg,
751 struct buffer_head *group_bh,
752 unsigned int bit_off,
753 unsigned int num_bits)
756 void *bitmap = bg->bg_bitmap;
757 int journal_type = OCFS2_JOURNAL_ACCESS_WRITE;
761 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
762 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg);
766 BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits);
768 mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off,
771 if (ocfs2_is_cluster_bitmap(alloc_inode))
772 journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
774 status = ocfs2_journal_access(handle,
783 le16_add_cpu(&bg->bg_free_bits_count, -num_bits);
786 ocfs2_set_bit(bit_off++, bitmap);
788 status = ocfs2_journal_dirty(handle,
800 /* find the one with the most empty bits */
801 static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl)
805 BUG_ON(!cl->cl_next_free_rec);
808 while (curr < le16_to_cpu(cl->cl_next_free_rec)) {
809 if (le32_to_cpu(cl->cl_recs[curr].c_free) >
810 le32_to_cpu(cl->cl_recs[best].c_free))
815 BUG_ON(best >= le16_to_cpu(cl->cl_next_free_rec));
819 static int ocfs2_relink_block_group(handle_t *handle,
820 struct inode *alloc_inode,
821 struct buffer_head *fe_bh,
822 struct buffer_head *bg_bh,
823 struct buffer_head *prev_bg_bh,
827 /* there is a really tiny chance the journal calls could fail,
828 * but we wouldn't want inconsistent blocks in *any* case. */
829 u64 fe_ptr, bg_ptr, prev_bg_ptr;
830 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) fe_bh->b_data;
831 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
832 struct ocfs2_group_desc *prev_bg = (struct ocfs2_group_desc *) prev_bg_bh->b_data;
834 if (!OCFS2_IS_VALID_DINODE(fe)) {
835 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
839 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
840 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg);
844 if (!OCFS2_IS_VALID_GROUP_DESC(prev_bg)) {
845 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, prev_bg);
850 mlog(0, "Suballoc %llu, chain %u, move group %llu to top, prev = %llu\n",
851 (unsigned long long)le64_to_cpu(fe->i_blkno), chain,
852 (unsigned long long)le64_to_cpu(bg->bg_blkno),
853 (unsigned long long)le64_to_cpu(prev_bg->bg_blkno));
855 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno);
856 bg_ptr = le64_to_cpu(bg->bg_next_group);
857 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group);
859 status = ocfs2_journal_access(handle, alloc_inode, prev_bg_bh,
860 OCFS2_JOURNAL_ACCESS_WRITE);
866 prev_bg->bg_next_group = bg->bg_next_group;
868 status = ocfs2_journal_dirty(handle, prev_bg_bh);
874 status = ocfs2_journal_access(handle, alloc_inode, bg_bh,
875 OCFS2_JOURNAL_ACCESS_WRITE);
881 bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno;
883 status = ocfs2_journal_dirty(handle, bg_bh);
889 status = ocfs2_journal_access(handle, alloc_inode, fe_bh,
890 OCFS2_JOURNAL_ACCESS_WRITE);
896 fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno;
898 status = ocfs2_journal_dirty(handle, fe_bh);
907 fe->id2.i_chain.cl_recs[chain].c_blkno = cpu_to_le64(fe_ptr);
908 bg->bg_next_group = cpu_to_le64(bg_ptr);
909 prev_bg->bg_next_group = cpu_to_le64(prev_bg_ptr);
916 static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg,
919 return le16_to_cpu(bg->bg_free_bits_count) > wanted;
922 /* return 0 on success, -ENOSPC to keep searching and any other < 0
924 static int ocfs2_cluster_group_search(struct inode *inode,
925 struct buffer_head *group_bh,
926 u32 bits_wanted, u32 min_bits,
927 u16 *bit_off, u16 *bits_found)
929 int search = -ENOSPC;
931 struct ocfs2_group_desc *gd = (struct ocfs2_group_desc *) group_bh->b_data;
932 u16 tmp_off, tmp_found;
933 unsigned int max_bits, gd_cluster_off;
935 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
937 if (gd->bg_free_bits_count) {
938 max_bits = le16_to_cpu(gd->bg_bits);
940 /* Tail groups in cluster bitmaps which aren't cpg
941 * aligned are prone to partial extention by a failed
942 * fs resize. If the file system resize never got to
943 * update the dinode cluster count, then we don't want
944 * to trust any clusters past it, regardless of what
945 * the group descriptor says. */
946 gd_cluster_off = ocfs2_blocks_to_clusters(inode->i_sb,
947 le64_to_cpu(gd->bg_blkno));
948 if ((gd_cluster_off + max_bits) >
949 OCFS2_I(inode)->ip_clusters) {
950 max_bits = OCFS2_I(inode)->ip_clusters - gd_cluster_off;
951 mlog(0, "Desc %llu, bg_bits %u, clusters %u, use %u\n",
952 (unsigned long long)le64_to_cpu(gd->bg_blkno),
953 le16_to_cpu(gd->bg_bits),
954 OCFS2_I(inode)->ip_clusters, max_bits);
957 ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb),
958 group_bh, bits_wanted,
960 &tmp_off, &tmp_found);
964 /* ocfs2_block_group_find_clear_bits() might
965 * return success, but we still want to return
966 * -ENOSPC unless it found the minimum number
968 if (min_bits <= tmp_found) {
970 *bits_found = tmp_found;
971 search = 0; /* success */
978 static int ocfs2_block_group_search(struct inode *inode,
979 struct buffer_head *group_bh,
980 u32 bits_wanted, u32 min_bits,
981 u16 *bit_off, u16 *bits_found)
984 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) group_bh->b_data;
986 BUG_ON(min_bits != 1);
987 BUG_ON(ocfs2_is_cluster_bitmap(inode));
989 if (bg->bg_free_bits_count)
990 ret = ocfs2_block_group_find_clear_bits(OCFS2_SB(inode->i_sb),
991 group_bh, bits_wanted,
992 le16_to_cpu(bg->bg_bits),
993 bit_off, bits_found);
998 static int ocfs2_alloc_dinode_update_counts(struct inode *inode,
1000 struct buffer_head *di_bh,
1006 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data;
1007 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &di->id2.i_chain;
1009 ret = ocfs2_journal_access(handle, inode, di_bh,
1010 OCFS2_JOURNAL_ACCESS_WRITE);
1016 tmp_used = le32_to_cpu(di->id1.bitmap1.i_used);
1017 di->id1.bitmap1.i_used = cpu_to_le32(num_bits + tmp_used);
1018 le32_add_cpu(&cl->cl_recs[chain].c_free, -num_bits);
1020 ret = ocfs2_journal_dirty(handle, di_bh);
1028 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac,
1033 unsigned int *num_bits,
1039 struct buffer_head *group_bh = NULL;
1040 struct ocfs2_group_desc *gd;
1041 struct inode *alloc_inode = ac->ac_inode;
1043 ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno,
1044 &group_bh, OCFS2_BH_CACHED, alloc_inode);
1050 gd = (struct ocfs2_group_desc *) group_bh->b_data;
1051 if (!OCFS2_IS_VALID_GROUP_DESC(gd)) {
1052 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, gd);
1057 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits,
1067 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh,
1069 le16_to_cpu(gd->bg_chain));
1075 ret = ocfs2_block_group_set_bits(handle, alloc_inode, gd, group_bh,
1076 *bit_off, *num_bits);
1080 *bits_left = le16_to_cpu(gd->bg_free_bits_count);
1088 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac,
1093 unsigned int *num_bits,
1098 u16 chain, tmp_bits;
1101 struct inode *alloc_inode = ac->ac_inode;
1102 struct buffer_head *group_bh = NULL;
1103 struct buffer_head *prev_group_bh = NULL;
1104 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data;
1105 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &fe->id2.i_chain;
1106 struct ocfs2_group_desc *bg;
1108 chain = ac->ac_chain;
1109 mlog(0, "trying to alloc %u bits from chain %u, inode %llu\n",
1111 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno);
1113 status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb),
1114 le64_to_cpu(cl->cl_recs[chain].c_blkno),
1115 &group_bh, OCFS2_BH_CACHED, alloc_inode);
1120 bg = (struct ocfs2_group_desc *) group_bh->b_data;
1121 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, bg);
1128 /* for now, the chain search is a bit simplistic. We just use
1129 * the 1st group with any empty bits. */
1130 while ((status = ac->ac_group_search(alloc_inode, group_bh,
1131 bits_wanted, min_bits, bit_off,
1132 &tmp_bits)) == -ENOSPC) {
1133 if (!bg->bg_next_group)
1136 if (prev_group_bh) {
1137 brelse(prev_group_bh);
1138 prev_group_bh = NULL;
1140 next_group = le64_to_cpu(bg->bg_next_group);
1141 prev_group_bh = group_bh;
1143 status = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb),
1144 next_group, &group_bh,
1145 OCFS2_BH_CACHED, alloc_inode);
1150 bg = (struct ocfs2_group_desc *) group_bh->b_data;
1151 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, bg);
1158 if (status != -ENOSPC)
1163 mlog(0, "alloc succeeds: we give %u bits from block group %llu\n",
1164 tmp_bits, (unsigned long long)le64_to_cpu(bg->bg_blkno));
1166 *num_bits = tmp_bits;
1168 BUG_ON(*num_bits == 0);
1171 * Keep track of previous block descriptor read. When
1172 * we find a target, if we have read more than X
1173 * number of descriptors, and the target is reasonably
1174 * empty, relink him to top of his chain.
1176 * We've read 0 extra blocks and only send one more to
1177 * the transaction, yet the next guy to search has a
1180 * Do this *after* figuring out how many bits we're taking out
1181 * of our target group.
1183 if (ac->ac_allow_chain_relink &&
1185 (ocfs2_block_group_reasonably_empty(bg, *num_bits))) {
1186 status = ocfs2_relink_block_group(handle, alloc_inode,
1187 ac->ac_bh, group_bh,
1188 prev_group_bh, chain);
1195 /* Ok, claim our bits now: set the info on dinode, chainlist
1196 * and then the group */
1197 status = ocfs2_journal_access(handle,
1200 OCFS2_JOURNAL_ACCESS_WRITE);
1206 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used);
1207 fe->id1.bitmap1.i_used = cpu_to_le32(*num_bits + tmp_used);
1208 le32_add_cpu(&cl->cl_recs[chain].c_free, -(*num_bits));
1210 status = ocfs2_journal_dirty(handle,
1217 status = ocfs2_block_group_set_bits(handle,
1228 mlog(0, "Allocated %u bits from suballocator %llu\n", *num_bits,
1229 (unsigned long long)le64_to_cpu(fe->i_blkno));
1231 *bg_blkno = le64_to_cpu(bg->bg_blkno);
1232 *bits_left = le16_to_cpu(bg->bg_free_bits_count);
1237 brelse(prev_group_bh);
1243 /* will give out up to bits_wanted contiguous bits. */
1244 static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb,
1245 struct ocfs2_alloc_context *ac,
1250 unsigned int *num_bits,
1256 u64 hint_blkno = ac->ac_last_group;
1257 struct ocfs2_chain_list *cl;
1258 struct ocfs2_dinode *fe;
1262 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted);
1263 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given));
1266 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data;
1267 if (!OCFS2_IS_VALID_DINODE(fe)) {
1268 OCFS2_RO_ON_INVALID_DINODE(osb->sb, fe);
1272 if (le32_to_cpu(fe->id1.bitmap1.i_used) >=
1273 le32_to_cpu(fe->id1.bitmap1.i_total)) {
1274 ocfs2_error(osb->sb, "Chain allocator dinode %llu has %u used "
1275 "bits but only %u total.",
1276 (unsigned long long)le64_to_cpu(fe->i_blkno),
1277 le32_to_cpu(fe->id1.bitmap1.i_used),
1278 le32_to_cpu(fe->id1.bitmap1.i_total));
1284 /* Attempt to short-circuit the usual search mechanism
1285 * by jumping straight to the most recently used
1286 * allocation group. This helps us mantain some
1287 * contiguousness across allocations. */
1288 status = ocfs2_search_one_group(ac, handle, bits_wanted,
1289 min_bits, bit_off, num_bits,
1290 hint_blkno, &bits_left);
1292 /* Be careful to update *bg_blkno here as the
1293 * caller is expecting it to be filled in, and
1294 * ocfs2_search_one_group() won't do that for
1296 *bg_blkno = hint_blkno;
1299 if (status < 0 && status != -ENOSPC) {
1305 cl = (struct ocfs2_chain_list *) &fe->id2.i_chain;
1307 victim = ocfs2_find_victim_chain(cl);
1308 ac->ac_chain = victim;
1309 ac->ac_allow_chain_relink = 1;
1311 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, bit_off,
1312 num_bits, bg_blkno, &bits_left);
1315 if (status < 0 && status != -ENOSPC) {
1320 mlog(0, "Search of victim chain %u came up with nothing, "
1321 "trying all chains now.\n", victim);
1323 /* If we didn't pick a good victim, then just default to
1324 * searching each chain in order. Don't allow chain relinking
1325 * because we only calculate enough journal credits for one
1326 * relink per alloc. */
1327 ac->ac_allow_chain_relink = 0;
1328 for (i = 0; i < le16_to_cpu(cl->cl_next_free_rec); i ++) {
1331 if (!cl->cl_recs[i].c_free)
1335 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits,
1336 bit_off, num_bits, bg_blkno,
1340 if (status < 0 && status != -ENOSPC) {
1347 if (status != -ENOSPC) {
1348 /* If the next search of this group is not likely to
1349 * yield a suitable extent, then we reset the last
1350 * group hint so as to not waste a disk read */
1351 if (bits_left < min_bits)
1352 ac->ac_last_group = 0;
1354 ac->ac_last_group = *bg_blkno;
1362 int ocfs2_claim_metadata(struct ocfs2_super *osb,
1364 struct ocfs2_alloc_context *ac,
1366 u16 *suballoc_bit_start,
1367 unsigned int *num_bits,
1374 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted));
1375 BUG_ON(ac->ac_which != OCFS2_AC_USE_META);
1377 status = ocfs2_claim_suballoc_bits(osb,
1389 atomic_inc(&osb->alloc_stats.bg_allocs);
1391 *blkno_start = bg_blkno + (u64) *suballoc_bit_start;
1392 ac->ac_bits_given += (*num_bits);
1399 int ocfs2_claim_new_inode(struct ocfs2_super *osb,
1401 struct ocfs2_alloc_context *ac,
1406 unsigned int num_bits;
1412 BUG_ON(ac->ac_bits_given != 0);
1413 BUG_ON(ac->ac_bits_wanted != 1);
1414 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE);
1416 status = ocfs2_claim_suballoc_bits(osb,
1428 atomic_inc(&osb->alloc_stats.bg_allocs);
1430 BUG_ON(num_bits != 1);
1432 *fe_blkno = bg_blkno + (u64) (*suballoc_bit);
1433 ac->ac_bits_given++;
1440 /* translate a group desc. blkno and it's bitmap offset into
1441 * disk cluster offset. */
1442 static inline u32 ocfs2_desc_bitmap_to_cluster_off(struct inode *inode,
1446 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1449 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
1451 if (bg_blkno != osb->first_cluster_group_blkno)
1452 cluster = ocfs2_blocks_to_clusters(inode->i_sb, bg_blkno);
1453 cluster += (u32) bg_bit_off;
1457 /* given a cluster offset, calculate which block group it belongs to
1458 * and return that block offset. */
1459 u64 ocfs2_which_cluster_group(struct inode *inode, u32 cluster)
1461 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1464 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
1466 group_no = cluster / osb->bitmap_cpg;
1468 return osb->first_cluster_group_blkno;
1469 return ocfs2_clusters_to_blocks(inode->i_sb,
1470 group_no * osb->bitmap_cpg);
1473 /* given the block number of a cluster start, calculate which cluster
1474 * group and descriptor bitmap offset that corresponds to. */
1475 static inline void ocfs2_block_to_cluster_group(struct inode *inode,
1480 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1481 u32 data_cluster = ocfs2_blocks_to_clusters(osb->sb, data_blkno);
1483 BUG_ON(!ocfs2_is_cluster_bitmap(inode));
1485 *bg_blkno = ocfs2_which_cluster_group(inode,
1488 if (*bg_blkno == osb->first_cluster_group_blkno)
1489 *bg_bit_off = (u16) data_cluster;
1491 *bg_bit_off = (u16) ocfs2_blocks_to_clusters(osb->sb,
1492 data_blkno - *bg_blkno);
1496 * min_bits - minimum contiguous chunk from this total allocation we
1497 * can handle. set to what we asked for originally for a full
1498 * contig. allocation, set to '1' to indicate we can deal with extents
1501 int __ocfs2_claim_clusters(struct ocfs2_super *osb,
1503 struct ocfs2_alloc_context *ac,
1510 unsigned int bits_wanted = max_clusters;
1516 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted);
1518 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL
1519 && ac->ac_which != OCFS2_AC_USE_MAIN);
1521 if (ac->ac_which == OCFS2_AC_USE_LOCAL) {
1522 status = ocfs2_claim_local_alloc_bits(osb,
1529 atomic_inc(&osb->alloc_stats.local_data);
1531 if (min_clusters > (osb->bitmap_cpg - 1)) {
1532 /* The only paths asking for contiguousness
1533 * should know about this already. */
1534 mlog(ML_ERROR, "minimum allocation requested %u exceeds "
1535 "group bitmap size %u!\n", min_clusters,
1540 /* clamp the current request down to a realistic size. */
1541 if (bits_wanted > (osb->bitmap_cpg - 1))
1542 bits_wanted = osb->bitmap_cpg - 1;
1544 status = ocfs2_claim_suballoc_bits(osb,
1554 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
1557 atomic_inc(&osb->alloc_stats.bitmap_data);
1561 if (status != -ENOSPC)
1566 ac->ac_bits_given += *num_clusters;
1573 int ocfs2_claim_clusters(struct ocfs2_super *osb,
1575 struct ocfs2_alloc_context *ac,
1580 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given;
1582 return __ocfs2_claim_clusters(osb, handle, ac, min_clusters,
1583 bits_wanted, cluster_start, num_clusters);
1586 static inline int ocfs2_block_group_clear_bits(handle_t *handle,
1587 struct inode *alloc_inode,
1588 struct ocfs2_group_desc *bg,
1589 struct buffer_head *group_bh,
1590 unsigned int bit_off,
1591 unsigned int num_bits)
1595 int journal_type = OCFS2_JOURNAL_ACCESS_WRITE;
1596 struct ocfs2_group_desc *undo_bg = NULL;
1600 if (!OCFS2_IS_VALID_GROUP_DESC(bg)) {
1601 OCFS2_RO_ON_INVALID_GROUP_DESC(alloc_inode->i_sb, bg);
1606 mlog(0, "off = %u, num = %u\n", bit_off, num_bits);
1608 if (ocfs2_is_cluster_bitmap(alloc_inode))
1609 journal_type = OCFS2_JOURNAL_ACCESS_UNDO;
1611 status = ocfs2_journal_access(handle, alloc_inode, group_bh,
1618 if (ocfs2_is_cluster_bitmap(alloc_inode))
1619 undo_bg = (struct ocfs2_group_desc *) bh2jh(group_bh)->b_committed_data;
1623 ocfs2_clear_bit((bit_off + tmp),
1624 (unsigned long *) bg->bg_bitmap);
1625 if (ocfs2_is_cluster_bitmap(alloc_inode))
1626 ocfs2_set_bit(bit_off + tmp,
1627 (unsigned long *) undo_bg->bg_bitmap);
1629 le16_add_cpu(&bg->bg_free_bits_count, num_bits);
1631 status = ocfs2_journal_dirty(handle, group_bh);
1639 * expects the suballoc inode to already be locked.
1641 int ocfs2_free_suballoc_bits(handle_t *handle,
1642 struct inode *alloc_inode,
1643 struct buffer_head *alloc_bh,
1644 unsigned int start_bit,
1650 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
1651 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) alloc_bh->b_data;
1652 struct ocfs2_chain_list *cl = &fe->id2.i_chain;
1653 struct buffer_head *group_bh = NULL;
1654 struct ocfs2_group_desc *group;
1658 if (!OCFS2_IS_VALID_DINODE(fe)) {
1659 OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe);
1663 BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl));
1665 mlog(0, "%llu: freeing %u bits from group %llu, starting at %u\n",
1666 (unsigned long long)OCFS2_I(alloc_inode)->ip_blkno, count,
1667 (unsigned long long)bg_blkno, start_bit);
1669 status = ocfs2_read_block(osb, bg_blkno, &group_bh, OCFS2_BH_CACHED,
1676 group = (struct ocfs2_group_desc *) group_bh->b_data;
1677 status = ocfs2_check_group_descriptor(alloc_inode->i_sb, fe, group);
1682 BUG_ON((count + start_bit) > le16_to_cpu(group->bg_bits));
1684 status = ocfs2_block_group_clear_bits(handle, alloc_inode,
1692 status = ocfs2_journal_access(handle, alloc_inode, alloc_bh,
1693 OCFS2_JOURNAL_ACCESS_WRITE);
1699 le32_add_cpu(&cl->cl_recs[le16_to_cpu(group->bg_chain)].c_free,
1701 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used);
1702 fe->id1.bitmap1.i_used = cpu_to_le32(tmp_used - count);
1704 status = ocfs2_journal_dirty(handle, alloc_bh);
1718 int ocfs2_free_dinode(handle_t *handle,
1719 struct inode *inode_alloc_inode,
1720 struct buffer_head *inode_alloc_bh,
1721 struct ocfs2_dinode *di)
1723 u64 blk = le64_to_cpu(di->i_blkno);
1724 u16 bit = le16_to_cpu(di->i_suballoc_bit);
1725 u64 bg_blkno = ocfs2_which_suballoc_group(blk, bit);
1727 return ocfs2_free_suballoc_bits(handle, inode_alloc_inode,
1728 inode_alloc_bh, bit, bg_blkno, 1);
1731 int ocfs2_free_clusters(handle_t *handle,
1732 struct inode *bitmap_inode,
1733 struct buffer_head *bitmap_bh,
1735 unsigned int num_clusters)
1740 struct ocfs2_dinode *fe;
1742 /* You can't ever have a contiguous set of clusters
1743 * bigger than a block group bitmap so we never have to worry
1744 * about looping on them. */
1748 /* This is expensive. We can safely remove once this stuff has
1749 * gotten tested really well. */
1750 BUG_ON(start_blk != ocfs2_clusters_to_blocks(bitmap_inode->i_sb, ocfs2_blocks_to_clusters(bitmap_inode->i_sb, start_blk)));
1752 fe = (struct ocfs2_dinode *) bitmap_bh->b_data;
1754 ocfs2_block_to_cluster_group(bitmap_inode, start_blk, &bg_blkno,
1757 mlog(0, "want to free %u clusters starting at block %llu\n",
1758 num_clusters, (unsigned long long)start_blk);
1759 mlog(0, "bg_blkno = %llu, bg_start_bit = %u\n",
1760 (unsigned long long)bg_blkno, bg_start_bit);
1762 status = ocfs2_free_suballoc_bits(handle, bitmap_inode, bitmap_bh,
1763 bg_start_bit, bg_blkno,
1772 static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg)
1774 printk("Block Group:\n");
1775 printk("bg_signature: %s\n", bg->bg_signature);
1776 printk("bg_size: %u\n", bg->bg_size);
1777 printk("bg_bits: %u\n", bg->bg_bits);
1778 printk("bg_free_bits_count: %u\n", bg->bg_free_bits_count);
1779 printk("bg_chain: %u\n", bg->bg_chain);
1780 printk("bg_generation: %u\n", le32_to_cpu(bg->bg_generation));
1781 printk("bg_next_group: %llu\n",
1782 (unsigned long long)bg->bg_next_group);
1783 printk("bg_parent_dinode: %llu\n",
1784 (unsigned long long)bg->bg_parent_dinode);
1785 printk("bg_blkno: %llu\n",
1786 (unsigned long long)bg->bg_blkno);
1789 static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe)
1793 printk("Suballoc Inode %llu:\n", (unsigned long long)fe->i_blkno);
1794 printk("i_signature: %s\n", fe->i_signature);
1795 printk("i_size: %llu\n",
1796 (unsigned long long)fe->i_size);
1797 printk("i_clusters: %u\n", fe->i_clusters);
1798 printk("i_generation: %u\n",
1799 le32_to_cpu(fe->i_generation));
1800 printk("id1.bitmap1.i_used: %u\n",
1801 le32_to_cpu(fe->id1.bitmap1.i_used));
1802 printk("id1.bitmap1.i_total: %u\n",
1803 le32_to_cpu(fe->id1.bitmap1.i_total));
1804 printk("id2.i_chain.cl_cpg: %u\n", fe->id2.i_chain.cl_cpg);
1805 printk("id2.i_chain.cl_bpc: %u\n", fe->id2.i_chain.cl_bpc);
1806 printk("id2.i_chain.cl_count: %u\n", fe->id2.i_chain.cl_count);
1807 printk("id2.i_chain.cl_next_free_rec: %u\n",
1808 fe->id2.i_chain.cl_next_free_rec);
1809 for(i = 0; i < fe->id2.i_chain.cl_next_free_rec; i++) {
1810 printk("fe->id2.i_chain.cl_recs[%d].c_free: %u\n", i,
1811 fe->id2.i_chain.cl_recs[i].c_free);
1812 printk("fe->id2.i_chain.cl_recs[%d].c_total: %u\n", i,
1813 fe->id2.i_chain.cl_recs[i].c_total);
1814 printk("fe->id2.i_chain.cl_recs[%d].c_blkno: %llu\n", i,
1815 (unsigned long long)fe->id2.i_chain.cl_recs[i].c_blkno);