-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tmpdir-setup: Use arguments instead of environment
Change the tmdir-setup script helper to get ist arguments from its argument list not from the environment. Change mxqd to use the mx_call_external helper to call it.
- Loading branch information
Showing
2 changed files
with
67 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,60 @@ | ||
#! /usr/bin/bash | ||
|
||
# Input (environment): | ||
# | ||
# MXQ_JOBID : job ident | ||
# MXQ_SIZE : size in GB | ||
# MXQ_UID : uid | ||
|
||
# Output: | ||
# | ||
# /dev/shm/mxqd/tmp/$JOBID mounted, space from /scratch/local2 | ||
usage() { | ||
cat <<EOF >&2 | ||
usage: | ||
$0 create JOBID SIZE UID # create SIZE GiB /dev/shm/mxqd/mnt/job/$JOBID | ||
EOF | ||
exit 1 | ||
} | ||
|
||
tmpdir=/scratch/local2/mxqd/tmp | ||
mntdir=/dev/shm/mxqd/mnt/job | ||
filename=$tmpdir/$MXQ_JOBID.tmp | ||
mountpoint=$mntdir/$MXQ_JOBID | ||
|
||
umask 006 | ||
mkdir -p $tmpdir | ||
mkdir -p $mntdir | ||
|
||
status=1; | ||
|
||
if fallocate -l ${MXQ_SIZE}G $filename; then | ||
if loopdevice=$(losetup --find --show $filename); then | ||
if mkfs.ext4 \ | ||
-q \ | ||
-m 0 \ | ||
-E nodiscard,mmp_update_interval=300,lazy_journal_init=1,root_owner=$MXQ_UID:0 \ | ||
-O '64bit,ext_attr,filetype,^has_journal,huge_file,inline_data,^mmp,^quota,sparse_super2' \ | ||
$loopdevice \ | ||
&& mkdir -p $mountpoint && mount -Odata=writeback,barrier=0 $loopdevice $mountpoint; then | ||
rmdir $mountpoint/lost+found | ||
status=0 | ||
|
||
cmd_create() { | ||
(( $# == 3 )) || usage | ||
MXQ_JOBID=$1 | ||
MXQ_SIZE=$2 | ||
MXQ_UID=$3 | ||
|
||
filename=$tmpdir/$MXQ_JOBID.tmp | ||
mountpoint=$mntdir/$MXQ_JOBID | ||
|
||
umask 006 | ||
mkdir -p $tmpdir | ||
mkdir -p $mntdir | ||
|
||
status=1; | ||
|
||
if fallocate -l ${MXQ_SIZE}G $filename; then | ||
if loopdevice=$(losetup --find --show $filename); then | ||
if mkfs.ext4 \ | ||
-q \ | ||
-m 0 \ | ||
-E nodiscard,mmp_update_interval=300,lazy_journal_init=1,root_owner=$MXQ_UID:0 \ | ||
-O '64bit,ext_attr,filetype,^has_journal,huge_file,inline_data,^mmp,^quota,sparse_super2' \ | ||
$loopdevice \ | ||
&& mkdir -p $mountpoint && mount -Odata=writeback,barrier=0 $loopdevice $mountpoint; then | ||
rmdir $mountpoint/lost+found | ||
status=0 | ||
fi | ||
losetup -d $loopdevice | ||
fi | ||
losetup -d $loopdevice | ||
rm $filename | ||
else | ||
test -e $filename && rm $filename | ||
fi | ||
rm $filename | ||
else | ||
test -e $filename && rm $filename | ||
fi | ||
exit $status | ||
exit $status | ||
} | ||
|
||
(( $# > 0 )) || usage | ||
cmd="$1" | ||
shift; | ||
case "$cmd" in | ||
create) | ||
cmd_create "$@" | ||
;; | ||
*) | ||
usage | ||
;; | ||
esac |
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