All of lore.kernel.org
 help / color / mirror / Atom feed
* Copying Data Blocks
@ 2009-01-06 10:36 Rohit Sharma
  2009-01-06 11:21 ` kanishk rastogi
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Rohit Sharma @ 2009-01-06 10:36 UTC (permalink / raw)
  To: ext4, Kernelnewbies

I want to read data blocks from one inode
and copy it to other inode.

I mean to copy data from data blocks associated with one inode
to the data blocks associated with other inode.

Is that possible in kernel space.?

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

* Re: Copying Data Blocks
  2009-01-06 10:36 Copying Data Blocks Rohit Sharma
@ 2009-01-06 11:21 ` kanishk rastogi
  2009-01-06 13:24 ` Manish Katiyar
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: kanishk rastogi @ 2009-01-06 11:21 UTC (permalink / raw)
  To: Rohit Sharma, ext4, Kernelnewbies

[-- Attachment #1: Type: text/plain, Size: 914 bytes --]

there is one operation called send_file() (i dont know the corresponding sys call for it ...)


i think its ment to do what u want to do ...
thankx
kanishk



________________________________
From: Rohit Sharma <imreckless@gmail.com>
To: ext4 <linux-ext4@vger.kernel.org>; Kernelnewbies <kernelnewbies@nl.linux.org>
Sent: Tuesday, 6 January, 2009 4:06:59 PM
Subject: Copying Data Blocks

I want to read data blocks from one inode
and copy it to other inode.

I mean to copy data from data blocks associated with one inode
to the data blocks associated with other inode.

Is that possible in kernel space.?

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ


      Get rid of Add-Ons in your email ID. Get yourname@rocketmail.com. Sign up now! http://in.promos.yahoo.com/address

[-- Attachment #2: Type: text/html, Size: 1757 bytes --]

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

* Re: Copying Data Blocks
  2009-01-06 10:36 Copying Data Blocks Rohit Sharma
  2009-01-06 11:21 ` kanishk rastogi
@ 2009-01-06 13:24 ` Manish Katiyar
  2009-01-06 14:12   ` rishi agrawal
  2009-01-11 15:11 ` Peter Teoh
  2009-01-11 15:15 ` Peter Teoh
  3 siblings, 1 reply; 17+ messages in thread
From: Manish Katiyar @ 2009-01-06 13:24 UTC (permalink / raw)
  To: Rohit Sharma; +Cc: ext4, Kernelnewbies

On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
> I want to read data blocks from one inode
> and copy it to other inode.
>
> I mean to copy data from data blocks associated with one inode
> to the data blocks associated with other inode.

Copying 4K chunk of data itself is a costly operation. and depending
on the size of your donor inode this can be huge . Why do you want to
do that ? Do you know the inode of the donor inode ?

thanks -
Manish
>
> Is that possible in kernel space.?
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" 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] 17+ messages in thread

* Re: Copying Data Blocks
  2009-01-06 13:24 ` Manish Katiyar
@ 2009-01-06 14:12   ` rishi agrawal
  2009-01-06 16:45     ` Rohit Sharma
  0 siblings, 1 reply; 17+ messages in thread
From: rishi agrawal @ 2009-01-06 14:12 UTC (permalink / raw)
  To: Manish Katiyar; +Cc: Rohit Sharma, ext4, Kernelnewbies

[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]

yes i suppose the donor inode is known
moreover the receiver inode's number is also known

On Tue, Jan 6, 2009 at 6:54 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:

> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
> > I want to read data blocks from one inode
> > and copy it to other inode.
> >
> > I mean to copy data from data blocks associated with one inode
> > to the data blocks associated with other inode.
>
> Copying 4K chunk of data itself is a costly operation. and depending
> on the size of your donor inode this can be huge . Why do you want to
> do that ? Do you know the inode of the donor inode ?
>
> thanks -
> Manish
> >
> > Is that possible in kernel space.?
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Regards,
Rishi B. Agrawal

[-- Attachment #2: Type: text/html, Size: 1957 bytes --]

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

* Re: Copying Data Blocks
  2009-01-06 14:12   ` rishi agrawal
@ 2009-01-06 16:45     ` Rohit Sharma
  2009-01-06 17:13       ` Manish Katiyar
  0 siblings, 1 reply; 17+ messages in thread
From: Rohit Sharma @ 2009-01-06 16:45 UTC (permalink / raw)
  To: rishi agrawal; +Cc: Manish Katiyar, ext4, Kernelnewbies

On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal <postrishi@gmail.com> wrote:
> yes i suppose the donor inode is known
> moreover the receiver inode's number is also known
>
> On Tue, Jan 6, 2009 at 6:54 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>
>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>> > I want to read data blocks from one inode
>> > and copy it to other inode.
>> >
>> > I mean to copy data from data blocks associated with one inode
>> > to the data blocks associated with other inode.
>>
>> Copying 4K chunk of data itself is a costly operation. and depending

Yes its a costly operation, but if this can be done then
we can definitely copy n blocks at a time.

>> on the size of your donor inode this can be huge . Why do you want to
>> do that ? Do you know the inode of the donor inode ?

For physically relocating a file from one disk to other.

Yes Manish, i know the donor inode and i will create the reciever inode.

Can we do that in kernel space.?
>>
>> thanks -
>> Manish
>> >
>> > Is that possible in kernel space.?
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> >
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Regards,
> Rishi B. Agrawal
>
>

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

* Re: Copying Data Blocks
  2009-01-06 16:45     ` Rohit Sharma
@ 2009-01-06 17:13       ` Manish Katiyar
  2009-01-06 17:16         ` Rohit Sharma
  0 siblings, 1 reply; 17+ messages in thread
From: Manish Katiyar @ 2009-01-06 17:13 UTC (permalink / raw)
  To: Rohit Sharma; +Cc: rishi agrawal, ext4, Kernelnewbies

On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma <imreckless@gmail.com> wrote:
> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal <postrishi@gmail.com> wrote:
>> yes i suppose the donor inode is known
>> moreover the receiver inode's number is also known
>>
>> On Tue, Jan 6, 2009 at 6:54 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>>
>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>> > I want to read data blocks from one inode
>>> > and copy it to other inode.
>>> >
>>> > I mean to copy data from data blocks associated with one inode
>>> > to the data blocks associated with other inode.
>>>
>>> Copying 4K chunk of data itself is a costly operation. and depending
>
> Yes its a costly operation, but if this can be done then
> we can definitely copy n blocks at a time.
>
>>> on the size of your donor inode this can be huge . Why do you want to
>>> do that ? Do you know the inode of the donor inode ?
>
> For physically relocating a file from one disk to other.
>
> Yes Manish, i know the donor inode and i will create the reciever inode.

I am guessing .......will something like this work ?

ino_t donor_inode_num;
struct inode *donor_inode = FS_iget(sb , donor_inode_num);
struct FS_inode_info * fsi = FSI(donor_inode) ;   // Do the regular
container_of stuff here

for ( i = 0; i < (donor_inode->i_size + sb->s_blocksize -
1)/sb->s_blocksize ; i ++ ) {
    // Do a memmove or memcpy here from fsi->i_data[i]
}

I am not sure though how will you prevent the donor inode from being
changed/resized during this period.

Thanks -
Manish


>
> Can we do that in kernel space.?
>>>
>>> thanks -
>>> Manish
>>> >
>>> > Is that possible in kernel space.?
>>> > --
>>> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>> > the body of a message to majordomo@vger.kernel.org
>>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>> >
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>
>>
>> --
>> Regards,
>> Rishi B. Agrawal
>>
>>
>

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

* Re: Copying Data Blocks
  2009-01-06 17:13       ` Manish Katiyar
@ 2009-01-06 17:16         ` Rohit Sharma
  2009-01-06 17:25           ` Rohit Sharma
  0 siblings, 1 reply; 17+ messages in thread
From: Rohit Sharma @ 2009-01-06 17:16 UTC (permalink / raw)
  To: Manish Katiyar; +Cc: rishi agrawal, ext4, Kernelnewbies

On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
> On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal <postrishi@gmail.com> wrote:
>>> yes i suppose the donor inode is known
>>> moreover the receiver inode's number is also known
>>>
>>> On Tue, Jan 6, 2009 at 6:54 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>>>
>>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>> > I want to read data blocks from one inode
>>>> > and copy it to other inode.
>>>> >
>>>> > I mean to copy data from data blocks associated with one inode
>>>> > to the data blocks associated with other inode.
>>>>
>>>> Copying 4K chunk of data itself is a costly operation. and depending
>>
>> Yes its a costly operation, but if this can be done then
>> we can definitely copy n blocks at a time.
>>
>>>> on the size of your donor inode this can be huge . Why do you want to
>>>> do that ? Do you know the inode of the donor inode ?
>>
>> For physically relocating a file from one disk to other.
>>
>> Yes Manish, i know the donor inode and i will create the reciever inode.
>
> I am guessing .......will something like this work ?
>
> ino_t donor_inode_num;
> struct inode *donor_inode = FS_iget(sb , donor_inode_num);
> struct FS_inode_info * fsi = FSI(donor_inode) ;   // Do the regular
> container_of stuff here
>
> for ( i = 0; i < (donor_inode->i_size + sb->s_blocksize -
> 1)/sb->s_blocksize ; i ++ ) {
>    // Do a memmove or memcpy here from fsi->i_data[i]
> }
>
> I am not sure though how will you prevent the donor inode from being
> changed/resized during this period.

I am thinking of remounting ext2 in readonly mode, or i'll change the
mount flags to readonly. But i m not sure if internally i can copy the
data from one block to other.

>
> Thanks -
> Manish
>
>
>>
>> Can we do that in kernel space.?
>>>>
>>>> thanks -
>>>> Manish
>>>> >
>>>> > Is that possible in kernel space.?
>>>> > --
>>>> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>> > the body of a message to majordomo@vger.kernel.org
>>>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>> >
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Rishi B. Agrawal
>>>
>>>
>>
>

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

* Re: Copying Data Blocks
  2009-01-06 17:16         ` Rohit Sharma
@ 2009-01-06 17:25           ` Rohit Sharma
  2009-01-06 17:28             ` Manish Katiyar
  0 siblings, 1 reply; 17+ messages in thread
From: Rohit Sharma @ 2009-01-06 17:25 UTC (permalink / raw)
  To: Manish Katiyar; +Cc: rishi agrawal, ext4, Kernelnewbies

We can find out no. of block currently being used by the donor inode,
The data we read from donor inode has to be in some buffer or page,
is there a way we can associate this buffer with the reciever inode
or write the contents of the buffer to the new inode.


On Tue, Jan 6, 2009 at 10:46 PM, Rohit Sharma <imreckless@gmail.com> wrote:
> On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>> On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal <postrishi@gmail.com> wrote:
>>>> yes i suppose the donor inode is known
>>>> moreover the receiver inode's number is also known
>>>>
>>>> On Tue, Jan 6, 2009 at 6:54 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>>>>
>>>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>>> > I want to read data blocks from one inode
>>>>> > and copy it to other inode.
>>>>> >
>>>>> > I mean to copy data from data blocks associated with one inode
>>>>> > to the data blocks associated with other inode.
>>>>>
>>>>> Copying 4K chunk of data itself is a costly operation. and depending
>>>
>>> Yes its a costly operation, but if this can be done then
>>> we can definitely copy n blocks at a time.
>>>
>>>>> on the size of your donor inode this can be huge . Why do you want to
>>>>> do that ? Do you know the inode of the donor inode ?
>>>
>>> For physically relocating a file from one disk to other.
>>>
>>> Yes Manish, i know the donor inode and i will create the reciever inode.
>>
>> I am guessing .......will something like this work ?
>>
>> ino_t donor_inode_num;
>> struct inode *donor_inode = FS_iget(sb , donor_inode_num);
>> struct FS_inode_info * fsi = FSI(donor_inode) ;   // Do the regular
>> container_of stuff here
>>
>> for ( i = 0; i < (donor_inode->i_size + sb->s_blocksize -
>> 1)/sb->s_blocksize ; i ++ ) {
>>    // Do a memmove or memcpy here from fsi->i_data[i]
>> }
>>
>> I am not sure though how will you prevent the donor inode from being
>> changed/resized during this period.
>
> I am thinking of remounting ext2 in readonly mode, or i'll change the
> mount flags to readonly. But i m not sure if internally i can copy the
> data from one block to other.
>
>>
>> Thanks -
>> Manish
>>
>>
>>>
>>> Can we do that in kernel space.?
>>>>>
>>>>> thanks -
>>>>> Manish
>>>>> >
>>>>> > Is that possible in kernel space.?
>>>>> > --
>>>>> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>>> > the body of a message to majordomo@vger.kernel.org
>>>>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>> >
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>>> the body of a message to majordomo@vger.kernel.org
>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>
>>>>
>>>>
>>>> --
>>>> Regards,
>>>> Rishi B. Agrawal
>>>>
>>>>
>>>
>>
>

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

* Re: Copying Data Blocks
  2009-01-06 17:25           ` Rohit Sharma
@ 2009-01-06 17:28             ` Manish Katiyar
  2009-01-06 17:36               ` Rohit Sharma
  0 siblings, 1 reply; 17+ messages in thread
From: Manish Katiyar @ 2009-01-06 17:28 UTC (permalink / raw)
  To: Rohit Sharma; +Cc: rishi agrawal, ext4, Kernelnewbies

On Tue, Jan 6, 2009 at 10:55 PM, Rohit Sharma <imreckless@gmail.com> wrote:
> We can find out no. of block currently being used by the donor inode,
> The data we read from donor inode has to be in some buffer or page,

Since we know the blocknumber of donor inode, it should be possible to
do a raw read and get the memory address of the data page using
sb_bread() and then accessing bh->b_data . Isn't it ?

Thanks -
Manish

> is there a way we can associate this buffer with the reciever inode
> or write the contents of the buffer to the new inode.
>
>
> On Tue, Jan 6, 2009 at 10:46 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>> On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>> On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal <postrishi@gmail.com> wrote:
>>>>> yes i suppose the donor inode is known
>>>>> moreover the receiver inode's number is also known
>>>>>
>>>>> On Tue, Jan 6, 2009 at 6:54 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>>>>>
>>>>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>>>> > I want to read data blocks from one inode
>>>>>> > and copy it to other inode.
>>>>>> >
>>>>>> > I mean to copy data from data blocks associated with one inode
>>>>>> > to the data blocks associated with other inode.
>>>>>>
>>>>>> Copying 4K chunk of data itself is a costly operation. and depending
>>>>
>>>> Yes its a costly operation, but if this can be done then
>>>> we can definitely copy n blocks at a time.
>>>>
>>>>>> on the size of your donor inode this can be huge . Why do you want to
>>>>>> do that ? Do you know the inode of the donor inode ?
>>>>
>>>> For physically relocating a file from one disk to other.
>>>>
>>>> Yes Manish, i know the donor inode and i will create the reciever inode.
>>>
>>> I am guessing .......will something like this work ?
>>>
>>> ino_t donor_inode_num;
>>> struct inode *donor_inode = FS_iget(sb , donor_inode_num);
>>> struct FS_inode_info * fsi = FSI(donor_inode) ;   // Do the regular
>>> container_of stuff here
>>>
>>> for ( i = 0; i < (donor_inode->i_size + sb->s_blocksize -
>>> 1)/sb->s_blocksize ; i ++ ) {
>>>    // Do a memmove or memcpy here from fsi->i_data[i]
>>> }
>>>
>>> I am not sure though how will you prevent the donor inode from being
>>> changed/resized during this period.
>>
>> I am thinking of remounting ext2 in readonly mode, or i'll change the
>> mount flags to readonly. But i m not sure if internally i can copy the
>> data from one block to other.
>>
>>>
>>> Thanks -
>>> Manish
>>>
>>>
>>>>
>>>> Can we do that in kernel space.?
>>>>>>
>>>>>> thanks -
>>>>>> Manish
>>>>>> >
>>>>>> > Is that possible in kernel space.?
>>>>>> > --
>>>>>> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>>>> > the body of a message to majordomo@vger.kernel.org
>>>>>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>> >
>>>>>> --
>>>>>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Regards,
>>>>> Rishi B. Agrawal
>>>>>
>>>>>
>>>>
>>>
>>
>

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

* Re: Copying Data Blocks
  2009-01-06 17:28             ` Manish Katiyar
@ 2009-01-06 17:36               ` Rohit Sharma
  0 siblings, 0 replies; 17+ messages in thread
From: Rohit Sharma @ 2009-01-06 17:36 UTC (permalink / raw)
  To: Manish Katiyar; +Cc: rishi agrawal, ext4, Kernelnewbies

On Tue, Jan 6, 2009 at 10:58 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
> On Tue, Jan 6, 2009 at 10:55 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>> We can find out no. of block currently being used by the donor inode,
>> The data we read from donor inode has to be in some buffer or page,
>
> Since we know the blocknumber of donor inode, it should be possible to
> do a raw read and get the memory address of the data page using
> sb_bread() and then accessing bh->b_data . Isn't it ?

Yes that's the way we can read blocks but the major issue here
is copying this content to newly allocated block.
>
> Thanks -
> Manish
>
>> is there a way we can associate this buffer with the reciever inode
>> or write the contents of the buffer to the new inode.
>>
>>
>> On Tue, Jan 6, 2009 at 10:46 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>> On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>>> On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>>> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal <postrishi@gmail.com> wrote:
>>>>>> yes i suppose the donor inode is known
>>>>>> moreover the receiver inode's number is also known
>>>>>>
>>>>>> On Tue, Jan 6, 2009 at 6:54 PM, Manish Katiyar <mkatiyar@gmail.com> wrote:
>>>>>>>
>>>>>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>>>>> > I want to read data blocks from one inode
>>>>>>> > and copy it to other inode.
>>>>>>> >
>>>>>>> > I mean to copy data from data blocks associated with one inode
>>>>>>> > to the data blocks associated with other inode.
>>>>>>>
>>>>>>> Copying 4K chunk of data itself is a costly operation. and depending
>>>>>
>>>>> Yes its a costly operation, but if this can be done then
>>>>> we can definitely copy n blocks at a time.
>>>>>
>>>>>>> on the size of your donor inode this can be huge . Why do you want to
>>>>>>> do that ? Do you know the inode of the donor inode ?
>>>>>
>>>>> For physically relocating a file from one disk to other.
>>>>>
>>>>> Yes Manish, i know the donor inode and i will create the reciever inode.
>>>>
>>>> I am guessing .......will something like this work ?
>>>>
>>>> ino_t donor_inode_num;
>>>> struct inode *donor_inode = FS_iget(sb , donor_inode_num);
>>>> struct FS_inode_info * fsi = FSI(donor_inode) ;   // Do the regular
>>>> container_of stuff here
>>>>
>>>> for ( i = 0; i < (donor_inode->i_size + sb->s_blocksize -
>>>> 1)/sb->s_blocksize ; i ++ ) {
>>>>    // Do a memmove or memcpy here from fsi->i_data[i]
>>>> }
>>>>
>>>> I am not sure though how will you prevent the donor inode from being
>>>> changed/resized during this period.
>>>
>>> I am thinking of remounting ext2 in readonly mode, or i'll change the
>>> mount flags to readonly. But i m not sure if internally i can copy the
>>> data from one block to other.
>>>
>>>>
>>>> Thanks -
>>>> Manish
>>>>
>>>>
>>>>>
>>>>> Can we do that in kernel space.?
>>>>>>>
>>>>>>> thanks -
>>>>>>> Manish
>>>>>>> >
>>>>>>> > Is that possible in kernel space.?
>>>>>>> > --
>>>>>>> > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>>>>> > the body of a message to majordomo@vger.kernel.org
>>>>>>> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>>> >
>>>>>>> --
>>>>>>> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
>>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Rishi B. Agrawal
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

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

* Re: Copying Data Blocks
  2009-01-06 10:36 Copying Data Blocks Rohit Sharma
  2009-01-06 11:21 ` kanishk rastogi
  2009-01-06 13:24 ` Manish Katiyar
@ 2009-01-11 15:11 ` Peter Teoh
  2009-01-11 15:15 ` Peter Teoh
  3 siblings, 0 replies; 17+ messages in thread
From: Peter Teoh @ 2009-01-11 15:11 UTC (permalink / raw)
  To: Rohit Sharma; +Cc: ext4, Kernelnewbies

[-- Attachment #1: Type: text/plain, Size: 842 bytes --]

Here are some tips on the blockdevice API:

http://lkml.org/lkml/2006/1/24/287
http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09388.html

as indicated, documentation is rather sparse in this area.

not sure if anyone else have a summary list of blockdevice API and its
explanation?

thanks.


On Tue, Jan 6, 2009 at 6:36 PM, Rohit Sharma <imreckless@gmail.com> wrote:

> I want to read data blocks from one inode
> and copy it to other inode.
>
> I mean to copy data from data blocks associated with one inode
> to the data blocks associated with other inode.
>
> Is that possible in kernel space.?
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
Regards,
Peter Teoh

[-- Attachment #2: Type: text/html, Size: 1542 bytes --]

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

* Re: Copying Data Blocks
  2009-01-06 10:36 Copying Data Blocks Rohit Sharma
                   ` (2 preceding siblings ...)
  2009-01-11 15:11 ` Peter Teoh
@ 2009-01-11 15:15 ` Peter Teoh
  2009-01-12  6:18   ` Rohit Sharma
  2009-01-12  6:48   ` Sandeep K Sinha
  3 siblings, 2 replies; 17+ messages in thread
From: Peter Teoh @ 2009-01-11 15:15 UTC (permalink / raw)
  To: Rohit Sharma; +Cc: ext4, Kernelnewbies

Sorry.....some mistakes...a resent:

Here are some tips on the blockdevice API:

http://lkml.org/lkml/2006/1/24/287
http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09388.html

as indicated, documentation is rather sparse in this area.

not sure if anyone else have a summary list of blockdevice API and its
explanation?

not wrt the following "cleanup patch", i am not sure how the API will change:

http://lwn.net/Articles/304485/

thanks.

On Tue, Jan 6, 2009 at 6:36 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>
> I want to read data blocks from one inode
> and copy it to other inode.
>
> I mean to copy data from data blocks associated with one inode
> to the data blocks associated with other inode.
>
> Is that possible in kernel space.?
> --



--
Regards,
Peter Teoh

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

* Re: Copying Data Blocks
  2009-01-11 15:15 ` Peter Teoh
@ 2009-01-12  6:18   ` Rohit Sharma
  2009-01-12  6:56     ` Sandeep K Sinha
  2009-01-12  7:41     ` Peter Teoh
  2009-01-12  6:48   ` Sandeep K Sinha
  1 sibling, 2 replies; 17+ messages in thread
From: Rohit Sharma @ 2009-01-12  6:18 UTC (permalink / raw)
  To: Peter Teoh; +Cc: ext4, Kernelnewbies

Hi,

I am having some issues in locking inode while copying data blocks.
We are trying to keep file system live during this operation, so
both read and write operations should work.
In this case what type of lock on inode should be used, semaphore,
mutex or spinlock?


On Sun, Jan 11, 2009 at 8:45 PM, Peter Teoh <htmldeveloper@gmail.com> wrote:
> Sorry.....some mistakes...a resent:
>
> Here are some tips on the blockdevice API:
>
> http://lkml.org/lkml/2006/1/24/287
> http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09388.html
>
> as indicated, documentation is rather sparse in this area.
>
> not sure if anyone else have a summary list of blockdevice API and its
> explanation?
>
> not wrt the following "cleanup patch", i am not sure how the API will change:
>
> http://lwn.net/Articles/304485/
>
> thanks.
>
> On Tue, Jan 6, 2009 at 6:36 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>
>> I want to read data blocks from one inode
>> and copy it to other inode.
>>
>> I mean to copy data from data blocks associated with one inode
>> to the data blocks associated with other inode.
>>
>> Is that possible in kernel space.?
>> --
>
>
>
> --
> Regards,
> Peter Teoh
>

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

* Re: Copying Data Blocks
  2009-01-11 15:15 ` Peter Teoh
  2009-01-12  6:18   ` Rohit Sharma
@ 2009-01-12  6:48   ` Sandeep K Sinha
  1 sibling, 0 replies; 17+ messages in thread
From: Sandeep K Sinha @ 2009-01-12  6:48 UTC (permalink / raw)
  To: Peter Teoh; +Cc: Rohit Sharma, ext4, Kernelnewbies

Hi Peter,

As our work veery tightly couples with the FS for our intial
implementation and we are working around with the inodes, we will
require to work at the filesystem level itself.
Though it may not be very feasible, but we will try to push everything
to the blockdev level once our base system is up and running.

Thanks a lot for your finding, I went through it and found that it
will be useful, but with some kind of tweaking around here and there.

We have taken note of the links that you have provided.

Thanks again.
On Sun, Jan 11, 2009 at 8:45 PM, Peter Teoh <htmldeveloper@gmail.com> wrote:
> Sorry.....some mistakes...a resent:
>
> Here are some tips on the blockdevice API:
>
> http://lkml.org/lkml/2006/1/24/287
> http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09388.html
>
> as indicated, documentation is rather sparse in this area.
>
> not sure if anyone else have a summary list of blockdevice API and its
> explanation?
>
> not wrt the following "cleanup patch", i am not sure how the API will change:
>
> http://lwn.net/Articles/304485/
>
> thanks.
>
> On Tue, Jan 6, 2009 at 6:36 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>
>> I want to read data blocks from one inode
>> and copy it to other inode.
>>
>> I mean to copy data from data blocks associated with one inode
>> to the data blocks associated with other inode.
>>
>> Is that possible in kernel space.?
>> --
>
>
>
> --
> Regards,
> Peter Teoh
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>



-- 
Regards,
Sandeep.





 	
"To learn is to change. Education is a process that changes the learner."

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

* Re: Copying Data Blocks
  2009-01-12  6:18   ` Rohit Sharma
@ 2009-01-12  6:56     ` Sandeep K Sinha
  2009-01-12  7:41     ` Peter Teoh
  1 sibling, 0 replies; 17+ messages in thread
From: Sandeep K Sinha @ 2009-01-12  6:56 UTC (permalink / raw)
  To: Rohit Sharma; +Cc: Peter Teoh, ext4, Kernelnewbies

Hi Rohit,

On Mon, Jan 12, 2009 at 11:48 AM, Rohit Sharma <imreckless@gmail.com> wrote:
> Hi,
>
> I am having some issues in locking inode while copying data blocks.
> We are trying to keep file system live during this operation, so
> both read and write operations should work.
> In this case what type of lock on inode should be used, semaphore,
> mutex or spinlock?
>

Now here you need to do some homework first.
Each of the locks have its own meaning and particular uses cases.

The current inode struct has the following locks:
1. i_lock
2. i_alloc_sem
3. i_mutex
4. i_flock

 646        spinlock_t              i_lock; /* i_blocks, i_bytes,
maybe i_size */
 647        struct mutex            i_mutex;
 648        struct rw_semaphore     i_alloc_sem;
 649        const struct inode_operations   *i_op;
 650        const struct file_operations    *i_fop; /* former
->i_op->default_file_ops */
 651        struct super_block      *i_sb;
 652        struct file_lock        *i_flock;

Read the difference between spinlock, mutex, and semaphore.
You will be able to understand the semantics of each of these.

>
> On Sun, Jan 11, 2009 at 8:45 PM, Peter Teoh <htmldeveloper@gmail.com> wrote:
>> Sorry.....some mistakes...a resent:
>>
>> Here are some tips on the blockdevice API:
>>
>> http://lkml.org/lkml/2006/1/24/287
>> http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09388.html
>>
>> as indicated, documentation is rather sparse in this area.
>>
>> not sure if anyone else have a summary list of blockdevice API and its
>> explanation?
>>
>> not wrt the following "cleanup patch", i am not sure how the API will change:
>>
>> http://lwn.net/Articles/304485/
>>
>> thanks.
>>
>> On Tue, Jan 6, 2009 at 6:36 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>
>>> I want to read data blocks from one inode
>>> and copy it to other inode.
>>>
>>> I mean to copy data from data blocks associated with one inode
>>> to the data blocks associated with other inode.
>>>
>>> Is that possible in kernel space.?
>>> --
>>
>>
>>
>> --
>> Regards,
>> Peter Teoh
>>
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>



-- 
Regards,
Sandeep.





 	
"To learn is to change. Education is a process that changes the learner."

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

* Re: Copying Data Blocks
  2009-01-12  6:18   ` Rohit Sharma
  2009-01-12  6:56     ` Sandeep K Sinha
@ 2009-01-12  7:41     ` Peter Teoh
  2009-01-12  8:26       ` Sandeep K Sinha
  1 sibling, 1 reply; 17+ messages in thread
From: Peter Teoh @ 2009-01-12  7:41 UTC (permalink / raw)
  To: Rohit Sharma; +Cc: ext4, Kernelnewbies

If u grep for spinlock, mutex, or "sem" in the fs/ext4 directory, u
can find all three types of lock are used - for different class of
object.

For data blocks I guessed is semaphore - read this
fs/ext4/inode.c:ext4_get_branch():

/**
 *      ext4_get_branch - read the chain of indirect blocks leading to data
<snip>
 *
 *      Need to be called with
 *      down_read(&EXT4_I(inode)->i_data_sem)
 */

i guess u have no choice, as it is semaphore, have to follow the rest
of kernel for consistency - don't create your own semaphore :-).

There exists i_lock as spinlock - which so far i know is for i_blocks
counting purposes:

       spin_lock(&inode->i_lock);
        inode->i_blocks += tmp_inode->i_blocks;
        spin_unlock(&inode->i_lock);
        up_write(&EXT4_I(inode)->i_data_sem);

But for data it should be i_data_sem.   Is that correct?

On Mon, Jan 12, 2009 at 2:18 PM, Rohit Sharma <imreckless@gmail.com> wrote:
> Hi,
>
> I am having some issues in locking inode while copying data blocks.
> We are trying to keep file system live during this operation, so
> both read and write operations should work.
> In this case what type of lock on inode should be used, semaphore,
> mutex or spinlock?
>
>
> On Sun, Jan 11, 2009 at 8:45 PM, Peter Teoh <htmldeveloper@gmail.com> wrote:
>> Sorry.....some mistakes...a resent:
>>
>> Here are some tips on the blockdevice API:
>>
>> http://lkml.org/lkml/2006/1/24/287
>> http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09388.html
>>
>> as indicated, documentation is rather sparse in this area.
>>
>> not sure if anyone else have a summary list of blockdevice API and its
>> explanation?
>>
>> not wrt the following "cleanup patch", i am not sure how the API will change:
>>
>> http://lwn.net/Articles/304485/
>>
>> thanks.
>>
>> On Tue, Jan 6, 2009 at 6:36 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>
>>> I want to read data blocks from one inode
>>> and copy it to other inode.
>>>
>>> I mean to copy data from data blocks associated with one inode
>>> to the data blocks associated with other inode.
>>>
>>> Is that possible in kernel space.?
>>> --
>>
>>
>>
>> --
>> Regards,
>> Peter Teoh
>>
>



-- 
Regards,
Peter Teoh

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

* Re: Copying Data Blocks
  2009-01-12  7:41     ` Peter Teoh
@ 2009-01-12  8:26       ` Sandeep K Sinha
  0 siblings, 0 replies; 17+ messages in thread
From: Sandeep K Sinha @ 2009-01-12  8:26 UTC (permalink / raw)
  To: Peter Teoh; +Cc: Rohit Sharma, ext4, Kernelnewbies

Hi Peter,

Don't you think that if will restrict this to a specific file system.
VFS inode should be used rather than the FS incore inode ?

The purpose if to sleep all the i/o's when we are updating the i_data
from the new inode to the old inode ( updation of the data blocks ).

I think i_alloc_sem should work here, but could not find any instance
of its use in the code.
It's working fine currently with i_mutex, meaning if we hold a i_mutex
lock on the inode while updating the i_data pointers.
And try to perform i/o from user space, they are queued. The file was
opened in r/w mode prior to taking the lock inside the kernel.

But, I still feel i_alloc_sem would be the right option to go ahead with.

On Mon, Jan 12, 2009 at 1:11 PM, Peter Teoh <htmldeveloper@gmail.com> wrote:
> If u grep for spinlock, mutex, or "sem" in the fs/ext4 directory, u
> can find all three types of lock are used - for different class of
> object.
>
> For data blocks I guessed is semaphore - read this
> fs/ext4/inode.c:ext4_get_branch():
>
> /**
>  *      ext4_get_branch - read the chain of indirect blocks leading to data
> <snip>
>  *
>  *      Need to be called with
>  *      down_read(&EXT4_I(inode)->i_data_sem)
>  */
>
> i guess u have no choice, as it is semaphore, have to follow the rest
> of kernel for consistency - don't create your own semaphore :-).
>
> There exists i_lock as spinlock - which so far i know is for i_blocks
> counting purposes:
>
>       spin_lock(&inode->i_lock);
>        inode->i_blocks += tmp_inode->i_blocks;
>        spin_unlock(&inode->i_lock);
>        up_write(&EXT4_I(inode)->i_data_sem);
>
> But for data it should be i_data_sem.   Is that correct?
>
> On Mon, Jan 12, 2009 at 2:18 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>> Hi,
>>
>> I am having some issues in locking inode while copying data blocks.
>> We are trying to keep file system live during this operation, so
>> both read and write operations should work.
>> In this case what type of lock on inode should be used, semaphore,
>> mutex or spinlock?
>>
>>
>> On Sun, Jan 11, 2009 at 8:45 PM, Peter Teoh <htmldeveloper@gmail.com> wrote:
>>> Sorry.....some mistakes...a resent:
>>>
>>> Here are some tips on the blockdevice API:
>>>
>>> http://lkml.org/lkml/2006/1/24/287
>>> http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09388.html
>>>
>>> as indicated, documentation is rather sparse in this area.
>>>
>>> not sure if anyone else have a summary list of blockdevice API and its
>>> explanation?
>>>
>>> not wrt the following "cleanup patch", i am not sure how the API will change:
>>>
>>> http://lwn.net/Articles/304485/
>>>
>>> thanks.
>>>
>>> On Tue, Jan 6, 2009 at 6:36 PM, Rohit Sharma <imreckless@gmail.com> wrote:
>>>>
>>>> I want to read data blocks from one inode
>>>> and copy it to other inode.
>>>>
>>>> I mean to copy data from data blocks associated with one inode
>>>> to the data blocks associated with other inode.
>>>>
>>>> Is that possible in kernel space.?
>>>> --
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Peter Teoh
>>>
>>
>
>
>
> --
> Regards,
> Peter Teoh
>
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@nl.linux.org
> Please read the FAQ at http://kernelnewbies.org/FAQ
>
>



-- 
Regards,
Sandeep.





 	
"To learn is to change. Education is a process that changes the learner."

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

end of thread, other threads:[~2009-01-12  8:26 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-06 10:36 Copying Data Blocks Rohit Sharma
2009-01-06 11:21 ` kanishk rastogi
2009-01-06 13:24 ` Manish Katiyar
2009-01-06 14:12   ` rishi agrawal
2009-01-06 16:45     ` Rohit Sharma
2009-01-06 17:13       ` Manish Katiyar
2009-01-06 17:16         ` Rohit Sharma
2009-01-06 17:25           ` Rohit Sharma
2009-01-06 17:28             ` Manish Katiyar
2009-01-06 17:36               ` Rohit Sharma
2009-01-11 15:11 ` Peter Teoh
2009-01-11 15:15 ` Peter Teoh
2009-01-12  6:18   ` Rohit Sharma
2009-01-12  6:56     ` Sandeep K Sinha
2009-01-12  7:41     ` Peter Teoh
2009-01-12  8:26       ` Sandeep K Sinha
2009-01-12  6:48   ` Sandeep K Sinha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.