This repository has been archived by the owner on Jan 21, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
redirect blob usage on /tmp folder to /var/vcap/data/vblob_tmp
src/services shortlog: git shortlog 42403b02c5..7ef924042d Yang Yang (2): make vblob service dir configurable Merge "make vblob service dir configurable" andyzh (1): correct the max clients formular src/vblob_src shortlog: git shortlog 622a1f6840..a12a88fa0c SonicWang (1): fixing pivotal tracker ticket https://www.pivotaltracker.com/projects/254145#!/stories/35010649 make vblob's usage on /tmp directory configurable Change-Id: I713b4d0da6bcd28ee893c84ab574d0718346628c
- Loading branch information
Showing
6 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/sh | ||
|
||
<% | ||
service = "vblob" | ||
plan_enabled = properties.service_plans && properties.service_plans.send(service.to_sym) | ||
plan = properties.plan || "free" | ||
plan_conf = plan_enabled && properties.service_plans.send(service.to_sym).send(plan.to_sym).configuration | ||
%> | ||
vblobd_tmp_loop=/var/vcap/data/vblob_tmp_loop | ||
vblobd_tmp_dir=/var/vcap/data/vblob_tmp | ||
capacity=<%= plan_enabled && plan_conf.capacity || 75 %> | ||
vblobd_tmp_size=$(expr ${capacity} \* 50) | ||
|
||
log_echo() { | ||
echo "`date` $1" >> /var/vcap/sys/log/vblob_node/vblob_create_tmp.log | ||
} | ||
|
||
create_loop_device() { | ||
/usr/bin/truncate -s ${vblobd_tmp_size}M ${vblobd_tmp_loop} | ||
if [ ! $? -eq 0 ]; then | ||
log_echo "ERROR: fail to create the loop device for vblobd tmp directory" | ||
rm -rf ${vblobd_tmp_loop} | ||
exit 1 | ||
else | ||
chmod 0700 ${vblobd_tmp_loop} | ||
fi | ||
} | ||
|
||
current_size=`ls -l ${vblobd_tmp_loop} | cut -d" " -f5` | ||
expected_size=`expr ${vblobd_tmp_size} \* 1024 \* 1024` | ||
|
||
will_create_file=0 | ||
will_setup_loop=0 | ||
will_create_dir=0 | ||
|
||
if [ ! -f "${vblobd_tmp_loop}" ]; then | ||
create_loop_device | ||
fi | ||
|
||
if [ ! "$current_size" = "$expected_size" ] ; then | ||
will_create_file=1 | ||
fi | ||
|
||
# vblob node will always create a new loop when size does not match or there does not exists a loopfile | ||
loop_status=`losetup -a | grep "$vblobd_tmp_loop"` | ||
if [ ! -z "$loop_status" ]; then | ||
loop_device=`echo "$loop_status" | cut -d: -f1` | ||
if [ -d "$vblobd_tmp_dir" ]; then | ||
check_mount=`mount -l | grep "$loop_device" | grep "$vblobd_tmp_dir"` | ||
if [ ! -z "$check_mount" ] && [ $will_create_file -eq 0 ]; then | ||
chown vcap $vblobd_tmp_dir | ||
exit 0 | ||
fi | ||
else | ||
will_create_dir=1 | ||
fi | ||
else | ||
loop_device=`losetup -f` | ||
if [ $? -ne 0 ]; then | ||
log_echo "ERROR: fail to get one free loop device" | ||
exit 1 | ||
fi | ||
will_setup_loop=1 | ||
if [ -d "$vblobd_tmp_dir" ]; then | ||
will_create_dir=1 | ||
fi | ||
fi | ||
|
||
if [ $will_create_file -eq 1 ]; then | ||
umount -d $vblobd_tmp_dir | ||
rm -rf $vblobd_tmp_dir | ||
losetup -d $loop_device | ||
rm -rf $vblobd_tmp_loop | ||
|
||
create_loop_device | ||
|
||
will_setup_loop=1 | ||
will_create_dir=1 | ||
fi | ||
|
||
if [ $will_setup_loop -eq 1 ]; then | ||
losetup $loop_device $vblobd_tmp_loop | ||
if [ $? -ne 0 ]; then | ||
log_echo "ERROR: fail to bind the loop device with the loop file" | ||
exit 1 | ||
fi | ||
mke2fs -t ext4 $loop_device | ||
if [ $? -ne 0 ]; then | ||
log_echo "ERROR: fail to make ext4 filesystem" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [ $will_create_dir -eq 1 ]; then | ||
if [ -d $vblobd_tmp_dir ]; then | ||
umount -d $vblobd_tmp_dir | ||
fi | ||
mkdir -p $vblobd_tmp_dir | ||
mount -t ext4 $loop_device $vblobd_tmp_dir | ||
if [ $? -ne 0 ]; then | ||
log_echo "ERROR: fail to mount $loop_device to $vblobd_tmp_dir" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
chown vcap $vblobd_tmp_dir | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule services
updated
from 42403b to 7ef924
Submodule vblob_src
updated
from 622a1f to a12a88