mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Francis Verscheure <fverscheure@wanadoo.fr>
To: linux-kernel@vger.kernel.org
Cc: marcelo@conectiva.com.br
Subject: Problem in IDE Disks cache handling in kernel 2.4.XX
Date: Fri, 10 Jan 2003 10:54:53 +0100	[thread overview]
Message-ID: <20030110095558.E144CFF11@postfix4-1.free.fr> (raw)


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


             reply	other threads:[~2003-01-10  9:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-10  9:54 Francis Verscheure [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030110095558.E144CFF11@postfix4-1.free.fr \
    --to=fverscheure@wanadoo.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®