IPF(IA64) support
Subsystems (8)
cover IPF(IA64) support
Hi,
I release new version of diskdump for kernel 2.6.7.
- IPF(IA64) support
- Fusion-MPT scsi driver support
Source code can be downloaded from
http://sourceforge.net/projects/lkdump
Please feel free to use!
Best Regards,
Takao Indoh
------------------------------------
Introduction
------------
Diskdump offers a function to execute so-called crash dump. When "panic" or "oops" happens, diskdump automatically saves system memory to the disk. We can investigate the cause of panic using this saved memory image which we call as crash dump.
Overview
-------
- How it works
This is 2-stage dump which is similar to traditional UNIX dump. The 1st stage starts when panic occurs, at which time the register state and other dump-related data is stored in a header, followed by the full contents of memory, in a dedicated dump partition. The dump partition will have been pre-formatted with per-block signatures. The 2nd stage is executed by rc script after the next system reboot, at which time the savecore command will create the vmcore file from the contents of the dump partition. After that, the per-block signatures will be re-written over the dump partition, in preparation for the next panic.
The handling of panic is essentially the same as netdump. It inhibits interrupts, freezes all other CPUs, and then for each page of data, issues the I/O command to the host adapter driver, followed by calling the interrupt handler of the adapter driver iteratively until the I/O has completed. The difference compared to netdump is that diskdump saves memory to the dump partition in its own loop, and does not wait for instructions from an external entity.
- Safety
When diskdump is executed, of course the system is in serious trouble. Therefore, there is a possibility that user resources on the disk containing the dump partition could be corrupted. To avoid this danger, signatures are written over the complete dump partition. When a panic occurs, the diskdump module reads the whole dump partition, and checks if the signatures are written correctly. If the signatures match, the diskdump presumes that it will be writing to the correct device, and that there is a high possibility that it will be able to write the dump correctly. The signatures should be the ones which have low possibility to exist on the disk.
We decided that the following format will be written in each one block (page-size) unit on the partition. The signatures are created by a simple formulas based on the block number, making it a low possibility that the created signature would ever be the same as a user resource:
32-bit word 0: "disk"
32-bit word 1: "dump"
32-bit word 2: block number
32-bit word 3: (block number+3)*11
32-bit word 4: ((word 3)+3)*11
32-bit work 5: ((word 4)+3)*11
32-bit work 6: ((word 5)+3)*11
...
32-bit work 1023: ((word 1022)+3)*11
The diskdump module also verifies that its code and data contents have not been corrupted. The dump module computes CRC value of its module at the point that dump device is registered, and saves it. When panic occurs, the dump module re-computes the CRC value at that point and compares with the saved value. If the values aren't the same, the dump knows that it has been damaged and aborts the dump process.
- Reliability
After panic occurs, I/O is executed by the diskdump module calling the queuecommand() function of the host adapter driver, and by polling the interrupt handler directly. The dump is executed by diskdump module and host adapter driver only. It is executed without depending on other components of kernel, so it works even when panic occurs in interrupt context. (XXX To be exact, a couple of drivers are not finished completely, because they calls kmalloc() as an extension of queuecommand())
In SCSI, a host reset is executed first, so it is possible to dump with a stable bus condition. In a couple of drivers, especially in the host reset process, timers and tasklets may be used. For these drivers, I created a helper library to emulate these functions. The helper library executes timer and tasklet functionality, which helps to minimize the modification required to support diskdump. The size of initrd increases slightly because the driver depends upon the helper library.
Multiple dump devices can be registered. When a panic occurs, the diskdump module checks each dump device condition and selects the first sane device that it finds.
Diskdump and netdump can co-exist. When both of modules are enabled, the diskdump works in preference to the netdump. If the signature checking fails, if a disk I/O error occurs, or if a double panic occurs in the diskdump process, it falls back to netdump.
- The architectures and drivers to be supported
IA32 only is supported. Regarding drivers, aic7xxx, aic79xx and qla1280 are supported. I will support some qlogic drivers later.
The modification of supported drivers is needed, but the changes are very small if they are SCSI drivers.
- The consistency with the netdump
The format of the saved vmcore file is completely the same as the one which is created by the netdump-server. The vmcore file created by the savecore command can be read by the existing crash utility.
The saved directory is /var/crash/127.0.0.1-<DATE> which is consistent with the netdump. 127.0.0.1 is an IP address which the netdump can never use, so there is no conflict. Our savecore command also calls /var/crash/scripts/netdump-nospace script as does the netdump-server daemon.
- Impact to kernel
The host adapter driver needs to be modified to support diskdump, but the required steps are small. For example, the modification patch for the aic7xxx/aic9xxx drivers contains 100 lines for each. At a minimum, a poll handler needs to be added, which is called from diskdump to handle I/O completion. If the adapter driver does not use timers or tasklets, that's all that is required. Even if timers or tasklets are used, it only requires a small amount of code from the emulation library.
Similar to netdump, the variable diskdump_mode, the diskdump_func hook, and the diskdump_register_hook() function has been created to register diskdump functionality.
To check the result code of Scsi_Cmnd, scsi_decide_disposition() is also exported.
scsi_done() and scsi_eh_done() discards Scsi_Cmnds when diskdump_mode is set. With this implementation, extra processing can be avoided in the the extension of outstanding completion of Scsi_Cmd, which is completed in the extension of host reset process. This is the only overhead to be added to the main route. It's simply an addition of "if unlikely(diskdump_mode) return", so the overhead is negligible.
Internal structure
------------------
- The interface between disdkdump.o and scsi_dump.o
scsi_dump.o is the diskdump driver for SCSI, and it registers itself to diskdump.o. (The diskdump drivers for IDE or SATA, if and when they are created, would also register themselves to diskdump.o.)
scsi_mod.o defines the following structures:
struct disk_dump_type {
void *(*probe)(struct device *);
int (*add_device)(struct disk_dump_device *);
void (*remove_device)(struct disk_dump_device *);
struct module *owner;
struct list_head list;
};static struct disk_dump_type scsi_dump_type = {
.probe = scsi_dump_probe,
.add_device = scsi_dump_add_device,
.remove_device = scsi_dump_remove_device,
.owner = THIS_MODULE,
};
scsi_dump registers them by register_disk_dump_type().
The probe() handler is called from diskdump.o to determine whether the selected kdev_t belongs to scsi_mod.o. If it returns 0 to probe(), diskdump.o creates a disk_dump_device structure and calls add_device(). The add_device() handler of scsi_dump.o populates the disk_dump_device_ops of the disk_dump_device. disk_dump_device_ops is the set of handlers which are called from diskdump.o when panic occurs:
struct disk_dump_device_ops {
int (*sanity_check)(struct disk_dump_device *);
int (*quiesce)(struct disk_dump_device *);
int (*shutdown)(struct disk_dump_device *);
int (*rw_block)(struct disk_dump_partition *, int rw, unsigned long
block_nr, void *buf, int len);
};The handler functions are only called when a panic occurs.
sanity_check() checks if the selected device works normally. A device which returns an error status will not be selected as the dump device.
quiesce() is called after the device is selected as the dump device. If it is SCSI, host reset is executed and Write Cache Enable bit of the disk device is temporarily set for the dump operation.
shutdown() is called after dump is completed. If it is SCSI, "SYNCHRONIZE CACHE" command is issued to the disk.
rw_block() executes I/O in one block unit. The length of data is a page size, and is guaranteed to be physically contiguous. In scsi_dump.o, it issues I/O by calling the queuecommand() handler from the rw_block() handler. The poll handler of adapter driver is called until the I/O has completed.
- The interface between scsi_dump.o and the adapter driver
The SCSI adapter which supports the diskdump prepares the following functions:
int (*sanity_check)(struct scsi_device *);
int (*quiesce)(struct scsi_device *);
int (*shutdown)(struct scsi_device *);
void (*poll)(struct scsi_device *);The poll function should call the interrupt handler. It is called repeatedly after queuecommand() is issued, and until the command is completed.
The other handlers are called by the handlers in scsi_dump.o which have the same names.
The adapter driver should set its own handlers to the scsi_host_template.
struct scsi_host_template {(snipped)
#if defined(CONFIG_SCSI_DUMP) || defined(CONFIG_SCSI_DUMP_MODULE)
/* operations for dump */
/*
* dump_sanity_check() checks if the selected device works normally.
* A device which returns an error status will not be selected as
* the dump device.
*
* Status: OPTIONAL
*/
int (* dump_sanity_check)(struct scsi_device *);
/*
* dump_quiesce() is called after the device is selected as the
* dump device. Usually, host reset is executed and Write Cache
* Enable bit of the disk device is temporarily set for the
* dump operation.
*
* Status: OPTIONAL
*/
int (* dump_quiesce)(struct scsi_device *);
/*
* dump_shutdown() is called after dump is completed. Usually
* "SYNCHRONIZE CACHE" command is issued to the disk.
*
* Status: OPTIONAL
*/
int (* dump_shutdown)(struct scsi_device *);
/*
* dump_poll() should call the interrupt handler. It is called
* repeatedly after queuecommand() is issued, and until the command
* is completed. If the low level device driver support crash dump,
* it must have this routine.
*
* Status: OPTIONAL
*/
void (* dump_poll)(struct scsi_device *);
#endif
};Supported Drivers
------------------
Disk dump only works on the disks which are connected to adapters that the following drivers control:
aic7xxx
aic79xx
mptscsihInstallation
------------
1) Download software
1. Linux kernel version 2.6.7
linux-2.6.7.tar.bz2 can be downloaded from
ftp://ftp.kernel.org/pub/linux/kernel/v2.6/
2. diskdump kernel patch
diskdump-0.6.tar.gz can be downloaded from the project page.
http://sourceforge.net/projects/lkdump
3. diskdumputils
diskdumputils-0.4.2.tar.bz2 can be downloaded from the project page.
4. crash command and patch
crash can be download from ftp://people.redhat.com/anderson/. A patch for crash-3.8-5.tar.gz can be downloaded from the project page.
2) Build and Install Kernel
1. Untar Linux kernel source
tar -xjvf linux-2.6.7.tar.bz2
2. Apply all patches in the diskdump-0.5.tar.gz
3. Kernel Configuration
a. make menuconfig
b. Under "Device Drivers"-> "Block devices", select the following:
i. Select "m" for "Disk dump support".
c. Under "Device Drivers"-> "SCSI device support", select the
following:
i. Select "m" for "SCSI dump support".
d. Under "Kernel hacking", select the following:
i. Select "y" for "Kernel debugging".
ii. Select "y" for "Magic SysRq key". (optional)
iii. Select "y" for "Compile the kernel with debug info".
e. Configure other kernel config settings as needed.
4. make
5. make modules_install
6. Build initrd if you need
7. Copy the kernel image to the boot directory
ex. cp arch/i386/boot/bzImage /boot/vmlinuz-2.6.7-diskdump8. Reboot
3) Build and Install diskdumputils
1. Untar diskdumputils package
tar -xjvf diskdumputils-0.4.2.tar.bz2
2. make
3. make install
4) Build and Install crash
1. Untar crash package
tar -xjvf crash-3.8-5.tar.gz
2. Apply crash-3.8-5.patch
3. make
4. make install
5) Setup
The setup procedure is as follows. First a dump device must be selected. Either whole device or a partition is fine. The dump device is wholly formatted for dump, it cannot be shared with a file system or as a swap partition. The size of dump device should be big enough to save the whole dump. The size to be written by the dump is the size of whole memory plus a header field. To determine the exact size, refer to the output kernel message after the diskdump module is loaded:
# modprobe diskdump
# dmesg | tail disk_dump: total blocks required: 262042 (header 3 + bitmap 8 + memory 262031) In this case, 262042 is the data size in pagesize units that will be written by the diskdump function.
select the dump partition in /etc/sysconfig/diskdump, as in the following example:
-------------------
DEVICE=/dev/sde1
-------------------
Next, Format the dump partition. The administrator needs to execute this once.
# service diskdump initialformat
Lastly, enable the service:
# chkconfig diskdump on # service diskdump start
To test the diskdump, use Alt-SysRq-C or "echo c > /proc/sysrq-trigger". After completing the dump, a vmcore file will created during the next reboot sequence, and saved in a directory of the name format:
/var/crash/127.0.0.1-<date>
The dump format is same as the netdump one, so we can use crash command to analyse.
# crash vmlinux vmcore
!!!NOTE!!!
Be careful when you investigate timer/tasklet/workqueue. Diskdump saves timer/tasklet/workqueue structure and clears them before dumping. Please see the following.
[timer]
Where is the structure saved?
static tvec_base_t saved_tvec_base;
How is the structure saved?
tvec_base_t *base = &per_cpu(tvec_bases, smp_processor_id()); memcpy(&saved_tvec_base, base, sizeof(saved_tvec_base));
How is the structure cleared?
init_timers_cpu(smp_processor_id());
[tasklet]
Where is the structure saved?
struct tasklet_head saved_tasklet;
How is the structure saved?
saved_tasklet.list = __get_cpu_var(tasklet_vec).list;
How is the structure cleared?
__get_cpu_var(tasklet_vec).list = NULL;
[workqueue]
Where is the structure saved?
struct cpu_workqueue_struct saved_cwq;
How is the structure saved?
int cpu = smp_processor_id(); struct cpu_workqueue_struct *cwq = keventd_wq->cpu_wq + cpu; memcpy(&saved_cwq, cwq, sizeof(saved_cwq));
How is the structure cleared?
spin_lock_init(&cwq->lock); INIT_LIST_HEAD(&cwq->worklist); init_waitqueue_head(&cwq->more_work); init_waitqueue_head(&cwq->work_done);
PATCH 1/5 IPF(IA64) support
This is a patch for diskdump common layer.
arch/i386/kernel/nmi.c +1 -0
@@ -524,3 +524,4 @@EXPORT_SYMBOL (release_lapic_nmi);EXPORT_SYMBOL (disable_timer_nmi_watchdog);EXPORT_SYMBOL (enable_timer_nmi_watchdog); +EXPORT_SYMBOL_GPL (touch_nmi_watchdog);
arch/i386/kernel/reboot.c +2 -1
@@ -252,7 +252,8 @@* Stop all CPUs and turn off local APICs and the IO-APIC, so * other OSs see a clean IRQ state. */ -smp_send_stop (); +if (!crashdump_mode ()) +smp_send_stop ();#elif defined(CONFIG_X86_LOCAL_APIC )if (cpu_has_apic) {local_irq_disable ();
arch/i386/kernel/smp.c +1 -1
@@ -520,7 +520,7 @@return 0 ;/* Can deadlock when called with interrupts disabled */ -WARN_ON (irqs_disabled ()); +WARN_ON (irqs_disabled () && !crashdump_mode ()); data.func = func; data.info = info;
arch/i386/kernel/traps.c +10 -1
@@ -294,6 +294,7 @@ }spinlock_t die_lock =SPIN_LOCK_UNLOCKED ; +static int die_owner =-1 ;void die (const char * str,struct pt_regs * regs,long err) {
@@ -301,7 +302,13 @@int nl =0 ;console_verbose (); -spin_lock_irq (&die_lock); +local_irq_disable (); +if (!spin_trylock (&die_lock)) { +if (smp_processor_id () != die_owner) +spin_lock (&die_lock); +/* allow recursive die to fall through */ + } + die_owner =smp_processor_id ();bust_spinlocks (1 );handle_BUG (regs);printk (KERN_ALERT "%s: %04lx [#%d]\n" , str, err &0xffff , ++die_counter);
@@ -320,7 +327,9 @@if (nl)printk ("\n" );show_registers (regs); +try_crashdump (regs);bust_spinlocks (0 ); + die_owner =-1 ;spin_unlock_irq (&die_lock);if (in_interrupt ())panic ("Fatal exception in interrupt" );
arch/i386/mm/init.c +2 -1
@@ -168,7 +168,7 @@extern int is_available_memory (efi_memory_desc_t *); -static inline int page_is_ram (unsigned long pagenr) +int page_is_ram (unsigned long pagenr) {int i;unsigned long addr, end;
@@ -205,6 +205,7 @@ }return 0 ; } +EXPORT_SYMBOL (page_is_ram);#ifdef CONFIG_HIGHMEM pte_t *kmap_pte;
arch/ia64/kernel/ia64_ksyms.c +10 -0
@@ -122,3 +122,13 @@# endif # endif #endif + +#include <linux/elf.h> +extern void ia64_do_copy_regs (struct unw_frame_info *info,void *arg); +EXPORT_SYMBOL (ia64_do_copy_regs); +extern void ia64_freeze_cpu (struct unw_frame_info *info,void *arg); +EXPORT_SYMBOL (ia64_freeze_cpu); + +extern int page_is_ram (unsigned long pagenr); +EXPORT_SYMBOL (page_is_ram); +
arch/ia64/kernel/process.c +19 -3
@@ -543,7 +543,7 @@ }void -do_copy_regs (struct unw_frame_info *info,void *arg) +ia64_do_copy_regs (struct unw_frame_info *info,void *arg) {do_copy_task_regs (current, info, arg); }
@@ -560,7 +560,7 @@struct unw_frame_info tcore_info;if (current = task) { -unw_init_running (do_copy_regs, regs); +unw_init_running (ia64_do_copy_regs, regs); }else {memset (&tcore_info,0 ,sizeof (tcore_info));unw_init_from_blocked_task (&tcore_info, task);
@@ -572,7 +572,7 @@void ia64_elf_core_copy_regs (struct pt_regs *pt,elf_gregset_t dst) { -unw_init_running (do_copy_regs, dst); +unw_init_running (ia64_do_copy_regs, dst); }int
@@ -767,3 +767,19 @@ }EXPORT_SYMBOL (machine_power_off); + +void +ia64_freeze_cpu (struct unw_frame_info *info,void *arg) +{ + current->thread.ksp = (__u64)(info->sw) -16 ; +for (;;)local_irq_disable (); +} + +void +ia64_start_dump (struct unw_frame_info *info,void *arg) +{ +struct dump_call_param *param = arg; + + param->func (param->regs, info); +} +
arch/ia64/kernel/smp.c +1 -1
@@ -332,7 +332,7 @@return 0 ;/* Can deadlock when called with interrupts disabled */ -WARN_ON (irqs_disabled ()); +WARN_ON (irqs_disabled () && !crashdump_mode ()); data.func = func; data.info = info;
arch/ia64/kernel/traps.c +4 -1
@@ -79,7 +79,9 @@if (die.lock_owner !=smp_processor_id ()) {console_verbose (); -spin_lock_irq (&die.lock); +local_irq_disable (); +if (!crashdump_mode ()) +spin_lock_irq (&die.lock); die.lock_owner =smp_processor_id (); die.lock_owner_depth =0 ;bust_spinlocks (1 );
@@ -92,6 +94,7 @@ }else printk (KERN_ERR "Recursive die() failure, output suppressed\n" ); +try_crashdump (regs);bust_spinlocks (0 ); die.lock_owner =-1 ;spin_unlock_irq (&die.lock);
arch/ia64/mm/init.c +45 -0
51 lines not on this page · raw message
drivers/block/Kconfig +5 -0
@@ -347,6 +347,11 @@ your machine, or if you want to have a raid or loopback device bigger than 2TB. Otherwise say N. +config DISKDUMP + tristate "Disk dump support" + ---help--- + Disk dump support. + source "drivers/s390/block/Kconfig" endmenu
drivers/block/Makefile +1 -0
@@ -43,3 +43,4 @@ obj-$(CONFIG_VIODASD) += viodasd.o obj-$(CONFIG_BLK_DEV_CARMEL) += carmel.o +obj-$(CONFIG_DISKDUMP) += diskdump.o
drivers/block/diskdump.c +895 -0
895 lines not on this page · raw message
drivers/char/sysrq.c +14 -1
@@ -107,6 +107,19 @@ .action_msg = "Resetting", }; +/* crash sysrq handler */ +static void sysrq_handle_crash (int key,struct pt_regs *pt_regs, +struct tty_struct *tty) +{ + *( (char *)0 ) =0 ; +} + +static struct sysrq_key_op sysrq_crash_op = { + .handler = sysrq_handle_crash, + .help_msg ="Crash" , + .action_msg ="Crashing the kernel by request" , +}; +static void sysrq_handle_sync (int key,struct pt_regs *pt_regs,struct tty_struct *tty) {
@@ -235,7 +248,7 @@it is handled specially on the sparc and will never arrive */ /* b */ &sysrq_reboot_op, -/* c */ NULL , +/* c */ &sysrq_crash_op,/* d */ NULL ,/* e */ &sysrq_term_op, /* f */ NULL,
include/asm-i386/diskdump.h +82 -0
82 lines not on this page · raw message
include/asm-i386/kmap_types.h +2 -1
@@ -23,7 +23,8 @@ D(10) KM_IRQ1, D(11) KM_SOFTIRQ0, D(12) KM_SOFTIRQ1, -D(13) KM_TYPE_NR +D(13) KM_DISKDUMP, +D(14) KM_TYPE_NR };#undef D
include/asm-ia64/diskdump.h +84 -0
84 lines not on this page · raw message
include/asm-ia64/ptrace.h +6 -0
@@ -295,6 +295,12 @@ struct ia64_fpreg fr[128]; }; +/* Container to hold dump hander information */ +struct dump_call_param { +void (*func)(struct pt_regs *,void *); +struct pt_regs *regs; +}; +#endif /* !__ASSEMBLY__ */ /* indices to application-registers array in pt_all_user_regs */
include/linux/diskdump.h +173 -0
173 lines not on this page · raw message
include/linux/interrupt.h +4 -0
@@ -246,4 +246,8 @@extern int probe_irq_off (unsigned long );/* returns 0 or negative on failure */ extern unsigned int probe_irq_mask (unsigned long );/* returns mask of ISA interrupts */ + +extern void dump_clear_tasklet (void ); +extern void dump_run_tasklet (void ); +#endif
include/linux/kernel.h +11 -0
@@ -111,6 +111,11 @@extern int panic_on_oops;extern int tainted;extern const char *print_tainted (void ); +struct pt_regs ; +extern void try_crashdump (struct pt_regs *); +extern void (*diskdump_func) (struct pt_regs *regs,void *platform_arg); +extern int diskdump_mode; +#define crashdump_mode () unlikely(diskdump_mode)/* Values used for system_state */ extern enum system_states {
@@ -139,6 +144,12 @@ #define pr_info(fmt,arg...) \ printk(KERN_INFO fmt,##arg) +#define pr_err(fmt,arg...) \ + printk(KERN_ERR fmt,##arg) + +#define pr_warn(fmt,arg...) \ + printk(KERN_WARNING fmt,##arg) +/* * Display an IP address in readable format. */
include/linux/timer.h +3 -0
@@ -99,4 +99,7 @@extern void run_local_timers (void );extern void it_real_fn (unsigned long ); +extern void dump_clear_timers (void ); +extern void dump_run_timers (void ); +#endif
include/linux/workqueue.h +3 -0
@@ -84,4 +84,7 @@ return ret; } +extern void dump_clear_workqueue (void ); +extern void dump_run_workqueue (void ); +#endif
kernel/Makefile +1 -1
@@ -7,7 +7,7 @@ sysctl.o capability.o ptrace.o timer.o user.o \ signal.o sys.o kmod.o workqueue.o pid.o \ rcupdate.o intermodule.o extable.o params.o posix-timers.o \ - kthread.o + kthread.o dump.o obj-$(CONFIG_FUTEX) += futex.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
kernel/dump.c +244 -0
244 lines not on this page · raw message
kernel/panic.c +2 -0
@@ -60,6 +60,8 @@vsnprintf (buf,sizeof (buf), fmt, args);va_end (args);printk (KERN_EMERG "Kernel panic: %s\n" ,buf); +if (diskdump_func) +BUG ();if (in_interrupt ())printk (KERN_EMERG "In interrupt handler - not syncing\n" );else if (!current->pid)
kernel/softirq.c +32 -0
@@ -314,6 +314,38 @@EXPORT_SYMBOL (tasklet_kill); +struct tasklet_head saved_tasklet; + +void dump_clear_tasklet (void ) +{ + saved_tasklet.list =__get_cpu_var (tasklet_vec).list; +__get_cpu_var (tasklet_vec).list =NULL ; +} + +EXPORT_SYMBOL (dump_clear_tasklet); + +void dump_run_tasklet (void ) +{ +struct tasklet_struct *list; + + list =__get_cpu_var (tasklet_vec).list; +__get_cpu_var (tasklet_vec).list =NULL ; + +while (list) { +struct tasklet_struct *t = list; + list = list->next; + +if (!atomic_read (&t->count) && + (test_and_clear_bit (TASKLET_STATE_SCHED , &t->state))) + t->func (t->data); + + t->next =__get_cpu_var (tasklet_vec).list; +__get_cpu_var (tasklet_vec).list = t; + } +} + +EXPORT_SYMBOL (dump_run_tasklet); +void __init softirq_init (void ) {open_softirq (TASKLET_SOFTIRQ , tasklet_action,NULL );
kernel/timer.c +33 -4
@@ -31,6 +31,7 @@#include <linux/time.h> #include <linux/jiffies.h> #include <linux/cpu.h> +#include <linux/delay.h> #include <asm/uaccess.h> #include <asm/unistd.h>
@@ -423,8 +424,9 @@static inline void __run_timers (tvec_base_t *base) {struct timer_list *timer; +unsigned long flags; -spin_lock_irq (&base->lock); +spin_lock_irqsave (&base->lock, flags);while (time_after_eq (jiffies, base->timer_jiffies)) {struct list_head work_list =LIST_HEAD_INIT (work_list);struct list_head *head = &work_list;
@@ -453,14 +455,14 @@set_running_timer (base, timer);smp_wmb (); timer->base =NULL ; -spin_unlock_irq (&base->lock); +spin_unlock_irqrestore (&base->lock, flags);fn (data);spin_lock_irq (&base->lock); goto repeat; } }set_running_timer (base,NULL ); -spin_unlock_irq (&base->lock); +spin_unlock_irqrestore (&base->lock, flags); }#ifdef CONFIG_NO_IDLE_HZ
@@ -1105,6 +1107,12 @@struct timer_list timer;unsigned long expire; +if (crashdump_mode ()) { +mdelay (timeout); +set_current_state (TASK_RUNNING ); +return timeout; + } +switch (timeout) {case MAX_SCHEDULE_TIMEOUT :
@@ -1308,7 +1316,7 @@return 0 ; } -static void __devinit init_timers_cpu (int cpu) +static void /* __devinit */ init_timers_cpu (int cpu) {int j;tvec_base_t *base;
@@ -1327,6 +1335,27 @@ base->timer_jiffies = jiffies; } +static tvec_base_t saved_tvec_base; + +void dump_clear_timers (void ) +{ +tvec_base_t *base = &per_cpu (tvec_bases,smp_processor_id ()); + +memcpy (&saved_tvec_base, base,sizeof (saved_tvec_base)); +init_timers_cpu (smp_processor_id ()); +} + +EXPORT_SYMBOL (dump_clear_timers); + +void dump_run_timers (void ) +{ +tvec_base_t *base = &__get_cpu_var (tvec_bases); + +__run_timers (base); +} + +EXPORT_SYMBOL (dump_run_timers); +#ifdef CONFIG_HOTPLUG_CPU static int migrate_timer_list (tvec_base_t *new_base,struct list_head *head) {
kernel/workqueue.c +34 -0
@@ -424,6 +424,37 @@ } +struct cpu_workqueue_struct saved_cwq; + +void dump_clear_workqueue (void ) +{ +int cpu =smp_processor_id (); +struct cpu_workqueue_struct *cwq = keventd_wq->cpu_wq + cpu; + +memcpy (&saved_cwq, cwq,sizeof (saved_cwq)); +spin_lock_init (&cwq->lock); +INIT_LIST_HEAD (&cwq->worklist); +init_waitqueue_head (&cwq->more_work); +init_waitqueue_head (&cwq->work_done); +} + +void dump_run_workqueue (void ) +{ +struct cpu_workqueue_struct *cwq; + + cwq = keventd_wq->cpu_wq +smp_processor_id (); +while (!list_empty (&cwq->worklist)) { +struct work_struct *work =list_entry (cwq->worklist.next, + struct work_struct, entry); +void (*f) (void *) = work->func; +void *data = work->data; + +list_del_init (cwq->worklist.next); +clear_bit (0 , &work->pending); +f (data); + } +} +#ifdef CONFIG_HOTPLUG_CPU /* Take the work from this (downed) CPU. */ static void take_over_work (struct workqueue_struct *wq,unsigned int cpu)
@@ -507,3 +538,6 @@EXPORT_SYMBOL (schedule_delayed_work);EXPORT_SYMBOL (flush_scheduled_work); +EXPORT_SYMBOL (dump_clear_workqueue); +EXPORT_SYMBOL (dump_run_workqueue); +
mm/bootmem.c +2 -0
@@ -16,6 +16,7 @@#include <linux/init.h> #include <linux/bootmem.h> #include <linux/mmzone.h> +#include <linux/module.h> #include <asm/dma.h> #include <asm/io.h>
@@ -26,6 +27,7 @@unsigned long max_low_pfn;unsigned long min_low_pfn;unsigned long max_pfn; +EXPORT_SYMBOL (max_pfn);/* return the number of _pages_ that will be allocated for the boot bitmap */ unsigned long __init bootmem_bootmap_pages (unsigned long pages)
drivers/block/diskdump.c line 65
Quoted 8 lines · Takao Indoh
drivers/block/diskdump.c +8
-0+static unsigned int fallback_on_err =1 ; +static unsigned int allow_risky_dumps =1 ; +static unsigned int block_order =2 ; +static int sample_rate =8 ; +module_param (fallback_on_err, uint,0 ); +module_param (allow_risky_dumps, uint,0 ); +module_param (block_order, uint,0 ); +module_param (sample_rate, int,0 );
Hi Takao!
Are you sure you want "uint" for fallback_on_err and allow_risky_dumps
and not "bool"? Also, I suggest "0400" as permissions so you can read them out of sysfs; maybe even 0600 if these parameters can be changed after loading.
Thanks!
Rusty.
Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell
Hi!
Quoted 12 lines · Rusty Russell
drivers/block/diskdump.c line 65
Quoted 8 lines · Takao Indoh
drivers/block/diskdump.c +8
-0+static unsigned int fallback_on_err =1 ; +static unsigned int allow_risky_dumps =1 ; +static unsigned int block_order =2 ; +static int sample_rate =8 ; +module_param (fallback_on_err, uint,0 ); +module_param (allow_risky_dumps, uint,0 ); +module_param (block_order, uint,0 ); +module_param (sample_rate, int,0 );Hi Takao!
Quoted 4 lines
Are you sure you want "uint" for
fallback_on_errandallow_risky_dumps
and not "bool"? Also, I suggest "0400" as permissions so you can read them out of sysfs; maybe even 0600 if these parameters can be changed after loading.
Thanks for comment.
The type of fallback_on_err and allow_risky_dumps is bool. The latest version of diskdump (released on 28th Aug) is as follows.
+static int fallback_on_err = 1;
+static int allow_risky_dumps = 1;
+static unsigned int block_order = 2;
+static int sample_rate = 8;
+module_param_named(fallback_on_err, fallback_on_err, bool, S_IRUGO|S_IWUSR); +module_param_named(allow_risky_dumps, allow_risky_dumps, bool, S_IRUGO|S_IWUSR); +module_param_named(block_order, block_order, uint, S_IRUGO|S_IWUSR); +module_param_named(sample_rate, sample_rate, int, S_IRUGO|S_IWUSR);
Regards,
Takao Indoh
PATCH 2/5 IPF(IA64) support
In reply to Takao IndohThis is a patch for scsi common layer.
drivers/scsi/Kconfig +6 -0
@@ -55,6 +55,12 @@ In this case, do not compile the driver for your SCSI host adapter (below) as a module either. +config SCSI_DUMP + tristate "SCSI dump support" + depends on DISKDUMP && SCSI + help + SCSI dump support + config CHR_DEV_ST tristate "SCSI tape support" depends on SCSI
drivers/scsi/Makefile +2 -0
@@ -136,6 +136,8 @@ obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o obj-$(CONFIG_CHR_DEV_SG) += sg.o +obj-$(CONFIG_SCSI_DUMP) += scsi_dump.o + scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \ scsicam.o scsi_error.o scsi_lib.o \ scsi_scan.o scsi_syms.o scsi_sysfs.o \
drivers/scsi/scsi.c +3 -0
@@ -691,6 +691,9 @@ {unsigned long flags; +if (crashdump_mode ()) +return ; +/* * We don't have to worry about this one timing out any more. * If we are unable to remove the timer, then the command
drivers/scsi/scsi_dump.c +597 -0
597 lines not on this page · raw message
drivers/scsi/scsi_error.c +3 -0
@@ -402,6 +402,9 @@**/ static void scsi_eh_done (struct scsi_cmnd *scmd) { +if (crashdump_mode ()) +return ; +/* * if the timeout handler is already running, then just set the * flag which says we finished late, and return. we have no
drivers/scsi/scsi_syms.c +3 -0
@@ -25,6 +25,7 @@#include "scsi.h" #include "scsi_logging.h" +#include "scsi_priv.h" /*
@@ -107,3 +108,5 @@*/ EXPORT_SYMBOL (scsi_add_timer);EXPORT_SYMBOL (scsi_delete_timer); + +EXPORT_SYMBOL (scsi_decide_disposition);
drivers/scsi/scsi_sysfs.c +3 -0
@@ -11,6 +11,7 @@#include <linux/init.h> #include <linux/blkdev.h> #include <linux/device.h> +#include <linux/diskdump.h> #include <scsi/scsi_host.h> #include <scsi/scsi_transport.h>
@@ -375,6 +376,7 @@DEVICE_ATTR (state,S_IRUGO |S_IWUSR , show_state_field, store_state_field); +DEVICE_ATTR (dump,S_IRUGO |S_IWUSR , diskdump_sysfs_show, diskdump_sysfs_store);/* Default template for device attributes. May NOT be modified */ static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
@@ -389,6 +391,7 @@ &dev_attr_delete, &dev_attr_state, &dev_attr_timeout, + &dev_attr_dump, NULL };
include/scsi/scsi_host.h +41 -0
47 lines not on this page · raw message
PATCH 3/5 IPF(IA64) support
In reply to Takao IndohThis is a patch for aic7xxx driver.
drivers/scsi/aic7xxx/aic7xxx_osm.c +39 -0
@@ -774,6 +774,8 @@static int ahc_linux_bus_reset (Scsi_Cmnd *);static int ahc_linux_dev_reset (Scsi_Cmnd *);static int ahc_linux_abort (Scsi_Cmnd *); +static int ahc_linux_sanity_check (struct scsi_device *); +static void ahc_linux_poll (struct scsi_device *);/* * Calculate a safe value for AHC_NSEG (as expressed through ahc_linux_nseg).
@@ -1315,6 +1317,8 @@ .slave_alloc = ahc_linux_slave_alloc, .slave_configure = ahc_linux_slave_configure, .slave_destroy = ahc_linux_slave_destroy, + .dump_sanity_check = ahc_linux_sanity_check, + .dump_poll = ahc_linux_poll, };/**************************** Tasklet Handler *********************************/
@@ -3868,6 +3872,41 @@return IRQ_RETVAL (ours); } +static int +ahc_linux_sanity_check (struct scsi_device *device) +{ +struct ahc_softc *ahc; +struct ahc_linux_device *dev; + + ahc = *(struct ahc_softc **)device->host->hostdata; + dev =ahc_linux_get_device (ahc, device->channel, + device->id, device->lun, +/*alloc*/ FALSE); +if (dev =NULL ) +return -ENXIO ; +if (ahc->platform_data->qfrozen || dev->qfrozen) +return -EBUSY ; +if (spin_is_locked (&ahc->platform_data->spin_lock)) +return -EBUSY ; +return 0 ; +} + +static void +ahc_linux_poll (struct scsi_device *device) +{ +struct ahc_softc *ahc; +struct ahc_linux_device *dev; + + ahc = *(struct ahc_softc **)device->host->hostdata; +ahc_intr (ahc); +while ((dev =ahc_linux_next_device_to_run (ahc)) !=NULL ) { +TAILQ_REMOVE (&ahc->platform_data->device_runq, dev, links); + dev->flags &= ~AHC_DEV_ON_RUN_LIST ; +ahc_linux_check_device_queue (ahc, dev); + } +ahc_linux_run_complete_queue (ahc); +} +void ahc_platform_flushwork (struct ahc_softc *ahc) {
PATCH 4/5 IPF(IA64) support
In reply to Takao IndohThis is a patch for aic79xx driver.
drivers/scsi/aic7xxx/aic79xx_osm.c +37 -0
@@ -786,6 +786,8 @@static int ahd_linux_bus_reset (Scsi_Cmnd *);static int ahd_linux_dev_reset (Scsi_Cmnd *);static int ahd_linux_abort (Scsi_Cmnd *); +static int ahd_linux_sanity_check (struct scsi_device *); +static void ahd_linux_poll (struct scsi_device *);/* * Calculate a safe value for AHD_NSEG (as expressed through ahd_linux_nseg).
@@ -1684,6 +1686,8 @@ .slave_alloc = ahd_linux_slave_alloc, .slave_configure = ahd_linux_slave_configure, .slave_destroy = ahd_linux_slave_destroy, + .dump_sanity_check = ahd_linux_sanity_check, + .dump_poll = ahd_linux_poll, };/**************************** Tasklet Handler *********************************/
@@ -4191,6 +4195,39 @@return IRQ_RETVAL (ours); } +static int +ahd_linux_sanity_check (struct scsi_device *device) +{ +struct ahd_softc *ahd; +struct ahd_linux_device *dev; + + ahd = *(struct ahd_softc **)device->host->hostdata; + dev =ahd_linux_get_device (ahd, device->channel, + device->id, device->lun, +/*alloc*/ FALSE); + +if (dev =NULL ) +return -ENXIO ; +if (ahd->platform_data->qfrozen || dev->qfrozen) +return -EBUSY ; +if (spin_is_locked (&ahd->platform_data->spin_lock)) +return -EBUSY ; +return 0 ; +} + +static void +ahd_linux_poll (struct scsi_device *device) +{ +struct ahd_softc *ahd; +int ours; + + ahd = *(struct ahd_softc **)device->host->hostdata; + ours =ahd_intr (ahd); +if (ahd_linux_next_device_to_run (ahd) !=NULL ) +ahd_schedule_runq (ahd); +ahd_linux_run_complete_queue (ahd); +} +void ahd_platform_flushwork (struct ahd_softc *ahd) {
PATCH 5/5 IPF(IA64) support
In reply to Takao IndohThis is a patch for Fusion-MPT scsi driver.
drivers/message/fusion/linux_compat.h +12 -0
@@ -192,6 +192,18 @@#define MPT_INIT_WORK (_task, _func, _data) INIT_WORK(_task, _func, _data)#define mpt_sync_irq (_irq) synchronize_irq(_irq) +#define MPT_HOST_LOCK (host_lock) \ + if (crashdump_mode()) \ + spin_lock(host_lock); \ + else \ + spin_lock_irq(host_lock); + +#define MPT_HOST_UNLOCK (host_lock) \ + if (crashdump_mode()) \ + spin_unlock(host_lock); \ + else \ + spin_unlock_irq(host_lock); +/*}-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ #endif /* _LINUX_COMPAT_H */
drivers/message/fusion/mptbase.c +12 -0
@@ -6292,6 +6292,17 @@ }/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void +mpt_poll_interrupt (MPT_ADAPTER *ioc) +{ +u32 intstat; + + intstat =CHIPREG_READ32 (&ioc->chip->IntStatus); + +if (intstat &MPI_HIS_REPLY_MESSAGE_INTERRUPT ) +mpt_interrupt (0 , (void *)ioc, (struct pt_regs *)NULL ); +} +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ EXPORT_SYMBOL (mpt_adapters);EXPORT_SYMBOL (mpt_proc_root_dir);
@@ -6332,6 +6343,7 @@EXPORT_SYMBOL (mpt_ASCQ_TableSz);EXPORT_SYMBOL (mpt_ScsiOpcodesPtr); +EXPORT_SYMBOL (mpt_poll_interrupt);static struct pci_driver mptbase_driver = { .name ="mptbase" ,
drivers/message/fusion/mptbase.h +2 -0
@@ -1066,6 +1066,8 @@extern int mpt_findImVolumes (MPT_ADAPTER *ioc);extern int mpt_read_ioc_pg_3 (MPT_ADAPTER *ioc); +extern void mpt_poll_interrupt (MPT_ADAPTER *ioc); +/* * Public data decl's... */
drivers/message/fusion/mptscsih.c +36 -2
@@ -273,6 +273,8 @@ .max_sectors = MPT_SCSI_MAX_SECTORS, .cmd_per_lun = MPT_SCSI_CMD_PER_LUN, .use_clustering = ENABLE_CLUSTERING, + .dump_sanity_check = x_scsi_sanity_check, + .dump_poll = x_scsi_poll, };/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -3053,7 +3055,7 @@/* If our attempts to reset the host failed, then return a failed * status. The host will be taken off line by the SCSI mid-layer. */ -spin_unlock_irq (host_lock); +MPT_HOST_UNLOCK (host_lock);if (mpt_HardResetHandler (hd->ioc,CAN_SLEEP ) <0 ){ status =FAILED ; }else {
@@ -3063,7 +3065,7 @@ hd->tmPending =0 ; hd->tmState =TM_STATE_NONE ; } -spin_lock_irq (host_lock); + MPT_HOST_LOCK(host_lock) dtmprintk( ( KERN_WARNING MYNAM ": mptscsih_host_reset: "
@@ -7272,6 +7274,38 @@ }#endif /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +int +mptscsih_sanity_check (struct scsi_device *sdev) +{ +MPT_ADAPTER *ioc; +MPT_SCSI_HOST *hd; + + hd = (MPT_SCSI_HOST *)sdev->host->hostdata; +if (!hd) +return -ENXIO ; + ioc = hd->ioc; + +/* message frame freeQ is busy */ +if (spin_is_locked (&ioc->FreeQlock)) { +return -EBUSY ; + } + +return 0 ; +} + +void +mptscsih_poll (struct scsi_device *sdev) +{ +MPT_SCSI_HOST *hd; + + hd = (MPT_SCSI_HOST *)sdev->host->hostdata; +if (!hd) +return ; + +/* check interrupt pending */ +mpt_poll_interrupt (hd->ioc); +} +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ module_init (mptscsih_init);
drivers/message/fusion/mptscsih.h +6 -0
@@ -143,6 +143,9 @@#define x_scsi_slave_destroy mptscsih_slave_destroy#define x_scsi_proc_info mptscsih_proc_info +#define x_scsi_sanity_check mptscsih_sanity_check +#define x_scsi_poll mptscsih_poll +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* * MPT SCSI Host / Initiator decls...
@@ -160,6 +163,9 @@extern void x_scsi_slave_destroy (Scsi_Device *);extern int x_scsi_proc_info (struct Scsi_Host *,char *,char **,off_t ,int ,int ); +extern int x_scsi_sanity_check (struct scsi_device *); +extern void x_scsi_poll (struct scsi_device *); +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* include/scsi/scsi.h may not be quite complete... */