Enable mount points below NFS export folder

It is quite common to use NFS share in Linux server, but we might have some problems when there are mount points below the exported folder.

For example:

/export     -> NFS export folder, fs1

/export/mount      -> a mount point with fs2

When nfsd try to open the files, it use the vfs_mount info in export folder “/export”. That means fs2 will never know any file operations.

And according to nfs man info, there are options nohide and crossmnt, that will check the mount points inside the export folder.

But unfortunately, it doesn’t work with that options only.

After checking NFS source code, infact, nfsd only check the inside NFS exported folder, and use the vfs_mount info in that sub export folder. So we need to export the sub mount point.

And in my ENV, I got “Stale NFS file handle” error after the above options, seems nfs get confused of the fs types, and it works after fsid option.

And here is the exports file:

/usr/rha 155.35.88.75(rw,sync,no_root_squash,nohide,crossmnt,fsid=0)
/usr/rha/root 155.35.88.75(rw,sync,no_root_squash,nohide,crossmnt,fsid=1)

 

XL c/cpp build ENV in AIX

  • Download XL c/c++ packet from IBM website: http://www14.software.ibm.com/webapp/download/preconfig.jsp?id=2011-11-24+08%3A35%3A02.456519R&S_TACT=&S_CMP=
  • I got file named as xlcpp.12.1.0.0.aix.eval.tar.tgz
  • ftp the file to aix box, and unzip
  • run “smit installp”, select folder “<unzipped-folder>/usr/sys/inst.images”, set “agreement licence” to yes.
    It will take some time for installation.
    Please make sure there are enough disk space in /usr, Installation will terminates if not enough space left.
    And please use “smit installp” instead of “ installp -aXgd .  all ” as it is in readme file. The agreement page doesn’t come up with the second command.
  • After installation:

  • # lslpp -l | grep xlC

    xlC.adt.include
    12.1.0.0 COMMITTED C Set ++ Application

    xlC.aix61.rte
    12.1.0.0 COMMITTED IBM XL C++ Runtime for AIX 6.1

    xlC.cpp
    9.0.0.0 COMMITTED C for AIX Preprocessor

    xlC.msg.en_US.rte 12.1.0.0
    COMMITTED IBM XL C++ Runtime

    xlC.rte
    12.1.0.0 COMMITTED IBM XL C++ Runtime for AIX

    xlC.sup.aix50.rte
    9.0.0.1 COMMITTED XL C/C++ Runtime for AIX 5.2
    #
     
    gmake:
    download rpm, and install by command “installp -aXgd .  rpm.rte”
    install gmake by command “rpm –ivh make-3.81-1.aix6.1.ppc.rpm”

Start ADPlus automatically

To start ADPlus automatically in case the process crashed soon after started, and you don’t have the time to attach to it.

· Navigate to registry “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options”

· Check if a key “notepad.exe” exists, if not, create one

· Add a string value below the key, value name “debugger”, value data “c:\autodump.bat”

· Create a file “c:\autodump.bat” with the content “cscript.exe “C:\Program Files\Debugging Tools for Windows 64-bit\adplus.vbs” -crash -quiet -o c:\dumps  -sc %1″

· Start backup job, and adplus will be started when notepad.exe process started.

· Please get the dump files in the folder “c:\dumps” if notepad.exe crash again.

AIX profile tools

List some AIX profiles tools here for later reference.

 

Debug malloc comes free of cost (in fact it is built into the malloc subsystem of libc),
but the problem with debug malloc is that it dumps at the first heap corruption.
You can only proceed to find the next problem once you’ve fixed the first problem and recompiled.
Usually, big programs do a lot of memory corruption,
and you’ll probably end up spending time on non-critical invalid memory operations.
Also debug-malloc has a limitation that it can’t report stack corruption.
Only malloc-ed memory corruption can be caught.

Rational purify. You might want to get a license for that.

Electric-fence is another tool that will help you to debug heap corruption.
It is available from http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/download.html
but I’ve never used it and I don’t know how good it is, or what is the
scope of electric fence.

Zerofault is another tool which reports a lot of statistics. But again,
that is not free.

AIX core dump with dbx

  • # file core  //Check who generated the core file:
    core: AIX core file fulldump largedata 32-bit, ws_rep
  • Check the working directory of a process, the code file is generated in that folder
    # procwdx -F 5963988
    5963988:        /var/tmp/ws_rep/

 

  • # dbx executable_file core
    # dbx –a pid executable_file
  • (dbx) where
    show current stack
  • (dbx) dump  //show the parameters in the current function
    unnamed block in thl_event_c::wait(int,bool)(this = 0x300f6404, timeout = 30000, need_reset = true), line 331 in “thl.cpp”
    ptime = 0x302c2958
    timebuf = (tv_sec = 1362055965, tv_nsec = 461275000)
    stat = 806001880
  • //move the current frame in the stack
    up
    up <count>
    down
    down <count>
            Move the current function, which is used for resolving
            names, up or down the stack <count> levels. The default
            <count> is one.
  • (dbx) registers
  • (dbx) thread
  • (dbx) listi <address\function>              listi address1, address2
    show the disassembler of the function, address
  • list    // show the source code

Continue reading

unzip on AIX

unzip is not installed on AIX be default.

We can use the command below instead:

# jar xvf core.2.20130222.zip
inflated: core
inflated: core.2

 

Or you can also manually download unzip.

 

在AIX上最常见的压缩文件就是.tar压缩格式的文件了。 而除了tar文件以外,有时会遇到数据是用其它的压缩文件格式,所以偶顺手整理了一些常见的压缩文件格式,在AIX要怎么解压缩:

.tar.Z file format

o 压缩 # compress filename.tar

o 解压 # zcat filename.tar.Z | tar -xvf -

 

.tar.gz file format

o 压缩 # tar cvf – folder | gzip > filename.tar.gz

o 解压 # gunzip -c filename.tar.gz | tar -xvf -

 

.zip file format (注1)

o 解压 # unzip filename.zip

.tgz file format

o 解压 # gzip -d filename.tgz | tar -xvf -

注1 :请注意,AIX预设并没有装unzip的程序,可以去这边抓下来安装

Linux Device Driver 3 note continued (block driver)

Block Driver register

在2.6内核, 对 register_blkdev 的调用完全是可选的. 由 register_blkdev 所进行的功能已随时间正在减少; 这个调用唯一的任务是 (1) 如果需要, 分配一个动态主编号, 并且在 /proc/devices 创建一个入口. 在将来的内核, register_blkdev 可能被一起去掉. 同时, 但是, 大部分驱动仍然调用它; 它是惯例.

// a static list with block device id and names,
// is only used to show the device name in /proc/devices
// proc_misc_init -> create_seq_entry("devices", 0, &proc_devinfo_operations);
// proc_devinfo_operations.open = devinfo_open -> seq_open(filp, &devinfo_ops);
// devinfo_ops.show = int devinfo_show(struct seq_file *f, void *v)
// .show = devinfo_show -> blkdev_show ->
static struct blk_major_name {
struct blk_major_name *next;
int major;
char name[16];

} *major_names[BLKDEV_MAJOR_HASH_SIZE];

int register_blkdev(unsigned int major, const char *name)
{
mutex_lock(&block_subsys_lock);

p = kmalloc(sizeof(struct blk_major_name), GFP_KERNEL);
p->major = major;
strlcpy(p->name, name, sizeof(p->name));
p->next = NULL;
index = major_to_index(major);

for (n = &major_names[index]; *n; n = &(*n)->next) {
if ((*n)->major == major)
break;
}
if (!*n)
*n = p;
else
ret = -EBUSY;
}


int unregister_blkdev(unsigned int major, const char *name)
{
//lock, and remove it from major_names
}

 

Continue reading

Linux Device Driver 3 notes

  • Linux Modules
    image
  • Char/BlockCharacter devices
    A character (char) device is one that can be accessed as a stream of bytes (like a
    file); a char driver is in charge of implementing this behavior. Such a driver usually
    implements at least the open, close, read, and write system calls. The text
    console (/dev/console) and the serial ports (/dev/ttyS0 and friends) are examples
    of char devices, as they are well represented by the stream abstraction. Char
    devices are accessed by means of filesystem nodes, such as /dev/tty1 and /dev/lp0.
    The only relevant difference between a char device and a regular file is that you
    can always move back and forth in the regular file, whereas most char devices
    are just data channels, which you can only access sequentially
    . There exist,
    nonetheless, char devices that look like data areas, and you can move back and
    forth in them; for instance, this usually applies to frame grabbers,
    where the
    applications can access the whole acquired image using mmap or lseek.

Block devices
Like char devices, block devices are accessed by filesystem nodes in the /dev
directory. A block device is a device (e.g., a disk) that can host a filesystem. In
most Unix systems, a block device can only handle I/O operations that transfer
one or more whole blocks, which are usually 512 bytes (or a larger power of
two) bytes in length. Linux, instead, allows the application to read and write a
block device like a char device—it permits the transfer of any number of bytes at
a time. As a result, block and char devices differ only in the way data is managed
internally by the kernel, and thus in the kernel/driver software interface. Like a
char device, each block device is accessed through a filesystem node, and the difference
between them is transparent to the user. Block drivers have a completely
different interface to the kernel than char drivers
.

 

Continue reading