public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Problem in IDE Disks cache handling in kernel 2.4.XX
@ 2003-01-10  9:54 Francis Verscheure
  2003-01-10 10:19 ` John Bradford
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Francis Verscheure @ 2003-01-10  9:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: marcelo


Hello to everybody  and a Happy New Year.
Thanks a lot for all the great job you are all doing.

Having EXT2 file system corruption after suspend on a notebook I investigate 
kernel code and it seems to me that IDE Disk cache handling is wrong in 
kernel 2.4.XX.

Sources extracts are from kernel 2.4.20.

If you look at  struct hd_driveid  in hdreg.h you will find :

unsigned short  command_set_1;	/* (word 82) supported
	 *  6:	look-ahead
	 *  5:	write cache			==== this means the Disk has a disk cache =====

unsigned short  command_set_2;	/* (word 83)
	 * 13:	FLUSH CACHE EXT		==== Those fields were RESERVED in ATA/ATAPI 5 
	 * 12:	FLUSH CACHE			==== and are used ONLY in ATA/ATAPI 6 ====
	 * 10:	48-bit Address Feature Set

unsigned short  cfs_enable_1;	/* (word 85)
	 *  6:	look-ahead
	 *  5:	write cache			==== this means the Disk cache is enabled or disabled
					 */
unsigned short  cfs_enable_2;	/* (word 86)
	 * 13:	FLUSH CACHE EXT		==== Those fields were RESERVED in ATA/ATAPI 5
	 * 12:	FLUSH CACHE			==== and are used ONLY in ATA/ATAPI 6 ====
	 * 10:	48-bit Address Feature Set

In ide-disk.c you have

static int write_cache (ide_drive_t *drive, int arg)
{
	struct hd_drive_task_hdr taskfile;
	struct hd_drive_hob_hdr hobfile;
	memset(&taskfile, 0, sizeof(struct hd_drive_task_hdr));
	memset(&hobfile, 0, sizeof(struct hd_drive_hob_hdr));
	taskfile.feature	= (arg) ? SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE;
	taskfile.command	= WIN_SETFEATURES;

	if (!(drive->id->cfs_enable_2 & 0x3000))	<==== WRONG ! ONLY FOR ATA/ATAPI 6
		return 1;

	(void) ide_wait_taskfile(drive, &taskfile, &hobfile, NULL);
	drive->wcache = arg;
	return 0;
}


In fact for ATA/ATAPI 5 cfs_enable_2  has no meaning.  The fields to test are 
write cache bits in command_set_1 and cfs_enable_1.
And in both cases the FLUSH CACHE command ALWAYS EXISTS !
The test of cfs_enable_2 must only be used for ATA/ATAPI 6 drives to use 
FLUSH CACHE or FLUSH CACHE EXT in case of 48 bit addressing mode.

And it seems to me that when an IDE drive has a cache enabled wcache must be 
initialized to say so ? Or you have to do a STANDY or SLEEP before APM 
suspend or power off to be sure that the cache has been written to the disk.

I had a look at patch 2.4.21pre3 and the code looks the same.

And by the way how are powered off the IDE drives ?
Because a FLUSH CACHE or STANDY or SLEEP is MANDATORY before powering off the 
drive with cache enabled or you will enjoy lost data.

I am not on the list so thank you to CC me.

Best regards to all.

Francis Verscheure


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2003-01-10 20:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-10  9:54 Problem in IDE Disks cache handling in kernel 2.4.XX Francis Verscheure
2003-01-10 10:19 ` John Bradford
2003-01-10 11:37 ` Alan Cox
2003-01-10 11:07   ` Benjamin Herrenschmidt
2003-01-10 11:14   ` Andre Hedrick
2003-01-10 13:35     ` Alan Cox
2003-01-10 13:03       ` Andre Hedrick
2003-01-10 14:13         ` Alan Cox
2003-01-10 16:48           ` Jens Axboe
2003-01-10 18:12             ` Alan Cox
2003-01-10 18:12               ` PATCH: [2.4.21-pre3] Fix for SMP race condition in IDE code Ross Biro
2003-01-10 19:29                 ` Alan Cox
2003-01-10 20:22                 ` Andre Hedrick
2003-01-10 18:25               ` Problem in IDE Disks cache handling in kernel 2.4.XX Jens Axboe
2003-01-10 17:23 ` Alan Cox
2003-01-10 17:02   ` John Bradford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox