From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rohit Sharma" Subject: Copying Data Blocks Date: Tue, 6 Jan 2009 16:06:59 +0530 Message-ID: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: ext4 , Kernelnewbies Return-path: Received: from rv-out-0506.google.com ([209.85.198.233]:24177 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751346AbZAFKhB (ORCPT ); Tue, 6 Jan 2009 05:37:01 -0500 Received: by rv-out-0506.google.com with SMTP id k40so7289647rvb.1 for ; Tue, 06 Jan 2009 02:37:00 -0800 (PST) Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: 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.? From mboxrd@z Thu Jan 1 00:00:00 1970 From: kanishk rastogi Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 16:51:12 +0530 (IST) Message-ID: <778827.10633.qm@web94905.mail.in2.yahoo.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0-893550176-1231240872=:10633" To: Rohit Sharma , ext4 , Kernelnewbies Return-path: Sender: kernelnewbies-bounce@nl.linux.org Errors-to: kernelnewbies-bounce@nl.linux.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: List-Id: linux-ext4.vger.kernel.org --0-893550176-1231240872=:10633 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable there is one operation called send_file() (i dont know the corresponding sy= s call for it ...)=0A=0A=0Ai think its ment to do what u want to do ...=0At= hankx=0Akanishk=0A=0A=0A=0A________________________________=0AFrom: Rohit S= harma =0ATo: ext4 ; Kerne= lnewbies =0ASent: Tuesday, 6 January, 2009 4:06= :59 PM=0ASubject: Copying Data Blocks=0A=0AI want to read data blocks from = one inode=0Aand copy it to other inode.=0A=0AI mean to copy data from data = blocks associated with one inode=0Ato the data blocks associated with other= inode.=0A=0AIs that possible in kernel space.?=0A=0A--=0ATo unsubscribe fr= om this list: send an email with=0A"unsubscribe kernelnewbies" to ecartis@n= l.linux.org=0APlease read the FAQ at http://kernelnewbies.org/FAQ=0A=0A=0A = Get rid of Add-Ons in your email ID. Get yourname@rocketmail.com. Sign= up now! http://in.promos.yahoo.com/address --0-893550176-1231240872=:10633 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
there is one operation called send_file() (i dont know th= e 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>; Kern= elnewbies <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 dat= a blocks associated with other inode.

Is that possible in kernel spa= ce.?

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


=0A=0A=0A
Get perfect Email ID for your Resume. Get before others grab. --0-893550176-1231240872=:10633-- -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Manish Katiyar" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 18:54:49 +0530 Message-ID: References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: ext4 , Kernelnewbies To: "Rohit Sharma" Return-path: Received: from ti-out-0910.google.com ([209.85.142.190]:52454 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751723AbZAFN0T (ORCPT ); Tue, 6 Jan 2009 08:26:19 -0500 Received: by ti-out-0910.google.com with SMTP id b6so9821126tic.23 for ; Tue, 06 Jan 2009 05:24:49 -0800 (PST) In-Reply-To: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: "rishi agrawal" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 19:42:34 +0530 Message-ID: <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_186753_25025349.1231251154659" Cc: "Rohit Sharma" , ext4 , Kernelnewbies To: "Manish Katiyar" Return-path: In-Reply-To: Sender: kernelnewbies-bounce@nl.linux.org Errors-to: kernelnewbies-bounce@nl.linux.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: List-Id: linux-ext4.vger.kernel.org ------=_Part_186753_25025349.1231251154659 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 wrote: > On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 ------=_Part_186753_25025349.1231251154659 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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

------=_Part_186753_25025349.1231251154659-- -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rohit Sharma" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 22:15:33 +0530 Message-ID: <2d08ef090901060845t85ac2b0i11c684a09d930608@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Manish Katiyar" , ext4 , Kernelnewbies To: "rishi agrawal" Return-path: Received: from rn-out-0910.google.com ([64.233.170.190]:41451 "EHLO rn-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbZAFQpe (ORCPT ); Tue, 6 Jan 2009 11:45:34 -0500 Received: by rn-out-0910.google.com with SMTP id k40so5399664rnd.17 for ; Tue, 06 Jan 2009 08:45:33 -0800 (PST) In-Reply-To: <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal 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 wrote: >> >> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 > > From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Manish Katiyar" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 22:43:00 +0530 Message-ID: References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> <2d08ef090901060845t85ac2b0i11c684a09d930608@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "rishi agrawal" , ext4 , Kernelnewbies To: "Rohit Sharma" Return-path: Received: from ti-out-0910.google.com ([209.85.142.191]:8189 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbZAFRNE (ORCPT ); Tue, 6 Jan 2009 12:13:04 -0500 Received: by ti-out-0910.google.com with SMTP id b6so9863685tic.23 for ; Tue, 06 Jan 2009 09:13:00 -0800 (PST) In-Reply-To: <2d08ef090901060845t85ac2b0i11c684a09d930608@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma wrote: > On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal 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 wrote: >>> >>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 >> >> > From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rohit Sharma" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 22:46:47 +0530 Message-ID: <2d08ef090901060916y4c49884dy4b44d6354b11ebb8@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> <2d08ef090901060845t85ac2b0i11c684a09d930608@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "rishi agrawal" , ext4 , Kernelnewbies To: "Manish Katiyar" Return-path: Received: from an-out-0708.google.com ([209.85.132.240]:16314 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751848AbZAFRQt (ORCPT ); Tue, 6 Jan 2009 12:16:49 -0500 Received: by an-out-0708.google.com with SMTP id d40so2555395and.1 for ; Tue, 06 Jan 2009 09:16:47 -0800 (PST) In-Reply-To: Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar wrote: > On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma wrote: >> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal 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 wrote: >>>> >>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 >>> >>> >> > From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rohit Sharma" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 22:55:23 +0530 Message-ID: <2d08ef090901060925p685506abkdc722c4099b485c7@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> <2d08ef090901060845t85ac2b0i11c684a09d930608@mail.gmail.com> <2d08ef090901060916y4c49884dy4b44d6354b11ebb8@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "rishi agrawal" , ext4 , Kernelnewbies To: "Manish Katiyar" Return-path: Received: from mail-gx0-f16.google.com ([209.85.217.16]:56230 "EHLO mail-gx0-f16.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751064AbZAFRZZ (ORCPT ); Tue, 6 Jan 2009 12:25:25 -0500 Received: by gxk9 with SMTP id 9so5772816gxk.8 for ; Tue, 06 Jan 2009 09:25:23 -0800 (PST) In-Reply-To: <2d08ef090901060916y4c49884dy4b44d6354b11ebb8@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: 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 wrote: > On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar wrote: >> On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma wrote: >>> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal 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 wrote: >>>>> >>>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 >>>> >>>> >>> >> > From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Manish Katiyar" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 22:58:13 +0530 Message-ID: References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> <2d08ef090901060845t85ac2b0i11c684a09d930608@mail.gmail.com> <2d08ef090901060916y4c49884dy4b44d6354b11ebb8@mail.gmail.com> <2d08ef090901060925p685506abkdc722c4099b485c7@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "rishi agrawal" , ext4 , Kernelnewbies To: "Rohit Sharma" Return-path: Received: from ti-out-0910.google.com ([209.85.142.191]:9479 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751403AbZAFR2P (ORCPT ); Tue, 6 Jan 2009 12:28:15 -0500 Received: by ti-out-0910.google.com with SMTP id b6so9866024tic.23 for ; Tue, 06 Jan 2009 09:28:13 -0800 (PST) In-Reply-To: <2d08ef090901060925p685506abkdc722c4099b485c7@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: On Tue, Jan 6, 2009 at 10:55 PM, Rohit Sharma 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 wrote: >> On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar wrote: >>> On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma wrote: >>>> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal 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 wrote: >>>>>> >>>>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 >>>>> >>>>> >>>> >>> >> > From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rohit Sharma" Subject: Re: Copying Data Blocks Date: Tue, 6 Jan 2009 23:06:16 +0530 Message-ID: <2d08ef090901060936r1c9f4eddxc188b8ef943c71f5@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <5feb302e0901060612p4e114953pb6e297778aa7c0a4@mail.gmail.com> <2d08ef090901060845t85ac2b0i11c684a09d930608@mail.gmail.com> <2d08ef090901060916y4c49884dy4b44d6354b11ebb8@mail.gmail.com> <2d08ef090901060925p685506abkdc722c4099b485c7@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "rishi agrawal" , ext4 , Kernelnewbies To: "Manish Katiyar" Return-path: Received: from wf-out-1314.google.com ([209.85.200.172]:30762 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751009AbZAFRgR (ORCPT ); Tue, 6 Jan 2009 12:36:17 -0500 Received: by wf-out-1314.google.com with SMTP id 27so8242306wfd.4 for ; Tue, 06 Jan 2009 09:36:16 -0800 (PST) In-Reply-To: Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: On Tue, Jan 6, 2009 at 10:58 PM, Manish Katiyar wrote: > On Tue, Jan 6, 2009 at 10:55 PM, Rohit Sharma 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 wrote: >>> On Tue, Jan 6, 2009 at 10:43 PM, Manish Katiyar wrote: >>>> On Tue, Jan 6, 2009 at 10:15 PM, Rohit Sharma wrote: >>>>> On Tue, Jan 6, 2009 at 7:42 PM, rishi agrawal 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 wrote: >>>>>>> >>>>>>> On Tue, Jan 6, 2009 at 4:06 PM, Rohit Sharma 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 >>>>>> >>>>>> >>>>> >>>> >>> >> > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Teoh Subject: Re: Copying Data Blocks Date: Sun, 11 Jan 2009 23:11:39 +0800 Message-ID: <804dabb00901110711w5061ccedha982792e73d7de1b@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd1d53a2fefd3046036685a Cc: ext4 , Kernelnewbies To: Rohit Sharma Return-path: In-Reply-To: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Sender: kernelnewbies-bounce@nl.linux.org Errors-to: kernelnewbies-bounce@nl.linux.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: List-Id: linux-ext4.vger.kernel.org --000e0cd1d53a2fefd3046036685a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 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 --000e0cd1d53a2fefd3046036685a Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Here are some tips on the blockdevice API:

http://lkml.org/lkml/2006/1/24/287<= /a>
http://linux.derkeiler.com/Mailing-Lists/Kernel/2006-01/msg09= 388.html

as indicated, documentation is rather sparse in this area.

not s= ure if anyone else have a summary list of blockdevice API and its explanati= on?

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&q= uot; in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



--
Regards,
Pete= r Teoh
--000e0cd1d53a2fefd3046036685a-- -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Teoh Subject: Re: Copying Data Blocks Date: Sun, 11 Jan 2009 23:15:24 +0800 Message-ID: <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: ext4 , Kernelnewbies To: Rohit Sharma Return-path: Received: from rv-out-0506.google.com ([209.85.198.229]:52443 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221AbZAKPPZ (ORCPT ); Sun, 11 Jan 2009 10:15:25 -0500 Received: by rv-out-0506.google.com with SMTP id k40so9858710rvb.1 for ; Sun, 11 Jan 2009 07:15:24 -0800 (PST) In-Reply-To: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> Sender: linux-ext4-owner@vger.kernel.org List-ID: 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rohit Sharma" Subject: Re: Copying Data Blocks Date: Mon, 12 Jan 2009 11:48:26 +0530 Message-ID: <2d08ef090901112218v1c6820d7q98d39af1350a07a0@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: ext4 , Kernelnewbies To: "Peter Teoh" Return-path: Received: from rv-out-0506.google.com ([209.85.198.238]:57164 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751253AbZALGS1 (ORCPT ); Mon, 12 Jan 2009 01:18:27 -0500 Received: by rv-out-0506.google.com with SMTP id k40so10079999rvb.1 for ; Sun, 11 Jan 2009 22:18:26 -0800 (PST) In-Reply-To: <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: 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 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 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 > From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sandeep K Sinha" Subject: Re: Copying Data Blocks Date: Mon, 12 Jan 2009 12:18:01 +0530 Message-ID: <37d33d830901112248r1616865aye537b5ff3f72780f@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Rohit Sharma" , ext4 , Kernelnewbies To: "Peter Teoh" Return-path: Received: from wa-out-1112.google.com ([209.85.146.183]:59700 "EHLO wa-out-1112.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752642AbZALGsD (ORCPT ); Mon, 12 Jan 2009 01:48:03 -0500 Received: by wa-out-1112.google.com with SMTP id v27so5519154wah.21 for ; Sun, 11 Jan 2009 22:48:01 -0800 (PST) In-Reply-To: <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: 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 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 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." From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sandeep K Sinha" Subject: Re: Copying Data Blocks Date: Mon, 12 Jan 2009 12:26:42 +0530 Message-ID: <37d33d830901112256g4aecafc0h9e5cdb08f268e6ab@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> <2d08ef090901112218v1c6820d7q98d39af1350a07a0@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Peter Teoh" , ext4 , Kernelnewbies To: "Rohit Sharma" Return-path: Received: from wa-out-1112.google.com ([209.85.146.177]:60357 "EHLO wa-out-1112.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752081AbZALG4n (ORCPT ); Mon, 12 Jan 2009 01:56:43 -0500 Received: by wa-out-1112.google.com with SMTP id v27so5520498wah.21 for ; Sun, 11 Jan 2009 22:56:42 -0800 (PST) In-Reply-To: <2d08ef090901112218v1c6820d7q98d39af1350a07a0@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: Hi Rohit, On Mon, Jan 12, 2009 at 11:48 AM, Rohit Sharma 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 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 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." From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Teoh Subject: Re: Copying Data Blocks Date: Mon, 12 Jan 2009 15:41:34 +0800 Message-ID: <804dabb00901112341m57cd7693y47dd2f713e6a4b31@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> <2d08ef090901112218v1c6820d7q98d39af1350a07a0@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: ext4 , Kernelnewbies To: Rohit Sharma Return-path: Received: from rv-out-0506.google.com ([209.85.198.237]:57389 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751674AbZALHlg (ORCPT ); Mon, 12 Jan 2009 02:41:36 -0500 Received: by rv-out-0506.google.com with SMTP id k40so10102672rvb.1 for ; Sun, 11 Jan 2009 23:41:35 -0800 (PST) In-Reply-To: <2d08ef090901112218v1c6820d7q98d39af1350a07a0@mail.gmail.com> Sender: linux-ext4-owner@vger.kernel.org List-ID: 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 * * 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 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 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 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 From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Sandeep K Sinha" Subject: Re: Copying Data Blocks Date: Mon, 12 Jan 2009 13:56:17 +0530 Message-ID: <37d33d830901120026k17beebc6h1c4eb932dd75d06d@mail.gmail.com> References: <2d08ef090901060236p46d4d396x797e4bceb24a2a34@mail.gmail.com> <804dabb00901110715x2baf84e8kc0fc5d6fa2512fe8@mail.gmail.com> <2d08ef090901112218v1c6820d7q98d39af1350a07a0@mail.gmail.com> <804dabb00901112341m57cd7693y47dd2f713e6a4b31@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: "Rohit Sharma" , ext4 , Kernelnewbies To: "Peter Teoh" Return-path: Received: from rv-out-0506.google.com ([209.85.198.231]:2740 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbZALI0S (ORCPT ); Mon, 12 Jan 2009 03:26:18 -0500 Received: by rv-out-0506.google.com with SMTP id k40so10114659rvb.1 for ; Mon, 12 Jan 2009 00:26:17 -0800 (PST) In-Reply-To: <804dabb00901112341m57cd7693y47dd2f713e6a4b31@mail.gmail.com> Content-Disposition: inline Sender: linux-ext4-owner@vger.kernel.org List-ID: 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 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 > > * > * 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 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 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 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."