From 9640f65abf69851d1124ec9866c4ea6a3001b266 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Thu, 5 May 2022 20:42:01 +0200 Subject: [PATCH] tmpdir-setup: Make umount faster The umount of the job tmpdir often takes a lot of time (minutes!) when the user write a lot of data to it, because there are many dirty pages which are written to the disk before the umount completes. This writing is obviously a waste of resources, because as soon as the unmount is finished, the backup image for the filesystem is destroyed anyway. Unfortunatly, we currenty don't have a solid way to avoid the unnecessary writeback. What we can do is to purge the directory. Experiments show, that this is indeed faster with both: few very big files or many small files. So do that. Hard-code the directory prefix into the rm command to decrease the risk of rm removing wrong files in case future code changes are buggy and, for example, missspell a shell variable. Because the cleanup still needs time, do that in the background so that mxqd can continue. --- helper/tmpdir-setup | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/helper/tmpdir-setup b/helper/tmpdir-setup index 088acdf3..fe47dc79 100755 --- a/helper/tmpdir-setup +++ b/helper/tmpdir-setup @@ -52,10 +52,12 @@ cmd_cleanup() { (( $# == 1 )) || usage MXQ_JOBID=$1 - mountpoint=$mntdir/$MXQ_JOBID - - umount $mountpoint - rmdir $mountpoint + ( + shopt -s dotglob; + rm -rf /dev/shm/mxqd/mnt/job/$MXQ_JOBID/* + umount /dev/shm/mxqd/mnt/job/$MXQ_JOBID + rmdir /dev/shm/mxqd/mnt/job/$MXQ_JOBID + ) & } (( $# > 0 )) || usage