From 06fa4f193919b72b99f78551234c2fefc5130485 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 15 Apr 2022 12:52:51 +0200 Subject: [PATCH] helper: Rename create_job_tmpdir to tmpdir-setup Rename helper/create_job_tmpdir to helper/tmpdir-setup. Leave the obsolete helper script around to support a rolling upgrade. --- Makefile | 4 ++-- helper/tmpdir-setup | 42 ++++++++++++++++++++++++++++++++++++++++++ mxqd.c | 8 ++++---- 3 files changed, 48 insertions(+), 6 deletions(-) create mode 100755 helper/tmpdir-setup diff --git a/Makefile b/Makefile index ec34bde5..4acc4afc 100644 --- a/Makefile +++ b/Makefile @@ -658,8 +658,8 @@ clean: CLEAN += mxqps ### script helper ----------------------------------------------------- -install:: helper/create_job_tmpdir - $(call quiet-install,0755,$^,${DESTDIR}${LIBEXECDIR}/mxq/create_job_tmpdir) +install:: helper/tmpdir-setup + $(call quiet-install,0755,$^,${DESTDIR}${LIBEXECDIR}/mxq/tmpdir-setup) install:: helper/gpu-setup $(call quiet-install,0755,$^,${DESTDIR}${LIBEXECDIR}/mxq/gpu-setup) diff --git a/helper/tmpdir-setup b/helper/tmpdir-setup new file mode 100755 index 00000000..01207427 --- /dev/null +++ b/helper/tmpdir-setup @@ -0,0 +1,42 @@ +#! /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 \ + -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 + rm $filename +else + test -e $filename && rm $filename +fi +exit $status diff --git a/mxqd.c b/mxqd.c index cec683bd..098595cf 100644 --- a/mxqd.c +++ b/mxqd.c @@ -1288,7 +1288,7 @@ static unsigned long start_job(struct mxq_group_list *glist) struct mxq_daemon *daemon; - static char create_job_tmpdir_script[] = LIBEXECDIR "/mxq/create_job_tmpdir"; + static char tmpdir_script[] = LIBEXECDIR "/mxq/tmpdir-setup"; pid_t pid; int res; @@ -1314,14 +1314,14 @@ static unsigned long start_job(struct mxq_group_list *glist) if (pid==0) { char *argv[2]; char *envp[4]; - argv[0] = create_job_tmpdir_script, + argv[0] = tmpdir_script, argv[1] = NULL; envp[0] = mx_asprintf_forever("MXQ_JOBID=%lu", job->job_id); envp[1] = mx_asprintf_forever("MXQ_SIZE=%u", group->job_tmpdir_size); envp[2] = mx_asprintf_forever("MXQ_UID=%d", group->user_uid); envp[3] = NULL; - execve(create_job_tmpdir_script,argv,envp); - mx_log_fatal("exec %s : %m",create_job_tmpdir_script); + execve(tmpdir_script, argv,envp); + mx_log_fatal("exec %s : %m", tmpdir_script); exit(1); } mx_mysql_connect_forever(&(server->mysql));