public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lei Yang <lya755@ece.northwestern.edu>
To: Bijoy Thomas <bijoyjth@gwu.edu>
Cc: linux-kernel@vger.kernel.org, kernelnewbies <kernelnewbies@nl.linux.org>
Subject: Re: set blksize of block device
Date: Wed, 27 Oct 2004 22:42:17 -0500	[thread overview]
Message-ID: <41806A99.7060807@ece.northwestern.edu> (raw)
In-Reply-To: <55dddd455db643.55db64355dddd4@gwu.edu>

Thank you very much for your reply!

The problem is, I want to do all these stuff in kernel space. More 
specifically,  I want to use them in a newbie kernel module. In this 
module, I wanna do something with a raw block device (with no 
filesystem).  Below are some more questions regarding to your comments.  
Really appreciate your help!

Lei


Bijoy Thomas wrote:

>You set the blocksize for block device when you format it. For e.g, when you format a device with mkfs.ext2, you specify what block size you wish to use. This gets recorded in the superblock of the device. You can see what blocksize a device is using by running the tune2fs command with the deivce as an argument.
>  
>
What if I don'w want to format the device with a filesystem?

>Reading and writing a block on a device in userspace is as simple as opening the device, lseeking to the block in question and doing a read or write. Keep in mind that the filesystem blocksize has nothing to do with the blocksize for the device. The sector size for most block devices is 512 bytes. This means that the unit in which we can communicate with the device is 512bytes. However, the filesystem driver will have it own unit i.e, the blocksize. Hence, usually many sectors will fall in a block. The blocks are held in the buffer cache.The filesystem block size should be a power of 2 and less than the pagesize.
>
>In kernel space, reads and writes to blocks on the device are done through the function bread and block_read. Both functions are used to read blocks from a device. If you modify a block, you can set the buffer as dirty and the kernel will later write it to disk.
>  
>
Isn't there a bwrite similar to bread?

>Regards,
>Bijoy.
>
>
>----- Original Message -----
>From: Lei Yang <lya755@ece.northwestern.edu>
>Date: Wednesday, October 27, 2004 10:25 pm
>Subject: Re: set blksize of block device
>
>  
>
>>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
>>    
>>



  reply	other threads:[~2004-10-28  3:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-28  3:34 set blksize of block device Bijoy Thomas
2004-10-28  3:42 ` Lei Yang [this message]
2004-11-01 13:55 ` Jon Masters
  -- strict thread matches above, loose matches on Subject: below --
2004-10-28  6:07 gopu.bhaskar
2004-10-27 18:19 Lei Yang
2004-10-27 18:30 ` Lei Yang
2004-10-28  1:44   ` Lei Yang
2004-10-28  2:25     ` Lei Yang
2004-10-28  6:11       ` Denis Vlasenko
2004-10-28 21:20         ` Lei Yang
2004-10-28 21:50           ` Todd Poynor
2004-10-28  6:09     ` Denis Vlasenko
2004-10-28 16:35     ` Shesha B.  Sreenivasamurthy
2004-10-28 21:04       ` Lei Yang

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=41806A99.7060807@ece.northwestern.edu \
    --to=lya755@ece.northwestern.edu \
    --cc=bijoyjth@gwu.edu \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-kernel@vger.kernel.org \
    /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