Lines Matching +full:range +full:- +full:double
1 // SPDX-License-Identifier: GPL-2.0
7 * Based on portions of file.c by Makoto Kato <m_kato@ga2.so-net.ne.jp>
39 * befs_read_datastream - get buffer_head containing data, starting from pos.
43 * @off: offset of data in buffer_head->b_data
56 befs_debug(sb, "---> %s %llu", __func__, pos); in befs_read_datastream()
57 block = pos >> BEFS_SB(sb)->block_shift; in befs_read_datastream()
59 *off = pos - (block << BEFS_SB(sb)->block_shift); in befs_read_datastream()
64 befs_debug(sb, "<--- %s ERROR", __func__); in befs_read_datastream()
74 befs_debug(sb, "<--- %s read data, starting at %llu", __func__, pos); in befs_read_datastream()
80 * befs_fblock2brun - give back block run for fblock
99 befs_off_t pos = fblock << BEFS_SB(sb)->block_shift; in befs_fblock2brun()
101 if (pos < data->max_direct_range) { in befs_fblock2brun()
104 } else if (pos < data->max_indirect_range) { in befs_fblock2brun()
107 } else if (pos < data->max_double_indirect_range) { in befs_fblock2brun()
121 * befs_read_lsmylink - read long symlink from datastream.
137 befs_debug(sb, "---> %s length: %llu", __func__, len); in befs_read_lsymlink()
144 befs_debug(sb, "<--- %s ERROR", __func__); in befs_read_lsymlink()
148 plen = ((bytes_read + BEFS_SB(sb)->block_size) < len) ? in befs_read_lsymlink()
149 BEFS_SB(sb)->block_size : len - bytes_read; in befs_read_lsymlink()
150 memcpy(buff + bytes_read, bh->b_data, plen); in befs_read_lsymlink()
155 befs_debug(sb, "<--- %s read %u bytes", __func__, (unsigned int) in befs_read_lsymlink()
161 * befs_count_blocks - blocks used by a file
179 befs_debug(sb, "---> %s", __func__); in befs_count_blocks()
181 datablocks = ds->size >> befs_sb->block_shift; in befs_count_blocks()
182 if (ds->size & (befs_sb->block_size - 1)) in befs_count_blocks()
188 if (ds->size > ds->max_direct_range) in befs_count_blocks()
189 metablocks += ds->indirect.len; in befs_count_blocks()
192 * Double indir block, plus all the indirect blocks it maps. in befs_count_blocks()
193 * In the double-indirect range, all block runs of data are in befs_count_blocks()
195 * how many data block runs are in the double-indirect region, in befs_count_blocks()
200 if (ds->size > ds->max_indirect_range && ds->max_indirect_range != 0) { in befs_count_blocks()
206 ds->max_double_indirect_range - ds->max_indirect_range; in befs_count_blocks()
208 dbl_bytes / (befs_sb->block_size * BEFS_DBLINDIR_BRUN_LEN); in befs_count_blocks()
211 metablocks += ds->double_indirect.len; in befs_count_blocks()
216 befs_debug(sb, "<--- %s %u blocks", __func__, (unsigned int)blocks); in befs_count_blocks()
222 * befs_find_brun_direct - find a direct block run in the datastream
237 * contains the blockno-th filesystem block. This is necessary
255 const befs_block_run *array = data->direct; in befs_find_brun_direct()
258 befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno); in befs_find_brun_direct()
263 int offset = blockno - sum; in befs_find_brun_direct()
265 run->allocation_group = array[i].allocation_group; in befs_find_brun_direct()
266 run->start = array[i].start + offset; in befs_find_brun_direct()
267 run->len = array[i].len - offset; in befs_find_brun_direct()
269 befs_debug(sb, "---> %s, " in befs_find_brun_direct()
278 befs_debug(sb, "---> %s ERROR", __func__); in befs_find_brun_direct()
283 * befs_find_brun_indirect - find a block run in the datastream
317 befs_block_run indirect = data->indirect; in befs_find_brun_indirect()
321 befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno); in befs_find_brun_indirect()
323 indir_start_blk = data->max_direct_range >> BEFS_SB(sb)->block_shift; in befs_find_brun_indirect()
324 search_blk = blockno - indir_start_blk; in befs_find_brun_indirect()
330 befs_error(sb, "---> %s failed to read " in befs_find_brun_indirect()
333 befs_debug(sb, "<--- %s ERROR", __func__); in befs_find_brun_indirect()
337 array = (befs_disk_block_run *) indirblock->b_data; in befs_find_brun_indirect()
343 int offset = search_blk - sum; in befs_find_brun_indirect()
344 run->allocation_group = in befs_find_brun_indirect()
346 run->start = in befs_find_brun_indirect()
348 run->len = in befs_find_brun_indirect()
349 fs16_to_cpu(sb, array[j].len) - offset; in befs_find_brun_indirect()
353 "<--- %s found file block " in befs_find_brun_indirect()
369 befs_debug(sb, "<--- %s ERROR", __func__); in befs_find_brun_indirect()
374 * befs_find_brun_dblindirect - find a block run in the datastream
382 * blockno is in the double-indirect region of the datastream.
388 * The block runs in the double-indirect region are different.
392 * double-indirect region we need to go to get to the one that
396 * inode addresses in the double-indirect block will point us
403 * though the double-indirect run may be several blocks long,
434 data->max_indirect_range >> BEFS_SB(sb)->block_shift; in befs_find_brun_dblindirect()
436 off_t dbl_indir_off = blockno - indir_start_blk; in befs_find_brun_dblindirect()
439 * the indirect block pointed to by the double indirect block in befs_find_brun_dblindirect()
444 * the double indirect block in befs_find_brun_dblindirect()
449 befs_debug(sb, "---> %s find %lu", __func__, (unsigned long)blockno); in befs_find_brun_dblindirect()
451 /* First, discover which of the double_indir->indir blocks in befs_find_brun_dblindirect()
461 /* Read double indirect block */ in befs_find_brun_dblindirect()
463 if (dbl_which_block > data->double_indirect.len) { in befs_find_brun_dblindirect()
464 befs_error(sb, "The double-indirect index calculated by " in befs_find_brun_dblindirect()
465 "%s, %d, is outside the range " in befs_find_brun_dblindirect()
466 "of the double-indirect block", __func__, in befs_find_brun_dblindirect()
472 sb_bread(sb, iaddr2blockno(sb, &data->double_indirect) + in befs_find_brun_dblindirect()
476 "double-indirect block at blockno %lu", __func__, in befs_find_brun_dblindirect()
478 iaddr2blockno(sb, &data->double_indirect) + in befs_find_brun_dblindirect()
484 dblindir_indx - (dbl_which_block * befs_iaddrs_per_block(sb)); in befs_find_brun_dblindirect()
485 iaddr_array = (befs_disk_inode_addr *) dbl_indir_block->b_data; in befs_find_brun_dblindirect()
493 "%s, %d, is outside the range " in befs_find_brun_dblindirect()
507 block_indx = indir_indx - (which_block * befs_iaddrs_per_block(sb)); in befs_find_brun_dblindirect()
508 iaddr_array = (befs_disk_inode_addr *) indir_block->b_data; in befs_find_brun_dblindirect()
515 offset = blockno - blockno_at_run_start; in befs_find_brun_dblindirect()
517 run->start += offset; in befs_find_brun_dblindirect()
518 run->len -= offset; in befs_find_brun_dblindirect()