---
# System prepended metadata

title: Concurrencs Feedback Metric
tags: [epfl, semesterproject]

---






# Concurrencs Feedback Metric

## General
Gluster docs: https://docs.gluster.org/en/main

Gluster Github: https://github.com/gluster/glusterfs


## Issues

### AddressSanitizer: heap-use-after-free in GlusterFS clients

https://github.com/gluster/glusterfs/issues/3945



## Commands

### Booting up VM

Prereq: kernel, qcow2 image and network settings

#### Network sttings (no internet access)
Network setup without access extern network:
```
#Host (make script, every time on startup)
sudo ip link add name br0 type bridge
sudo ip addr add 192.168.0.1/24 brd + dev br0
sudo ip link set br0 up
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t filter -A FORWARD -i br0 -j ACCEPT
sudo iptables -t filter -A FORWARD -o br0 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o enp0s31f6 -j MASQUERADE

#Guest
ip addr add 192.168.0.5/24 brd + dev eth0
ip link set eth0 up
```
#### Network sttings (no internet access)
Network setup without access extern network:

```
#Host
sudo ip link add name br0 type bridge
sudo ip addr add 192.168.100.1/24 brd + dev br0
sudo ip link set br0 up
sudo sysctl -w net.ipv4.ip_forward=1
sudo iptables -t filter -A FORWARD -i br0 -j ACCEPT
sudo iptables -t filter -A FORWARD -o br0 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o enp0s31f6 -j MASQUERADE

#Guest 
ip addr add 192.168.100.2/24 brd + dev enp0s3
ip link set enp0s3 up
ip route add default via 192.168.100.1 dev enp0s3
#8.8.8.8 -> /etc/resolv.conf

```

#### Starting VMs
unique port, mac and ip for each VM

```
sudo qemu-system-x86_64 -m 10240 -smp 4 -chardev socket,id=SOCKSYZ,server=on,nowait,host=localhost,port=3257 -mon chardev=SOCKSYZ,mode=control -display none -serial stdio -device virtio-rng-pci -enable-kvm -cpu host,migratable=off -netdev bridge,id=hn40 -device virtio-net,netdev=hn40,mac=e6:c8:ff:09:76:38 -hda /home/tlyu/dfs-fuzzing/disk-images/glusterfs-images/focal.qcow2 -kernel /home/tlyu/dfs-fuzzing/kernels/kernel-5.15/kernel-5.15-glusterfs/arch/x86_64/boot/bzImage -append "root=/dev/sda console=ttyS0 net.ifnames=0 ip=192.168.0.10" -snapshot
```

#### Automatic startup

`run script start_ip srv_cnt client_cnt mode`

```
#args
start_ip=$1
srv_cnt=$2
client_cnt=$3
mode=$4

cur_ip=$start_ip

nextip(){
	IP=$1
	IP_HEX=$(printf '%.2X%.2X%.2X%.2X\n' `echo $IP | sed -e 's/\./ /g'`)
	NEXT_IP_HEX=$(printf %.8X `echo $(( 0x$IP_HEX + 1 ))`)
	NEXT_IP=$(printf '%d.%d.%d.%d\n' `echo $NEXT_IP_HEX | sed -r 's/(..)/0x\1 /g'`)
	echo "$NEXT_IP"
}

i=0
srvs=""    
while [ $i -lt $srv_cnt ]
do
    {
   	 if [ $i -eq 0 ]; then
   		 systemctl restart glusterd 	 
   		 #mkfs.ext4 /dev/vda
   		 #mount -t ext4 /dev/vda /root/glusterfs-server -o sync
    	else
   	 	sshpass -p "123456" ssh -o StrictHostKeyChecking=no root@$cur_ip LD_PRELOAD=/root/dfs-fuzzing/libucov.so systemctl restart glusterd
   		 #sshpass -p "123456" ssh -o StrictHostKeyChecking=no root@$cur_ip mkfs.ext4 /dev/vda
   		 #sshpass -p "123456" ssh -o StrictHostKeyChecking=no root@$cur_ip mount -t ext4 /dev/vda /root/glusterfs-server -o sync
   		 echo gluster peer probe $cur_ip
   	 gluster peer probe $cur_ip
   	 fi
    }&
	srvs="${srvs} ${cur_ip}:/root/glusterfs-server"
	cur_ip=$(nextip $cur_ip)
	i=$(( i + 1 ))
done

wait

sleep 2s
gluster peer status
echo gluster volume create test-volume disperse 3 redundancy 1 $srvs force
#disperse 3 redundancy 1
LD_PRELOAD=/root/dfs-fuzzing/libucov.so gluster volume create test-volume $mode $srvs force
#gluster volume create test-volume $srvs force
LD_PRELOAD=/root/dfs-fuzzing/libucov.so gluster volume start test-volume force
gluster volume set test-volume network.ping-timeout 1

#client
i=0
while [ $i -lt $client_cnt ]
do
	#export ASAN_OPTIONS=detect_leaks=0
	sshpass -p "123456" ssh -o StrictHostKeyChecking=no root@$cur_ip mount -t glusterfs $start_ip:/test-volume glusterfs-client &
	cur_ip=$(nextip $cur_ip)
	i=$(( i + 1 ))
done
echo "mount finished"
wait

```




