Linux 2.6.6 "IDE cache-flush at shutdown fixes"
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
If this is indeed the case, that those drives don't support the "flush write cache" command, I'd like to see Maxtor's excuse as to why.. I believe that Windows always powers down IDE drives before shutdown, maybe this is because of non-universal support for the "flush write cache" command?
----- Original Message -----
From: "Rene Herman" <[email protected]>
Newsgroups: fa.linux.kernel
To: <[email protected]>
Cc: <[email protected]>
Sent: Monday, May 10, 2004 6:08 AM
Subject: Re: Linux 2.6.6 "IDE cache-flush at shutdown fixes"
Quoted 23 lines
Quoted 5 lines · Gene Heskett
Quoted 1 line
hda: Maxtor 6Y120P0, ATA DISK drive
I note the drive is the same model here too, Rene.
The question remains however, is our data in danger?
There's a fair change that we'll be told, yes, very much so, since these drives don't seem to correctly support this life saving feature. The real answer though will be more easily deducted by calculating the ratio of unexplained file system corruptions you've had and reboots you've managed (0, that is).
Rene.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 4 lines · Robert Hancock
If this is indeed the case, that those drives don't support the "flush write cache" command, I'd like to see Maxtor's excuse as to why.. I believe that Windows always powers down IDE drives before shutdown, maybe this is because of non-universal support for the "flush write cache" command?
The issue is a bit more subtle, and I'm not making an "excuse" per say...
(Not speaking officially for Maxtor, but I'm just trying to help...)
As per the email I got from Bart, the drive in question doesn't support 48-bit commands. The wierdness is that it claims to support the FLUSH CACHE EXT (0xEA) command. Obviously, this combination doesn't make it safe to issue FLUSH CACHE EXT since the drive will not be able to properly report a failing location in the event of a failure to flush due to a fatal write fault. The drive knows a FLUSH CACHE EXT command isn't safe, so it aborts that command which is the error message you see.
The code that Bart showed me does a '&' on the feature word with the required support bits, but uses the result in an 'if' conditional. I believe that means that in C, if either of the bits is set, then the 'if' will evaluate to true, which is causing the problem.
The solution (that should work for all drives) would be to test properly to make sure the drive reports support for both 48-bit commands and FLUSH CACHE EXT, with something like:
if ((feature & bits) == bits)
then issue that command. If *either* of these bits is false, then the drive should be issued a normal FLUSH CACHE (0xE7) command (which is a reasonably standard 28-bit command, and all Maxtor drives support, including the models in question.)
Note that this only affects newer drives (last 18 months or so) that are <120GB. (Yes, I know that is still a truckload)
There are a gazillion of these in the field (we sell ~60 million drives/year?) so I don't believe a firmware "upgrade" or equivalent simply is logistically possible, but this inconsistency is going to be addressed in future products, I'm making sure of it.
If anyone has questions, please don't hesitate to email and I'll do my best to help.
Signature · 2 lines
Eric D. Mudama [email protected]
Eric D. Mudama wrote:
Thanks much for responding. I have one of these maxtor drives.
Quoted 2 lines
Note that this only affects newer drives (last 18 months or so) that are <120GB. (Yes, I know that is still a truckload)
Possibly <=, but at least both 6Y120P0 (120G, 8M cache) en 6Y120L0 (120G, 2M cache) are affected. Experiencing it myself on 6Y120P0.
Quoted 4 lines
There are a gazillion of these in the field (we sell ~60 million drives/year?) so I don't believe a firmware "upgrade" or equivalent simply is logistically possible, but this inconsistency is going to be addressed in future products, I'm making sure of it.
As to logistics... must say I'd already be satisfied with a new firmware
downloadable from the maxtor site and a means to upload it. Of course,
a linux means would be best for me. If not possible, real-mode DOS is useable.
Quoted 2 lines
If anyone has questions, please don't hesitate to email and I'll do my best to help.
Thanks for responding! Please do consider making an updated firmware available through the site...
Rene.
[ Rene, Alan, Arjan, Andrew and Linus added to cc: ]
Quoted 31 lines · Eric D. Mudama
Quoted 5 lines · Robert Hancock
If this is indeed the case, that those drives don't support the "flush write cache" command, I'd like to see Maxtor's excuse as to why.. I believe that Windows always powers down IDE drives before shutdown, maybe this is because of non-universal support for the "flush write cache" command?
The issue is a bit more subtle, and I'm not making an "excuse" per say...
(Not speaking officially for Maxtor, but I'm just trying to help...)
As per the email I got from Bart, the drive in question doesn't support 48-bit commands. The wierdness is that it claims to support the FLUSH CACHE EXT (
0xEA) command. Obviously, this combination doesn't make it safe to issue FLUSH CACHE EXT since the drive will not be able to properly report a failing location in the event of a failure to flush due to a fatal write fault. The drive knows a FLUSH CACHE EXT command isn't safe, so it aborts that command which is the error message you see.The code that Bart showed me does a '&' on the feature word with the required support bits, but uses the result in an 'if' conditional. I believe that means that in C, if either of the bits is set, then the 'if' will evaluate to true, which is causing the problem.
The solution (that should work for all drives) would be to test properly to make sure the drive reports support for both 48-bit commands and FLUSH CACHE EXT, with something like:
Quoted 6 lines
if ((feature & bits) == bits)
then issue that command. If *either* of these bits is false, then the drive should be issued a normal FLUSH CACHE (
0xE7) command (which is a reasonably standard 28-bit command, and all Maxtor drives support, including the models in question.)
Yes, this should work. Thanks Eric.
The other part of the story is a nasty bug in ide-disk.c driver:
write_cache() is called with (drive->id->cfs_enable_2 & 0x300) as argument 'arg' of type 'int' and then this value is assigned to the 'drive->wcache' of type 'unsigned char' so drive->wcache == 0 because 0x3000 gets truncated.
This bug has been present since introduction of drive->wcache (2.5.3), therefore we have never handled cache flush correctly before and never hit '& 0x2400' problem before.
Linus & Alan, you were almost right after all, drive->wcache was almost always zero for normal disks before 2.6.6. It could be forced by user but only for disks having ATA-6 cache flush bits and was auto-set but only for removable disks (after Alan's fixes in 2.6.65). You lucky b*st*rds. ;-)
Rene, that's why wcache is 0 in /proc/ide/hdX/settings for older kernels or with my 'bandaid' fixes for 2.6.6. 'hdparm -W1' should work but only on quite recent drives (having ATA-6 bits). However I don't know why you get regression in tiobench, we still need to explain this.
Andrew, I will send some patches to you today/tomorrow.
Quoted 7 lines
Note that this only affects newer drives (last 18 months or so) that are <120GB. (Yes, I know that is still a truckload)
There are a gazillion of these in the field (we sell ~60 million drives/year?) so I don't believe a firmware "upgrade" or equivalent simply is logistically possible, but this inconsistency is going to be addressed in future products, I'm making sure of it.
Yep, I don't think firmware 'upgrade' is needed/feasable.
Cheers.
Quoted 15 lines · Bartlomiej Zolnierkiewicz
The other part of the story is a nasty bug in
ide-disk.cdriver:
write_cache()is called with (drive->id->cfs_enable_2&0x300) as argument 'arg' of type 'int' and then this value is assigned to the 'drive->wcache' of type 'unsigned char' sodrive->wcache== 0 because0x3000gets truncated.This bug has been present since introduction of
drive->wcache(2.5.3), therefore we have never handled cache flush correctly before and never hit '&0x2400' problem before.Linus & Alan, you were almost right after all,
drive->wcachewas almost always zero for normal disks before 2.6.6. It could be forced by user but only for disks having ATA-6 cache flush bits and was auto-set but only for removable disks (after Alan's fixes in 2.6.65). You lucky b*st*rds. ;-)
Quoted 4 lines
Rene, that's why wcache is 0 in
/proc/ide/hdX/settingsfor older kernels or with my 'bandaid' fixes for 2.6.6. 'hdparm -W1' should work but only on quite recent drives (having ATA-6 bits). However I don't know why you get regression in tiobench, we still need to explain this.
I'm afraid I can explain it. Even though hdparm -W0/-W1 didn't show up in the settings, they certainly do take effect (on this drive). The bad results I posted appear to have been with -W0. By default, and after -W1, it's back up to normal again. Sorry if I confused the issue.
Rene.
Quoted 41 lines · Eric D. Mudama
Quoted 5 lines · Robert Hancock
If this is indeed the case, that those drives don't support the "flush write cache" command, I'd like to see Maxtor's excuse as to why.. I believe that Windows always powers down IDE drives before shutdown, maybe this is because of non-universal support for the "flush write cache" command?
The issue is a bit more subtle, and I'm not making an "excuse" per say...
(Not speaking officially for Maxtor, but I'm just trying to help...)
As per the email I got from Bart, the drive in question doesn't support 48-bit commands. The wierdness is that it claims to support the FLUSH CACHE EXT (
0xEA) command. Obviously, this combination doesn't make it safe to issue FLUSH CACHE EXT since the drive will not be able to properly report a failing location in the event of a failure to flush due to a fatal write fault. The drive knows a FLUSH CACHE EXT command isn't safe, so it aborts that command which is the error message you see.The code that Bart showed me does a '&' on the feature word with the required support bits, but uses the result in an 'if' conditional. I believe that means that in C, if either of the bits is set, then the 'if' will evaluate to true, which is causing the problem.
The solution (that should work for all drives) would be to test properly to make sure the drive reports support for both 48-bit commands and FLUSH CACHE EXT, with something like:
if ((feature & bits) == bits)
then issue that command. If *either* of these bits is false, then the drive should be issued a normal FLUSH CACHE (
0xE7) command (which is a reasonably standard 28-bit command, and all Maxtor drives support, including the models in question.)Note that this only affects newer drives (last 18 months or so) that are <120GB. (Yes, I know that is still a truckload)
Quoted 8 lines
There are a gazillion of these in the field (we sell ~60 million drives/year?) so I don't believe a firmware "upgrade" or equivalent simply is logistically possible, but this inconsistency is going to be addressed in future products, I'm making sure of it.
If anyone has questions, please don't hesitate to email and I'll do my best to help.
Thank you Eric, for such a clear explanation of the problem (I have one of those drives and was the one who made the second report I believe... Now it seems that a fix can be written into our driver without a lot of fuss, so it becomes a non-issue for us once thats filtered thru Andrew and on up to Linus.
My Q for you, is, does M$ already have a similar workaround in their drivers? Just curious. :)
Signature · 8 lines
Cheers, Gene "There are four boxes to be used in defense of liberty: soap, ballot, jury, and ammo. Please use in that order." -Ed Howdershelt (Author) 99.22% setiathome rank, not too shabby for a WV hillbilly Yahoo.com attorneys please note, additions to this message by Gene Heskett are: Copyright 2004 by Maurice Eugene Heskett, all rights reserved.
Quoted 1 line · Gene Heskett
Thank you Eric, for such a clear explanation of the problem (I have one of those drives and was the one who made the second report I believe... Now it seems that a fix can be written into our driver without a lot of fuss, so it becomes a non-issue for us once thats filtered thru Andrew and on up to Linus.
Glad I could help. As I said in a private email to a few people, I fixed this for all future drives this morning, so that wierdness shouldn't show up again. If anyone notices anything wierd or has questions, I'd be happy to hear about it and try to help.
Quoted 1 line
My Q for you, is, does M$ already have a similar workaround in their drivers? Just curious. :)
I am not privy to any "M$" driver code so I have no idea what is in their driver.
--eric
Signature · 2 lines
Eric D. Mudama [email protected]