Re: panic during fdisk'ing a md(4) device

2002-01-18 Thread Bruce Evans

On Thu, 17 Jan 2002, Michael Reifenberger wrote:

 On Thu, 17 Jan 2002, Bruce Evans wrote:
 ...
  Oops.  There should be no alias for md10c.  Try this version.  It fixes
  the may want an alias case in dkmodminor() and moves all the dk inlines
  to subr_diskslice.c.
 This patch works better.
 This brings us back to the original problem :-)
 Now it doesn't panic during fsck immediately, it panics after unconfiguring
 the md(4) device (which leaves the /dev/md11* devices in place instead removing
 them) reconfiguring and then doing a new `disklabel ...` which tries to do
 a (still existing) new 'make_dev(md11s1)'
 See the attached backroot.sh.

It somehow worked here, but after fixing the non-removal of the
/dev/md11*, I got back what is probably the original panic too.  At
least with my fixed changes, the panic is caused by not clearing
pointers in destroy_dev().  The pointers come back in make_dev() and
bite you a little later.  My orginal fixes helped by not doing all the
necessary calls to destroy_dev().

devfs still leaks 2 DEVFS allocations and 6 devbuf allocations for every
iteration of the script.

%%%
Index: kern/kern_conf.c
===
RCS file: /home/ncvs/src/sys/kern/kern_conf.c,v
retrieving revision 1.104
diff -u -2 -r1.104 kern_conf.c
--- kern/kern_conf.c9 Jan 2002 04:58:49 -   1.104
+++ kern/kern_conf.c18 Jan 2002 12:19:35 -
@@ -384,4 +384,5 @@
dev-si_drv2 = 0;
dev-si_devsw = 0;
+   bzero(dev-__si_u, sizeof(dev-__si_u));   /* XXX */
dev-si_flags = ~SI_NAMED;
dev-si_flags = ~SI_ALIAS;
Index: kern/subr_disk.c
===
RCS file: /home/ncvs/src/sys/kern/subr_disk.c,v
retrieving revision 1.50
diff -u -2 -r1.50 subr_disk.c
--- kern/subr_disk.c4 Nov 2001 11:56:22 -   1.50
+++ kern/subr_disk.c14 Jan 2002 11:42:38 -
@@ -301,5 +301,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);

dp = pdev-si_disk;
@@ -349,5 +349,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -365,5 +365,5 @@
struct disk *dp;

-   pdev = dkmodpart(dkmodslice(bp-bio_dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(bp-bio_dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
bp-bio_resid = bp-bio_bcount;
@@ -400,5 +400,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -416,5 +416,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
Index: kern/subr_diskmbr.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskmbr.c,v
retrieving revision 1.54
diff -u -2 -r1.54 subr_diskmbr.c
--- kern/subr_diskmbr.c 11 Dec 2001 05:35:43 -  1.54
+++ kern/subr_diskmbr.c 9 Jan 2002 10:34:30 -
@@ -209,5 +209,5 @@
/* Read master boot record. */
bp = geteblk((int)lp-d_secsize);
-   bp-b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   bp-b_dev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
bp-b_blkno = mbr_offset;
bp-b_bcount = lp-d_secsize;
Index: kern/subr_diskslice.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskslice.c,v
retrieving revision 1.97
diff -u -2 -r1.97 subr_diskslice.c
--- kern/subr_diskslice.c   17 Jan 2002 18:33:18 -  1.97
+++ kern/subr_diskslice.c   18 Jan 2002 10:02:09 -
@@ -68,4 +68,5 @@

 static struct disklabel *clone_label __P((struct disklabel *lp));
+static dev_t dkmodminor __P((dev_t dev, int mynor, int slicehint));
 static void dsiodone __P((struct bio *bp));
 static char *fixlabel __P((char *sname, struct diskslice *sp,
@@ -77,4 +78,5 @@
  struct disklabel *lp));
 static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp));
+static void set_ds_labeldevs_unaliased __P((dev_t dev, struct diskslices *ssp));
 static void set_ds_wlabel __P((struct diskslices *ssp, int slice,
   int wlabel));
@@ -122,8 +124,89 @@
 }

+/*
+ * XXX should be able to share more code between disk_dev_synth(),
+ * disk_clone() and here.
+ * XXX using dsname() only slightly insulates us from complications.
+ */
+static dev_t
+dkmodminor(dev_t dev, int mynor, int slicehint)
+{
+   dev_t newdev, newdev_alias;
+   

Re: panic during fdisk'ing a md(4) device

2002-01-18 Thread Michael Reifenberger

On Fri, 18 Jan 2002, Bruce Evans wrote:
...
 It somehow worked here, but after fixing the non-removal of the
 /dev/md11*, I got back what is probably the original panic too.  At
 least with my fixed changes, the panic is caused by not clearing
 pointers in destroy_dev().  The pointers come back in make_dev() and
 bite you a little later.  My orginal fixes helped by not doing all the
 necessary calls to destroy_dev().

 devfs still leaks 2 DEVFS allocations and 6 devbuf allocations for every
 iteration of the script.
...
Does this mean that your latest patch removes the panic but leaks some
resources.

Bye!

Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-18 Thread Bruce Evans

On Fri, 18 Jan 2002, Michael Reifenberger wrote:

 On Fri, 18 Jan 2002, Bruce Evans wrote:
 ...
  devfs still leaks 2 DEVFS allocations and 6 devbuf allocations for every
  iteration of the script.
 ...
 Does this mean that your latest patch removes the panic but leaks some
 resources.

No :).  It means that I think it is an old leak in devfs.  The leak was
hard to see before because the system paniced.

Bruce


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-17 Thread Michael Reifenberger

On Thu, 17 Jan 2002, Bruce Evans wrote:
...
 Oops.  There should be no alias for md10c.  Try this version.  It fixes
 the may want an alias case in dkmodminor() and moves all the dk inlines
 to subr_diskslice.c.
This patch works better.
This brings us back to the original problem :-)
Now it doesn't panic during fsck immediately, it panics after unconfiguring
the md(4) device (which leaves the /dev/md11* devices in place instead removing
them) reconfiguring and then doing a new `disklabel ...` which tries to do
a (still existing) new 'make_dev(md11s1)'
See the attached backroot.sh.

Bye!

Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS



backroot.sh
Description: Bourne shell script


Re: panic during fdisk'ing a md(4) device

2002-01-16 Thread Bruce Evans

On Mon, 14 Jan 2002, Michael Reifenberger wrote:

 On Tue, 15 Jan 2002, Bruce Evans wrote:
 ...
  Try this version.  Only disklabel.h has many changes.  The code for
  avoiding creation of bogus 'c' partitions didn't work at all.

 This works during startup but the following commands cases a panic
 while executing newfs (BT is attached):

 mdconfig -a -t swap -s 128M -o reserve -u 10
 disklabel -r -w md10 auto
   (When looking into /dev now I see two! md10c devices!)
 newfs -f 4096 /dev/md10c
 tunefs -n enable /dev/md10c
 mount /dev/md10c /tmp

Oops.  There should be no alias for md10c.  Try this version.  It fixes
the may want an alias case in dkmodminor() and moves all the dk inlines
to subr_diskslice.c.

%%%
Index: kern/subr_disk.c
===
RCS file: /home/ncvs/src/sys/kern/subr_disk.c,v
retrieving revision 1.50
diff -u -2 -r1.50 subr_disk.c
--- kern/subr_disk.c4 Nov 2001 11:56:22 -   1.50
+++ kern/subr_disk.c14 Jan 2002 11:42:38 -
@@ -301,5 +301,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);

dp = pdev-si_disk;
@@ -349,5 +349,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -365,5 +365,5 @@
struct disk *dp;

-   pdev = dkmodpart(dkmodslice(bp-bio_dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(bp-bio_dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
bp-bio_resid = bp-bio_bcount;
@@ -400,5 +400,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -416,5 +416,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
Index: kern/subr_diskmbr.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskmbr.c,v
retrieving revision 1.54
diff -u -2 -r1.54 subr_diskmbr.c
--- kern/subr_diskmbr.c 11 Dec 2001 05:35:43 -  1.54
+++ kern/subr_diskmbr.c 9 Jan 2002 10:34:30 -
@@ -209,5 +209,5 @@
/* Read master boot record. */
bp = geteblk((int)lp-d_secsize);
-   bp-b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   bp-b_dev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
bp-b_blkno = mbr_offset;
bp-b_bcount = lp-d_secsize;
Index: kern/subr_diskslice.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskslice.c,v
retrieving revision 1.96
diff -u -2 -r1.96 subr_diskslice.c
--- kern/subr_diskslice.c   12 Sep 2001 08:37:45 -  1.96
+++ kern/subr_diskslice.c   17 Jan 2002 04:19:10 -
@@ -68,4 +68,5 @@

 static struct disklabel *clone_label __P((struct disklabel *lp));
+static dev_t dkmodminor __P((dev_t dev, int mynor, int slicehint));
 static void dsiodone __P((struct bio *bp));
 static char *fixlabel __P((char *sname, struct diskslice *sp,
@@ -77,4 +78,5 @@
  struct disklabel *lp));
 static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp));
+static void set_ds_labeldevs_unaliased __P((dev_t dev, struct diskslices *ssp));
 static void set_ds_wlabel __P((struct diskslices *ssp, int slice,
   int wlabel));
@@ -123,4 +125,106 @@

 /*
+ * XXX should be able to share more code between disk_dev_synth(),
+ * disk_clone() and here.
+ * XXX using dsname() only slightly insulates us from complications.
+ */
+static dev_t
+dkmodminor(dev_t dev, int mynor, int slicehint)
+{
+   dev_t newdev, newdev_alias;
+   const char *sname;
+   char partname[2];
+
+   newdev = makedev(major(dev), mynor);
+   if ((dev-si_flags  SI_NAMED) == 0)
+   return (newdev);/* XXX should panic. */
+   if (newdev-si_flags  SI_NAMED) {
+   /* We have found a device, but may want an alias. */
+   if (dkslice(newdev) == WHOLE_DISK_SLICE ||
+   dkslice(newdev) == COMPATIBILITY_SLICE ||
+   dkpart(newdev) != RAW_PART || slicehint)
+   return (newdev);
+
+   /* We do want an alias.  There can be only one.  XXX. */
+   newdev_alias = LIST_FIRST(newdev-si_children);
+   if (newdev_alias != NULL)
+   return (newdev_alias);
+   sname = dsname(dev, dkunit(newdev), dkslice(newdev),
+   dkpart(newdev), partname);
+   return (make_dev_alias(newdev, 

Re: panic during fdisk'ing a md(4) device

2002-01-14 Thread Michael Reifenberger

Hi,
more food:
The kernel startup is:
...
vga: ...
makedev(116,65538)
make_dev(maj=116,min=65538,name=ad0)
ad0: ...
makedev(116,65546)
make_dev(maj=116,min=65546,name=ad1)
ad1: ...
acd0: ...
Mounting root from ufs:/dev/ad0s3a
makedev(116,65538) (?!?!? Why, where)
makedev(116,262144)
make_dev(maj=116,min=262144,name=ad0s3a)
makedev(116,262146)
dkmodminor()
dsname()
makedev(116,262146)
make_dev(maj=116,min=262146,name=ad0s3
dkmodminor()
dsname()
  PENG

What else to debug?

BTW: sys/types.h defines another makedev() as kern_conf.c

Bye!

Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-14 Thread Bruce Evans

On Mon, 14 Jan 2002, Michael Reifenberger wrote:

 Hi,
 more food:
 The kernel startup is:
 ...
 vga: ...
 makedev(116,65538)
 make_dev(maj=116,min=65538,name=ad0)
 ad0: ...
 makedev(116,65546)
 make_dev(maj=116,min=65546,name=ad1)
 ad1: ...
 acd0: ...
 Mounting root from ufs:/dev/ad0s3a
 makedev(116,65538) (?!?!? Why, where)

This just looks up ad0.  A previous make_dev() created the complete
device struct for ad0.

 makedev(116,262144)
 make_dev(maj=116,min=262144,name=ad0s3a)
 makedev(116,262146)
 dkmodminor()
 dsname()
 makedev(116,262146)
 make_dev(maj=116,min=262146,name=ad0s3

I think it actually wants ad0s3c here.  I was wrong about ad0s3 getting
created before ad0s3[a-h].  The order is actually ad0s3a..ad0s3h, but
bugs prevented proper creation of ad0s3c.

 dkmodminor()
 dsname()
   PENG

 What else to debug?

I think I found the bug.  It manifests as a panic for accessing the
'c' partition which doesn't get created properly.  There was only a
problem for partitions on slices (s1-s30), but I use ad0[a-h] for
filesystems and ad0s4 for swap so I didn't see it.

 BTW: sys/types.h defines another makedev() as kern_conf.c

Yes, it is a bit confusing.  sys/types.h gives the userland version.

Try this version.  Only disklabel.h has many changes.  The code for
avoiding creation of bogus 'c' partitions didn't work at all.

Index: kern/subr_disk.c
===
RCS file: /home/ncvs/src/sys/kern/subr_disk.c,v
retrieving revision 1.50
diff -u -2 -r1.50 subr_disk.c
--- kern/subr_disk.c4 Nov 2001 11:56:22 -   1.50
+++ kern/subr_disk.c14 Jan 2002 11:42:38 -
@@ -301,5 +301,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);

dp = pdev-si_disk;
@@ -349,5 +349,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -365,5 +365,5 @@
struct disk *dp;

-   pdev = dkmodpart(dkmodslice(bp-bio_dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(bp-bio_dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
bp-bio_resid = bp-bio_bcount;
@@ -400,5 +400,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -416,5 +416,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
Index: kern/subr_diskmbr.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskmbr.c,v
retrieving revision 1.54
diff -u -2 -r1.54 subr_diskmbr.c
--- kern/subr_diskmbr.c 11 Dec 2001 05:35:43 -  1.54
+++ kern/subr_diskmbr.c 9 Jan 2002 10:34:30 -
@@ -209,5 +209,5 @@
/* Read master boot record. */
bp = geteblk((int)lp-d_secsize);
-   bp-b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   bp-b_dev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
bp-b_blkno = mbr_offset;
bp-b_bcount = lp-d_secsize;
Index: kern/subr_diskslice.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskslice.c,v
retrieving revision 1.96
diff -u -2 -r1.96 subr_diskslice.c
--- kern/subr_diskslice.c   12 Sep 2001 08:37:45 -  1.96
+++ kern/subr_diskslice.c   14 Jan 2002 12:49:02 -
@@ -77,4 +77,5 @@
  struct disklabel *lp));
 static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp));
+static void set_ds_labeldevs_unaliased __P((dev_t dev, struct diskslices *ssp));
 static void set_ds_wlabel __P((struct diskslices *ssp, int slice,
   int wlabel));
@@ -649,4 +650,5 @@
char*msg;
u_char  mask;
+   char*oldsname;
int part;
charpartname[2];
@@ -728,11 +730,29 @@
)
continue;
-   dev1 = dkmodslice(dkmodpart(dev, RAW_PART), slice);
-#if 0
-   sname = dsname(dev, unit, slice, RAW_PART, partname);
-#else
-   *partname='\0';
-   sname = dev1-si_name;
-#endif
+   dev1 = dkmodslice(dkmodpart(dev, -RAW_PART), slice);
+   if (dev1-si_devsw == NULL) {
+   Debugger(dsopen: no devsw (can't happen));
+   dev1-si_devsw = dev-si_devsw;
+   }
+   /*
+* XXX we want a device name without any partition letter
+* in it for use in error messages.  

Re: panic during fdisk'ing a md(4) device

2002-01-14 Thread Michael Reifenberger

On Tue, 15 Jan 2002, Bruce Evans wrote:
...
 Yes, it is a bit confusing.  sys/types.h gives the userland version.

Only as confusing as the rest of the dk* code :-)


 Try this version.  Only disklabel.h has many changes.  The code for
 avoiding creation of bogus 'c' partitions didn't work at all.

This works during startup but the following commands cases a panic
while executing newfs (BT is attached):

mdconfig -a -t swap -s 128M -o reserve -u 10
disklabel -r -w md10 auto
  (When looking into /dev now I see two! md10c devices!)
newfs -f 4096 /dev/md10c
tunefs -n enable /dev/md10c
mount /dev/md10c /tmp



Bye!

Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS


GNU gdb 4.18
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type show copying to see the conditions.
There is absolutely no warranty for GDB.  Type show warranty for details.
This GDB was configured as i386-unknown-freebsd...
IdlePTD at phsyical address 0x00412000
initial pcb at physical address 0x00284ca0
panicstr: bdwrite: buffer is not busy
panic messages:
---
Fatal trap 12: page fault while in kernel mode
fault virtual address   = 0x1c
fault code  = supervisor read, page not present
instruction pointer = 0x8:0xc0178647
stack pointer   = 0x10:0xca3d0ab0
frame pointer   = 0x10:0xca3d0acc
code segment= base 0x0, limit 0xf, type 0x1b
= DPL 0, pres 1, def32 1, gran 1
processor eflags= interrupt enabled, resume, IOPL = 0
current process = 364 (newfs)
trap number = 12
panic: page fault

syncing disks... panic: bdwrite: buffer is not busy
Uptime: 9s
pfs_vncache_unload(): 1 entries remaining

dumping to dev ad0s3b, offset 3933440
dump ata0: resetting devices .. done
127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 
106 105 104 103 102 101 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 
80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 
51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 
22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 
---
#0  dumpsys () at ../../../kern/kern_shutdown.c:492
492 if (!dodump)
Cannot access memory at address 0x18.
(kgdb) #0  dumpsys () at ../../../kern/kern_shutdown.c:492
#1  0xc01664c8 in boot (howto=0x104) at ../../../kern/kern_shutdown.c:335
#2  0xc0166917 in panic (fmt=0xc023b201 bdwrite: buffer is not busy) at 
../../../kern/kern_shutdown.c:634
#3  0xc019932b in bdwrite (bp=0xc4b286c8) at ../../../kern/vfs_bio.c:856
#4  0xc01d2c5e in ffs_update (vp=0xc9e7dde0, waitfor=0x0) at 
../../../ufs/ffs/ffs_inode.c:120
#5  0xc01e00d6 in ffs_fsync (ap=0xca3d096c) at ../../../ufs/ffs/ffs_vnops.c:292
#6  0xc01de656 in ffs_sync (mp=0xc139c000, waitfor=0x2, cred=0xc0b44f00, 
td=0xc0259f24) at vnode_if.h:441
#7  0xc01a62d6 in sync (td=0xc0259f24, uap=0x0) at ../../../kern/vfs_syscalls.c:669
#8  0xc0166129 in boot (howto=0x100) at ../../../kern/kern_shutdown.c:244
#9  0xc0166917 in panic (fmt=0xc024dffe %s) at ../../../kern/kern_shutdown.c:634
#10 0xc021a070 in trap_fatal (frame=0xca3d0a70, eva=0x1c) at 
../../../i386/i386/trap.c:842
#11 0xc0219d99 in trap_pfault (frame=0xca3d0a70, usermode=0x0, eva=0x1c) at 
../../../i386/i386/trap.c:756
#12 0xc02197a3 in trap (frame={tf_fs = 0x18, tf_es = 0x10, tf_ds = 0xca3d0010, tf_edi 
= 0x2, tf_esi = 0xc151dc00, 
  tf_ebp = 0xca3d0acc, tf_isp = 0xca3d0a9c, tf_ebx = 0xc4b454e4, tf_edx = 0x0, 
tf_ecx = 0xc0b43560, tf_eax = 0x0, 
  tf_trapno = 0xc, tf_err = 0x0, tf_eip = 0xc0178647, tf_cs = 0x8, tf_eflags = 
0x10246, tf_esp = 0xc4b454e4, 
  tf_ss = 0xc151db00}) at ../../../i386/i386/trap.c:426
#13 0xc0178647 in writedisklabel (dev=0xc151dc00, lp=0xc1351400) at 
../../../kern/subr_disklabel.c:323
#14 0xc0179703 in dsioctl (dev=0xc151dc00, cmd=0x81146467, data=0xc1351600 WEV\202, 
flags=0x2, sspp=0xc15190d4)
at ../../../kern/subr_diskslice.c:520
#15 0xc0177a61 in diskioctl (dev=0xc151dc00, cmd=0x81146467, data=0xc1351600 
WEV\202, fflag=0x2, td=0xc98ad404)
at ../../../kern/subr_disk.c:406
#16 0xc014244c in spec_ioctl (ap=0xca3d0ba4) at ../../../fs/specfs/spec_vnops.c:320
#17 0xc01420cd in spec_vnoperate (ap=0xca3d0ba4) at 
../../../fs/specfs/spec_vnops.c:119
#18 0xc01aceb7 in vn_ioctl (fp=0xc1518100, com=0x81146467, data=0xc1351600 WEV\202, 
td=0xc98ad404) at vnode_if.h:357
#19 0xc0183b03 in ioctl (td=0xc98ad404, uap=0xca3d0d20) at ../../../sys/file.h:200
#20 0xc021a500 in syscall (frame={tf_fs = 0x2f, tf_es = 0x2f, tf_ds = 0x2f, tf_edi = 
0xbfbffe67, tf_esi = 0x806dae0, 
  tf_ebp = 0xbfbff6f8, tf_isp = 0xca3d0d74, tf_ebx = 0xc02, tf_edx = 0x806dbf4, 
tf_ecx = 0x806dae0, tf_eax = 0x36, 
  tf_trapno = 0xc, 

Re: panic during fdisk'ing a md(4) device

2002-01-13 Thread Bruce Evans

On Sat, 12 Jan 2002, Michael Reifenberger wrote:

 Hi,
 more input:
 The panic occurs in dsname() while dereferencing devsw(dev)-d_name.
 devsw(dev) gives NULL.

This was fairly clear from the panic message (the low fault address
is almost certainly for a null pointer + offset, and it's fairly clear
how dsname() gets a null pointer).  Sorry I didn't reply earlier and
save you the work debugging this.

 The call to dsname() occurs from dkmodminor() defined in disklabel.h
 I've seen two calls to dsname, only the second one panics.
 Any thoughts?

dkmodminor() is supposed to modify a minor device that already has a
devswitch.  Since dsname() in it panics, the problem is earlier when
the minor device is created without giving it a devswitch.  Minor
devices are supposed to be created in a hierarchial order so that
this doesn't happen.  E.g.,

ad0  in disk_create() (only ?)
ad0s1now in dsopen()
ad0s2
ad0s2a   now in dsopen()
...

I suggest adding printfs to make_dev() and makedev() to track the order.
The problem occurs when makedev() is called without a corresponding
make_dev().

Bruce


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-12 Thread Michael Reifenberger

Hi,
more input:
The panic occurs in dsname() while dereferencing devsw(dev)-d_name.
devsw(dev) gives NULL.
The call to dsname() occurs from dkmodminor() defined in disklabel.h
I've seen two calls to dsname, only the second one panics.
Any thoughts?

Bye!

Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-10 Thread Michael Reifenberger

Hi,
 Hmm.  I used an old set of patches to avoid filtering out local changes
 again.  Try the enclosed up to date patches.
Hmmm.
Fresh -current, fresh patch.
 (Hunk 2 still doesnt apply cleanly, but this seems to be irrelevant
 for the problem)
Old symptom:
...
mounting root from ufs:/dev/ad0s3a

Fatal Trap 12: page fault while in kernel mode
fault virt. addr. = 0x20
fault code = superv. read, page not present
IP = 0x8:0xc0176b61
SP = 0x10:0xc03d6b7c
FP = 0x10:0xc03d6b8c
CS = base 0x0, limit 0x, type 0x1b
 DPL 0, pres 1, def32 1, gran 1
processor eflags = interrupt enabled, resume, IOPL = 0
curproc = 0 (swapper)


Can I get from kernel.debug and the IP-address the faulting code
postmortem for shure?
`nm /boot/kernel~/kernel | grep c0176b` gives:
c0176b4c T dsname
c0176bf8 T dsopen


Bye!

Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-09 Thread Bruce Evans

On Tue, 8 Jan 2002, Michael Reifenberger wrote:

 Hi,
 the following script panics my system when executed twice:
 (uncomment the dd lines for the first time or do it manually)


 ##

 #!bin/sh

 block_size=512
 blocks=$((120 * 1024 * 1024 / $block_size))
 heads=16
 sectors=63
 cyl_size=$(($heads * $sectors));
 cylinders=$(($blocks / $cyl_size + 2))

 #dd if=/dev/zero of=root.image \
 # bs=$block_size count=$(($cyl_size * $cylinders))

 mdconfig -d -u 11
 mdconfig -a -t vnode -f root.image -u 11

 fdisk -f - -iv /dev/md11 EOF1
 g c$cylinders h$heads s$sectors
 p 1 165 $sectors $(($cyl_size * $cylinders))
 a 1
 EOF1

 echo $cyl_size $blocks $cylinders
 

This seems to be just another null pointer panic caused by the dk macros
creating half-baked devices with null devswitches.  I sent the following
quick fixes for this to the devfs maintainer a couple of weeks ago.  They
also fix the non-creation of all minor devices on the disk when the first
one is opened.

%%%
Index: kern/subr_disk.c
===
RCS file: /home/ncvs/src/sys/kern/subr_disk.c,v
retrieving revision 1.50
diff -u -2 -r1.50 subr_disk.c
--- kern/subr_disk.c4 Nov 2001 11:56:22 -   1.50
+++ kern/subr_disk.c26 Dec 2001 13:23:42 -
@@ -79,6 +79,8 @@
UID_ROOT, GID_OPERATOR, 0640, %s%ds%d,
dp-d_devsw-d_name, u, s - BASE_SLICE + 1);
+#if 0
make_dev_alias(dev, %s%ds%dc,
dp-d_devsw-d_name, u, s - BASE_SLICE + 1);
+#endif
}
dev_depends(pdev, dev);
@@ -150,6 +152,8 @@
UID_ROOT, GID_OPERATOR, 0640, %s%ds%d,
pdev-si_devsw-d_name, u, s - BASE_SLICE + 1);
+#if 0
make_dev_alias(*dev, %s%ds%dc,
pdev-si_devsw-d_name, u, s - BASE_SLICE + 1);
+#endif
} else {
*dev = make_dev(pdev-si_devsw, dkmakeminor(u, s, p),
@@ -301,5 +305,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);

dp = pdev-si_disk;
@@ -349,5 +353,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -365,5 +369,5 @@
struct disk *dp;

-   pdev = dkmodpart(dkmodslice(bp-bio_dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(bp-bio_dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
bp-bio_resid = bp-bio_bcount;
@@ -400,5 +404,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -416,5 +420,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
Index: kern/subr_diskmbr.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskmbr.c,v
retrieving revision 1.54
diff -u -2 -r1.54 subr_diskmbr.c
--- kern/subr_diskmbr.c 11 Dec 2001 05:35:43 -  1.54
+++ kern/subr_diskmbr.c 26 Dec 2001 08:43:14 -
@@ -209,5 +209,5 @@
/* Read master boot record. */
bp = geteblk((int)lp-d_secsize);
-   bp-b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   bp-b_dev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
bp-b_blkno = mbr_offset;
bp-b_bcount = lp-d_secsize;
Index: kern/subr_diskslice.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskslice.c,v
retrieving revision 1.96
diff -u -2 -r1.96 subr_diskslice.c
--- kern/subr_diskslice.c   12 Sep 2001 08:37:45 -  1.96
+++ kern/subr_diskslice.c   26 Dec 2001 10:52:30 -
@@ -77,4 +77,5 @@
  struct disklabel *lp));
 static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp));
+static void set_ds_labeldevs_unaliased __P((dev_t dev, struct diskslices *ssp));
 static void set_ds_wlabel __P((struct diskslices *ssp, int slice,
   int wlabel));
@@ -649,4 +650,5 @@
char*msg;
u_char  mask;
+   char*oldsname;
int part;
charpartname[2];
@@ -728,11 +730,29 @@
)
continue;
-   dev1 = dkmodslice(dkmodpart(dev, RAW_PART), slice);
-#if 0
-   sname = dsname(dev, unit, slice, RAW_PART, partname);
-#else
-   *partname='\0';
-   sname = 

Re: panic during fdisk'ing a md(4) device

2002-01-09 Thread Poul-Henning Kamp

In message [EMAIL PROTECTED], Bruce Evans writes:

This seems to be just another null pointer panic caused by the dk macros
creating half-baked devices with null devswitches.  I sent the following
quick fixes for this to the devfs maintainer a couple of weeks ago.  They
also fix the non-creation of all minor devices on the disk when the first
one is opened.

Yeah, I admit I've been sitting on these patches for a bit too long,
I'll try to get through my pile and get to them.

-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
[EMAIL PROTECTED] | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-09 Thread Michael Reifenberger

On Wed, 9 Jan 2002, Bruce Evans wrote:
...
 This seems to be just another null pointer panic caused by the dk macros
 creating half-baked devices with null devswitches.  I sent the following
 quick fixes for this to the devfs maintainer a couple of weeks ago.  They
 also fix the non-creation of all minor devices on the disk when the first
 one is opened.
Applying your patch to a fresh -current tree leads to a page-fault in (swapper)
after mounting root from ...
(I had to apply the second Hunk of subr_disk by hand)
Do you know how to enable a dumpdev via the boot loader in order to
get a dump?

Bye!

Michael Reifenberger
^.*Plaut.*$, IT, R/3 Basis, GPS


To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-current in the body of the message



Re: panic during fdisk'ing a md(4) device

2002-01-09 Thread Bruce Evans

On Wed, 9 Jan 2002, Michael Reifenberger wrote:

 On Wed, 9 Jan 2002, Bruce Evans wrote:
 ...
  This seems to be just another null pointer panic caused by the dk macros
  creating half-baked devices with null devswitches.  I sent the following
  quick fixes for this to the devfs maintainer a couple of weeks ago.  They
  also fix the non-creation of all minor devices on the disk when the first
  one is opened.
 Applying your patch to a fresh -current tree leads to a page-fault in (swapper)
 after mounting root from ...
 (I had to apply the second Hunk of subr_disk by hand)

Hmm.  I used an old set of patches to avoid filtering out local changes
again.  Try the enclosed up to date patches.

 Do you know how to enable a dumpdev via the boot loader in order to
 get a dump?

Not really.  I wouldn't trust dumpdev early here since the bugs are in the
disk layer.

%%%
Index: kern/subr_disk.c
===
RCS file: /home/ncvs/src/sys/kern/subr_disk.c,v
retrieving revision 1.50
diff -u -2 -r1.50 subr_disk.c
--- kern/subr_disk.c4 Nov 2001 11:56:22 -   1.50
+++ kern/subr_disk.c9 Jan 2002 10:34:30 -
@@ -79,6 +79,8 @@
UID_ROOT, GID_OPERATOR, 0640, %s%ds%d,
dp-d_devsw-d_name, u, s - BASE_SLICE + 1);
+#if 0
make_dev_alias(dev, %s%ds%dc,
dp-d_devsw-d_name, u, s - BASE_SLICE + 1);
+#endif
}
dev_depends(pdev, dev);
@@ -150,6 +152,8 @@
UID_ROOT, GID_OPERATOR, 0640, %s%ds%d,
pdev-si_devsw-d_name, u, s - BASE_SLICE + 1);
+#if 0
make_dev_alias(*dev, %s%ds%dc,
pdev-si_devsw-d_name, u, s - BASE_SLICE + 1);
+#endif
} else {
*dev = make_dev(pdev-si_devsw, dkmakeminor(u, s, p),
@@ -301,5 +305,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);

dp = pdev-si_disk;
@@ -349,5 +353,5 @@

error = 0;
-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -365,5 +369,5 @@
struct disk *dp;

-   pdev = dkmodpart(dkmodslice(bp-bio_dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(bp-bio_dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
bp-bio_resid = bp-bio_bcount;
@@ -400,5 +404,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
@@ -416,5 +420,5 @@
dev_t pdev;

-   pdev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   pdev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
dp = pdev-si_disk;
if (!dp)
Index: kern/subr_diskmbr.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskmbr.c,v
retrieving revision 1.54
diff -u -2 -r1.54 subr_diskmbr.c
--- kern/subr_diskmbr.c 11 Dec 2001 05:35:43 -  1.54
+++ kern/subr_diskmbr.c 9 Jan 2002 10:34:30 -
@@ -209,5 +209,5 @@
/* Read master boot record. */
bp = geteblk((int)lp-d_secsize);
-   bp-b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
+   bp-b_dev = dkmodslice(dkmodpart(dev, -RAW_PART), WHOLE_DISK_SLICE);
bp-b_blkno = mbr_offset;
bp-b_bcount = lp-d_secsize;
Index: kern/subr_diskslice.c
===
RCS file: /home/ncvs/src/sys/kern/subr_diskslice.c,v
retrieving revision 1.96
diff -u -2 -r1.96 subr_diskslice.c
--- kern/subr_diskslice.c   12 Sep 2001 08:37:45 -  1.96
+++ kern/subr_diskslice.c   9 Jan 2002 10:34:30 -
@@ -77,4 +77,5 @@
  struct disklabel *lp));
 static void set_ds_labeldevs __P((dev_t dev, struct diskslices *ssp));
+static void set_ds_labeldevs_unaliased __P((dev_t dev, struct diskslices *ssp));
 static void set_ds_wlabel __P((struct diskslices *ssp, int slice,
   int wlabel));
@@ -649,4 +650,5 @@
char*msg;
u_char  mask;
+   char*oldsname;
int part;
charpartname[2];
@@ -728,11 +730,29 @@
)
continue;
-   dev1 = dkmodslice(dkmodpart(dev, RAW_PART), slice);
-#if 0
-   sname = dsname(dev, unit, slice, RAW_PART, partname);
-#else
-   *partname='\0';
-   sname = dev1-si_name;
-#endif
+   dev1 = dkmodslice(dkmodpart(dev, -RAW_PART), slice);
+   if (dev1-si_devsw == NULL) {
+