static void expand (struct mempool *pool) { size_t size; char *mem; size = pool->chunk_size; GET_MEMORY (mem, size); if (!mem) { size = UNW_ALIGN(pool->obj_size, pg_size); GET_MEMORY (mem, size); if (!mem) { /* last chance: try to allocate one object from the SOS memory */ size = pool->obj_size; mem = sos_alloc (size); } } add_memory (pool, mem, size, pool->obj_size); }
BS_IO_RETURN_t simpleOSD_lun_open(char *path, /*IN*/ int oflag, /*IN*/ uint64_t *size, /*OUT*/ uint32_t *blksize, /*OUT*/ int *lun_index){ /*OUT*/ BS_IO_RETURN_t ret = BS_IO_SUCCESS; int next_free_lun=0; int is_free=FALSE; for(next_free_lun=0;next_free_lun<NB_MAX_LUN && (p_simpleOSD_lun_list[next_free_lun]);next_free_lun++){ if((IS_FREE(p_simpleOSD_lun_list[next_free_lun]))) break; } if(next_free_lun>=NB_MAX_LUN){ ret=BS_IO_ERROR; BLOCKFRONT_LOG(LOG_CRITICAL,"\n Reached max LUN limit:%d",NB_MAX_LUN); goto end; } if(!(p_simpleOSD_lun_list[next_free_lun])) p_simpleOSD_lun_list[next_free_lun]=GET_MEMORY(sizeof(osd_lun_t)); USE_LUN(p_simpleOSD_lun_list[next_free_lun]); osd_lun_t *p_curr_lun=(osd_lun_t*)VAL_POINTER(p_simpleOSD_lun_list[next_free_lun]); /*Need to modify path name as <dc_path>/dev_blockdev_name and separate block_dev_name from absolute path*/ strncpy(p_curr_lun->lun_vol,path,MAXNAMESIZE); p_curr_lun->lun_index=next_free_lun; p_curr_lun->io_flag=oflag; snprintf(p_curr_lun->datacache_info.lun_dc_path,MAXPATHSIZE,"/%s/%s/", global_blk_frontend_parameters.dc_path,p_curr_lun->lun_vol); /*Update Lun from MDS or conf file based on device name */ if(ret=simpleOSD_get_lun_info(p_curr_lun)){ ret=BS_IO_ERROR; goto end; } *size=p_curr_lun->lun_capacity; *blksize=p_curr_lun->block_size; *lun_index=next_free_lun; end: return ret; }