mcoverlayfs: supported only Linux kernel 4.0

This commit is contained in:
Yoichi Umezawa
2016-06-03 18:36:55 +09:00
parent 14ec92518e
commit d0ee60f9e3
3 changed files with 29 additions and 13 deletions

View File

@ -59,9 +59,18 @@ mem="512M@0"
cpus=""
ihk_ikc_irq_core=0
kernel_release=`uname -r`
enable_mcoverlay=`if [[ ${kernel_release} =~ ^4.* && "${ENABLE_MCOVERLAYFS}" == "yes" ]]; then echo "yes"; fi`
release=`uname -r`
major=`echo ${release} | sed -e 's/^\([0-9]*\).*/\1/'`
minor=`echo ${release} | sed -e 's/^[0-9]*.\([0-9]*\).*/\1/'`
patch=`echo ${release} | sed -e 's/^[0-9]*.[0-9]*.\([0-9]*\).*/\1/'`
linux_version_code=`expr \( ${major} \* 65536 \) + \( ${minor} \* 256 \) + ${patch}`
rhel_release=`echo ${release} | sed -e 's/^[0-9]*.[0-9]*.[0-9]*-\([0-9]*\).*/\1/'`
if [ "${release}" == "${rhel_release}" ]; then rhel_release=""; fi
if [ "${ENABLE_MCOVERLAYFS}" == "yes" ]; then
enable_mcoverlay=`if ( [ ${linux_version_code} -ge 262144 ] && [ ${linux_version_code} -lt 262400 ] ); then echo "yes"; else echo "no"; fi`
else
enable_mcoverlay=no
fi
if [ "$cpus" == "" ]; then
# Get the number of CPUs on NUMA node 0
@ -79,7 +88,7 @@ if [ "`lsmod | grep mcctrl`" != "" ]; then
fi
# Remove mcoverlay if loaded
if [ "$enable_mcoverlay" != "" ]; then
if [ "$enable_mcoverlay" == "yes" ]; then
if [ "`lsmod | grep mcoverlay`" != "" ]; then
if [ "`cat /proc/mounts | grep /tmp/mcos/mcos0_sys`" != "" ]; then umount -l /tmp/mcos/mcos0_sys; fi
if [ "`cat /proc/mounts | grep /tmp/mcos/mcos0_proc`" != "" ]; then umount -l /tmp/mcos/mcos0_proc; fi
@ -149,7 +158,7 @@ if ! ${SBINDIR}/ihkosctl 0 boot; then echo "error: booting"; exit; fi
if ! insmod ${KMODDIR}/mcctrl.ko; then echo "error: inserting mcctrl.ko"; exit; fi
if ! chown `logname` /dev/mcd* /dev/mcos*; then echo "error: chowning device files"; exit; fi
if [ "$enable_mcoverlay" != "" ]; then
if [ "$enable_mcoverlay" == "yes" ]; then
if [ ! -e /tmp/mcos ]; then mkdir -p /tmp/mcos; fi
if ! mount -t tmpfs tmpfs /tmp/mcos; then echo "error: mount /tmp/mcos"; exit; fi
if [ ! -e /tmp/mcos/linux_proc ]; then mkdir -p /tmp/mcos/linux_proc; fi

View File

@ -4,9 +4,15 @@ KMODDIR=@KMODDIR@
src = @abs_srcdir@
ENABLE_MCOVERLAYFS=@ENABLE_MCOVERLAYFS@
RELEASE=$(shell uname -r | cut -d"." -f1)
RELEASE=$(shell uname -r)
MAJOR=$(shell echo ${RELEASE} | sed -e 's/^\([0-9]*\).*/\1/')
MINOR=$(shell echo ${RELEASE} | sed -e 's/^[0-9]*.\([0-9]*\).*/\1/')
PATCH=$(shell echo ${RELEASE} | sed -e 's/^[0-9]*.[0-9]*.\([0-9]*\).*/\1/')
LINUX_VERSION_CODE=$(shell expr \( ${MAJOR} \* 65536 \) + \( ${MINOR} \* 256 \) + ${PATCH})
RHEL_RELEASE=$(shell echo ${RELEASE} | sed -e 's/^[0-9]*.[0-9]*.[0-9]*-\([0-9]*\).*/\1/')
RHEL_RELEASE=$(shell if [ "${RELEASE}" == "${RHEL_RELEASE}" ]; then echo ""; else echo ${RHEL_RELEASE}; fi)
ifeq ($(ENABLE_MCOVERLAYFS),yes)
ENABLE_BUILD=$(shell if [ "${RELEASE}" == "4" ]; then echo "yes"; fi)
ENABLE_BUILD=$(shell if ( [ ${LINUX_VERSION_CODE} -ge 262144 ] && [ ${LINUX_VERSION_CODE} -lt 262400 ] ); then echo "yes"; else echo "no"; fi)
else
ENABLE_BUILD=no
endif

View File

@ -1091,7 +1091,7 @@ void init_worker_threads(int fd)
}
#ifdef ENABLE_MCOVERLAYFS
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
#define READ_BUFSIZE 1024
static int isunshare(void)
{
@ -1353,7 +1353,7 @@ int main(int argc, char **argv)
}
#ifdef ENABLE_MCOVERLAYFS
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
__dprintf("mcoverlay enable\n");
char mcos_procdir[PATH_MAX];
char mcos_sysdir[PATH_MAX];
@ -1401,7 +1401,7 @@ int main(int argc, char **argv)
} else if (error == -1) {
return 1;
}
#endif // LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)
#endif
#else
__dprintf("mcoverlay disable\n");
#endif // ENABLE_MCOVERLAYFS
@ -1737,9 +1737,11 @@ int close_cloexec_fds(int mcos_fd)
char *
chgpath(char *in, char *buf)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)
#ifdef ENABLE_MCOVERLAYFS
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0) && LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)
return in;
#else
#endif
#endif // ENABLE_MCOVERLAYFS
char *fn = in;
struct stat sb;
@ -1760,7 +1762,6 @@ chgpath(char *in, char *buf)
if(stat(fn, &sb) == -1)
return in;
return fn;
#endif
}
int main_loop(int fd, int cpu, pthread_mutex_t *lock)