summaryrefslogtreecommitdiffstats
path: root/fs/befs/datastream.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/befs/datastream.c')
-rw-r--r--fs/befs/datastream.c87
1 files changed, 45 insertions, 42 deletions
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index 59096b5e0fc7..c467bebd50af 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -52,26 +52,25 @@ befs_read_datastream(struct super_block *sb, befs_data_stream * ds,
52 befs_block_run run; 52 befs_block_run run;
53 befs_blocknr_t block; /* block coresponding to pos */ 53 befs_blocknr_t block; /* block coresponding to pos */
54 54
55 befs_debug(sb, "---> befs_read_datastream() %Lu", pos); 55 befs_debug(sb, "---> %s %llu", __func__, pos);
56 block = pos >> BEFS_SB(sb)->block_shift; 56 block = pos >> BEFS_SB(sb)->block_shift;
57 if (off) 57 if (off)
58 *off = pos - (block << BEFS_SB(sb)->block_shift); 58 *off = pos - (block << BEFS_SB(sb)->block_shift);
59 59
60 if (befs_fblock2brun(sb, ds, block, &run) != BEFS_OK) { 60 if (befs_fblock2brun(sb, ds, block, &run) != BEFS_OK) {
61 befs_error(sb, "BeFS: Error finding disk addr of block %lu", 61 befs_error(sb, "BeFS: Error finding disk addr of block %lu",
62 block); 62 (unsigned long)block);
63 befs_debug(sb, "<--- befs_read_datastream() ERROR"); 63 befs_debug(sb, "<--- %s ERROR", __func__);
64 return NULL; 64 return NULL;
65 } 65 }
66 bh = befs_bread_iaddr(sb, run); 66 bh = befs_bread_iaddr(sb, run);
67 if (!bh) { 67 if (!bh) {
68 befs_error(sb, "BeFS: Error reading block %lu from datastream", 68 befs_error(sb, "BeFS: Error reading block %lu from datastream",
69 block); 69 (unsigned long)block);
70 return NULL; 70 return NULL;
71 } 71 }
72 72
73 befs_debug(sb, "<--- befs_read_datastream() read data, starting at %Lu", 73 befs_debug(sb, "<--- %s read data, starting at %llu", __func__, pos);
74 pos);
75 74
76 return bh; 75 return bh;
77} 76}
@@ -106,7 +105,8 @@ befs_fblock2brun(struct super_block *sb, befs_data_stream * data,
106 } else { 105 } else {
107 befs_error(sb, 106 befs_error(sb,
108 "befs_fblock2brun() was asked to find block %lu, " 107 "befs_fblock2brun() was asked to find block %lu, "
109 "which is not mapped by the datastream\n", fblock); 108 "which is not mapped by the datastream\n",
109 (unsigned long)fblock);
110 err = BEFS_ERR; 110 err = BEFS_ERR;
111 } 111 }
112 return err; 112 return err;
@@ -128,14 +128,14 @@ befs_read_lsymlink(struct super_block * sb, befs_data_stream * ds, void *buff,
128 befs_off_t bytes_read = 0; /* bytes readed */ 128 befs_off_t bytes_read = 0; /* bytes readed */
129 u16 plen; 129 u16 plen;
130 struct buffer_head *bh = NULL; 130 struct buffer_head *bh = NULL;
131 befs_debug(sb, "---> befs_read_lsymlink() length: %Lu", len); 131 befs_debug(sb, "---> %s length: %llu", __func__, len);
132 132
133 while (bytes_read < len) { 133 while (bytes_read < len) {
134 bh = befs_read_datastream(sb, ds, bytes_read, NULL); 134 bh = befs_read_datastream(sb, ds, bytes_read, NULL);
135 if (!bh) { 135 if (!bh) {
136 befs_error(sb, "BeFS: Error reading datastream block " 136 befs_error(sb, "BeFS: Error reading datastream block "
137 "starting from %Lu", bytes_read); 137 "starting from %llu", bytes_read);
138 befs_debug(sb, "<--- befs_read_lsymlink() ERROR"); 138 befs_debug(sb, "<--- %s ERROR", __func__);
139 return bytes_read; 139 return bytes_read;
140 140
141 } 141 }
@@ -146,7 +146,8 @@ befs_read_lsymlink(struct super_block * sb, befs_data_stream * ds, void *buff,
146 bytes_read += plen; 146 bytes_read += plen;
147 } 147 }
148 148
149 befs_debug(sb, "<--- befs_read_lsymlink() read %u bytes", bytes_read); 149 befs_debug(sb, "<--- %s read %u bytes", __func__, (unsigned int)
150 bytes_read);
150 return bytes_read; 151 return bytes_read;
151} 152}
152 153
@@ -169,7 +170,7 @@ befs_count_blocks(struct super_block * sb, befs_data_stream * ds)
169 befs_blocknr_t metablocks; /* FS metadata blocks */ 170 befs_blocknr_t metablocks; /* FS metadata blocks */
170 befs_sb_info *befs_sb = BEFS_SB(sb); 171 befs_sb_info *befs_sb = BEFS_SB(sb);
171 172
172 befs_debug(sb, "---> befs_count_blocks()"); 173 befs_debug(sb, "---> %s", __func__);
173 174
174 datablocks = ds->size >> befs_sb->block_shift; 175 datablocks = ds->size >> befs_sb->block_shift;
175 if (ds->size & (befs_sb->block_size - 1)) 176 if (ds->size & (befs_sb->block_size - 1))
@@ -206,7 +207,7 @@ befs_count_blocks(struct super_block * sb, befs_data_stream * ds)
206 } 207 }
207 208
208 blocks = datablocks + metablocks; 209 blocks = datablocks + metablocks;
209 befs_debug(sb, "<--- befs_count_blocks() %u blocks", blocks); 210 befs_debug(sb, "<--- %s %u blocks", __func__, (unsigned int)blocks);
210 211
211 return blocks; 212 return blocks;
212} 213}
@@ -251,11 +252,11 @@ befs_find_brun_direct(struct super_block *sb, befs_data_stream * data,
251 befs_blocknr_t max_block = 252 befs_blocknr_t max_block =
252 data->max_direct_range >> BEFS_SB(sb)->block_shift; 253 data->max_direct_range >> BEFS_SB(sb)->block_shift;
253 254
254 befs_debug(sb, "---> befs_find_brun_direct(), find %lu", blockno); 255 befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno);
255 256
256 if (blockno > max_block) { 257 if (blockno > max_block) {
257 befs_error(sb, "befs_find_brun_direct() passed block outside of" 258 befs_error(sb, "%s passed block outside of direct region",
258 "direct region"); 259 __func__);
259 return BEFS_ERR; 260 return BEFS_ERR;
260 } 261 }
261 262
@@ -267,13 +268,14 @@ befs_find_brun_direct(struct super_block *sb, befs_data_stream * data,
267 run->start = array[i].start + offset; 268 run->start = array[i].start + offset;
268 run->len = array[i].len - offset; 269 run->len = array[i].len - offset;
269 270
270 befs_debug(sb, "---> befs_find_brun_direct(), " 271 befs_debug(sb, "---> %s, "
271 "found %lu at direct[%d]", blockno, i); 272 "found %lu at direct[%d]", __func__,
273 (unsigned long)blockno, i);
272 return BEFS_OK; 274 return BEFS_OK;
273 } 275 }
274 } 276 }
275 277
276 befs_debug(sb, "---> befs_find_brun_direct() ERROR"); 278 befs_debug(sb, "---> %s ERROR", __func__);
277 return BEFS_ERR; 279 return BEFS_ERR;
278} 280}
279 281
@@ -316,7 +318,7 @@ befs_find_brun_indirect(struct super_block *sb,
316 befs_blocknr_t indirblockno = iaddr2blockno(sb, &indirect); 318 befs_blocknr_t indirblockno = iaddr2blockno(sb, &indirect);
317 int arraylen = befs_iaddrs_per_block(sb); 319 int arraylen = befs_iaddrs_per_block(sb);
318 320
319 befs_debug(sb, "---> befs_find_brun_indirect(), find %lu", blockno); 321 befs_debug(sb, "---> %s, find %lu", __func__, (unsigned long)blockno);
320 322
321 indir_start_blk = data->max_direct_range >> BEFS_SB(sb)->block_shift; 323 indir_start_blk = data->max_direct_range >> BEFS_SB(sb)->block_shift;
322 search_blk = blockno - indir_start_blk; 324 search_blk = blockno - indir_start_blk;
@@ -325,10 +327,9 @@ befs_find_brun_indirect(struct super_block *sb,
325 for (i = 0; i < indirect.len; i++) { 327 for (i = 0; i < indirect.len; i++) {
326 indirblock = befs_bread(sb, indirblockno + i); 328 indirblock = befs_bread(sb, indirblockno + i);
327 if (indirblock == NULL) { 329 if (indirblock == NULL) {
328 befs_debug(sb, 330 befs_debug(sb, "---> %s failed to read "
329 "---> befs_find_brun_indirect() failed to " 331 "disk block %lu from the indirect brun",
330 "read disk block %lu from the indirect brun", 332 __func__, (unsigned long)indirblockno + i);
331 indirblockno + i);
332 return BEFS_ERR; 333 return BEFS_ERR;
333 } 334 }
334 335
@@ -348,9 +349,10 @@ befs_find_brun_indirect(struct super_block *sb,
348 349
349 brelse(indirblock); 350 brelse(indirblock);
350 befs_debug(sb, 351 befs_debug(sb,
351 "<--- befs_find_brun_indirect() found " 352 "<--- %s found file block "
352 "file block %lu at indirect[%d]", 353 "%lu at indirect[%d]", __func__,
353 blockno, j + (i * arraylen)); 354 (unsigned long)blockno,
355 j + (i * arraylen));
354 return BEFS_OK; 356 return BEFS_OK;
355 } 357 }
356 sum += len; 358 sum += len;
@@ -360,10 +362,10 @@ befs_find_brun_indirect(struct super_block *sb,
360 } 362 }
361 363
362 /* Only fallthrough is an error */ 364 /* Only fallthrough is an error */
363 befs_error(sb, "BeFS: befs_find_brun_indirect() failed to find " 365 befs_error(sb, "BeFS: %s failed to find "
364 "file block %lu", blockno); 366 "file block %lu", __func__, (unsigned long)blockno);
365 367
366 befs_debug(sb, "<--- befs_find_brun_indirect() ERROR"); 368 befs_debug(sb, "<--- %s ERROR", __func__);
367 return BEFS_ERR; 369 return BEFS_ERR;
368} 370}
369 371
@@ -444,7 +446,7 @@ befs_find_brun_dblindirect(struct super_block *sb,
444 size_t diblklen = iblklen * befs_iaddrs_per_block(sb) 446 size_t diblklen = iblklen * befs_iaddrs_per_block(sb)
445 * BEFS_DBLINDIR_BRUN_LEN; 447 * BEFS_DBLINDIR_BRUN_LEN;
446 448
447 befs_debug(sb, "---> befs_find_brun_dblindirect() find %lu", blockno); 449 befs_debug(sb, "---> %s find %lu", __func__, (unsigned long)blockno);
448 450
449 /* First, discover which of the double_indir->indir blocks 451 /* First, discover which of the double_indir->indir blocks
450 * contains pos. Then figure out how much of pos that 452 * contains pos. Then figure out how much of pos that
@@ -460,8 +462,9 @@ befs_find_brun_dblindirect(struct super_block *sb,
460 dbl_which_block = dblindir_indx / befs_iaddrs_per_block(sb); 462 dbl_which_block = dblindir_indx / befs_iaddrs_per_block(sb);
461 if (dbl_which_block > data->double_indirect.len) { 463 if (dbl_which_block > data->double_indirect.len) {
462 befs_error(sb, "The double-indirect index calculated by " 464 befs_error(sb, "The double-indirect index calculated by "
463 "befs_read_brun_dblindirect(), %d, is outside the range " 465 "%s, %d, is outside the range "
464 "of the double-indirect block", dblindir_indx); 466 "of the double-indirect block", __func__,
467 dblindir_indx);
465 return BEFS_ERR; 468 return BEFS_ERR;
466 } 469 }
467 470
@@ -469,10 +472,10 @@ befs_find_brun_dblindirect(struct super_block *sb,
469 befs_bread(sb, iaddr2blockno(sb, &data->double_indirect) + 472 befs_bread(sb, iaddr2blockno(sb, &data->double_indirect) +
470 dbl_which_block); 473 dbl_which_block);
471 if (dbl_indir_block == NULL) { 474 if (dbl_indir_block == NULL) {
472 befs_error(sb, "befs_read_brun_dblindirect() couldn't read the " 475 befs_error(sb, "%s couldn't read the "
473 "double-indirect block at blockno %lu", 476 "double-indirect block at blockno %lu", __func__,
474 iaddr2blockno(sb, 477 (unsigned long)
475 &data->double_indirect) + 478 iaddr2blockno(sb, &data->double_indirect) +
476 dbl_which_block); 479 dbl_which_block);
477 brelse(dbl_indir_block); 480 brelse(dbl_indir_block);
478 return BEFS_ERR; 481 return BEFS_ERR;
@@ -489,16 +492,16 @@ befs_find_brun_dblindirect(struct super_block *sb,
489 which_block = indir_indx / befs_iaddrs_per_block(sb); 492 which_block = indir_indx / befs_iaddrs_per_block(sb);
490 if (which_block > indir_run.len) { 493 if (which_block > indir_run.len) {
491 befs_error(sb, "The indirect index calculated by " 494 befs_error(sb, "The indirect index calculated by "
492 "befs_read_brun_dblindirect(), %d, is outside the range " 495 "%s, %d, is outside the range "
493 "of the indirect block", indir_indx); 496 "of the indirect block", __func__, indir_indx);
494 return BEFS_ERR; 497 return BEFS_ERR;
495 } 498 }
496 499
497 indir_block = 500 indir_block =
498 befs_bread(sb, iaddr2blockno(sb, &indir_run) + which_block); 501 befs_bread(sb, iaddr2blockno(sb, &indir_run) + which_block);
499 if (indir_block == NULL) { 502 if (indir_block == NULL) {
500 befs_error(sb, "befs_read_brun_dblindirect() couldn't read the " 503 befs_error(sb, "%s couldn't read the indirect block "
501 "indirect block at blockno %lu", 504 "at blockno %lu", __func__, (unsigned long)
502 iaddr2blockno(sb, &indir_run) + which_block); 505 iaddr2blockno(sb, &indir_run) + which_block);
503 brelse(indir_block); 506 brelse(indir_block);
504 return BEFS_ERR; 507 return BEFS_ERR;
@@ -519,7 +522,7 @@ befs_find_brun_dblindirect(struct super_block *sb,
519 run->len -= offset; 522 run->len -= offset;
520 523
521 befs_debug(sb, "Found file block %lu in double_indirect[%d][%d]," 524 befs_debug(sb, "Found file block %lu in double_indirect[%d][%d],"
522 " double_indirect_leftover = %lu", 525 " double_indirect_leftover = %lu", (unsigned long)
523 blockno, dblindir_indx, indir_indx, dblindir_leftover); 526 blockno, dblindir_indx, indir_indx, dblindir_leftover);
524 527
525 return BEFS_OK; 528 return BEFS_OK;