Deadlocked kernel when using brw_kiovec to do direct I/O

2005-03-17 Thread Hanson, Jonathan M
I'm using brw_kiovec() on a 2.4.28 kernel to write directly to a
hard drive from a kernel module that I wrote. I have a 64k buffer that I
pass to brw_kiovec() and it writes the data to the hard drive directly
like it's supposed to. However, I noticed that if I make more than one
call to brw_kiovec() to write more data, the second call will cause the
machine to freeze hard. I have to reboot via the reset button (SysRq
doesn't work). Below is the code from just the part that calls
brw_kiovec() (based on some of the code in the Linux Kernel Crash Dump):

void RC_file_writer(const char *buffer)
{
int return_value, i;
unsigned long *b = RC_dump_iobuf->blocks, blocknr, blocks;

if (RC_dump_offset & (RC_dump_block_size - 1))
{
printk(KERN_ERR "RapidCapture: RC_dump_offset wasn't
aligned properly.\n");
return;
}

/* Reset the block number values */
blocknr = RC_dump_offset >> RC_dump_block_shift;


/* Calculate the number of blocks */
blocks = RC_BUFFER_SIZE >> RC_dump_block_shift;
if (blocks > (KIO_MAX_SECTORS >> (RC_dump_block_shift - 9)))
blocks = KIO_MAX_SECTORS >> (RC_dump_block_shift - 9);

/* Map the block numbers */
for (i = 0; i < blocks; i++)
b[i] = blocknr++;

/* Write the data to the raw device bypassing any file caches.
*/
return_value = brw_kiovec(WRITE, 1, _dump_iobuf,
RC_dump_device, b, RC_dump_block_size);
if (return_value != RC_BUFFER_SIZE)
printk(KERN_ERR "RapidCapture: Write was trucated!\n");
else
RC_dump_offset += return_value;
}
-
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/


Deadlocked kernel when using brw_kiovec to do direct I/O

2005-03-17 Thread Hanson, Jonathan M
I'm using brw_kiovec() on a 2.4.28 kernel to write directly to a
hard drive from a kernel module that I wrote. I have a 64k buffer that I
pass to brw_kiovec() and it writes the data to the hard drive directly
like it's supposed to. However, I noticed that if I make more than one
call to brw_kiovec() to write more data, the second call will cause the
machine to freeze hard. I have to reboot via the reset button (SysRq
doesn't work). Below is the code from just the part that calls
brw_kiovec() (based on some of the code in the Linux Kernel Crash Dump):

void RC_file_writer(const char *buffer)
{
int return_value, i;
unsigned long *b = RC_dump_iobuf-blocks, blocknr, blocks;

if (RC_dump_offset  (RC_dump_block_size - 1))
{
printk(KERN_ERR RapidCapture: RC_dump_offset wasn't
aligned properly.\n);
return;
}

/* Reset the block number values */
blocknr = RC_dump_offset  RC_dump_block_shift;


/* Calculate the number of blocks */
blocks = RC_BUFFER_SIZE  RC_dump_block_shift;
if (blocks  (KIO_MAX_SECTORS  (RC_dump_block_shift - 9)))
blocks = KIO_MAX_SECTORS  (RC_dump_block_shift - 9);

/* Map the block numbers */
for (i = 0; i  blocks; i++)
b[i] = blocknr++;

/* Write the data to the raw device bypassing any file caches.
*/
return_value = brw_kiovec(WRITE, 1, RC_dump_iobuf,
RC_dump_device, b, RC_dump_block_size);
if (return_value != RC_BUFFER_SIZE)
printk(KERN_ERR RapidCapture: Write was trucated!\n);
else
RC_dump_offset += return_value;
}
-
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/


RE: Using O_DIRECT for file writing in a kernel module

2005-02-12 Thread Hanson, Jonathan M
On Fri, 2005-02-11 at 17:58 -0700, Hanson, Jonathan M wrote:
>   I'm trying to write to a file with the O_DIRECT flag from a
> kernel module in a 2.4 series of kernel on x86 hardware. I've learned
> that the O_DIRECT flag requires that the amount of data written and
the
> file offset pointer must be multiples of the underlying "block size."


ehhh why are you writing to a file from a kernel module? That's
generally considered a really bad idea

[Jon M. Hanson] For what I'm doing I have no other choice but to write
to a file from my kernel module.

-
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/


RE: Using O_DIRECT for file writing in a kernel module

2005-02-12 Thread Hanson, Jonathan M
On Fri, 2005-02-11 at 17:58 -0700, Hanson, Jonathan M wrote:
   I'm trying to write to a file with the O_DIRECT flag from a
 kernel module in a 2.4 series of kernel on x86 hardware. I've learned
 that the O_DIRECT flag requires that the amount of data written and
the
 file offset pointer must be multiples of the underlying block size.


ehhh why are you writing to a file from a kernel module? That's
generally considered a really bad idea

[Jon M. Hanson] For what I'm doing I have no other choice but to write
to a file from my kernel module.

-
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/


Using O_DIRECT for file writing in a kernel module

2005-02-11 Thread Hanson, Jonathan M
I'm trying to write to a file with the O_DIRECT flag from a
kernel module in a 2.4 series of kernel on x86 hardware. I've learned
that the O_DIRECT flag requires that the amount of data written and the
file offset pointer must be multiples of the underlying "block size."
To try things out I've been successful is writing to a file with
O_DIRECT in user space using multiples of PAGE_SIZE.
However, when I try to do the same from my kernel module I'm
always greeted with an -EINVAL as the return code from the write call
when trying multiples of PAGE_SIZE. Then I realized that the kernel uses
four megabyte pages and not four kilobyte pages so I tried passing four
megabytes of data to the write call but also got -EINVAL in return.
Is it possible to use O_DIRECT to write a file from a kernel
module? If so, what size of data do I need to pass so that it will work?
I've been through Google and the kernel source code but didn't see an
answer as to the size required to get it to work.
Thanks in advance for any assistance offered.

-
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/


Using O_DIRECT for file writing in a kernel module

2005-02-11 Thread Hanson, Jonathan M
I'm trying to write to a file with the O_DIRECT flag from a
kernel module in a 2.4 series of kernel on x86 hardware. I've learned
that the O_DIRECT flag requires that the amount of data written and the
file offset pointer must be multiples of the underlying block size.
To try things out I've been successful is writing to a file with
O_DIRECT in user space using multiples of PAGE_SIZE.
However, when I try to do the same from my kernel module I'm
always greeted with an -EINVAL as the return code from the write call
when trying multiples of PAGE_SIZE. Then I realized that the kernel uses
four megabyte pages and not four kilobyte pages so I tried passing four
megabytes of data to the write call but also got -EINVAL in return.
Is it possible to use O_DIRECT to write a file from a kernel
module? If so, what size of data do I need to pass so that it will work?
I've been through Google and the kernel source code but didn't see an
answer as to the size required to get it to work.
Thanks in advance for any assistance offered.

-
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/