@@ -75,7 +75,13 @@ befs_read_datastream(struct super_block *sb, const befs_data_stream *ds,
7575 return bh ;
7676}
7777
78- /*
78+ /**
79+ * befs_fblock2brun - give back block run for fblock
80+ * @sb: the superblock
81+ * @data: datastream to read from
82+ * @fblock: the blocknumber with the file position to find
83+ * @run: The found run is passed back through this pointer
84+ *
7985 * Takes a file position and gives back a brun who's starting block
8086 * is block number fblock of the file.
8187 *
@@ -212,36 +218,35 @@ befs_count_blocks(struct super_block *sb, const befs_data_stream *ds)
212218 return blocks ;
213219}
214220
215- /*
216- Finds the block run that starts at file block number blockno
217- in the file represented by the datastream data, if that
218- blockno is in the direct region of the datastream.
219-
220- sb: the superblock
221- data: the datastream
222- blockno: the blocknumber to find
223- run: The found run is passed back through this pointer
224-
225- Return value is BEFS_OK if the blockrun is found, BEFS_ERR
226- otherwise.
227-
228- Algorithm:
229- Linear search. Checks each element of array[] to see if it
230- contains the blockno-th filesystem block. This is necessary
231- because the block runs map variable amounts of data. Simply
232- keeps a count of the number of blocks searched so far (sum),
233- incrementing this by the length of each block run as we come
234- across it. Adds sum to *count before returning (this is so
235- you can search multiple arrays that are logicaly one array,
236- as in the indirect region code).
237-
238- When/if blockno is found, if blockno is inside of a block
239- run as stored on disk, we offset the start and length members
240- of the block run, so that blockno is the start and len is
241- still valid (the run ends in the same place).
242-
243- 2001-11-15 Will Dyson
244- */
221+ /**
222+ * befs_find_brun_direct - find a direct block run in the datastream
223+ * @sb: the superblock
224+ * @data: the datastream
225+ * @blockno: the blocknumber to find
226+ * @run: The found run is passed back through this pointer
227+ *
228+ * Finds the block run that starts at file block number blockno
229+ * in the file represented by the datastream data, if that
230+ * blockno is in the direct region of the datastream.
231+ *
232+ * Return value is BEFS_OK if the blockrun is found, BEFS_ERR
233+ * otherwise.
234+ *
235+ * Algorithm:
236+ * Linear search. Checks each element of array[] to see if it
237+ * contains the blockno-th filesystem block. This is necessary
238+ * because the block runs map variable amounts of data. Simply
239+ * keeps a count of the number of blocks searched so far (sum),
240+ * incrementing this by the length of each block run as we come
241+ * across it. Adds sum to *count before returning (this is so
242+ * you can search multiple arrays that are logicaly one array,
243+ * as in the indirect region code).
244+ *
245+ * When/if blockno is found, if blockno is inside of a block
246+ * run as stored on disk, we offset the start and length members
247+ * of the block run, so that blockno is the start and len is
248+ * still valid (the run ends in the same place).
249+ */
245250static int
246251befs_find_brun_direct (struct super_block * sb , const befs_data_stream * data ,
247252 befs_blocknr_t blockno , befs_block_run * run )
@@ -273,29 +278,28 @@ befs_find_brun_direct(struct super_block *sb, const befs_data_stream *data,
273278 return BEFS_ERR ;
274279}
275280
276- /*
277- Finds the block run that starts at file block number blockno
278- in the file represented by the datastream data, if that
279- blockno is in the indirect region of the datastream.
280-
281- sb: the superblock
282- data: the datastream
283- blockno: the blocknumber to find
284- run: The found run is passed back through this pointer
285-
286- Return value is BEFS_OK if the blockrun is found, BEFS_ERR
287- otherwise.
288-
289- Algorithm:
290- For each block in the indirect run of the datastream, read
291- it in and search through it for search_blk.
292-
293- XXX:
294- Really should check to make sure blockno is inside indirect
295- region.
296-
297- 2001-11-15 Will Dyson
298- */
281+ /**
282+ * befs_find_brun_indirect - find a block run in the datastream
283+ * @sb: the superblock
284+ * @data: the datastream
285+ * @blockno: the blocknumber to find
286+ * @run: The found run is passed back through this pointer
287+ *
288+ * Finds the block run that starts at file block number blockno
289+ * in the file represented by the datastream data, if that
290+ * blockno is in the indirect region of the datastream.
291+ *
292+ * Return value is BEFS_OK if the blockrun is found, BEFS_ERR
293+ * otherwise.
294+ *
295+ * Algorithm:
296+ * For each block in the indirect run of the datastream, read
297+ * it in and search through it for search_blk.
298+ *
299+ * XXX:
300+ * Really should check to make sure blockno is inside indirect
301+ * region.
302+ */
299303static int
300304befs_find_brun_indirect (struct super_block * sb ,
301305 const befs_data_stream * data ,
@@ -365,47 +369,46 @@ befs_find_brun_indirect(struct super_block *sb,
365369 return BEFS_ERR ;
366370}
367371
368- /*
369- Finds the block run that starts at file block number blockno
370- in the file represented by the datastream data, if that
371- blockno is in the double-indirect region of the datastream.
372-
373- sb: the superblock
374- data: the datastream
375- blockno: the blocknumber to find
376- run: The found run is passed back through this pointer
377-
378- Return value is BEFS_OK if the blockrun is found, BEFS_ERR
379- otherwise.
380-
381- Algorithm:
382- The block runs in the double-indirect region are different.
383- They are always allocated 4 fs blocks at a time, so each
384- block run maps a constant amount of file data. This means
385- that we can directly calculate how many block runs into the
386- double-indirect region we need to go to get to the one that
387- maps a particular filesystem block.
388-
389- We do this in two stages. First we calculate which of the
390- inode addresses in the double-indirect block will point us
391- to the indirect block that contains the mapping for the data,
392- then we calculate which of the inode addresses in that
393- indirect block maps the data block we are after.
394-
395- Oh, and once we've done that, we actually read in the blocks
396- that contain the inode addresses we calculated above. Even
397- though the double-indirect run may be several blocks long,
398- we can calculate which of those blocks will contain the index
399- we are after and only read that one. We then follow it to
400- the indirect block and perform a similar process to find
401- the actual block run that maps the data block we are interested
402- in.
403-
404- Then we offset the run as in befs_find_brun_array() and we are
405- done.
406-
407- 2001-11-15 Will Dyson
408- */
372+ /**
373+ * befs_find_brun_dblindirect - find a block run in the datastream
374+ * @sb: the superblock
375+ * @data: the datastream
376+ * @blockno: the blocknumber to find
377+ * @run: The found run is passed back through this pointer
378+ *
379+ * Finds the block run that starts at file block number blockno
380+ * in the file represented by the datastream data, if that
381+ * blockno is in the double-indirect region of the datastream.
382+ *
383+ * Return value is BEFS_OK if the blockrun is found, BEFS_ERR
384+ * otherwise.
385+ *
386+ * Algorithm:
387+ * The block runs in the double-indirect region are different.
388+ * They are always allocated 4 fs blocks at a time, so each
389+ * block run maps a constant amount of file data. This means
390+ * that we can directly calculate how many block runs into the
391+ * double-indirect region we need to go to get to the one that
392+ * maps a particular filesystem block.
393+ *
394+ * We do this in two stages. First we calculate which of the
395+ * inode addresses in the double-indirect block will point us
396+ * to the indirect block that contains the mapping for the data,
397+ * then we calculate which of the inode addresses in that
398+ * indirect block maps the data block we are after.
399+ *
400+ * Oh, and once we've done that, we actually read in the blocks
401+ * that contain the inode addresses we calculated above. Even
402+ * though the double-indirect run may be several blocks long,
403+ * we can calculate which of those blocks will contain the index
404+ * we are after and only read that one. We then follow it to
405+ * the indirect block and perform a similar process to find
406+ * the actual block run that maps the data block we are interested
407+ * in.
408+ *
409+ * Then we offset the run as in befs_find_brun_array() and we are
410+ * done.
411+ */
409412static int
410413befs_find_brun_dblindirect (struct super_block * sb ,
411414 const befs_data_stream * data ,
0 commit comments