Tuesday, May 22, 2012

AIX KDB: "no real storage"

When using AIX kdb to analysis kernel dump, the following error may happen:

[kdb_read_mem] no real storage @ FFFFFFFFFFF98B0

The reason is that kdb is trying to access virtual memory which was swapped to disk. AIX kernel core dump contains data in physical memory only. So for data structure in swap partition or swap file, kdb cannot address it correctly. That's why such error happened. The solution is to pin all kernel data structure and text segments so that they never are swapped to disk. If you encouter the error, that means you are not good luck and some kernel data strcuture were not pinned. No solution.

Good news for  AIX version 7.1, it is a default setting and this problem won't happen.

Sunday, May 20, 2012

AIX Kernel Dump Analysis

1. Uncompress core dump from customer

#ulimit -f unlimited //Avoid too large file error on AIX
#ulimit -Hf unlimited

#gunzip SR_99999999_99997.7TD.000.snap.pax.Z
#pax -rvf SR_99999999_99997.7TD.000.snap.pax -x pax

#cd dump
#dmpuncompress -p dump.BZ
#uncompress unix.Z

2. Load kdb
#kdb dump unix
dump mapped from @ 700000000000000 to @ 7000001475f12c5
Preserving 1921497 bytes of symbol table [unix]
Component Names:
 1)  minidump [2 entries]
 2)  dmp_minimal [10 entries]
 3)  proc [1636 entries]
 4)  thrd [5152 entries]
 5)  mtrc [97 entries]
 6)  lfs [6 entries]
 7)  bos [6 entries]
[kdb_dump_llseek] Invalid file offset
WARNING: Version mismatch between unix file and command kdb
           START              END <name>
0000000000001000 0000000004070000 start+000FD8
F00000002FF47600 F00000002FFDF940 __ublock+000000
000000002FF22FF4 000000002FF22FF8 environ+000000
000000002FF22FF8 000000002FF22FFC errno+000000
F1000F0A00000000 F1000F0A10000000 pvproc+000000
F1000F0A10000000 F1000F0A18000000 pvthread+000000
Dump analysis on CHRP_SMP_PCI POWER_PC POWER_6 machine with 32 available CPU(s)  (64-bit registers)
Processing symbol table...
.......................done
read vscsi_scsi_ptrs OK, ptr = 0x0
[kdb_read_mem] no real storage @ F1000100120D9000
(0) status
(0) stat

3. Common used files in kernel snap
       
errpt(kernel log): general/errpt.out
LVM configuration: lvm/*.snap
Process/Memory/Drivers: kernel/kernel.snap
         
4. Refer the following post for general introduction of kdb

http://www.ibm.com/developerworks/aix/library/au-kdbsteps/index.html



Sunday, May 13, 2012

SVN+SSH Access without password

Amazon EC2 instances allows SSH login without password. If you setup SVN server on Amazon EC2 instance,  you can easily use SVN+SSH access your source code server without password as well. The following is guideline.

Assume svn repository was created as normal:

$sudo svnadmin create /var/lib/svnroot
$sudo chown -R ubuntu /var/lib/svnroot
$sudo chmod -R g+rws svnroot

Then at client side:
$export SVN_EDITOR=vi
$export SVN_SSH="ssh -i /path/to/your.pem -l ubuntu"
$svn import myproject svn+ssh://ec2instancename.compute-1.amazonaws.com/var/lib/svnroot/myproject

Tuesday, May 1, 2012

SCST Build Error: arch/x86/Makefile_32.cpu: No such file or directory

Try to build SCST module on Ubuntu 11(Linux 3.0) and got the following error:
cd scst && make all
make[1]: Entering directory `/home/hui/scst/scst'
cd src && make all
make[2]: Entering directory `/home/hui/scst/scst/src'
make -C /lib/modules/3.0.22-scstcustom/build SUBDIRS=/home/hui/scst/scst/src BUILD_DEV=m
make[3]: Entering directory `/usr/src/linux-headers-3.0.22-scstcustom'
/usr/src/linux-headers-3.0.22-scstcustom/arch/x86/Makefile:39: /usr/src/linux-headers-3.0.22-scstcustom/arch/x86/Makefile_32.cpu: No such file or directory
make[3]: *** No rule to make target `/usr/src/linux-headers-3.0.22-scstcustom/arch/x86/Makefile_32.cpu'.  Stop.
make[3]: Leaving directory `/usr/src/linux-headers-3.0.22-scstcustom'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/hui/scst/scst/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/hui/scst/scst'
make: *** [scst] Error 2
It was caused by incorrect linux-headers. Try to recreate headers for arch/x86 and the problem was fixed:

Go to Linux source directory:
#cd /usr/src/linux-3.0.0/arch
#tar zcvf x86.tgz x86

Put x86.tgz to /usr/src/linux-headers-3.0.22-scstcustom/arch and untar the x86 files
#cd /usr/src/linux-headers-3.0.22-scstcustom/arch/
#tar xvf x86.tgz


locale: Cannot set LC_CTYPE to default locale: No such file or directory

Ubuntu 11 errors:
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_CTYPE = "UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
After executing the following commands, the error was fixed.

$sudo locale-gen en_US
$sudo dpkg-reconfigure locales

Compile SCST on ubuntu 11

1) Get Compile tools

$sudo apt-get install subversion
$sudo apt-get kernel-package libncurses5-dev fakeroot wget bzip2

2) Get Linux source

$cd ~
$sudo svn co https://scst.svn.sourceforge.net/svnroot/scst/trunk scst
$cd /usr/src
$sudo apt-get source linux-image-$(uname -r)
$cd /usr/src/linux-3.0.0
$sudo cp /home/hui/scst/iscsi-scst/kernel/patches/put_page_callback-3.0.patch .
$sudo cp /home/hui/scst/scst/kernel/scst_exec_req_fifo-3.0.patch .
$sudo patch -p1 <put_page_callback-3.0.patch
$sudo patch -p1 <scst_exec_req_fifo-3.0.patch
$sudo cp /boot/config-3.0.0-12-generic .config

4) Build kernel
$sudo make-kpkg clean
$sudo fakeroot make-kpkg --initrd --append-to-version=-scstcustom kernel_image kernel_headers

5) Install kernel
$sudo dpkg -i linux-headers-3.0.22-scstcustom_3.0.22-scstcustom-10.00.Custom_i386.deb
$sudo dpkg -i linux-image-3.0.22-scstcustom_3.0.22-scstcustom-10.00.Custom_i386.deb

6) Reboot the host and switch to scstcustom  then build scst

$cd ~/scst
$sudo make scst scst_install iscsi iscsi_install scstadm scstadm_install

That's all. You will be able to find scst modules in /lib/modules/`uname -r`/

Monday, April 23, 2012

SCSI-3 Persist Reservation Command on Linux

Note: Linux sg3_utils packages are required.

To query all registrant keys for given device
#sg_persist -i -k -d /dev/sdd

To query all reservations for given device
#sg_persist -i -r -d /dev/sdd

To register
#sg_persist -o -G -S 123abc /dev/sdd

To clear all registrants
#sg_persist -C -K 123abc -o -d /dev/sdd

To reserve
#sg_persist -o -R -K 123abc -T 5 -d /dev/sdd

To release
#sg_persist -o -L -K 123abc -T 5 -d /dev/sdd

Common used reservation Types:
5 - Write Exclusive, registrants only
6 - Exclusive Access, registrants only

Setup iSCSI Target with iscsi-scst 2.0

Environment: Ubuntu 11.04 for i386

1) Install Linux kernel with scst patches(See my post on how to compile scst patched Linux kernel)

$sudo dpkg -i linux-headers-3.0.22-scstcustom_3.0.22-scstcustom-10.00.Custom_i386.deb
$sudo dpkg -i linux-image-3.0.22-scstcustom_3.0.22-scstcustom-10.00.Custom_i386.deb
Edit /boot/grub/grub.cfg to enable new kernel and reboot the host

2) Build scst and iscsi-scst against the new kernel

$cd ~/scst
$sudo make scst scst_install iscsi-scst iscsi_install scstadmin scstadmin_install

See iscsi-scst/README and iscsi-scst/doc for detailed instructions for iscsi-scst compile and configuration introduction.

3) Setup iSCSI target with 2 LUNs (based on iscsi-scst)
$ su
Password:
# modprobe scst
# modprobe scst_vdisk
# echo "add_device disk1 filename=/home/hui/vdisk1; nv_cache=1" >/sys/kernel/scst_tgt/handlers/vdisk_fileio/mgmt
# echo "add_device disk2 filename=/home/hui/vdisk2; nv_cache=1" >/sys/kernel/scst_tgt/handlers/vdisk_fileio/mgmt
# modprobe iscsi_scst
# iscsi-scstd
# echo "add_target iqn.2006-10.net.vlnb:tgt" >/sys/kernel/scst_tgt/targets/iscsi/mgmt
# echo "add disk1 0" >/sys/kernel/scst_tgt/targets/iscsi/iqn.2006-10.net.vlnb:tgt/luns/mgmt
# echo "add disk2 1" >/sys/kernel/scst_tgt/targets/iscsi/iqn.2006-10.net.vlnb:tgt/luns/mgmt
# echo 1 >/sys/kernel/scst_tgt/targets/iscsi/iqn.2006-10.net.vlnb:tgt/enabled
# echo 1 >/sys/kernel/scst_tgt/targets/iscsi/enabled
4)Alternative way to setup iscsi target is to put the following content to /etc/scst.conf.
HANDLER vdisk_fileio {
        DEVICE disk01 {
                filename /home/hui/vdisk1
                nv_cache 1
        }
        DEVICE disk02 {
                filename /home/hui/vdisk2
                nv_cache 1
        }
}

TARGET_DRIVER iscsi {
        enabled 1

        TARGET iqn.2006-10.net.vlnb:tgt {
                LUN 0 disk01
                LUN 1 disk02

                enabled 1
        }
}
Then start scst service:
$sudo service scst start

5) Setup iSCSI initiator to discover the new devices(assume open-iscsi installed)

$sudo iscsiadm -m discovery -t st -p192.168.1.1
$sudo iscsiadm -m node -T iqn.2006-10.net.vlnb:tgt -p 192.168.1.1 -l

Sunday, April 22, 2012

Session lost after switch from HTTPS to HTTP

I notice an issue that http session Id is not unique from single browser. The following debugging code was added for each Spring controller class:

HttpSession session = request.getSession();
logger.debug("Current session id: " + session.getId());

The session id was always same for https access from the browser. And it was changed for http access even with the same browser.

That looks like a well known issue. I should keep https access for all links to my web application if I would like the session being kept.