These patchset bases on the patch: Author: Minfei Huang mhuang@redhat.com Date: Tue Mar 3 20:54:54 2015 +0800
kdump-lib: Add new function to fix duplicated "/" in path
Enhance kdump to support bind mounted target in Atomic, since kdump cann't parse the bind mounted path.
Following is the testcases which kdump can generate the core sucessfully. 1) rootfs, default path / specified path 2) rootfs with bind mounted path which is in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount -o bind /var/crash /mnt/crash 4) rootfs with bind mounted path which is not in the rootfs device # cat /etc/kdump | grep ^path path /var/crash # mount /dev/vdb /mnt # mount -o bind /var/crash /mnt/crash 5) no-rootfs 6) no-rootfs with bind mounted path which is in the same device 7) no-rootfs with bind mounted path which is not in the same device 8) nfs 9) nfs with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump 10) nfs with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs nfs 192.168.122.134:/opt/crash # cat /etc/kdump | grep ^path path /var/crash # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # mount -o bind /mnt/nfs/var/crash /mnt/dump 11) nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/nfs/dump 12) nfs which don't specify the nfs option in the /etc/kdump, with bind mounted path which is not under the nfs mount point path # cat /etc/kdump | grep ^nfs # mount.nfs 192.168.122.134:/opt/crash /mnt/nfs # cat /etc/kdump | grep ^path path /mnt/nfs/var/crash # mount -o bind /mnt/nfs/var/crash /mnt/dump 13) ext4 14) ext4 with bind mounted path which is under the ext4 mount point path 15) ext4 with bind mounted path which is not under the ext4 mount point path 16) btrfs 17) btrfs with subvolume which mounts under mount point path 18) btrfs with subvolume which does not mount under mount point path
Minfei Huang (3): kdump-lib: Add the new function to enhance bind mounted judgement kdump-lib: Get the mount point correctly, if the device has several mount point dracut-module-setup: Enhance kdump to support the bind mounted feature in Atomic
===
v1: - add the judgment to make it work only in Atomic
===
dracut-module-setup.sh | 39 ++++++++++++++++++++++++++++++++++----- kdump-lib.sh | 48 +++++++++++++++++++++++++++++++++++++++++++++++- mkdumprd | 32 +++++++++++++++++++++++++------- 3 files changed, 106 insertions(+), 13 deletions(-)
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.
the value of $_mntpoint may be /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the directory is bind mounted. The former part represents the device path, the rest part is the bind mounted directory which quotes by bracket "[]".
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ab01d74..2ad528e 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}')
On 04/08/15 at 12:30am, Minfei Huang wrote:
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.
the value of $_mntpoint may be /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the directory is bind mounted. The former part represents the device path, the rest part is the bind mounted directory which quotes by bracket "[]".
Signed-off-by: Minfei Huang mhuang@redhat.com
It looks good to me. At least up to now no other better way to judge and retrieve bind mount info.
Acked-by: Baoquan He bhe@redhat.com
kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ab01d74..2ad528e 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}') -- 1.9.3
On 04/08/15 at 12:30am, Minfei Huang wrote:
+# 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 "[]".
Hold on. I remember I suggested use sed command, you said it can't handle this case, namely the name of file or dir contains a bracket:
/dev/mapper/atomicos-[root]
Does below function can handle it? What if below case?
/dev/mapper/atomicos-root[/ostree/deploy/[rhel-atomic-host]/var]
+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}') -- 1.9.3
On 04/08/15 at 01:56pm, Baoquan He wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
+# 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 "[]".
Hold on. I remember I suggested use sed command, you said it can't handle this case, namely the name of file or dir contains a bracket:
/dev/mapper/atomicos-[root]
Does below function can handle it? What if below case?
/dev/mapper/atomicos-root[/ostree/deploy/[rhel-atomic-host]/var]
Hi, Bao.
The function get_bind_mount_directory works well, while I use the above testcase.
Thanks Minfei
+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}') -- 1.9.3
On 04/08/15 at 12:30am, Minfei Huang wrote:
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.
the value of $_mntpoint may be /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the directory is bind mounted. The former part represents the device path, the rest part is the bind mounted directory which quotes by bracket "[]".
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ab01d74..2ad528e 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]
This is an adjective word, please use exclude in v3.
+# 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}') -- 1.9.3
On 04/08/15 at 01:56pm, Baoquan He wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
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.
the value of $_mntpoint may be /dev/mapper/atomicos-root[/ostree/deploy/rhel-atomic-host/var], if the directory is bind mounted. The former part represents the device path, the rest part is the bind mounted directory which quotes by bracket "[]".
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh index ab01d74..2ad528e 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]
This is an adjectiveword, please use exclude in v3.
Hi, Bao.
Thank you for your correction.
Thanks Minfei
+# 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}') -- 1.9.3
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com --- kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() { - echo $(findmnt -k -f -n -r -o TARGET $1) + for _mnt in $(findmnt -k -n -r -o TARGET $1) + do + if ! is_bind_mount $_mnt; then + echo $_mnt + return + fi + done + + echo "Mount $1 firstly, without the bind mode" >&2 + exit 1 }
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev) - _target=$(findmnt -k -f -n -r -o TARGET $_dev) + _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it. @@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() { - echo $(findmnt -k -f -n -r -o TARGET $1) -} - is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() { - local _mnt=$(to_mount_point $1) + local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}') }
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points.
^ Please add a "on" here.
The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find
^ change it to "in". ^ change it to vmcore.
the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
What do you mean here? In the end who is the mount point you want to get? Please describe it clearly. Make people who don't talk to you face to face can understand it.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturn
You make a change against non bind mount case. non bind mount don't get a mntpoint any more. Is that OK? And I don't see you explain it in patch log.
fi- done
- echo "Mount $1 firstly, without the bind mode" >&2
- exit 1
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
On 04/08/15 at 02:03pm, Baoquan He wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points.
^ Please add a "on"here.
The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find
^ change it to "in". ^ change it to vmcore.the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
What do you mean here? In the end who is the mount point you want to get? Please describe it clearly. Make people who don't talk to you face to face can understand it.
Hi, bao.
Thank you for your review.
We can find that /mnt/bind-dir is a bind mounted directory which points to the /dev/vda[/var], meanwhile, the device /dev/vda is mounted on directory /mnt/ext4. So the bind mounted directory /mnt/bind-dir points to the /mnt/ext4/var.
How about above comment?
Thanks Minfei
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnYou make a change against non bind mount case. non bind mount don't get a mntpoint any more. Is that OK? And I don't see you explain it in patch log.
Yes, the function get_mntpoint_from_target may fail, if all of the mount points are in bind mode. If so, kdump will raise the error message, and kill itself.
Will add the explanation.
Thanks Minfei
fi- done
- echo "Mount $1 firstly, without the bind mode" >&2
- exit 1
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
On 04/08/15 at 02:52pm, Minfei Huang wrote:
On 04/08/15 at 02:03pm, Baoquan He wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points.
^ Please add a "on"here.
The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find
^ change it to "in". ^ change it to vmcore.the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
What do you mean here? In the end who is the mount point you want to get? Please describe it clearly. Make people who don't talk to you face to face can understand it.
Hi, bao.
Thank you for your review.
We can find that /mnt/bind-dir is a bind mounted directory which points to the /dev/vda[/var], meanwhile, the device /dev/vda is mounted on directory /mnt/ext4. So the bind mounted directory /mnt/bind-dir points to the /mnt/ext4/var.
Then what's the mount point you get? You tell a series of analysis, what's the result?
Could you please assume a reviewer who didn't follow this issue want to help review this patchset and get into it quickly? The reason for this is we can recall these later by checking the commit log. I often forget the details several months later.
On 04/08/15 at 04:03pm, Baoquan He wrote:
On 04/08/15 at 02:52pm, Minfei Huang wrote:
On 04/08/15 at 02:03pm, Baoquan He wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points.
^ Please add a "on"here.
The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find
^ change it to "in". ^ change it to vmcore.the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
What do you mean here? In the end who is the mount point you want to get? Please describe it clearly. Make people who don't talk to you face to face can understand it.
Hi, bao.
Thank you for your review.
We can find that /mnt/bind-dir is a bind mounted directory which points to the /dev/vda[/var], meanwhile, the device /dev/vda is mounted on directory /mnt/ext4. So the bind mounted directory /mnt/bind-dir points to the /mnt/ext4/var.
Then what's the mount point you get? You tell a series of analysis, what's the result?
Could you please assume a reviewer who didn't follow this issue want to help review this patchset and get into it quickly? The reason for this is we can recall these later by checking the commit log. I often forget the details several months later.
Hi, bao.
I just show the view what bind mounted is. Where the real location is, if the path is bind mounted.
Thanks Minfei
On 04/08/15 at 04:23pm, Minfei Huang wrote:
On 04/08/15 at 04:03pm, Baoquan He wrote:
We can find that /mnt/bind-dir is a bind mounted directory which points to the /dev/vda[/var], meanwhile, the device /dev/vda is mounted on directory /mnt/ext4. So the bind mounted directory /mnt/bind-dir points to the /mnt/ext4/var.
Then what's the mount point you get? You tell a series of analysis, what's the result?
Could you please assume a reviewer who didn't follow this issue want to help review this patchset and get into it quickly? The reason for this is we can recall these later by checking the commit log. I often forget the details several months later.
Hi, bao.
I just show the view what bind mounted is. Where the real location is, if the path is bind mounted.
OK. I think in patch log you should present:
1) what's wrong when bind mount in current code, you can give a example command.
2)The reason is the mount point is not correct and that cause storing in wrong place in 2nd kernel.
3) how do you fix it with code in this patch. Namely how to get the mount point correctly.
With the help of command example it should be easy to explain what/why/how. So if you just show the view what bind mounted is, where is the real location is if bind mount, I still need try it by myself to get what's the correct mount point, but not get it directly from you patch log.
Thanks Baoquan
On 04/08/15 at 04:28pm, Baoquan He wrote:
On 04/08/15 at 04:23pm, Minfei Huang wrote:
On 04/08/15 at 04:03pm, Baoquan He wrote:
We can find that /mnt/bind-dir is a bind mounted directory which points to the /dev/vda[/var], meanwhile, the device /dev/vda is mounted on directory /mnt/ext4. So the bind mounted directory /mnt/bind-dir points to the /mnt/ext4/var.
Then what's the mount point you get? You tell a series of analysis, what's the result?
Could you please assume a reviewer who didn't follow this issue want to help review this patchset and get into it quickly? The reason for this is we can recall these later by checking the commit log. I often forget the details several months later.
Hi, bao.
I just show the view what bind mounted is. Where the real location is, if the path is bind mounted.
OK. I think in patch log you should present:
- what's wrong when bind mount in current code, you can give a example
command.
2)The reason is the mount point is not correct and that cause storing in wrong place in 2nd kernel.
- how do you fix it with code in this patch. Namely how to get the
mount point correctly.
With the help of command example it should be easy to explain what/why/how. So if you just show the view what bind mounted is, where is the real location is if bind mount, I still need try it by myself to get what's the correct mount point, but not get it directly from you patch log.
Thanks Baoquan
Thanks for your suggestion. Will modify the commit log as what you said.
Thanks Minfei
On 04/08/15 at 02:52pm, Minfei Huang wrote:
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnYou make a change against non bind mount case. non bind mount don't get a mntpoint any more. Is that OK? And I don't see you explain it in patch log.
Yes, the function get_mntpoint_from_target may fail, if all of the mount points are in bind mode. If so, kdump will raise the error message, and kill itself.
No, I mean a normal machine, just on my personal PC. I plan take a kdump. Then here it returned a mntpoint from get_mntpoint_from_target, but now it doesn't since it's not bind mount. Why it does't matter, could you also explain it? Above what you mentioned is another issue.
On 04/08/15 at 04:41pm, Baoquan He wrote:
On 04/08/15 at 02:52pm, Minfei Huang wrote:
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnYou make a change against non bind mount case. non bind mount don't get a mntpoint any more. Is that OK? And I don't see you explain it in patch log.
Yes, the function get_mntpoint_from_target may fail, if all of the mount points are in bind mode. If so, kdump will raise the error message, and kill itself.
No, I mean a normal machine, just on my personal PC. I plan take a kdump. Then here it returned a mntpoint from get_mntpoint_from_target, but now it doesn't since it's not bind mount. Why it does't matter, could you also explain it? Above what you mentioned is another issue.
Hi, bao.
Ok, I will add the log to explain the case that get_mntpoint_from_target return NULL.
Thanks Minfei
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnfi- done
- echo "Mount $1 firstly, without the bind mode" >&2
- exit 1
Per discussion, we should limit the function only to atomic case.
So it should be like below:
get_mntpoint_from_target(){ if (!atomic) echo $(findmnt -k -f -n -r -o TARGET $1) else { ... } }
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
On 04/09/15 at 10:46am, Dave Young wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnfi- done
- echo "Mount $1 firstly, without the bind mode" >&2
- exit 1
Per discussion, we should limit the function only to atomic case.
So it should be like below:
get_mntpoint_from_target(){ if (!atomic) echo $(findmnt -k -f -n -r -o TARGET $1) else { ... } }
It does not impact on the general system, so there is no limitation for this function.
Thanks Minfei
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
On 04/09/15 at 10:55am, Minfei Huang wrote:
On 04/09/15 at 10:46am, Dave Young wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnfi- done
- echo "Mount $1 firstly, without the bind mode" >&2
- exit 1
Per discussion, we should limit the function only to atomic case.
So it should be like below:
get_mntpoint_from_target(){ if (!atomic) echo $(findmnt -k -f -n -r -o TARGET $1) else { ... } }
It does not impact on the general system, so there is no limitation for this function.
You assume it does not, but it could, the code flow is different from old one.
I still do not trust is_bind_mnt though we have no other better way for atomic..
Thanks Minfei
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
On 04/09/15 at 11:00am, Dave Young wrote:
On 04/09/15 at 10:55am, Minfei Huang wrote:
On 04/09/15 at 10:46am, Dave Young wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnfi- done
- echo "Mount $1 firstly, without the bind mode" >&2
- exit 1
Per discussion, we should limit the function only to atomic case.
So it should be like below:
get_mntpoint_from_target(){ if (!atomic) echo $(findmnt -k -f -n -r -o TARGET $1) else { ... } }
It does not impact on the general system, so there is no limitation for this function.
You assume it does not, but it could, the code flow is different from old one.
I still do not trust is_bind_mnt though we have no other better way for atomic..
I am fine with it to add limitation. Will add it in next posting patch.
Thanks Minfei
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
We can find that /mnt/bind-dir is mounted in the path /dev/vda[/var], in the other word, the /mnt/bind-dir points to the /var directory in the /dev/vda. The /mnt/ext4 is the root path in the device.
Signed-off-by: Minfei Huang mhuang@redhat.com
kdump-lib.sh | 11 ++++++++++- mkdumprd | 8 ++------ 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index 2ad528e..75d7673 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -135,7 +135,16 @@ get_fs_type_from_target()
get_mntpoint_from_target() {
Also, for any new functions, there should be code comments to describe the function itself, the input params, the output etc.
Ditto to other functions you introduced like trimming mnt point from path.
- echo $(findmnt -k -f -n -r -o TARGET $1)
- for _mnt in $(findmnt -k -n -r -o TARGET $1)
- do
if ! is_bind_mount $_mnt; thenecho $_mntreturnfi- done
- echo "Mount $1 firstly, without the bind mode" >&2
- exit 1
}
# get_option_value <option_name> diff --git a/mkdumprd b/mkdumprd index a8f9cbb..7fdcebf 100644 --- a/mkdumprd +++ b/mkdumprd @@ -100,7 +100,7 @@ to_mount() { local _dev=$1 _source _target _fstype _options _mntopts _pdev
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
- _target=$(findmnt -k -f -n -r -o TARGET $_dev)
- _target=$(get_mntpoint_from_target $_dev) # mount under /sysroot if dump to root disk or mount under #/kdumproot/$_target in other cases in 2nd kernel. systemd #will be in charge to umount it.
@@ -144,10 +144,6 @@ to_mount() { echo "$_pdev $_mntopts" }
-to_mount_point() {
- echo $(findmnt -k -f -n -r -o TARGET $1)
-}
is_readonly_mount() { local _mnt _mnt=$(findmnt -k -f -n -r -o OPTIONS $1) @@ -201,7 +197,7 @@ mkdir_save_path_ssh() #Function: get_fs_size #$1=dump target get_fs_size() {
- local _mnt=$(to_mount_point $1)
- local _mnt=$(get_mntpoint_from_target $1) echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
}
-- 1.9.3
Hi, Dave, Bao.
I will re-post a new patch according to Dave's suggestion.
Thank you all for reviewing.
Thanks Minfei
On 04/09/15 at 10:59am, Dave Young wrote:
On 04/08/15 at 12:30am, Minfei Huang wrote:
The filesystem support the device to be mounted different mount points. The root path in the device may be different, if the mount point is mounted by bind mode. In order to dump core correctly, we should find the root path in the device.
Following is the case that device is mounted by bind mode.
TARGET SOURCE FSTYPE OPTIONS /mnt/ext4 /dev/vda btrfs rw,relatime,seclabel,space_cache TARGET SOURCE FSTYPE OPTIONS /mnt/bind-dir /dev/vda[/var] btrfs rw,relatime,seclabel,space_cache
The kdump will dump the core in incorrect target directory, if the target is bind mounted.
The kdump cann't parse the bind mounted path, if we specifies the vale "path /var/crash" in the /etc/kdump.conf.
To correct dumping target, we can construct the real dumping path in Atomic, 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
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@redhat.com --- dracut-module-setup.sh | 39 ++++++++++++++++++++++++++++++++++----- kdump-lib.sh | 5 +++++ mkdumprd | 24 +++++++++++++++++++++++- 3 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 477ede1..7915b82 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,8 +311,7 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype - local _mntpoint - local _save_path + local _mntpoint _save_path
is_user_configured_dump_target && return
@@ -321,6 +320,17 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path) _target=$(get_target_from_path $_save_path) + + if is_atomic && is_bind_mount $_mntpoint; then + _save_path=$(cut_out_substring $_save_path $_mntpoint) + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path + _mntpoint=$(get_mntpoint_from_target $_target) + + # the absolute path in the 1st kernel + _save_path=$_mntpoint/$_save_path + fi + if [ "$_mntpoint" != "/" ]; then _fstype=$(get_fs_type_from_target $_target)
@@ -332,14 +342,30 @@ default_dump_target_install_conf() fi
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf - _save_path=$(cut_out_substring $_save_path $_mntpoint) + fi + + sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf + echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf +} + +adjust_bind_mount_path() +{ + local _target=$1 + local _save_path=$(get_option_value "path") + [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH + + local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path + local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) + + if is_bind_mount $_mntpoint; then + _save_path=$(cut_out_substring $_absolute_save_path $_mntpoint) + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + _save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path
- #erase the old path line, then insert the parsed path sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf fi - }
#install kdump.conf and what user specifies in kdump.conf @@ -353,6 +379,9 @@ kdump_install_conf() { case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) sed -i -e "s#^$config_opt[[:space:]]+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" ${initdir}/tmp/$$-kdump.conf + if is_atomic; then + adjust_bind_mount_path "$config_val" + fi ;; ssh|nfs) kdump_install_net "$config_val" diff --git a/kdump-lib.sh b/kdump-lib.sh index 75d7673..8aa0da4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -237,3 +237,8 @@ cut_out_substring() local _sub_str=$(echo $2|sed "s#/{1,}#/#g") echo ${_main_str#*"$_sub_str"} } + +is_atomic() +{ + grep -q "ostree" /proc/cmdline +} diff --git a/mkdumprd b/mkdumprd index 7fdcebf..d7d006f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -359,6 +359,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) + + if is_atomic && is_bind_mount $_mntpoint; then + SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH + _mntpoint=$(get_mntpoint_from_target $_target) + + # the absolute path in the 1st kernel + SAVE_PATH=$_mntpoint/$SAVE_PATH + fi + if [ "$_mntpoint" != "/" ]; then SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target) @@ -530,8 +541,19 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi + + _absolute_save_path=$(make_absolute_save_path $config_val) + if is_atomic; then + _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) + if is_bind_mount $_mntpoint; then + SAVE_PATH=$(cut_out_substring $_absolute_save_path $_mntpoint) + # the real dump path in the 2nd kernel, if the mount point is bind mounted. + SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH + fi + fi + add_mount "$config_val" - check_save_path_fs $(make_absolute_save_path $config_val) + check_save_path_fs $_absolute_save_path check_size fs $config_val ;; raw)
If I understand correctly, this patch contains 2 parts. The 1st part is to make check_save_path_fs works well. The 2nd part is to store correct path into initramfs.
If that's true could you please split it into 2 patches and describe both of them separately?
Thanks Baoquan
On 04/08/15 at 12:30am, Minfei Huang wrote:
The kdump will dump the core in incorrect target directory, if the target is bind mounted.
The kdump cann't parse the bind mounted path, if we specifies the vale "path /var/crash" in the /etc/kdump.conf.
To correct dumping target, we can construct the real dumping path in Atomic, 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-rootThen 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@redhat.com
dracut-module-setup.sh | 39 ++++++++++++++++++++++++++++++++++----- kdump-lib.sh | 5 +++++ mkdumprd | 24 +++++++++++++++++++++++- 3 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 477ede1..7915b82 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,8 +311,7 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype
- local _mntpoint
- local _save_path
local _mntpoint _save_path
is_user_configured_dump_target && return
@@ -321,6 +320,17 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path) _target=$(get_target_from_path $_save_path)
- if is_atomic && is_bind_mount $_mntpoint; then
_save_path=$(cut_out_substring $_save_path $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted._save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path_mntpoint=$(get_mntpoint_from_target $_target)# the absolute path in the 1st kernel_save_path=$_mntpoint/$_save_path- fi
- if [ "$_mntpoint" != "/" ]; then _fstype=$(get_fs_type_from_target $_target)
@@ -332,14 +342,30 @@ default_dump_target_install_conf() fi
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
_save_path=$(cut_out_substring $_save_path $_mntpoint)
- fi
- sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
- echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
+}
+adjust_bind_mount_path() +{
- local _target=$1
- local _save_path=$(get_option_value "path")
- [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
- local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path
- local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
- if is_bind_mount $_mntpoint; then
_save_path=$(cut_out_substring $_absolute_save_path $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted._save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path
fi#erase the old path line, then insert the parsed path sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf}
#install kdump.conf and what user specifies in kdump.conf @@ -353,6 +379,9 @@ kdump_install_conf() { case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) sed -i -e "s#^$config_opt[[:space:]]+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" ${initdir}/tmp/$$-kdump.conf
if is_atomic; thenadjust_bind_mount_path "$config_val"fi ;; ssh|nfs) kdump_install_net "$config_val"diff --git a/kdump-lib.sh b/kdump-lib.sh index 75d7673..8aa0da4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -237,3 +237,8 @@ cut_out_substring() local _sub_str=$(echo $2|sed "s#/{1,}#/#g") echo ${_main_str#*"$_sub_str"} }
+is_atomic() +{
- grep -q "ostree" /proc/cmdline
+} diff --git a/mkdumprd b/mkdumprd index 7fdcebf..d7d006f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -359,6 +359,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH)
- if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted.SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH_mntpoint=$(get_mntpoint_from_target $_target)# the absolute path in the 1st kernelSAVE_PATH=$_mntpoint/$SAVE_PATH- fi
- if [ "$_mntpoint" != "/" ]; then SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target)
@@ -530,8 +541,19 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi
_absolute_save_path=$(make_absolute_save_path $config_val)if is_atomic; then_mntpoint=$(get_mntpoint_from_path $_absolute_save_path)if is_bind_mount $_mntpoint; thenSAVE_PATH=$(cut_out_substring $_absolute_save_path $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted.SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATHfifiadd_mount "$config_val"
check_save_path_fs $(make_absolute_save_path $config_val)
raw)check_save_path_fs $_absolute_save_path check_size fs $config_val ;;-- 1.9.3
On 04/08/15 at 03:58pm, Baoquan He wrote:
If I understand correctly, this patch contains 2 parts. The 1st part is to make check_save_path_fs works well. The 2nd part is to store correct path into initramfs.
If that's true could you please split it into 2 patches and describe both of them separately?
Ok, I am fine with it. Will bisect this patch.
Thanks Minfei
Thanks Baoquan
On 04/08/15 at 12:30am, Minfei Huang wrote:
The kdump will dump the core in incorrect target directory, if the target is bind mounted.
The kdump cann't parse the bind mounted path, if we specifies the vale "path /var/crash" in the /etc/kdump.conf.
To correct dumping target, we can construct the real dumping path in Atomic, 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-rootThen 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@redhat.com
dracut-module-setup.sh | 39 ++++++++++++++++++++++++++++++++++----- kdump-lib.sh | 5 +++++ mkdumprd | 24 +++++++++++++++++++++++- 3 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 477ede1..7915b82 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,8 +311,7 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype
- local _mntpoint
- local _save_path
local _mntpoint _save_path
is_user_configured_dump_target && return
@@ -321,6 +320,17 @@ default_dump_target_install_conf()
_mntpoint=$(get_mntpoint_from_path $_save_path) _target=$(get_target_from_path $_save_path)
- if is_atomic && is_bind_mount $_mntpoint; then
_save_path=$(cut_out_substring $_save_path $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted._save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path_mntpoint=$(get_mntpoint_from_target $_target)# the absolute path in the 1st kernel_save_path=$_mntpoint/$_save_path- fi
- if [ "$_mntpoint" != "/" ]; then _fstype=$(get_fs_type_from_target $_target)
@@ -332,14 +342,30 @@ default_dump_target_install_conf() fi
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
_save_path=$(cut_out_substring $_save_path $_mntpoint)
- fi
- sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
- echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
+}
+adjust_bind_mount_path() +{
- local _target=$1
- local _save_path=$(get_option_value "path")
- [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
- local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path
- local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
- if is_bind_mount $_mntpoint; then
_save_path=$(cut_out_substring $_absolute_save_path $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted._save_path=$(get_bind_mount_directory $_mntpoint)/$_save_path
fi#erase the old path line, then insert the parsed path sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf}
#install kdump.conf and what user specifies in kdump.conf @@ -353,6 +379,9 @@ kdump_install_conf() { case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) sed -i -e "s#^$config_opt[[:space:]]+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" ${initdir}/tmp/$$-kdump.conf
if is_atomic; thenadjust_bind_mount_path "$config_val"fi ;; ssh|nfs) kdump_install_net "$config_val"diff --git a/kdump-lib.sh b/kdump-lib.sh index 75d7673..8aa0da4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -237,3 +237,8 @@ cut_out_substring() local _sub_str=$(echo $2|sed "s#/{1,}#/#g") echo ${_main_str#*"$_sub_str"} }
+is_atomic() +{
- grep -q "ostree" /proc/cmdline
+} diff --git a/mkdumprd b/mkdumprd index 7fdcebf..d7d006f 100644 --- a/mkdumprd +++ b/mkdumprd @@ -359,6 +359,17 @@ handle_default_dump_target()
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH)
- if is_atomic && is_bind_mount $_mntpoint; then
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted.SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH_mntpoint=$(get_mntpoint_from_target $_target)# the absolute path in the 1st kernelSAVE_PATH=$_mntpoint/$SAVE_PATH- fi
- if [ "$_mntpoint" != "/" ]; then SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target)
@@ -530,8 +541,19 @@ do if [ "$config_opt" = "nfs" ]; then add_dracut_module "nfs" fi
_absolute_save_path=$(make_absolute_save_path $config_val)if is_atomic; then_mntpoint=$(get_mntpoint_from_path $_absolute_save_path)if is_bind_mount $_mntpoint; thenSAVE_PATH=$(cut_out_substring $_absolute_save_path $_mntpoint)# the real dump path in the 2nd kernel, if the mount point is bind mounted.SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATHfifiadd_mount "$config_val"
check_save_path_fs $(make_absolute_save_path $config_val)
raw)check_save_path_fs $_absolute_save_path check_size fs $config_val ;;-- 1.9.3