Skip to content

Commit

Permalink
create_job_tmdir: Add helper script
Browse files Browse the repository at this point in the history
Add helpder script to set up and mount a tmpdir volume for a job. Use
ext4, because is causes less load on the system than xfs. Tune
filesystem for speed, not for durability.
  • Loading branch information
donald committed Jan 29, 2020
1 parent 1f07958 commit f00d24c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ build: mxqps

clean: CLEAN += mxqps

### script helper -----------------------------------------------------

install:: helper/create_job_tmpdir
$(call quiet-install,0755,$^,${DESTDIR}${LIBEXECDIR}/mxq/create_job_tmpdir)

########################################################################

fix: FIX += mxqdctl-hostconfig.sh
Expand Down
40 changes: 40 additions & 0 deletions helper/create_job_tmpdir
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#! /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

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 \
-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
status=0
fi
losetup -d $loopdevice
fi
rm $filename
else
test -e $fileame && rm $filename
fi
exit $status

0 comments on commit f00d24c

Please sign in to comment.