set blksize of block device
Hello,
I am learning block device drivers and have a newbie question. Given a block device, is there anyway that I could set its block size? For example, I want to write a block device driver that will work on an existing block device. In this driver, I want block size smaller. (The idea looks confusing but I could explain if anybody is interested :- ) However, typically the block size is 1KB, now I want to set it to 512 or 256. Can I do it?
TIA
Lei
Please cc me if you have answers to this, I am not on the list. Thanks a lot!
Quoted 7 lines · Lei Yang
Hello,
I am learning block device drivers and have a newbie question. Given a block device, is there anyway that I could set its block size? For example, I want to write a block device driver that will work on an existing block device. In this driver, I want block size smaller. (The idea looks confusing but I could explain if anybody is interested :- ) However, typically the block size is 1KB, now I want to set it to 512 or 256. Can I do it?
TIA
Lei
If nobody could answer this question, what about another one? Is there a system call or a kernel interface that would allow me to write a block of data to block 1 of a certain block device?
Thanks for your reply in advance!
Lei
Quoted 14 lines · Lei Yang
Please cc me if you have answers to this, I am not on the list. Thanks a lot!
Quoted 7 lines · Lei Yang
Hello,
I am learning block device drivers and have a newbie question. Given a block device, is there anyway that I could set its block size? For example, I want to write a block device driver that will work on an existing block device. In this driver, I want block size smaller. (The idea looks confusing but I could explain if anybody is interested :- ) However, typically the block size is 1KB, now I want to set it to 512 or 256. Can I do it?
TIA
Lei
Or in other words, is there generic routines for block devices such that we could:
get (set) block size of a block device;
read an existing block (e.g. block 4);
write an existing block (e.g. block 5);
Please help!!!!
TIA
Lei
Quoted 31 lines · Lei Yang
If nobody could answer this question, what about another one? Is there a system call or a kernel interface that would allow me to write a block of data to block 1 of a certain block device?
Thanks for your reply in advance!
Lei
Quoted 14 lines · Lei Yang
Please cc me if you have answers to this, I am not on the list. Thanks a lot!
Quoted 7 lines · Lei Yang
Hello,
I am learning block device drivers and have a newbie question. Given a block device, is there anyway that I could set its block size? For example, I want to write a block device driver that will work on an existing block device. In this driver, I want block size smaller. (The idea looks confusing but I could explain if anybody is interested :- ) However, typically the block size is 1KB, now I want to set it to 512 or 256. Can I do it?
TIA
LeiSignature · 3 lines
Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/
Quoted 6 lines · Lei Yang
Or in other words, is there generic routines for block devices such that we could:
get (set) block size of a block device;
read an existing block (e.g. block 4);
write an existing block (e.g. block 5);
Can you stick to "reply below quote" style please?
Quoted 2 lines
Quoted 2 lines
If nobody could answer this question, what about another one? Is there a system call or a kernel interface that would allow me to write a
Can you use read, write and seek system calls?
--
vda
Quoted 5 lines · Denis Vlasenko
Quoted 2 lines · Lei Yang
Or in other words, is there generic routines for block devices such that we could:
Quoted 9 lines
Quoted 5 lines
get (set) block size of a block device;
read an existing block (e.g. block 4);
write an existing block (e.g. block 5);Can you stick to "reply below quote" style please?
OK
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
If nobody could answer this question, what about another one? Is there a system call or a kernel interface that would allow me to write a
Can you use read, write and seek system calls?
--
vda
Not really, as I've explained, I want to do all these stuff in kernel space. More specifically, I want to write a newbie kernel module. In this module, I'll do something with a raw block device (with no filesystem). For example, I want to do block I/O operations on ramdisk, and I want to set the block size of ramdisk to whatever value I want (power of 2 of course).
Any comments?
Thanks,
Lei
Quoted 1 line · Lei Yang
Denis Vlasenko wrote:
...
Quoted 1 line
Quoted 1 line
Can you use read, write and seek system calls?
...
Quoted 1 line
Not really, as I've explained, I want to do all these stuff in kernel space. More specifically, I want to write a newbie kernel module. In this module, I'll do something with a raw block device (with no filesystem). For example, I want to do block I/O operations on ramdisk, and I want to set the block size of ramdisk to whatever value I want (power of 2 of course).
Pick up a copy of Linux Device Drivers by Rubini & Corbet (O'Reilly, 2001) and start with the example ramdisk block driver in chapter 12.
Signature · 1 line
Todd
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
I am learning block device drivers and have a newbie question. Given a block device, is there anyway that I could set its block size? For example, I want to write a block device driver that will work on an existing block device. In this driver, I want block size smaller. (The idea looks confusing but I could explain if anybody is interested :- ) However, typically the block size is 1KB, now I want to set it to 512 or 256. Can I do it?
256 - no way if hardware can do only 512-byte writes.
You need read-modify-write for this.
--
vda
Firstly you cannot set the block size to lesser than 512.
When there is a request for the IO, you populate "struct req" data structure which you will pass it to the kernel or lower level SCSI/SATA driver. In the "struct req" there is a field "b_size" which may be what you are interested in. At the user level you can use the IOCTLs to set the block size of the RAW block device.
-Shesha
Quoted 38 lines · Lei Yang
If nobody could answer this question, what about another one? Is there a system call or a kernel interface that would allow me to write a block of data to block 1 of a certain block device?
Thanks for your reply in advance!
Lei
Quoted 21 lines · Lei Yang
Please cc me if you have answers to this, I am not on the list. Thanks a lot!
Quoted 13 lines · Lei Yang
Hello,
I am learning block device drivers and have a newbie question. Given a block device, is there anyway that I could set its block size? For example, I want to write a block device driver that will work on an existing block device. In this driver, I want block size smaller. (The idea looks confusing but I could explain if anybody is interested :- ) However, typically the block size is 1KB, now I want to set it to 512 or 256. Can I do it?
TIA
Lei--
Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/
Signature · 5 lines
.-----.
/ \
{ o | o }
|
\_/Quoted 11 lines · Shesha B. Sreenivasamurthy
Firstly you cannot set the block size to lesser than 512.
When there is a request for the IO, you populate "struct req" data structure which you will pass it to the kernel or lower level SCSI/SATA driver. In the "struct req" there is a field "
b_size" which may be what you are interested in. At the user level you can use the IOCTLs to set the block size of the RAW block device.-Shesha
I understand that for real block device (like hard disk), block size cannot be less than 512. But to ramdisks, I think they are truely random addressable, and should be able to move on blocks even with size of 2 bytes.
Any comments?
Quoted 38 lines · Lei Yang
Quoted 37 lines
If nobody could answer this question, what about another one? Is there a system call or a kernel interface that would allow me to write a block of data to block 1 of a certain block device?
Thanks for your reply in advance!
Lei
Quoted 18 lines · Lei Yang
Please cc me if you have answers to this, I am not on the list. Thanks a lot!
Quoted 9 lines · Lei Yang
Hello,
I am learning block device drivers and have a newbie question. Given a block device, is there anyway that I could set its block size? For example, I want to write a block device driver that will work on an existing block device. In this driver, I want block size smaller. (The idea looks confusing but I could explain if anybody is interested :- ) However, typically the block size is 1KB, now I want to set it to 512 or 256. Can I do it?
TIA
Lei--
Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/