Hi All, I am trying to write a linux kernel module which can send/receive ATA SMART cmds to a HDD. The kernel module will take a set of actions based on the responses it receives from the HDD. I went through the ATA smart cmds spec and the "smartctl" user space code which sends the ATA cmds from user space via SG_IO ioctl cmd. I am not able to figure out how to open /dev/sda from kernel and achieve similar functionalities line "smartctl" tool from a kernel module. 1. Can someone point me to any sample code which tries to send ATA smart cmds from a kernel module instead of user space via ioctl? 2. Seems like I need to use some exported API from SG driver or libata. is this the right direction? 3. Please feel free to suggest how can I achieve this. Thanks, Sid
On Mon, Jan 30, 2017 at 01:38:01PM -0600, Siddhartha Baral wrote:
Hi All,
I am trying to write a linux kernel module which can send/receive ATA SMART cmds to a HDD.
First off, why? What problem are you trying to solve that you have decided that this is the correct solution? thanks, greg k-h
Hi Greg, I am trying to add a new thermal zone driver for HDD which will be part of the thermal framework in the kernel. Thanks, Sid On Thu, Feb 2, 2017 at 1:11 AM, Greg KH <greg@kroah.com> wrote:
On Mon, Jan 30, 2017 at 01:38:01PM -0600, Siddhartha Baral wrote:
Hi All,
I am trying to write a linux kernel module which can send/receive ATA SMART cmds to a HDD.
First off, why? What problem are you trying to solve that you have decided that this is the correct solution?
thanks,
greg k-h
On Thu, Feb 02, 2017 at 08:54:27AM -0600, Siddhartha Baral wrote:
Hi Greg, I am trying to add a new thermal zone driver for HDD which will be part of the thermal framework in the kernel.
Why does it have to be in the kernel? Why can't you do it all from userspace? thanks, greg k-h
On Thu, 02 Feb 2017 08:54:27 -0600, Siddhartha Baral said:
I am trying to add a new thermal zone driver for HDD which will be part of the thermal framework in the kernel.
First Law of Systems Programming: Never test for an error condition you don't know how to handle anyhow. If the disk reports that it is over-temperature, *what can you do about it*? If a CPU gets too hot you can reduce the clock frequency. You don't have that sort of option on a disk drive - especially from inside the kernel. You can't change its rotation rate, and throttling I/O won't significantly change the temperature (but can hang the system if writeback of dirty pages stops....)
We have a separate cooling device for HDD. On Thu, Feb 2, 2017 at 10:28 AM, <valdis.kletnieks@vt.edu> wrote:
On Thu, 02 Feb 2017 08:54:27 -0600, Siddhartha Baral said:
I am trying to add a new thermal zone driver for HDD which
will
be part of the thermal framework in the kernel.
First Law of Systems Programming:
Never test for an error condition you don't know how to handle anyhow.
If the disk reports that it is over-temperature, *what can you do about it*?
If a CPU gets too hot you can reduce the clock frequency. You don't have that sort of option on a disk drive - especially from inside the kernel. You can't change its rotation rate, and throttling I/O won't significantly change the temperature (but can hang the system if writeback of dirty pages stops....)
I think it needs a much bigger change i.e need to move the framework to kernel space to control this from user space. In short, I need to get this done in kernel as I want this module to fit in the current framework. Please suggest if you have any implementation specific idea for this. Thanks, Sid On Thu, Feb 2, 2017 at 10:57 AM, Greg KH <greg@kroah.com> wrote:
On Thu, Feb 02, 2017 at 10:32:56AM -0600, Siddhartha Baral wrote:
We have a separate cooling device for HDD.
Why aren't you controlling that from userspace as well?
On Thu, Feb 02, 2017 at 11:27:26AM -0600, Siddhartha Baral wrote:
I think it needs a much bigger change i.e need to move the framework to kernel space to control this from user space.
I don't understand, what framework do you have to move? Userspace can read the temperature and then do whatever it wants to do (i.e. send commands to your cooling system).
In short, I need to get this done in kernel as I want this module to fit in the current framework. Please suggest if you have any implementation specific idea for this.
Do you have a pointer to your code somewhere that we can see what you are doing and have tried that did not work out? thanks, greg k-h
I don't have any code yet and was doing the design analysis part. I will try some experimental stuff soon and then move from there I guess. BTW, thanks for your time! On Thu, Feb 2, 2017 at 11:35 AM, Greg KH <greg@kroah.com> wrote:
On Thu, Feb 02, 2017 at 11:27:26AM -0600, Siddhartha Baral wrote:
I think it needs a much bigger change i.e need to move the framework to kernel space to control this from user space.
I don't understand, what framework do you have to move? Userspace can read the temperature and then do whatever it wants to do (i.e. send commands to your cooling system).
In short, I need to get this done in kernel as I want this module to fit in the current framework. Please suggest if you have any implementation specific idea for this.
Do you have a pointer to your code somewhere that we can see what you are doing and have tried that did not work out?
thanks,
greg k-h
participants (3)
-
Greg KH -
Siddhartha Baral -
valdis.kletnieks@vt.edu