iscsi_allocmap_update(IscsiLun *iscsilun, int64_t sector_num,

                      int nb_sectors, bool allocated, bool valid)

{

    int64_t cl_num_expanded, nb_cls_expanded, cl_num_shrunk, nb_cls_shrunk;



    if (iscsilun->allocmap == NULL) {

        return;

    }

    /* expand to entirely contain all affected clusters */

    cl_num_expanded = sector_num / iscsilun->cluster_sectors;

    nb_cls_expanded = DIV_ROUND_UP(sector_num + nb_sectors,

                                   iscsilun->cluster_sectors) - cl_num_expanded;

    /* shrink to touch only completely contained clusters */

    cl_num_shrunk = DIV_ROUND_UP(sector_num, iscsilun->cluster_sectors);

    nb_cls_shrunk = (sector_num + nb_sectors) / iscsilun->cluster_sectors

                      - cl_num_shrunk;

    if (allocated) {

        bitmap_set(iscsilun->allocmap, cl_num_expanded, nb_cls_expanded);

    } else {

        bitmap_clear(iscsilun->allocmap, cl_num_shrunk, nb_cls_shrunk);

    }



    if (iscsilun->allocmap_valid == NULL) {

        return;

    }

    if (valid) {

        bitmap_set(iscsilun->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);

    } else {

        bitmap_clear(iscsilun->allocmap_valid, cl_num_expanded,

                     nb_cls_expanded);

    }

}

iscsi_allocmap_update(IscsiLun *iscsilun, int64_t sector_num,

                      int nb_sectors, bool allocated, bool valid)

{

    int64_t cl_num_expanded, nb_cls_expanded, cl_num_shrunk, nb_cls_shrunk;



    if (iscsilun->allocmap == NULL) {

        return;

    }

    

    cl_num_expanded = sector_num / iscsilun->cluster_sectors;

    nb_cls_expanded = DIV_ROUND_UP(sector_num + nb_sectors,

                                   iscsilun->cluster_sectors) - cl_num_expanded;

    

    cl_num_shrunk = DIV_ROUND_UP(sector_num, iscsilun->cluster_sectors);

    nb_cls_shrunk = (sector_num + nb_sectors) / iscsilun->cluster_sectors

                      - cl_num_shrunk;

    if (allocated) {

        bitmap_set(iscsilun->allocmap, cl_num_expanded, nb_cls_expanded);

    } else {

        bitmap_clear(iscsilun->allocmap, cl_num_shrunk, nb_cls_shrunk);

    }



    if (iscsilun->allocmap_valid == NULL) {

        return;

    }

    if (valid) {

        bitmap_set(iscsilun->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);

    } else {

        bitmap_clear(iscsilun->allocmap_valid, cl_num_expanded,

                     nb_cls_expanded);

    }

}

        bitmap_clear(iscsilun->allocmap, cl_num_shrunk, nb_cls_shrunk);         bitmap_set(iscsilun->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);
FUNC_0(IscsiLun *VAR_0, int64_t VAR_1,

                      int VAR_2, bool VAR_3, bool VAR_4)

{

    int64_t cl_num_expanded, nb_cls_expanded, cl_num_shrunk, nb_cls_shrunk;



    if (VAR_0->allocmap == NULL) {

        return;

    }

    

    cl_num_expanded = VAR_1 / VAR_0->cluster_sectors;

    nb_cls_expanded = DIV_ROUND_UP(VAR_1 + VAR_2,

                                   VAR_0->cluster_sectors) - cl_num_expanded;

    

    cl_num_shrunk = DIV_ROUND_UP(VAR_1, VAR_0->cluster_sectors);

    nb_cls_shrunk = (VAR_1 + VAR_2) / VAR_0->cluster_sectors

                      - cl_num_shrunk;

    if (VAR_3) {

        bitmap_set(VAR_0->allocmap, cl_num_expanded, nb_cls_expanded);

    } else {

        bitmap_clear(VAR_0->allocmap, cl_num_shrunk, nb_cls_shrunk);

    }



    if (VAR_0->allocmap_valid == NULL) {

        return;

    }

    if (VAR_4) {

        bitmap_set(VAR_0->allocmap_valid, cl_num_shrunk, nb_cls_shrunk);

    } else {

        bitmap_clear(VAR_0->allocmap_valid, cl_num_expanded,

                     nb_cls_expanded);

    }

}

FUNC_0(IscsiLun *VAR_0, int64_t VAR_1,
int VAR_2, bool VAR_3, bool VAR_4)
{ int64_t cl_num_expanded, nb_cls_expanded, cl_num_shrunk, nb_cls_shrunk; if (VAR_0->allocmap == NULL) { return; } cl_num_expanded = VAR_1 / VAR_0->cluster_sectors; nb_cls_expanded = DIV_ROUND_UP(VAR_1 + VAR_2,
VAR_0->cluster_sectors) - cl_num_expanded; cl_num_shrunk = DIV_ROUND_UP(VAR_1, VAR_0->cluster_sectors); nb_cls_shrunk = (VAR_1 + VAR_2) / VAR_0->cluster_sectors
- cl_num_shrunk; if (VAR_3) { bitmap_set(VAR_0->allocmap, cl_num_expanded, nb_cls_expanded); } else { bitmap_clear(VAR_0->allocmap, cl_num_shrunk, nb_cls_shrunk); } if (VAR_0->allocmap_valid == NULL) { return; } if (VAR_4) { bitmap_set(VAR_0->allocmap_valid, cl_num_shrunk, nb_cls_shrunk); } else { bitmap_clear(VAR_0->allocmap_valid, cl_num_expanded,
nb_cls_expanded); } }