Logo Search packages:      
Sourcecode: ganeti version File versions  Download package

def lib::bdev::MDRaid1::_ZeroSuperblock (   dev_path  )  [private]

Zero the possible locations for an MD superblock.

The zero-ing can't be done via ``mdadm --zero-superblock`` as that
fails in versions 2.x with the same error code as non-writable
device.

The superblocks are located at (negative values are relative to
the end of the block device):
  - -128k to end for version 0.90 superblock
  - -8k to -12k for version 1.0 superblock (included in the above)
  - 0k to 4k for version 1.1 superblock
  - 4k to 8k for version 1.2 superblock

To cover all situations, the zero-ing will be:
  - 0k to 128k
  - -128k to end

As such, the minimum device size must be 128k, otherwise we'll get
I/O errors.

Note that this function depends on the fact that one can open,
read and write block devices normally.

Definition at line 659 of file bdev.py.

00659                                :
    """Zero the possible locations for an MD superblock.

    The zero-ing can't be done via ``mdadm --zero-superblock`` as that
    fails in versions 2.x with the same error code as non-writable
    device.

    The superblocks are located at (negative values are relative to
    the end of the block device):
      - -128k to end for version 0.90 superblock
      - -8k to -12k for version 1.0 superblock (included in the above)
      - 0k to 4k for version 1.1 superblock
      - 4k to 8k for version 1.2 superblock

    To cover all situations, the zero-ing will be:
      - 0k to 128k
      - -128k to end

    As such, the minimum device size must be 128k, otherwise we'll get
    I/O errors.

    Note that this function depends on the fact that one can open,
    read and write block devices normally.

    """
    overwrite_size = 128 * 1024
    empty_buf = '\0' * overwrite_size
    fd = open(dev_path, "r+")
    try:
      fd.seek(0, 0)
      p1 = fd.tell()
      fd.write(empty_buf)
      p2 = fd.tell()
      logger.Debug("Zeroed %s from %d to %d" % (dev_path, p1, p2))
      fd.seek(-overwrite_size, 2)
      p1 = fd.tell()
      fd.write(empty_buf)
      p2 = fd.tell()
      logger.Debug("Zeroed %s from %d to %d" % (dev_path, p1, p2))
    finally:
      fd.close()

  @classmethod
  def Create(cls, unique_id, children, size):


Generated by  Doxygen 1.6.0   Back to index