Beispiel #1
0
    def get_internal_md_kiB(cls, is_net_size, size_kiB, peers, al_stripes,
                            al_stripe_kiB):
        """
        Returns the amount of storage required for internal meta data
        """
        if type(is_net_size) is not bool:
            logging.error(
                "Implementation error: Incorrect use of "
                "drbdmanage.drbd.metadata.MetaData.get_internal_md_kiB")
            raise dmexc.DebugException
        size_kiB = long(size_kiB)
        peers = int(peers)
        al_stripes = int(al_stripes)
        al_stripe_kiB = int(al_stripe_kiB)

        size_kiB = utils.align_up(size_kiB, MetaData.DRBD_BM_BIT_COVER_kiB)

        al_kiB = MetaData._get_al_kiB(al_stripes, al_stripe_kiB)
        md_kiB = 0
        if is_net_size:
            bitmap_kiB = MetaData._get_bitmap_internal_kiB_net(
                size_kiB, peers, al_stripes, al_stripe_kiB)
            md_kiB = utils.align_up(
                al_kiB + bitmap_kiB + MetaData.DRBD_MD_SUPERBLK_kiB,
                MetaData.DRBD_MD_ALIGN_kiB)
        else:
            bitmap_kiB = MetaData._get_bitmap_internal_kiB_gross(
                size_kiB, peers)
            md_kiB = utils.align_up(
                al_kiB + bitmap_kiB + MetaData.DRBD_MD_SUPERBLK_kiB,
                MetaData.DRBD_MD_ALIGN_kiB)

        return md_kiB
Beispiel #2
0
    def get_gross_kiB(cls, net_kiB, peers, al_stripes, al_stripe_kiB):
        """
        Returns the backend storage gross size required to provide the specified net size
        """
        net_kiB = long(net_kiB)
        peers = int(peers)
        al_stripes = int(al_stripes)
        al_stripe_kiB = int(al_stripe_kiB)

        # BEGIN HOTFIX
        # FIXME: Hotfix for resizing restored snapshots
        #        after reducing the number of maximum peers
        peers = consts.HOTFIX_MAX_PEERS
        # END HOTFIX

        gross_kiB = 0

        bitmap_kiB = MetaData._get_bitmap_internal_kiB_net(
            net_kiB, peers, al_stripes, al_stripe_kiB)

        al_kiB = MetaData._get_al_kiB(al_stripes, al_stripe_kiB)
        md_kiB = utils.align_up(
            bitmap_kiB + al_kiB + MetaData.DRBD_MD_SUPERBLK_kiB,
            MetaData.DRBD_MD_ALIGN_kiB)
        gross_kiB = utils.align_up(net_kiB,
                                   MetaData.DRBD_BM_BIT_COVER_kiB) + md_kiB

        check_max_drbd_kiB(gross_kiB)
        if gross_kiB < MetaData.DRBD_MIN_GROSS_kiB:
            gross_kiB = MetaData.DRBD_MIN_GROSS_kiB

        return gross_kiB
Beispiel #3
0
    def _get_bitmap_internal_kiB_net(cls, net_kiB, peers, al_stripes,
                                     al_stripe_kiB):
        net_kiB = long(net_kiB)
        peers = int(peers)
        al_stripes = int(al_stripes)
        al_stripe_kiB = int(al_stripe_kiB)

        check_min_drbd_kiB_net(net_kiB)
        check_max_drbd_kiB(net_kiB)
        check_peers(peers)

        al_kiB = MetaData._get_al_kiB(al_stripes, al_stripe_kiB)

        # Base size for the recalculation of the gross size
        # in each iteration of the sequence limit loop
        # The base size is the net data + activity log + superblock,
        # but without the bitmap, therefore:
        # base_size_kiB + bitmap_kiB == gross_kiB
        base_kiB = net_kiB + al_kiB + MetaData.DRBD_MD_SUPERBLK_kiB

        # Calculate the size of the bitmap required to cover the
        # gross size of the device, which includes the size of the bitmap.
        gross_kiB = base_kiB
        bitmap_kiB = 0
        bitmap_cover_kiB = 0
        while bitmap_cover_kiB < gross_kiB:
            # Bitmap size required to cover the gross size on each peer
            bitmap_peer_b = utils.ceiling_divide(
                gross_kiB, MetaData.DRBD_BM_BYTE_COVER_kiB)
            # Align to the per-peer bitmap granularity
            bitmap_peer_b = utils.align_up(bitmap_peer_b,
                                           MetaData.DRBD_BM_PEER_ALIGN)

            # Bitmap size for all peers
            bitmap_b = bitmap_peer_b * peers

            # Gross size covered by the current bitmap size
            bitmap_cover_kiB = bitmap_peer_b * MetaData.DRBD_BM_BYTE_COVER_kiB

            # Actual size of the bitmap in the DRBD metadata area (after alignment)
            bitmap_kiB = utils.align_up(
                utils.align_up(bitmap_b, 1024) / 1024,
                MetaData.DRBD_BM_ALIGN_kiB)

            # Resulting gross size after including the bitmap size
            gross_kiB = base_kiB + bitmap_kiB

        check_max_drbd_kiB(gross_kiB)

        return bitmap_kiB
Beispiel #4
0
    def get_net_kiB(cls, gross_kiB, peers, al_stripes, al_stripe_kiB):
        """
        Returns the net size that can be provided by a backend storage with the specified gross size
        """
        gross_kiB = long(gross_kiB)
        peers = int(peers)
        al_stripes = int(al_stripes)
        al_stripe_kiB = int(al_stripe_kiB)

        net_kiB = 0

        bitmap_kiB = MetaData._get_bitmap_internal_kiB_gross(gross_kiB, peers)
        al_kiB = MetaData._get_al_kiB(al_stripes, al_stripe_kiB)

        md_kiB = utils.align_up(
            bitmap_kiB + al_kiB + MetaData.DRBD_MD_SUPERBLK_kiB,
            MetaData.DRBD_MD_ALIGN_kiB)
        gross_kiB = utils.align_down(gross_kiB, MetaData.DRBD_BM_BIT_COVER_kiB)
        if md_kiB < gross_kiB:
            net_kiB = gross_kiB - md_kiB
        else:
            raise MinSizeException(
                "The specified DRBD volume gross size (%d kiB) is too small to keep the volume's meta data area"
                % (gross_kiB))

        return net_kiB
Beispiel #5
0
    def _get_al_kiB(cls, al_stripes, al_stripe_kiB):
        al_stripes = int(al_stripes)
        al_stripe_kiB = long(al_stripe_kiB)

        if al_stripes < 1:
            raise AlStripesException(
                "Number of activity log strips (%d) is smaller than the minimum of 1"
                % (al_stripes))

        if al_stripe_kiB < 1:
            raise MinAlSizeException(
                "Activity log stripe size (%d kiB) is smaller than the minimum of 1 kiB"
                % (al_stripe_kiB))

        if al_stripe_kiB > MetaData.DRBD_MAX_AL_kiB:
            raise MaxAlSizeException(
                "Activity log stripe size (%d kiB) is larger than the maximum of %d kiB"
                % (al_stripe_kiB, MetaData.DRBD_MAX_AL_kiB))

        al_kiB = al_stripe_kiB * al_stripes
        al_kiB = utils.align_up(al_kiB, MetaData.DRBD_AL_ALIGN_kiB)

        if al_kiB < MetaData.DRBD_MIN_AL_kiB:
            raise MinAlSizeException(
                "Activity log total size (%d kiB) is smaller than the minimum of 1 kiB"
                % (al_stripe_kiB))
        elif al_kiB > MetaData.DRBD_MAX_AL_kiB:
            raise MaxAlSizeException(
                "Activity log total size (%d kiB) is larger than the maximum of %d kiB"
                % (al_stripe_kiB, MetaData.DRBD_MAX_AL_kiB))

        return al_kiB
Beispiel #6
0
    def _get_bitmap_external_kiB(cls, size_kiB, peers):
        size_kiB = long(size_kiB)
        peers = int(peers)

        check_max_drbd_kiB(size_kiB)
        check_peers(peers)

        size_kiB = utils.align_up(size_kiB, MetaData.DRBD_BM_BIT_COVER_kiB)

        bitmap_peer_b = utils.ceiling_divide(size_kiB,
                                             MetaData.DRBD_BM_BYTE_COVER_kiB)
        bitmap_peer_b = utils.align_up(bitmap_peer_b,
                                       MetaData.DRBD_BM_PEER_ALIGN)
        bitmap_b = bitmap_peer_b * peers
        bitmap_kiB = utils.align_up(
            utils.align_up(bitmap_b, 1024) / 1024, MetaData.DRBD_BM_ALIGN_kiB)

        return bitmap_kiB
Beispiel #7
0
    def _get_bitmap_internal_kiB_gross(cls, gross_kiB, peers):
        gross_kiB = long(gross_kiB)
        peers = int(peers)

        check_min_drbd_kiB_gross(gross_kiB)
        check_max_drbd_kiB(gross_kiB)
        check_peers(peers)

        gross_kiB = utils.align_up(gross_kiB, MetaData.DRBD_BM_BIT_COVER_kiB)

        bitmap_peer_b = utils.ceiling_divide(gross_kiB,
                                             MetaData.DRBD_BM_BYTE_COVER_kiB)
        bitmap_peer_b = utils.align_up(bitmap_peer_b,
                                       MetaData.DRBD_BM_PEER_ALIGN)
        bitmap_b = bitmap_peer_b * peers
        bitmap_kiB = utils.align_up(
            utils.align_up(bitmap_b, 1024) / 1024, MetaData.DRBD_BM_ALIGN_kiB)

        return bitmap_kiB
Beispiel #8
0
    def get_external_md_kiB(cls, size_kiB, peers, al_stripes, al_stripe_kiB):
        """
        Returns the amount of storage required for external meta data
        """
        size_kiB = long(size_kiB)
        peers = int(peers)
        al_stripes = int(al_stripes)
        al_stripe_kiB = int(al_stripe_kiB)

        md_kiB = 0

        check_max_drbd_kiB(size_kiB)
        check_peers(peers)

        size_kiB = utils.align_up(size_kiB, MetaData.DRBD_BM_BIT_COVER_kiB)

        al_kiB = MetaData._get_al_kiB(al_stripes, al_stripe_kiB)
        bitmap_kiB = MetaData._get_bitmap_external_kiB(size_kiB, peers)
        md_kiB = utils.align_up(
            al_kiB + bitmap_kiB + MetaData.DRBD_MD_SUPERBLK_kiB,
            MetaData.DRBD_MD_ALIGN_kiB)

        return md_kiB