-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolling-io-2-of-7.patch
1333 lines (1295 loc) · 36.9 KB
/
polling-io-2-of-7.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From [email protected] Mon Mar 7 19:19:33 2005
Date: Mon, 7 Mar 2005 19:19:33 -0800
From: Jason Uhlenkott <[email protected]>
Subject: Re: [PATCH 2/7] Polling I/O: Core
Message-ID: <[email protected]>
References: <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <[email protected]>
User-Agent: Mutt/1.5.6i
Status: RO
Content-Length: 37263
Lines: 1316
Core support for polling I/O. This provides the infrastructure for
polling mode dump types to be registered (using an interface
compatible with diskdump) and dumped to, if the user has set the
DUMP_FLAGS_POLL flag. (If the flag is not set, or the dump device
doesn't support polling I/O, we fall back to a traditional
interrupt-driven dump.)
Index: linux/include/linux/workqueue.h
===================================================================
--- linux.orig/include/linux/workqueue.h 2004-10-18 14:54:54.000000000 -0700
+++ linux/include/linux/workqueue.h 2005-03-07 13:47:56.593559206 -0800
@@ -86,4 +86,7 @@
return ret;
}
+extern void dump_clear_workqueue(void);
+extern void dump_run_workqueue(void);
+
#endif
Index: linux/include/asm-ppc64/diskdump.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux/include/asm-ppc64/diskdump.h 2005-03-07 13:47:56.612114051 -0800
@@ -0,0 +1,33 @@
+#ifndef _ASM_PPC64_DISKDUMP_H_
+#define _ASM_PPC64_DISKDUMP_H_
+
+/*
+ * linux/include/asm-ppc64/diskdump.h
+ *
+ * Copyright (c) 2004 FUJITSU LIMITED
+ * Copyright (c) 2003 Red Hat, Inc. All rights reserved.
+ */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifdef __KERNEL__
+
+#include <asm/crashdump.h>
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_PPC64_DISKDUMP_H_ */
Index: linux/include/linux/timer.h
===================================================================
--- linux.orig/include/linux/timer.h 2004-10-18 14:54:40.000000000 -0700
+++ linux/include/linux/timer.h 2005-03-07 13:47:56.618950046 -0800
@@ -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
Index: linux/kernel/timer.c
===================================================================
--- linux.orig/kernel/timer.c 2005-03-07 13:02:41.913799392 -0800
+++ linux/kernel/timer.c 2005-03-07 13:47:56.632622037 -0800
@@ -31,6 +31,8 @@
#include <linux/time.h>
#include <linux/jiffies.h>
#include <linux/cpu.h>
+#include <linux/delay.h>
+#include <linux/diskdump.h>
#include <linux/syscalls.h>
#include <asm/uaccess.h>
@@ -434,8 +436,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;
@@ -464,14 +467,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
@@ -1115,6 +1118,12 @@
struct timer_list timer;
unsigned long expire;
+ if (crashdump_mode()) {
+ diskdump_mdelay(timeout);
+ set_current_state(TASK_RUNNING);
+ return timeout;
+ }
+
switch (timeout)
{
case MAX_SCHEDULE_TIMEOUT:
@@ -1317,7 +1326,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;
@@ -1336,6 +1345,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_GPL(dump_clear_timers);
+
+void dump_run_timers(void)
+{
+ tvec_base_t *base = &__get_cpu_var(tvec_bases);
+
+ __run_timers(base);
+}
+
+EXPORT_SYMBOL_GPL(dump_run_timers);
+
#ifdef CONFIG_HOTPLUG_CPU
static int migrate_timer_list(tvec_base_t *new_base, struct list_head *head)
{
@@ -1620,6 +1650,11 @@
{
unsigned long timeout = msecs_to_jiffies(msecs) + 1;
+ if (crashdump_mode()) {
+ while (msecs--) udelay(1000);
+ return;
+ }
+
while (timeout) {
set_current_state(TASK_UNINTERRUPTIBLE);
timeout = schedule_timeout(timeout);
Index: linux/include/linux/diskdump.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux/include/linux/diskdump.h 2005-03-07 13:47:56.653130022 -0800
@@ -0,0 +1,99 @@
+#ifndef _LINUX_DISKDUMP_H
+#define _LINUX_DISKDUMP_H
+
+/*
+ * linux/include/linux/diskdump.h
+ *
+ * Copyright (c) 2004 FUJITSU LIMITED
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/list.h>
+#include <linux/blkdev.h>
+#include <linux/utsname.h>
+#include <linux/device.h>
+#include <linux/nmi.h>
+#include <linux/dump.h>
+
+/* The minimum dump I/O unit. Must be the same as PAGE_SIZE. */
+#define DUMP_BLOCK_SIZE PAGE_SIZE
+#define DUMP_BLOCK_SHIFT PAGE_SHIFT
+
+#define pr_err(fmt,arg...) \
+ printk(KERN_ERR fmt,##arg)
+
+#define pr_warn(fmt,arg...) \
+ printk(KERN_WARNING fmt,##arg)
+
+#define crashdump_mode() unlikely(dump_polling_oncpu)
+
+extern unsigned long dump_polling_oncpu;
+
+
+struct disk_dump_partition;
+struct disk_dump_device;
+
+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;
+};
+
+struct disk_dump_device_ops {
+ 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);
+};
+
+struct disk_dump_device {
+ struct disk_dump_device_ops ops;
+ struct disk_dump_type *dump_type;
+ void *device;
+ unsigned int max_blocks;
+};
+
+struct disk_dump_partition {
+ struct disk_dump_device *device;
+ struct block_device *bdev;
+ unsigned long start_sect;
+ unsigned long nr_sects;
+};
+
+int register_disk_dump_type(struct disk_dump_type *);
+int unregister_disk_dump_type(struct disk_dump_type *);
+
+void diskdump_update(void);
+
+#define diskdump_mdelay(n) \
+({ \
+ unsigned long __ms=(n); \
+ while (__ms--) { \
+ udelay(1000); \
+ touch_nmi_watchdog(); \
+ } \
+})
+
+extern enum disk_dump_states {
+ DISK_DUMP_INITIAL,
+ DISK_DUMP_RUNNING,
+ DISK_DUMP_SUCCESS,
+ DISK_DUMP_FAILURE,
+} disk_dump_state;
+
+#endif /* _LINUX_DISKDUMP_H */
Index: linux/include/asm-ppc/diskdump.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux/include/asm-ppc/diskdump.h 2005-03-07 13:47:56.671684867 -0800
@@ -0,0 +1,6 @@
+#ifndef _ASM_PPC_DISKDUMP_H_
+#define _ASM_PPC_DISKDUMP_H_
+
+#include <asm-generic/diskdump.h>
+
+#endif /* _ASM_PPC_DISKDUMP_H_ */
Index: linux/drivers/dump/dump_blockdev.c
===================================================================
--- linux.orig/drivers/dump/dump_blockdev.c 2005-03-07 13:43:37.438043042 -0800
+++ linux/drivers/dump/dump_blockdev.c 2005-03-07 16:05:08.624795800 -0800
@@ -1,7 +1,7 @@
/*
* Implements the dump driver interface for saving a dump to
- * a block device through the kernel's generic low level block i/o
- * routines.
+ * a block device through the kernel's generic low level block I/O
+ * routines, or through polling I/O.
*
* Started: June 2002 - Mohamed Abbas <[email protected]>
* Moved original lkcd kiobuf dump i/o code from dump_base.c
@@ -13,10 +13,15 @@
* Oct 2002 - Suparna Bhattacharya <[email protected]>
* Rework to new dumpdev.h structures, implement open/close/
* silence, misc fixes (blocknr removal, bio_add_page usage)
+ * Oct 2004 - Mar 2005 - Mohamed Abbas <[email protected]>
+ * Jason Uhlenkott <[email protected]>
+ * Implement polling I/O (adapted from lkdump, with thanks
+ * to Nobuhiro Tachino).
*
- * Copyright (C) 1999 - 2002 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 1999 - 2005 Silicon Graphics, Inc. All rights reserved.
* Copyright (C) 2001 - 2002 Matt D. Robinson. All rights reserved.
* Copyright (C) 2002 International Business Machines Corp.
+ * Copyright (C) 2004 FUJITSU LIMITED
*
* This code is released under version 2 of the GNU GPL.
*/
@@ -27,10 +32,17 @@
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/bio.h>
-#include <asm/hardirq.h>
+#include <linux/diskdump.h>
#include <linux/dump.h>
+#include <linux/delay.h>
+#include <asm/diskdump.h>
+#include <asm/hardirq.h>
#include "dump_methods.h"
+
+/* ----- Support functions for interrupt-driven dumps ----- */
+
+
extern void *dump_page_buf;
/* The end_io callback for dump i/o completion */
@@ -113,7 +125,7 @@
}
if ((unsigned long)buf & bsize) {
- printk("map: not aligned \n");
+ printk("map: not aligned\n");
return -EINVAL;
}
@@ -148,17 +160,166 @@
kfree(bio);
}
-/*
- * Prepares the dump device so we can take a dump later.
- * The caller is expected to have filled up the dev_id field in the
- * block dump dev structure.
- *
- * At dump time when dump_block_write() is invoked it will be too
- * late to recover, so as far as possible make sure obvious errors
- * get caught right here and reported back to the caller.
- */
+
+/* ----- Support functions for polling I/O based dumps ----- */
+
+static DECLARE_MUTEX(disk_dump_mutex);
+static LIST_HEAD(disk_dump_types);
+static struct disk_dump_device dump_device;
+static struct disk_dump_partition dump_part;
+static unsigned long long timestamp_base;
+static unsigned long timestamp_hz;
+static unsigned long flags_global;
+static int polling_mode;
+static void dump_blockdev_unconfigure(void);
+
+void diskdump_setup_timestamp(void)
+{
+ unsigned long long t=0;
+
+ platform_timestamp(timestamp_base);
+ udelay(1000000/HZ);
+ platform_timestamp(t);
+ timestamp_hz = (unsigned long)(t - timestamp_base);
+ diskdump_update();
+}
+
+void diskdump_update(void)
+{
+ unsigned long long t=0;
+
+ touch_nmi_watchdog();
+
+ /* update jiffies */
+ platform_timestamp(t);
+ while (t > timestamp_base + timestamp_hz) {
+ timestamp_base += timestamp_hz;
+ jiffies++;
+ platform_timestamp(t);
+ }
+
+ dump_run_timers();
+ dump_run_tasklet();
+ dump_run_workqueue();
+}
+EXPORT_SYMBOL_GPL(diskdump_update);
+
+static void *find_real_device(struct device *dev,
+ struct disk_dump_type **_dump_type)
+{
+ void *real_device;
+ struct disk_dump_type *dump_type;
+
+ list_for_each_entry(dump_type, &disk_dump_types, list) {
+ real_device = dump_type->probe(dev);
+ if (real_device) {
+ *_dump_type = dump_type;
+ return real_device;
+ }
+ }
+ return NULL;
+}
+
+static int register_disk_dump_device(struct device *dev, struct block_device *bdev)
+{
+ struct disk_dump_type *dump_type = NULL;
+ void *real_device;
+ int ret = 0;
+
+ if (!bdev->bd_part)
+ return -EINVAL;
+
+ down(&disk_dump_mutex);
+
+ real_device = find_real_device(dev, &dump_type);
+ if (!real_device) {
+ ret = -ENXIO;
+ goto err;
+ }
+
+ if (dump_device.device == real_device) {
+ ret = -EEXIST;
+ goto err;
+ } else if (dump_device.device) {
+ BUG();
+ }
+
+ dump_device.device = real_device;
+
+ ret = dump_type->add_device(&dump_device);
+ if (ret < 0) {
+ dump_device.device = NULL;
+ goto err;
+ }
+
+ dump_device.dump_type = dump_type;
+ dump_part.device = &dump_device;
+ dump_part.bdev = bdev;
+ dump_part.nr_sects = bdev->bd_part->nr_sects;
+ dump_part.start_sect = bdev->bd_part->start_sect;
+
+err:
+ up(&disk_dump_mutex);
+ return ret;
+}
+
+static void unregister_disk_dump_device(struct block_device *bdev)
+{
+ struct disk_dump_type *dump_type;
+
+ down(&disk_dump_mutex);
+
+ if(!dump_part.device) {
+ up(&disk_dump_mutex);
+ return;
+ }
+
+ BUG_ON(dump_part.device != &dump_device);
+ BUG_ON(dump_part.bdev != bdev);
+
+ dump_part.device = NULL;
+ dump_part.bdev = NULL;
+
+ dump_type = dump_device.dump_type;
+ dump_type->remove_device(&dump_device);
+ dump_device.device = NULL;
+ dump_device.dump_type = NULL;
+
+ up(&disk_dump_mutex);
+}
+
+int register_disk_dump_type(struct disk_dump_type *dump_type)
+{
+ down(&disk_dump_mutex);
+ list_add(&dump_type->list, &disk_dump_types);
+ up(&disk_dump_mutex);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(register_disk_dump_type);
+
+int unregister_disk_dump_type(struct disk_dump_type *dump_type)
+{
+ lock_kernel(); /* guard against the dump ioctl */
+
+ if (dump_device.dump_type == dump_type)
+ dump_blockdev_unconfigure();
+
+ down(&disk_dump_mutex);
+ list_del(&dump_type->list);
+ up(&disk_dump_mutex);
+
+ unlock_kernel();
+ return 0;
+}
+EXPORT_SYMBOL_GPL(unregister_disk_dump_type);
+
+
+/* --------------------------------------------------- */
+
+
static int
-dump_block_open(struct dump_dev *dev, unsigned long arg)
+dump_block_intr_open(struct dump_dev *dev, unsigned long arg)
{
struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
struct block_device *bdev;
@@ -237,8 +398,96 @@
err: return retval;
}
+static int
+dump_block_poll_open(struct dump_dev *dev, unsigned long arg)
+{
+ struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+ struct block_device *bdev;
+ int retval = 0;
+ struct device *target = NULL;
+
+ /* make sure this is a valid block device */
+ if (!arg) {
+ retval = -EINVAL;
+ goto err;
+ }
+
+ /* Convert it to the new dev_t format */
+ arg = MKDEV((arg >> OLDMINORBITS), (arg & OLDMINORMASK));
+
+ /* get a corresponding block_dev struct for this */
+ bdev = bdget((dev_t)arg);
+ if (!bdev) {
+ retval = -ENODEV;
+ goto err;
+ }
+
+ /* get the block device opened */
+ if ((retval = blkdev_get(bdev, O_RDWR | O_LARGEFILE, 0))) {
+ goto err1;
+ }
+
+ dump_bdev->bio = 0;
+ dump_bdev->dev_id = (dev_t)arg;
+ dump_bdev->bdev = bdev;
+
+ /* make a note of the limit */
+ dump_bdev->limit = bdev->bd_inode->i_size;
+
+ target = get_device(bdev->bd_disk->driverfs_dev);
+ if (!target) {
+ retval = -EINVAL;
+ goto err2;
+ }
+ retval = register_disk_dump_device(target,bdev);
+ if (retval == -EEXIST)
+ retval = 0;
+ else if (retval < 0)
+ goto err2;
+
+ printk("Block device (%d,%d) successfully configured for dumping using polling I/O\n",
+ MAJOR((dev_t)arg), MINOR((dev_t)arg));
+
+ /* after opening the block device, return */
+ return retval;
+
+err2: if (bdev) blkdev_put(bdev);
+ goto err;
+err1: if (bdev) bdput(bdev);
+err: return retval;
+}
+
/*
- * Close the dump device and release associated resources
+ * Prepares the dump device so we can take a dump later.
+ * The caller is expected to have filled up the dev_id field in the
+ * block dump dev structure.
+ *
+ * At dump time when dump_block_write() is invoked it will be too
+ * late to recover, so as far as possible make sure obvious errors
+ * get caught right here and reported back to the caller.
+ */
+static int
+dump_block_open(struct dump_dev *dev, unsigned long arg)
+{
+ if (dump_config.flags & DUMP_FLAGS_POLL) {
+ polling_mode = 1;
+ if (!dump_block_poll_open(dev, arg)) {
+ return 0;
+ } else {
+ /*
+ * If polling I/O isn't supported by this
+ * device, fall back to interrupt-driven mode.
+ */
+ dump_config.flags &= ~DUMP_FLAGS_POLL;
+ }
+ }
+
+ polling_mode = 0;
+ return dump_block_intr_open(dev, arg);
+}
+
+/*
+ * Close the dump device and release associated resources.
* Invoked when unconfiguring the dump device.
*/
static int
@@ -248,23 +497,21 @@
/* release earlier bdev if present */
if (dump_bdev->bdev) {
+ unregister_disk_dump_device(dump_bdev->bdev);
blkdev_put(dump_bdev->bdev);
dump_bdev->bdev = NULL;
}
- dump_free_bio(dump_bdev->bio);
- dump_bdev->bio = NULL;
+ if (dump_bdev->bio) {
+ dump_free_bio(dump_bdev->bio);
+ dump_bdev->bio = NULL;
+ }
return 0;
}
-
-/*
- * Prepare the dump device for use (silence any ongoing activity
- * and quiesce state) when the system crashes.
- */
static int
-dump_block_silence(struct dump_dev *dev)
+dump_block_intr_silence(struct dump_dev *dev)
{
struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
struct request_queue *q = bdev_get_queue(dump_bdev->bdev);
@@ -303,6 +550,93 @@
return 0;
}
+static int
+dump_block_poll_silence(struct dump_dev *dev)
+{
+ struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+ int ret;
+
+ local_irq_save(flags_global);
+ preempt_disable();
+
+ touch_nmi_watchdog();
+
+ if (down_trylock(&disk_dump_mutex))
+ return -EBUSY;
+
+ dump_polling_oncpu = smp_processor_id() + 1;
+
+ /*
+ * Setup timer/tasklet
+ */
+ dump_clear_timers();
+ dump_clear_tasklet();
+ dump_clear_workqueue();
+
+ diskdump_setup_timestamp();
+
+ BUG_ON(dump_part.bdev != dump_bdev->bdev);
+
+ /*
+ * Move to a softer level of silencing where no spin_lock_irqs
+ * are held on other cpus
+ */
+ dump_silence_level = DUMP_SOFT_SPIN_CPUS;
+
+ touch_nmi_watchdog();
+
+ if (dump_device.ops.quiesce)
+ if ((ret = dump_device.ops.quiesce(&dump_device)) < 0) {
+ printk("Quiesce failed. error %d\n", ret);
+ return ret;
+ }
+ touch_nmi_watchdog();
+ printk(KERN_CRIT "Dumping to block device (%d,%d) on CPU %d using polling I/O ...\n",
+ MAJOR(dump_bdev->dev_id), MINOR(dump_bdev->dev_id),
+ smp_processor_id());
+
+ return 0;
+}
+
+/*
+ * Prepare the dump device for use (silence any ongoing activity
+ * and quiesce state) when the system crashes.
+ */
+static int
+dump_block_silence(struct dump_dev *dev)
+{
+ if (polling_mode)
+ return dump_block_poll_silence(dev);
+ else
+ return dump_block_intr_silence(dev);
+}
+
+
+static int
+dump_block_intr_resume(struct dump_dev *dev)
+{
+ __dump_irq_restore();
+ return 0;
+}
+
+static int
+dump_block_poll_resume(struct dump_dev *dev)
+{
+ struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+
+ BUG_ON(dump_part.bdev != dump_bdev->bdev);
+
+ if (dump_device.device && dump_device.ops.shutdown)
+ if (dump_device.ops.shutdown(&dump_device))
+ printk("polling dev: adapter shutdown failed.\n");
+
+ dump_polling_oncpu = 0;
+ preempt_enable_no_resched();
+ local_irq_restore(flags_global);
+ up(&disk_dump_mutex);
+ return 0;
+}
+
/*
* Invoked when dumping is done. This is the time to put things back
* (i.e. undo the effects of dump_block_silence) so the device is
@@ -311,8 +645,10 @@
static int
dump_block_resume(struct dump_dev *dev)
{
- __dump_irq_restore();
- return 0;
+ if (polling_mode)
+ return dump_block_poll_resume(dev);
+ else
+ return dump_block_intr_resume(dev);
}
@@ -344,15 +680,9 @@
return 0;
}
-/*
- * Write out a buffer after checking the device limitations,
- * sector sizes, etc. Assumes the buffer is in directly mapped
- * kernel address space (not vmalloc'ed).
- *
- * Returns: number of bytes written or -ERRNO.
- */
+
static int
-dump_block_write(struct dump_dev *dev, void *buf,
+dump_block_intr_write(struct dump_dev *dev, void *buf,
unsigned long len)
{
struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
@@ -391,6 +721,61 @@
return retval;
}
+static int
+dump_block_poll_write(struct dump_dev *dev, void *buf,
+ unsigned long len)
+{
+ struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
+ loff_t offset = dev->curr_offset + dump_bdev->start_offset;
+ int retval = -ENOSPC;
+ int ret;
+
+ if (offset >= dump_bdev->limit) {
+ printk("write: not enough space left on device!\n");
+ goto out;
+ }
+
+ /* don't write more blocks than our max limit */
+ if (offset + len > dump_bdev->limit)
+ len = dump_bdev->limit - offset;
+
+ if (dump_part.bdev != dump_bdev->bdev) {
+ return -EBUSY;
+ goto out;
+ }
+
+ local_irq_disable();
+ touch_nmi_watchdog();
+ ret = dump_device.ops.rw_block(&dump_part, WRITE, offset >> DUMP_PAGE_SHIFT,
+ buf, len >> DUMP_PAGE_SHIFT);
+ if (ret < 0) {
+ printk("write error\n");
+ goto out;
+ }
+
+ retval = len;
+out:
+ return retval;
+}
+
+/*
+ * Write out a buffer after checking the device limitations,
+ * sector sizes, etc. Assumes the buffer is in directly mapped
+ * kernel address space (not vmalloc'ed).
+ *
+ * Returns: number of bytes written or -ERRNO.
+ */
+static int
+dump_block_write(struct dump_dev *dev, void *buf,
+ unsigned long len)
+{
+ if (polling_mode)
+ return dump_block_poll_write(dev, buf, len);
+ else
+ return dump_block_intr_write(dev, buf, len);
+}
+
+
/*
* Name: dump_block_ready()
* Func: check if the last dump i/o is over and ready for next request
@@ -398,8 +783,14 @@
static int
dump_block_ready(struct dump_dev *dev, void *buf)
{
- struct dump_blockdev *dump_bdev = DUMP_BDEV(dev);
- request_queue_t *q = bdev_get_queue(dump_bdev->bio->bi_bdev);
+ struct dump_blockdev *dump_bdev;
+ request_queue_t *q;
+
+ if (polling_mode)
+ return 0;
+
+ dump_bdev = DUMP_BDEV(dev);
+ q = bdev_get_queue(dump_bdev->bio->bi_bdev);
/* check for io completion */
if (dump_bdev->err == -EAGAIN) {
@@ -442,6 +833,18 @@
struct dump_blockdev *dump_blockdev = &default_dump_blockdev;
+/*
+ * Unregister and reregister ourselves. This has the side effect
+ * of unconfiguring the current dump device.
+ */
+static void
+dump_blockdev_unconfigure(void)
+{
+ dump_unregister_device(&dump_blockdev->ddev);
+ if (dump_register_device(&dump_blockdev->ddev) < 0)
+ printk("block device driver registration failed\n");
+}
+
static int __init
dump_blockdev_init(void)
{
Index: linux/kernel/sched.c
===================================================================
--- linux.orig/kernel/sched.c 2005-03-07 13:43:38.356019589 -0800
+++ linux/kernel/sched.c 2005-03-07 13:47:56.700981989 -0800
@@ -57,6 +57,8 @@
/* used to soft spin in sched while dump is in progress */
unsigned long dump_oncpu;
EXPORT_SYMBOL(dump_oncpu);
+unsigned long dump_polling_oncpu;
+EXPORT_SYMBOL(dump_polling_oncpu);
/*
* Convert user-nice values [ -20 ... 0 ... 19 ]
Index: linux/include/asm-i386/crashdump.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux/include/asm-i386/crashdump.h 2005-03-07 13:47:56.719536834 -0800
@@ -0,0 +1,35 @@
+#ifndef _ASM_I386_CRASHDUMP_H
+#define _ASM_I386_CRASHDUMP_H
+
+/*
+ * linux/include/asm-i386/crashdump.h
+ *
+ * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifdef __KERNEL__
+
+#include <asm/irq.h>
+
+#define platform_timestamp(x) rdtscll(x)
+
+
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_I386_CRASHDUMP_H */
Index: linux/include/asm-ppc64/crashdump.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux/include/asm-ppc64/crashdump.h 2005-03-07 13:47:56.732232254 -0800
@@ -0,0 +1,35 @@
+#ifndef _ASM_PPC64_CRASHDUMP_H
+#define _ASM_PPC64_CRASHDUMP_H
+
+/*
+ * linux/include/asm-ppc64/crashdump.h
+ *
+ * Copyright (c) 2003, 2004 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004 IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#ifdef __KERNEL__
+
+#include <asm/time.h>
+
+#define platform_timestamp(x) (x = get_tb())
+
+
+#endif /* __KERNEL__ */
+
+#endif /* _ASM_PPC64_CRASHDUMP_H */
Index: linux/include/asm-ia64/crashdump.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux/include/asm-ia64/crashdump.h 2005-03-07 13:47:56.750787098 -0800
@@ -0,0 +1,36 @@
+#ifndef _ASM_IA64_CRASHDUMP_H
+#define _ASM_IA64_CRASHDUMP_H
+
+/*
+ * linux/include/asm-ia64/crashdump.h
+ *
+ * Copyright (c) 2004 FUJITSU LIMITED
+ * Copyright (c) 2003 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)