BurstFS_Server/burstfs_metadata.c
int meta_process_fsync (int sock_id) {
	int ret = 0;

	int app_id = invert_sock_ids[sock_id];
	app_config_t *app_config = (app_config_t *)arraylist_get(app_config_list, app_id);

	int client_side_id = app_config->client_ranks[sock_id];

	unsigned long num_entries =\
			*((unsigned long *)(app_config->shm_superblocks[client_side_id]\
			+ app_config->meta_offset));

	/* indices are stored in the superblock shared memory
	 *  created by the client*/
	int page_sz = getpagesize();
	burstfs_index_t *meta_payload =\
			(burstfs_index_t *)(app_config->shm_superblocks[client_side_id]\
			+ app_config->meta_offset + page_sz);

	md->primary_index = burstfs_indexes[0];

	long i;
	for (i = 0; i < num_entries; i++) {
		burstfs_keys[i]->fid = meta_payload[i].fid;
		burstfs_keys[i]->offset = meta_payload[i].file_pos;
		burstfs_vals[i]->addr = meta_payload[i].mem_pos;
		burstfs_vals[i]->len = meta_payload[i].length;
		burstfs_vals[i]->delegator_id = glb_rank;
		memcpy((char *)&(burstfs_vals[i]->app_rank_id), &app_id, sizeof(int));
		memcpy((char  *)&(burstfs_vals[i]->app_rank_id) + sizeof(int),\
				&client_side_id, sizeof(int));

		burstfs_key_lens[i] = sizeof(burstfs_key_t);
		burstfs_val_lens[i] = sizeof(burstfs_val_t);
	}

   // print_fsync_indices(burstfs_keys, burstfs_vals, num_entries);

	brm = mdhimBPut(md, (void **)(&burstfs_keys[0]), burstfs_key_lens,
			(void **)(&burstfs_vals[0]), burstfs_val_lens, num_entries,
			NULL, NULL);
	brmp = brm;
	if (!brmp || brmp->error) {
		  ret = ULFS_ERROR_MDHIM;
		  LOG(LOG_DBG, "Rank - %d: Error inserting keys/values into MDHIM\n",\
				  md->mdhim_rank);
	}

	while (brmp) {
		if (brmp->error < 0) {
			ret = ULFS_ERROR_MDHIM;
			break;
		}

		brm = brmp;
		brmp = brmp->next;
		mdhim_full_release_msg(brm);

	}

	md->primary_index = burstfs_indexes[1];

	num_entries =\
			*((unsigned long *)(app_config->shm_superblocks[client_side_id]\
					+ app_config->fmeta_offset));

	/* file attributes are stored in the superblock shared memory
	 * created by the client*/
	burstfs_file_attr_t *attr_payload =\
			(burstfs_file_attr_t *)(app_config->shm_superblocks[client_side_id]\
					+ app_config->fmeta_offset + page_sz);


	for (i = 0; i < num_entries; i++) {
		*fattr_keys[i] = attr_payload[i].gfid;
		fattr_vals[i]->file_attr = attr_payload[i].file_attr;
		strcpy(fattr_vals[i]->fname, attr_payload[i].filename);

		fattr_key_lens[i] = sizeof(fattr_key_t);
		fattr_val_lens[i] = sizeof(fattr_val_t);
	}

	brm = mdhimBPut(md, (void **)(&fattr_keys[0]), fattr_key_lens,
			(void **)(&fattr_vals[0]), fattr_val_lens, num_entries,
			NULL, NULL);
	brmp = brm;
	if (!brmp || brmp->error) {
		  ret = ULFS_ERROR_MDHIM;
		  LOG(LOG_DBG, "Rank - %d: Error inserting keys/values into MDHIM\n",\
				  md->mdhim_rank);
	}

	while (brmp) {
		if (brmp->error < 0) {
			ret = ULFS_ERROR_MDHIM;
			break;
		}

		brm = brmp;
		brmp = brmp->next;
		mdhim_full_release_msg(brm);

	}

	return ret;
}
/*synchronize all the indices and file attributes
* to the key-value store
* @param sock_id: the connection id in poll_set of the delegator
* @return success/error code
*/
synchronize all the indices and file attributes
to the key-value store
synchronize all the indices and file attributes to the key - value store
int meta_process_fsync (int sock_id) {
	int ret = 0;
	int app_id = invert_sock_ids[sock_id];
	app_config_t *app_config = (app_config_t *)arraylist_get(app_config_list, app_id);
	int client_side_id = app_config->client_ranks[sock_id];
	unsigned long num_entries =\
			*((unsigned long *)(app_config->shm_superblocks[client_side_id]\
			+ app_config->meta_offset));
	int page_sz = getpagesize();
	burstfs_index_t *meta_payload =\
			(burstfs_index_t *)(app_config->shm_superblocks[client_side_id]\
			+ app_config->meta_offset + page_sz);
	md->primary_index = burstfs_indexes[0];
	long i;
	for (i = 0; i < num_entries; i++) {
		burstfs_keys[i]->fid = meta_payload[i].fid;
		burstfs_keys[i]->offset = meta_payload[i].file_pos;
		burstfs_vals[i]->addr = meta_payload[i].mem_pos;
		burstfs_vals[i]->len = meta_payload[i].length;
		burstfs_vals[i]->delegator_id = glb_rank;
		memcpy((char *)&(burstfs_vals[i]->app_rank_id), &app_id, sizeof(int));
		memcpy((char  *)&(burstfs_vals[i]->app_rank_id) + sizeof(int),\
				&client_side_id, sizeof(int));
		burstfs_key_lens[i] = sizeof(burstfs_key_t);
		burstfs_val_lens[i] = sizeof(burstfs_val_t);
	}
	brm = mdhimBPut(md, (void **)(&burstfs_keys[0]), burstfs_key_lens,
			(void **)(&burstfs_vals[0]), burstfs_val_lens, num_entries,
			NULL, NULL);
	brmp = brm;
	if (!brmp || brmp->error) {
		  ret = ULFS_ERROR_MDHIM;
		  LOG(LOG_DBG, "Rank - %d: Error inserting keys/values into MDHIM\n",\
				  md->mdhim_rank);
	}
	while (brmp) {
		if (brmp->error < 0) {
			ret = ULFS_ERROR_MDHIM;
			break;
		}
		brm = brmp;
		brmp = brmp->next;
		mdhim_full_release_msg(brm);
	}
	md->primary_index = burstfs_indexes[1];
	num_entries =\
			*((unsigned long *)(app_config->shm_superblocks[client_side_id]\
					+ app_config->fmeta_offset));
	burstfs_file_attr_t *attr_payload =\
			(burstfs_file_attr_t *)(app_config->shm_superblocks[client_side_id]\
					+ app_config->fmeta_offset + page_sz);
	for (i = 0; i < num_entries; i++) {
		*fattr_keys[i] = attr_payload[i].gfid;
		fattr_vals[i]->file_attr = attr_payload[i].file_attr;
		strcpy(fattr_vals[i]->fname, attr_payload[i].filename);
		fattr_key_lens[i] = sizeof(fattr_key_t);
		fattr_val_lens[i] = sizeof(fattr_val_t);
	}
	brm = mdhimBPut(md, (void **)(&fattr_keys[0]), fattr_key_lens,
			(void **)(&fattr_vals[0]), fattr_val_lens, num_entries,
			NULL, NULL);
	brmp = brm;
	if (!brmp || brmp->error) {
		  ret = ULFS_ERROR_MDHIM;
		  LOG(LOG_DBG, "Rank - %d: Error inserting keys/values into MDHIM\n",\
				  md->mdhim_rank);
	}
	while (brmp) {
		if (brmp->error < 0) {
			ret = ULFS_ERROR_MDHIM;
			break;
		}
		brm = brmp;
		brmp = brmp->next;
		mdhim_full_release_msg(brm);
	}
	return ret;
}
int meta_process_fsync ( int sock_id ) { int ret = 0 ; int app_id = invert_sock_ids [ sock_id ] ; app_config_t * app_config = ( app_config_t * ) arraylist_get ( app_config_list , app_id ) ; int client_side_id = app_config -> client_ranks [ sock_id ] ; unsigned long num_entries = * ( ( unsigned long * ) ( app_config -> shm_superblocks [ client_side_id ] + app_config -> meta_offset ) ) ; int page_sz = getpagesize ( ) ; burstfs_index_t * meta_payload = ( burstfs_index_t * ) ( app_config -> shm_superblocks [ client_side_id ] + app_config -> meta_offset + page_sz ) ; md -> primary_index = burstfs_indexes [ 0 ] ; long i ; for ( i = 0 ; i < num_entries ; i ++ ) { burstfs_keys [ i ] -> fid = meta_payload [ i ] . fid ; burstfs_keys [ i ] -> offset = meta_payload [ i ] . file_pos ; burstfs_vals [ i ] -> addr = meta_payload [ i ] . mem_pos ; burstfs_vals [ i ] -> len = meta_payload [ i ] . length ; burstfs_vals [ i ] -> delegator_id = glb_rank ; memcpy ( ( char * ) & ( burstfs_vals [ i ] -> app_rank_id ) , & app_id , sizeof ( int ) ) ; memcpy ( ( char * ) & ( burstfs_vals [ i ] -> app_rank_id ) + sizeof ( int ) , & client_side_id , sizeof ( int ) ) ; burstfs_key_lens [ i ] = sizeof ( burstfs_key_t ) ; burstfs_val_lens [ i ] = sizeof ( burstfs_val_t ) ; } brm = mdhimBPut ( md , ( void * * ) ( & burstfs_keys [ 0 ] ) , burstfs_key_lens , ( void * * ) ( & burstfs_vals [ 0 ] ) , burstfs_val_lens , num_entries , NULL , NULL ) ; brmp = brm ; if ( ! brmp || brmp -> error ) { ret = ULFS_ERROR_MDHIM ; LOG ( LOG_DBG , " \n " , md -> mdhim_rank ) ; } while ( brmp ) { if ( brmp -> error < 0 ) { ret = ULFS_ERROR_MDHIM ; break ; } brm = brmp ; brmp = brmp -> next ; mdhim_full_release_msg ( brm ) ; } md -> primary_index = burstfs_indexes [ 1 ] ; num_entries = * ( ( unsigned long * ) ( app_config -> shm_superblocks [ client_side_id ] + app_config -> fmeta_offset ) ) ; burstfs_file_attr_t * attr_payload = ( burstfs_file_attr_t * ) ( app_config -> shm_superblocks [ client_side_id ] + app_config -> fmeta_offset + page_sz ) ; for ( i = 0 ; i < num_entries ; i ++ ) { * fattr_keys [ i ] = attr_payload [ i ] . gfid ; fattr_vals [ i ] -> file_attr = attr_payload [ i ] . file_attr ; strcpy ( fattr_vals [ i ] -> fname , attr_payload [ i ] . filename ) ; fattr_key_lens [ i ] = sizeof ( fattr_key_t ) ; fattr_val_lens [ i ] = sizeof ( fattr_val_t ) ; } brm = mdhimBPut ( md , ( void * * ) ( & fattr_keys [ 0 ] ) , fattr_key_lens , ( void * * ) ( & fattr_vals [ 0 ] ) , fattr_val_lens , num_entries , NULL , NULL ) ; brmp = brm ; if ( ! brmp || brmp -> error ) { ret = ULFS_ERROR_MDHIM ; LOG ( LOG_DBG , " \n " , md -> mdhim_rank ) ; } while ( brmp ) { if ( brmp -> error < 0 ) { ret = ULFS_ERROR_MDHIM ; break ; } brm = brmp ; brmp = brmp -> next ; mdhim_full_release_msg ( brm ) ; } return ret ; }
synchronize all the indices and file attributes
to the key-value store
synchronize all the indices and file attributes to the key - value store
/* indices are stored in the superblock shared memory
	 *  created by the client*/ // print_fsync_indices(burstfs_keys, burstfs_vals, num_entries);
 /* file attributes are stored in the superblock shared memory
	 * created by the client*/