BurstFS_Client/src/cruise-sysio.c
int burstfs_split_read_requests(read_req_t *cur_read_req, read_req_set_t *read_req_set,\
		long slice_range) {
	long cur_read_start = cur_read_req->offset;
	long cur_read_end = cur_read_req->offset + cur_read_req->length - 1;

	long cur_slice_start = cur_read_req->offset / slice_range * slice_range;
	long cur_slice_end = cur_slice_start + slice_range - 1;

	read_req_set->count = 0;

	if (cur_read_end <= cur_slice_end) {
		/*
		cur_slice_start		             				 cur_slice_end
						 cur_read_start		cur_read_end

		*/
		read_req_set->read_reqs[read_req_set->count] \
			= *cur_read_req;
		read_req_set->count++;
	} else {
		/*
		cur_slice_start		             	cur_slice_endnext_slice_start					next_slice_end
						 cur_read_start										cur_read_end

		*/
		read_req_set->read_reqs[read_req_set->count] = *cur_read_req;
		read_req_set->read_reqs[read_req_set->count].length =\
				cur_slice_end - cur_read_start + 1;
		read_req_set->count++;

		cur_slice_start = cur_slice_end + 1;
		cur_slice_end = cur_slice_start + slice_range - 1;

		while (1) {
			if (cur_read_end <= cur_slice_end) {
				break;
			}

			read_req_set->read_reqs[read_req_set->count].fid = cur_read_req->fid;
			read_req_set->read_reqs[read_req_set->count].offset = cur_slice_start;
			read_req_set->read_reqs[read_req_set->count].length = slice_range;

			cur_slice_start = cur_slice_end + 1;
			cur_slice_end = cur_slice_start + slice_range - 1;
			read_req_set->count++;

		}

		read_req_set->read_reqs[read_req_set->count].fid = cur_read_req->fid;
		read_req_set->read_reqs[read_req_set->count].offset = cur_slice_start;
		read_req_set->read_reqs[read_req_set->count].length =\
				cur_read_end - cur_slice_start + 1;
		read_req_set->count++;
	}

	return 0;
}
/*
 * given an read request, split it into multiple indices whose range is equal or smaller
 * than slice_range size
 * @param cur_read_req: the read request to split
 * @param slice_range: the slice size of the key-value store
 * @return read_req_set: the set of split read requests
 * */
given an read request, split it into multiple indices whose range is equal or smaller
than slice_range size
@param cur_read_req: the read request to split
@param slice_range: the slice size of the key-value store
@return read_req_set: the set of split read requests
given an read request split it into multiple indices whose range is equal or smaller than slice_range size @param cur_read_req : the read request to split @param slice_range : the slice size of the key - value store @return read_req_set : the set of split read requests
int burstfs_split_read_requests(read_req_t *cur_read_req, read_req_set_t *read_req_set,\
		long slice_range) {
	long cur_read_start = cur_read_req->offset;
	long cur_read_end = cur_read_req->offset + cur_read_req->length - 1;
	long cur_slice_start = cur_read_req->offset / slice_range * slice_range;
	long cur_slice_end = cur_slice_start + slice_range - 1;
	read_req_set->count = 0;
	if (cur_read_end <= cur_slice_end) {
		read_req_set->read_reqs[read_req_set->count] \
			= *cur_read_req;
		read_req_set->count++;
	} else {
		read_req_set->read_reqs[read_req_set->count] = *cur_read_req;
		read_req_set->read_reqs[read_req_set->count].length =\
				cur_slice_end - cur_read_start + 1;
		read_req_set->count++;
		cur_slice_start = cur_slice_end + 1;
		cur_slice_end = cur_slice_start + slice_range - 1;
		while (1) {
			if (cur_read_end <= cur_slice_end) {
				break;
			}
			read_req_set->read_reqs[read_req_set->count].fid = cur_read_req->fid;
			read_req_set->read_reqs[read_req_set->count].offset = cur_slice_start;
			read_req_set->read_reqs[read_req_set->count].length = slice_range;
			cur_slice_start = cur_slice_end + 1;
			cur_slice_end = cur_slice_start + slice_range - 1;
			read_req_set->count++;
		}
		read_req_set->read_reqs[read_req_set->count].fid = cur_read_req->fid;
		read_req_set->read_reqs[read_req_set->count].offset = cur_slice_start;
		read_req_set->read_reqs[read_req_set->count].length =\
				cur_read_end - cur_slice_start + 1;
		read_req_set->count++;
	}
	return 0;
}
int burstfs_split_read_requests ( read_req_t * cur_read_req , read_req_set_t * read_req_set , long slice_range ) { long cur_read_start = cur_read_req -> offset ; long cur_read_end = cur_read_req -> offset + cur_read_req -> length - 1 ; long cur_slice_start = cur_read_req -> offset / slice_range * slice_range ; long cur_slice_end = cur_slice_start + slice_range - 1 ; read_req_set -> count = 0 ; if ( cur_read_end <= cur_slice_end ) { read_req_set -> read_reqs [ read_req_set -> count ] = * cur_read_req ; read_req_set -> count ++ ; } else { read_req_set -> read_reqs [ read_req_set -> count ] = * cur_read_req ; read_req_set -> read_reqs [ read_req_set -> count ] . length = cur_slice_end - cur_read_start + 1 ; read_req_set -> count ++ ; cur_slice_start = cur_slice_end + 1 ; cur_slice_end = cur_slice_start + slice_range - 1 ; while ( 1 ) { if ( cur_read_end <= cur_slice_end ) { break ; } read_req_set -> read_reqs [ read_req_set -> count ] . fid = cur_read_req -> fid ; read_req_set -> read_reqs [ read_req_set -> count ] . offset = cur_slice_start ; read_req_set -> read_reqs [ read_req_set -> count ] . length = slice_range ; cur_slice_start = cur_slice_end + 1 ; cur_slice_end = cur_slice_start + slice_range - 1 ; read_req_set -> count ++ ; } read_req_set -> read_reqs [ read_req_set -> count ] . fid = cur_read_req -> fid ; read_req_set -> read_reqs [ read_req_set -> count ] . offset = cur_slice_start ; read_req_set -> read_reqs [ read_req_set -> count ] . length = cur_read_end - cur_slice_start + 1 ; read_req_set -> count ++ ; } return 0 ; }
given an read request, split it into multiple indices whose range is equal or smaller
 than slice_range size
 @param cur_read_req: the read request to split
 @param slice_range: the slice size of the key-value store
 @return read_req_set: the set of split read requests
given an read request split it into multiple indices whose range is equal or smaller than slice_range size @param cur_read_req : the read request to split @param slice_range : the slice size of the key - value store @return read_req_set : the set of split read requests
/*
		cur_slice_start		             				 cur_slice_end
						 cur_read_start		cur_read_end

		*/ /*
		cur_slice_start		             	cur_slice_endnext_slice_start					next_slice_end
						 cur_read_start										cur_read_end

		*/