[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

ext3_free_data()



Hi,
why is there a window between  statements "err = ext3_journal_get_write_access(handle, this_bh);" and "ext3_journal_dirty_metadata(handle, this_bh);" ?
 
In my test, there is an error in journal_dirty_metadata: jh is null
thanks!
D.Yang
April 1, 2004
----------------------------------------------------------------------------------------------------------------------------------
/**
 * ext3_free_data - free a list of data blocks
 * @handle: handle for this transaction
 * @inode: inode we are dealing with
 * @this_bh: indirect buffer_head which contains * first and * last
 * @first: array of block numbers
 * @last: points immediately past the end of array
 *
 * We are freeing all blocks refered from that array (numbers are stored as
 * little-endian 32-bit) and updating @inode->i_blocks appropriately.
 *
 * We accumulate contiguous runs of blocks to free.  Conveniently, if these
 * blocks are contiguous then releasing them at one time will only affect one
 * or two bitmap blocks (+ group descriptor(s) and superblock) and we won't
 * actually use a lot of journal space.
 *
 * @this_bh will be %NULL if @first and @last point into the! inode's direct
 * block pointers.
 */
static void ext3_free_data(handle_t *handle, struct inode *inode,
      struct buffer_head *this_bh, u32 *first, u32 *last)
{
 unsigned long block_to_free = 0;    /* Starting block # of a run */
 unsigned long count = 0;     /* Number of blocks in the run */
 u32 *block_to_free_p = NULL;     /* Pointer into inode/ind
            corresponding to
            block_to_free */
 unsigned long nr;      /* Current block # */
 u32 *p;        /* Pointer into inode/ind
            for current block */
 int err;
 if (this_bh) {    /* For indirect block */
  BUFFER_TRACE(this_bh, "get_write_access");
  err = ext3_journal_get_write_access(handle, this_bh);
  /* Important: if we can't update the indirect pointers
   * to the blocks, we can't free them. */
  if (err)
   return;
 }
 for (p = first; p < last; p++) {
  conditional_schedule();
  nr = le32_to_cpu(*p);
  if (nr) {
   /* accumulate blocks to free if they're contiguous */
   if (count == 0) {
    block_to_free = nr;
    block_to_free_p = p;
    count = 1;
   } else if (nr == block_to_free + count) {
    count++;
   } else {
    ext3_clear_blocks(handle, inode, this_bh,
        block_to_free,
        count, block_to_free_p, p);
    block_to_free = nr;
    block_to_free_p = p;
    count = 1;
   }
  }
 }
 if (count > 0)
  ext3_clear_blocks(handle, inode, this_bh, block_to_free,
      count, block_to_free_p, p);
 if (this_bh) {
  BUFFER_TRACE(this_bh, "call ext3_journal_dirty_metadata");
  ext3_journal_dirty_metadata(handle, this_bh);
 }
}


Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway - Enter today
[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]