Re: Unclean sync in current
Thus spake Kevin Oberman <[EMAIL PROTECTED]>: > I've been seeing this for a couple of weeks since I updated my laptop to > CURRENT. I do a normal shutdown (-p or -r) and reboot. The shutdown > looked normal, with no problems reported with the sync, but, when the > system is rebooted, the partitions are all shown as possibly > unclean. From my dmesg: > Mounting root from ufs:/dev/ad0s3a > WARNING: / was not properly dismounted > WARNING: / was not properly dismounted > WARNING: /tmp was not properly dismounted > WARNING: /usr was not properly dismounted > WARNING: /var was not properly dismounted > > All disks are mounted with soft-updates enabled. > > I don't see any other reports of this. Is this unique to my system? Unlike the SCSI driver, the ATA driver does not send a flush cache command to your disks before powering off the system. The kernel waits for five seconds in either case, but for some disks that may not be sufficient. The following patch should fix that, although it may have rotted a bit in the last two months given Soeren's sweeping ATA changes. I also edited an unrelated change out of the diff, which might confuse patch(1). If you run into problems getting it to apply, let me know and I'll fix it when I'm back from vacation. Index: sys/dev/ata/ata-all.c === RCS file: /home/ncvs/src/sys/dev/ata/ata-all.c,v retrieving revision 1.163 diff -u -r1.163 ata-all.c --- sys/dev/ata/ata-all.c 2003/01/19 20:18:07 1.163 +++ sys/dev/ata/ata-all.c 2003/01/27 09:17:02 @@ -77,6 +77,7 @@ static void ata_intr(void *); static int ata_getparam(struct ata_device *, u_int8_t); static int ata_service(struct ata_channel *); +static void ata_shutdown(void *arg, int howto); static void bswap(int8_t *, int); static void btrim(int8_t *, int); static void bpack(int8_t *, int8_t *, int); @@ -1160,7 +1161,32 @@ return error; } +/* + * This procedure is called during shutdown, + * after all dirty buffers have been flushed. + */ static void +ata_shutdown(void *arg, int howto) +{ +struct ata_channel *ch; +int ctlr; + +#ifdef DEV_ATADISK +/* Flush the caches of each open ATA disk device. */ +for (ctlr = 0; ctlr < devclass_get_maxunit(ata_devclass); ctlr++) { + if (!(ch = devclass_get_softc(ata_devclass, ctlr))) + continue; + ch->lock_func(ch, ATA_LF_LOCK); + if (ch->devices & ATA_ATA_MASTER && ch->device[MASTER].driver) + ad_sync(&ch->device[MASTER]); + if (ch->devices & ATA_ATA_SLAVE && ch->device[SLAVE].driver) + ad_sync(&ch->device[SLAVE]); + ch->lock_func(ch, ATA_LF_UNLOCK); +} +#endif /* DEV_ATADISK */ +} + +static void ata_drawer_start(struct ata_device *atadev) { ATA_INB(atadev->channel->r_io, ATA_DRIVE); @@ -1516,5 +1542,10 @@ printf("ata: config_intrhook_establish failed\n"); free(ata_delayed_attach, M_TEMP); } + +/* Register a handler to flush write caches on shutdown */ +if ((EVENTHANDLER_REGISTER(shutdown_post_sync, ata_shutdown, + NULL, SHUTDOWN_PRI_DEFAULT)) == NULL) + printf("ata: shutdown event registration failed!\n"); } SYSINIT(atadev, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_init, NULL) Index: sys/dev/ata/ata-disk.c === RCS file: /home/ncvs/src/sys/dev/ata/ata-disk.c,v retrieving revision 1.139 diff -u -r1.139 ata-disk.c --- sys/dev/ata/ata-disk.c 2002/12/17 16:26:22 1.139 +++ sys/dev/ata/ata-disk.c 2003/01/27 09:17:04 @@ -255,10 +255,8 @@ disk_invalidate(&adp->disk); disk_destroy(adp->dev); devstat_remove_entry(&adp->stats); -if (flush) { - if (ata_command(atadev, ATA_C_FLUSHCACHE, 0, 0, 0, ATA_WAIT_READY)) - ata_prtdev(atadev, "flushing cache on detach failed\n"); -} +if (flush) + ad_sync(atadev); if (adp->flags & AD_F_RAID_SUBDISK) ata_raiddisk_detach(adp); ata_free_name(atadev); @@ -289,8 +287,7 @@ adp->device->channel->lock_func(adp->device->channel, ATA_LF_LOCK); ATA_SLEEPLOCK_CH(adp->device->channel, ATA_CONTROL); -if (ata_command(adp->device, ATA_C_FLUSHCACHE, 0, 0, 0, ATA_WAIT_READY)) - ata_prtdev(adp->device, "flushing cache on close failed\n"); +ad_sync(adp->device); ATA_UNLOCK_CH(adp->device->channel); adp->device->channel->lock_func(adp->device->channel, ATA_LF_UNLOCK); return 0; @@ -765,6 +762,20 @@ return ATA_OP_CONTINUES; } return ATA_OP_FINISHED; +} + +/* + * Flush the write cache of the given device. + */ +int +ad_sync(struct ata_device *atadev) +{ +int error; + +/* XXX The ATA standard says this command can take up to 30 seconds. */ +if ((error = ata_command(atadev,ATA_C_FLUSHCACHE,0,0,0,ATA_WAIT_READY))) + ata_prtdev(atadev, "flushing cache failed\n"); +return error; } static void Index: sys/dev/ata/ata-disk.h
Re: Unclean sync in current
> Date: Fri, 28 Mar 2003 16:18:59 -0800 > From: David Schultz <[EMAIL PROTECTED]> > > Thus spake Kevin Oberman <[EMAIL PROTECTED]>: > > I've been seeing this for a couple of weeks since I updated my laptop to > > CURRENT. I do a normal shutdown (-p or -r) and reboot. The shutdown > > looked normal, with no problems reported with the sync, but, when the > > system is rebooted, the partitions are all shown as possibly > > unclean. From my dmesg: > > Mounting root from ufs:/dev/ad0s3a > > WARNING: / was not properly dismounted > > WARNING: / was not properly dismounted > > WARNING: /tmp was not properly dismounted > > WARNING: /usr was not properly dismounted > > WARNING: /var was not properly dismounted > > > > All disks are mounted with soft-updates enabled. > > > > I don't see any other reports of this. Is this unique to my system? > > Unlike the SCSI driver, the ATA driver does not send a flush cache > command to your disks before powering off the system. The kernel > waits for five seconds in either case, but for some disks that may > not be sufficient. > > The following patch should fix that, although it may have rotted a > bit in the last two months given Soeren's sweeping ATA changes. I > also edited an unrelated change out of the diff, which might > confuse patch(1). If you run into problems getting it to apply, > let me know and I'll fix it when I'm back from vacation. Thanks, but the issue was not a write cache problem. It was the change in the UFS1 super-block in V5. After I performed an fsck_ffs on each partition, the errors vanished. All appears to be running fine. R. Kevin Oberman, Network Engineer Energy Sciences Network (ESnet) Ernest O. Lawrence Berkeley National Laboratory (Berkeley Lab) E-mail: [EMAIL PROTECTED] Phone: +1 510 486-8634 ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Unclean sync in current
>Date: Tue, 25 Mar 2003 13:47:18 -0800 >From: "Kevin Oberman" <[EMAIL PROTECTED]> >> On Tue, Mar 25, 2003 at 01:14:26PM -0800, Kevin Oberman wrote: >> > I've been seeing this for a couple of weeks since I updated my laptop to >> > CURRENT. I do a normal shutdown (-p or -r) and reboot. The shutdown >> > looked normal, with no problems reported with the sync, but, when the >> > system is rebooted, the partitions are all shown as possibly >> > unclean. From my dmesg: >> > Mounting root from ufs:/dev/ad0s3a >> > WARNING: / was not properly dismounted >> > ... >> > All disks are mounted with soft-updates enabled. >> > >> > I don't see any other reports of this. Is this unique to my system? >> Go to single user mode and run "fsck -f -p" on each filesystem. >>... >Actually, 'fsck -f -p' didn't help at all. I had to do fsck_ffs on every >partition (as per the message cited). >Looks to me like this belongs in UPDATING, although it does not break >anything. Maybe in the v4 to current update instructions. Sorry to quote so much; I was offline most of the day Anyway: I am continuing to track both -STABLE and -CURRENT on a daily basis on a couple of machines, one of which is my laptop (a Dell i5000e). I have soft updates enabled for each (UFS) file system. (I set up /tmp as mfs/md; I do not enable soft updates on it.) I have a couple of file systems that are mounted read-write regardless of what I boot (one of which is /var, so I have some assurance that both -STABLE and -CURRENT are mounting the file system and writing to it). (The other is the one that has my home directory, the local CVS repository, /usr/local, and the various /usr/obj hierarchies that correspond to each bootable slice. So yeah, this one gets mounted read-write, and is written to.) When I boot -STABLE, I typically mount all mountable file systems. When I boot -CURRENT, I typically do not mount the root and /usr file systems that I use for -STABLE. I have seen no problems doing this in several months. (Last time I did was because -STABLE's fsck needed a tweak to accomodate a change made in -CURRENT. This merely caused whines and annoyance; there was no data loss. Cheers, david (links to my resume at http://www.catwhisker.org/~david) -- David H. Wolfskill [EMAIL PROTECTED] Based on what I have seen to date, the use of Microsoft products is not consistent with reliability. I recommend FreeBSD for reliable systems. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "[EMAIL PROTECTED]"
[Re: Unclean sync in current
Kevin Oberman wrote: > > I've been seeing this for a couple of weeks since I updated my laptop to > CURRENT. I do a normal shutdown (-p or -r) and reboot. The shutdown > looked normal, with no problems reported with the sync, but, when the > system is rebooted, the partitions are all shown as possibly > unclean. From my dmesg: > Mounting root from ufs:/dev/ad0s3a > WARNING: / was not properly dismounted [ ... ] There was an issue reported some time back about the power being shut off before the disks had been forced to sync their write caches out to stable storage, resulting in this behaviour. I believe Soeren updated the driver to force this sync before returning, at least for ATA drives, so you may just be running stale code. Alternately, you may just have disk drives that ignore the command. I think it was controlled by a sysctl with "sync" in the name, so you might want to look it up via: sysctl -A | grep sync if you are in fact running the most recent -CURRENT. I think there was a delay factor, in seconds, involved (FWIW). Another alternative is to disable write caching on the disk, as a workaround (amazing how many times recently that that's been the answer to someone's problem...). -- Terry ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Unclean sync in current
I've been seeing this for a couple of weeks since I updated my laptop to CURRENT. I do a normal shutdown (-p or -r) and reboot. The shutdown looked normal, with no problems reported with the sync, but, when the system is rebooted, the partitions are all shown as possibly unclean. From my dmesg: Mounting root from ufs:/dev/ad0s3a WARNING: / was not properly dismounted WARNING: / was not properly dismounted WARNING: /tmp was not properly dismounted WARNING: /usr was not properly dismounted WARNING: /var was not properly dismounted All disks are mounted with soft-updates enabled. I don't see any other reports of this. Is this unique to my system? R. Kevin Oberman, Network Engineer Energy Sciences Network (ESnet) Ernest O. Lawrence Berkeley National Laboratory (Berkeley Lab) E-mail: [EMAIL PROTECTED] Phone: +1 510 486-8634 To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message