Lines Matching full:block
17 * Find a number of contiguous clear bits in a directory block bitmask.
20 * variable. The first bit doesn't count as it corresponds to the block header
23 static int afs_find_contig_bits(union afs_xdr_dir_block *block, unsigned int nr_slots) in afs_find_contig_bits() argument
29 bitmap = (u64)block->hdr.bitmap[0] << 0 * 8; in afs_find_contig_bits()
30 bitmap |= (u64)block->hdr.bitmap[1] << 1 * 8; in afs_find_contig_bits()
31 bitmap |= (u64)block->hdr.bitmap[2] << 2 * 8; in afs_find_contig_bits()
32 bitmap |= (u64)block->hdr.bitmap[3] << 3 * 8; in afs_find_contig_bits()
33 bitmap |= (u64)block->hdr.bitmap[4] << 4 * 8; in afs_find_contig_bits()
34 bitmap |= (u64)block->hdr.bitmap[5] << 5 * 8; in afs_find_contig_bits()
35 bitmap |= (u64)block->hdr.bitmap[6] << 6 * 8; in afs_find_contig_bits()
36 bitmap |= (u64)block->hdr.bitmap[7] << 7 * 8; in afs_find_contig_bits()
66 * Set a number of contiguous bits in the directory block bitmap.
68 static void afs_set_contig_bits(union afs_xdr_dir_block *block, in afs_set_contig_bits() argument
76 before = *(u64 *)block->hdr.bitmap; in afs_set_contig_bits()
78 block->hdr.bitmap[0] |= (u8)(mask >> 0 * 8); in afs_set_contig_bits()
79 block->hdr.bitmap[1] |= (u8)(mask >> 1 * 8); in afs_set_contig_bits()
80 block->hdr.bitmap[2] |= (u8)(mask >> 2 * 8); in afs_set_contig_bits()
81 block->hdr.bitmap[3] |= (u8)(mask >> 3 * 8); in afs_set_contig_bits()
82 block->hdr.bitmap[4] |= (u8)(mask >> 4 * 8); in afs_set_contig_bits()
83 block->hdr.bitmap[5] |= (u8)(mask >> 5 * 8); in afs_set_contig_bits()
84 block->hdr.bitmap[6] |= (u8)(mask >> 6 * 8); in afs_set_contig_bits()
85 block->hdr.bitmap[7] |= (u8)(mask >> 7 * 8); in afs_set_contig_bits()
87 after = *(u64 *)block->hdr.bitmap; in afs_set_contig_bits()
91 * Clear a number of contiguous bits in the directory block bitmap.
93 static void afs_clear_contig_bits(union afs_xdr_dir_block *block, in afs_clear_contig_bits() argument
101 before = *(u64 *)block->hdr.bitmap; in afs_clear_contig_bits()
103 block->hdr.bitmap[0] &= ~(u8)(mask >> 0 * 8); in afs_clear_contig_bits()
104 block->hdr.bitmap[1] &= ~(u8)(mask >> 1 * 8); in afs_clear_contig_bits()
105 block->hdr.bitmap[2] &= ~(u8)(mask >> 2 * 8); in afs_clear_contig_bits()
106 block->hdr.bitmap[3] &= ~(u8)(mask >> 3 * 8); in afs_clear_contig_bits()
107 block->hdr.bitmap[4] &= ~(u8)(mask >> 4 * 8); in afs_clear_contig_bits()
108 block->hdr.bitmap[5] &= ~(u8)(mask >> 5 * 8); in afs_clear_contig_bits()
109 block->hdr.bitmap[6] &= ~(u8)(mask >> 6 * 8); in afs_clear_contig_bits()
110 block->hdr.bitmap[7] &= ~(u8)(mask >> 7 * 8); in afs_clear_contig_bits()
112 after = *(u64 *)block->hdr.bitmap; in afs_clear_contig_bits()
116 * Scan a directory block looking for a dirent of the right name.
118 static int afs_dir_scan_block(union afs_xdr_dir_block *block, struct qstr *name, in afs_dir_scan_block() argument
127 bitmap = (u64)block->hdr.bitmap[0] << 0 * 8; in afs_dir_scan_block()
128 bitmap |= (u64)block->hdr.bitmap[1] << 1 * 8; in afs_dir_scan_block()
129 bitmap |= (u64)block->hdr.bitmap[2] << 2 * 8; in afs_dir_scan_block()
130 bitmap |= (u64)block->hdr.bitmap[3] << 3 * 8; in afs_dir_scan_block()
131 bitmap |= (u64)block->hdr.bitmap[4] << 4 * 8; in afs_dir_scan_block()
132 bitmap |= (u64)block->hdr.bitmap[5] << 5 * 8; in afs_dir_scan_block()
133 bitmap |= (u64)block->hdr.bitmap[6] << 6 * 8; in afs_dir_scan_block()
134 bitmap |= (u64)block->hdr.bitmap[7] << 7 * 8; in afs_dir_scan_block()
141 de = &block->dirents[d]; in afs_dir_scan_block()
145 /* The block was NUL-terminated by afs_dir_check_page(). */ in afs_dir_scan_block()
160 * Initialise a new directory block. Note that block 0 is special and contains
164 union afs_xdr_dir_block *block, int block_num) in afs_edit_init_block() argument
166 memset(block, 0, sizeof(*block)); in afs_edit_init_block()
167 block->hdr.npages = htons(1); in afs_edit_init_block()
168 block->hdr.magic = AFS_DIR_MAGIC; in afs_edit_init_block()
169 block->hdr.bitmap[0] = 1; in afs_edit_init_block()
172 block->hdr.bitmap[0] = 0xff; in afs_edit_init_block()
173 block->hdr.bitmap[1] = 0x1f; in afs_edit_init_block()
174 memset(block->meta.alloc_ctrs, in afs_edit_init_block()
176 sizeof(block->meta.alloc_ctrs)); in afs_edit_init_block()
198 union afs_xdr_dir_block *meta, *block; in afs_edit_dir_add() local
235 /* Find a block that has sufficient slots available. Each VM page in afs_edit_dir_add()
265 block = &dir_page->blocks[b % AFS_DIR_BLOCKS_PER_PAGE]; in afs_edit_dir_add()
267 _debug("block %u: %2u %3u %u", in afs_edit_dir_add()
270 ntohs(block->hdr.npages), in afs_edit_dir_add()
271 ntohs(block->hdr.magic)); in afs_edit_dir_add()
273 /* Initialise the block if necessary. */ in afs_edit_dir_add()
276 afs_edit_init_block(meta, block, b); in afs_edit_dir_add()
286 slot = afs_find_contig_bits(block, need_slots); in afs_edit_dir_add()
313 block = meta; in afs_edit_dir_add()
321 de = &block->dirents[slot]; in afs_edit_dir_add()
331 afs_set_contig_bits(block, slot, need_slots); in afs_edit_dir_add()
379 union afs_xdr_dir_block *meta, *block; in afs_edit_dir_remove() local
431 block = &dir_page->blocks[b % AFS_DIR_BLOCKS_PER_PAGE]; in afs_edit_dir_remove()
435 slot = afs_dir_scan_block(block, name, b); in afs_edit_dir_remove()
454 de = &block->dirents[slot]; in afs_edit_dir_remove()
463 afs_clear_contig_bits(block, slot, need_slots); in afs_edit_dir_remove()