Relocating a File Data Structure

Since file data structures can be cached in memory by the H5AC package it becomes problematic to move such a data structure in the file. One cannot just copy a portion of the file from one location to another because:

  1. the file might not contain the latest information, and
  2. the H5AC package might not realize that the object's address has changed and attempt to write the object to disk at the old address.

Here's a correct method to move data from one location to another. The example code assumes that one is moving a B-link tree node from old_addr to new_addr.

  1. Make sure the disk is up-to-date with respect to the cache. There is no need to remove the item from the cache, hence the final argument to H5AC_flush is FALSE.

    H5AC_flush (f, H5AC_BT, old_addr, FALSE);

  2. Read the data from the old address and write it to the new address.

    H5F_block_read (f, old_addr, size, buf);
    H5F_block_write (f, new_addr, size, buf);

  3. Notify the cache that the address of the object changed.

    H5AC_rename (f, H5AC_BT, old_addr, new_addr);

Last modified: Mon Jul 14 15:38:29 EST