public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Linux kernel - Libata bad block error handling to user mode program
@ 2010-03-04  4:52 foo saa
  2010-03-04  6:42 ` Andrew Morton
  0 siblings, 1 reply; 34+ messages in thread
From: foo saa @ 2010-03-04  4:52 UTC (permalink / raw)
  To: linux-kernel

hi everyone,

I am in the process of writing a disk erasure application in C. The
program does zerofill the drive (Good or Bad) before someone destroys
it. During the erasure process, I need to record the number of bad
sectors during the zerofill operation.

The method used to write to the hdd involves opening the appropriate
/dev block device using open() call with O_WRONLY flag, start issuing
write() calls to fill the sectors. A 512 byte buffer filled with
zero's is used. All calls are of 64bit enabled. (I am using
_LARGEFILE64_SOURCE define).

The problem is (mostly with the bad hdd's), when the write call
encounters a bad sector, it takes a bit longer than usual and writes
the sector without any errors. (dmesg shows a lot of error messages
embedded in the LIBATA error handling code!). The call never fails for
any reason.

I am using 2.6.27-7-generic  and gcc version 4.3.2  on ubuntu 8.10. I
have tried upto 2.6.30.10 and multiple distros with similar behavior.

Here is a summary of things I have attempted.

I know about the bad sector and it's location on the hdd, since it has
been verified by using Windows based hex editor utilities, DOS based
erasure applications, MHDD and many other HDD utilities.

I have tried using O_DIRECT with aligned buffers, but still could not
identify the bad sectors during the writing process.

I have tried using fadvise, posix_fadvise functions to get of the
caching, but still failed.

I have tried using SG_IO and SAT translation (direct ATA commands with
device addressing) and it fails too. Raw devices is out of question
now.

The libata is not letting / informing the user mode program (executing
under root) about the media / write errors / bad blocks and failures,
though it notifies the kernel and logs to syslog. It also tries to
reallocate, softreset, hardreset the block device which is evident
from the dmesg logs.

What has to be done for my program to identify / receive the bad block
/ sector information during the read / write process?

How can I receive the bad sector / physical and media write errors in
my program? This is my only requirement and question.

I am currently out of options unless anyone from here can show some
new direction!

My only option is to recompile the kernel with libata customization
and changes according to my requirement. (Can I instruct to libata to
skip the error handling process and pass certain errors to my
program?).

Is this a good approach and recommended one? If not what should be
done to achieve it? If yes, can somebody throw some light on it?

Please let me know if you have any queries in my above explanation.

Thank you for reading this rather long post!

Regards
sponnusa

^ permalink raw reply	[flat|nested] 34+ messages in thread
* RE: Linux kernel - Libata bad block error handling to user mode  program
@ 2010-03-04 18:40 Kalra Ashish-B00888
  0 siblings, 0 replies; 34+ messages in thread
From: Kalra Ashish-B00888 @ 2010-03-04 18:40 UTC (permalink / raw)
  To: Mark Lord, foo saa
  Cc: Greg Freemyer, Andrew Morton, linux-kernel, linux-ide, Jens Axboe,
	linux-mm



Sent from my HTC

-----Original Message-----
From: Mark Lord <kernel@teksavvy.com>
Sent: 04 March 2010 11:20 PM
To: foo saa <foosaa@gmail.com>
Cc: Greg Freemyer <greg.freemyer@gmail.com>; Andrew Morton <akpm@linux-foundation.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; linux-ide@vger.kernel.org <linux-ide@vger.kernel.org>; Jens Axboe <jens.axboe@oracle.com>; linux-mm@kvack.org <linux-mm@kvack.org>
Subject: Re: Linux kernel - Libata bad block error handling to user mode  program

On 03/04/10 10:33, foo saa wrote:
..
> hdparm is good, but I don't want to use the internal ATA SECURE ERASE
> because I can never get the amount of bad sectors the drive had.
..

Oh.. but isn't that information in the S.M.A.R.T. data ??

You'll not find the bad sectors by writing -- a true WRITE nearly never
reports a media error.  Instead, the drive simply remaps to a good sector
on the fly and returns success.

Generally, only READs report media errors.

Cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 34+ messages in thread
* RE: Linux kernel - Libata bad block error handling to user mode  program
@ 2010-03-04 18:41 Kalra Ashish-B00888
  0 siblings, 0 replies; 34+ messages in thread
From: Kalra Ashish-B00888 @ 2010-03-04 18:41 UTC (permalink / raw)
  To: Mark Lord, foo saa
  Cc: Greg Freemyer, Andrew Morton, linux-kernel, linux-ide, Jens Axboe,
	linux-mm



Sent from my HTC

-----Original Message-----
From: Mark Lord <kernel@teksavvy.com>
Sent: 04 March 2010 11:20 PM
To: foo saa <foosaa@gmail.com>
Cc: Greg Freemyer <greg.freemyer@gmail.com>; Andrew Morton <akpm@linux-foundation.org>; linux-kernel@vger.kernel.org <linux-kernel@vger.kernel.org>; linux-ide@vger.kernel.org <linux-ide@vger.kernel.org>; Jens Axboe <jens.axboe@oracle.com>; linux-mm@kvack.org <linux-mm@kvack.org>
Subject: Re: Linux kernel - Libata bad block error handling to user mode  program

On 03/04/10 10:33, foo saa wrote:
..
> hdparm is good, but I don't want to use the internal ATA SECURE ERASE
> because I can never get the amount of bad sectors the drive had.
..

Oh.. but isn't that information in the S.M.A.R.T. data ??

You'll not find the bad sectors by writing -- a true WRITE nearly never
reports a media error.  Instead, the drive simply remaps to a good sector
on the fly and returns success.

Generally, only READs report media errors.

Cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2010-03-14 16:12 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-04  4:52 Linux kernel - Libata bad block error handling to user mode program foo saa
2010-03-04  6:42 ` Andrew Morton
2010-03-04 12:58   ` foo saa
2010-03-04 16:31     ` Mike Hayward
2010-03-04 18:12       ` s ponnusa
2010-03-05  0:42         ` Mike Hayward
2010-03-05  2:23           ` s ponnusa
2010-03-05 16:31             ` Mike Hayward
2010-03-05  6:01           ` Greg Freemyer
2010-03-05 13:04             ` Alan Cox
2010-03-04 16:37     ` Mike Hayward
2010-03-04 18:23       ` s ponnusa
2010-03-04 14:17   ` Greg Freemyer
2010-03-04 14:41     ` Mark Lord
2010-03-04 15:33       ` foo saa
2010-03-04 17:49         ` Mark Lord
2010-03-04 18:20           ` s ponnusa
2010-03-04 19:41             ` Greg Freemyer
2010-03-04 19:50               ` s ponnusa
2010-03-05  1:58             ` Robert Hancock
2010-03-05  2:11               ` s ponnusa
2010-03-05  2:16                 ` Robert Hancock
2010-03-05  2:17                   ` s ponnusa
2010-03-05 12:03                 ` Alan Cox
2010-03-05 22:27                   ` s ponnusa
2010-03-11 18:29       ` Greg Freemyer
2010-03-13 22:44         ` s ponnusa
2010-03-13 23:44           ` Robert Hancock
2010-03-14  0:12             ` s ponnusa
2010-03-14  5:06               ` Robert Hancock
2010-03-14 16:02         ` Mark Lord
2010-03-14 16:12           ` Greg Freemyer
  -- strict thread matches above, loose matches on Subject: below --
2010-03-04 18:40 Kalra Ashish-B00888
2010-03-04 18:41 Kalra Ashish-B00888

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