Minfei
The patch seems conflicts with Bao's patch for cleaning up /tmp/ files.
BTW, what's the difference between this version and the previous version?
On 02/16/15 at 06:03pm, Minfei Huang wrote:
The kdump will dump the core in incorrect target directory
/sysroot/crash, if the target is bind mounted.
The /var is bind mounted in Atomic, kdump will dump the core in
/sysroot/crash, instead of /var/crash, if we specifies the value
"path /var/crash" in the /etc/kdump.conf.
To correct dumping target, we can construct the real dumping path, which
contains two part, one bind mounted path, the other specified dump
target.
Following is an example:
-bash-4.2# cat /etc/kdump.conf | grep ^path
path /var/crash
-bash-4.2# findmnt /var | tail -n 1 | awk '{print $2}'
/dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var]
-bash-4.2# findmnt -v /var | tail -n 1 | awk '{print $2}'
/dev/mapper/atomicos-root
There's no real dumping path for bind mount as we discussed in previous
thread, right?
BTW btrfs subvolumes also use [] in findmnt output, how to differenciate them?
I'm thinking we can do nothing for bind mount, we probably can only fix
things case by case..
Then we can found it that the real path of dumping core is
/ostree/deploy/rhel-atomic-host/var/crash.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
dracut-module-setup.sh | 29 +++++++++++++++++++----------
kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++
mkdumprd | 4 +---
3 files changed, 52 insertions(+), 13 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index ff7a088..b7ef56d 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -304,10 +304,19 @@ kdump_install_net() {
fi
}
+adjust_dump_target()
+{
+ local _fstype=$1 _target=$2 _path=$3
+ echo "$_fstype $_target" >> /tmp/$$-kdump.conf
+
+ #erase the old path line, then insert the parsed path
+ sed -i "/^path/d" /tmp/$$-kdump.conf
+ echo "path $_path" >> /tmp/$$-kdump.conf
+}
+
default_dump_target_install_conf()
{
local _target _fstype
- local _s _t
local _mntpoint
local _path _save_path
@@ -318,25 +327,25 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path)
_target=$(get_target_from_path $_save_path)
- if [ "$_mntpoint" != "/" ]; then
- _fstype=$(get_fs_type_from_target $_target)
+ _fstype=$(get_fs_type_from_target $_target)
+ if is_bind_mount $_mntpoint; then
+ _path=${_save_path##"$_mntpoint"}
+ # the real dump path in the 2nd kernel, if the mount point is bind mounted.
+ _path=$(get_bind_mount_directory $_mntpoint)/$_path
+
+ adjust_dump_target $_fstype $_target $_path
+ elif [ "$_mntpoint" != "/" ]; then
if $(is_fs_type_nfs $_fstype); then
kdump_install_net "$_target"
_fstype="nfs"
else
_target=$(kdump_to_udev_name $_target)
fi
-
- echo "$_fstype $_target" >> /tmp/$$-kdump.conf
-
_path=${_save_path##"$_mntpoint"}
- #erase the old path line, then insert the parsed path
- sed -i "/^path/d" /tmp/$$-kdump.conf
- echo "path $_path" >> /tmp/$$-kdump.conf
+ adjust_dump_target $_fstype $_target $_path
fi
-
}
#install kdump.conf and what user specifies in kdump.conf
diff --git a/kdump-lib.sh b/kdump-lib.sh
index f24f08d..d8a547a 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -86,6 +86,38 @@ get_root_fs_device()
return
}
+# findmnt uses the option "-v, --nofsroot" to exclusive the [/dir]
+# in the SOURCE column for bind-mounts, then if $_mntpoint equals to
+# $_mntpoint_nofsroot, the mountpoint is not bind mounted directory.
+is_bind_mount()
+{
+ local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
+ local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
+
+ if [[ $_mntpoint = $_mntpoint_nofsroot ]]; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+# the value of $_mntpoint will be
+# /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the
+# directory is bind mounted. The former part represents the device path, rest
+# part is the bind mounted directory which quotes by bracket "[]".
+get_bind_mount_directory()
+{
+ local _mntpoint=$(findmnt $1 | tail -n 1 | awk '{print $2}')
+ local _mntpoint_nofsroot=$(findmnt -v $1 | tail -n 1 | awk '{print $2}')
+
+ _mntpoint=${_mntpoint##$_mntpoint_nofsroot}
+
+ _mntpoint=${_mntpoint#[}
+ _mntpoint=${_mntpoint%]}
+
+ echo $_mntpoint
+}
+
get_mntpoint_from_path()
{
echo $(df $1 | tail -1 | awk '{print $NF}')
diff --git a/mkdumprd b/mkdumprd
index 4d251ba..951eb6d 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -201,8 +201,7 @@ mkdir_save_path_ssh()
#Function: get_fs_size
#$1=dump target
get_fs_size() {
- local _mnt=$(to_mount_point $1)
- echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
+ echo -n $(df -P "$SAVE_PATH"|tail -1|awk '{print $4}')
}
#Function: get_raw_size
@@ -364,7 +363,6 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH)
_target=$(get_target_from_path $SAVE_PATH)
if [ "$_mntpoint" != "/" ]; then
- SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
_fstype=$(get_fs_type_from_target $_target)
if $(is_fs_type_nfs $_fstype); then
--
2.2.2
_______________________________________________
kexec mailing list
kexec(a)lists.fedoraproject.org
https://lists.fedoraproject.org/mailman/listinfo/kexec