LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Problem in getting the physical block number for new file in EXT4 through cat/echo (http://www.linuxquestions.org/questions/linux-kernel-70/problem-in-getting-the-physical-block-number-for-new-file-in-ext4-through-cat-echo-4175446048/)

vinay18.patil 01-17-2013 11:17 AM

Problem in getting the physical block number for new file in EXT4 through cat/echo
 
Hi,
I am doing a project in EXT4 ,and I am facing one problem..

1)When I am creating a new file and writing into it through cat/echo, the functions(ext4_mb_new_blocks) of mballoc are not getting called,so I am not able to get the required physical block number..

However when doing the same with vim/gedit or even when overwriting the file with cat/echo the functions are getting called and I am able to get the required physical block number and when verifying it with blkcat the data gets printed properly...

Please help with this issue...

Mara 01-20-2013 08:57 AM

What happends when you write a small program yurself that just runs open(), write() and close() ?
Also, what command exactly you use with cat/echo?

vinay18.patil 01-20-2013 09:12 AM

My aim is to get the phy block number for the new file...
I have just written a simple prog say hello world in a.txt..
And I am running the command:
cat a.txt > b.txt
above command I am executing when b.txt is not there.

Now if b.txt has some data already ,then only I am able to get the phy. blk number of b.txt(by executing the abv command), otherwise not.

rknichols 01-20-2013 02:26 PM

When you run the command
Code:

cat a.txt > b.txt
the shell creates the empty file b.txt. Since nothing has yet been written to the file, no physical blocks have yet been allocated.

vinay18.patil 01-23-2013 01:12 PM

Quote:

Originally Posted by rknichols (Post 4874230)
When you run the command
Code:

cat a.txt > b.txt
the shell creates the empty file b.txt. Since nothing has yet been written to the file, no physical blocks have yet been allocated.

Ok b.txt is treated as a empty file, but since a.txt has some data, we are actually writing the data of a.txt to b.txt...so we should get the block number for b.txt???

rknichols 01-23-2013 03:39 PM

Yes, it certainly should. Sorry, but it is not clear exactly when and how you are trying to get the block number for b.txt.

vinay18.patil 01-24-2013 08:05 AM

Quote:

Originally Posted by rknichols (Post 4876403)
Yes, it certainly should. Sorry, but it is not clear exactly when and how you are trying to get the block number for b.txt.

We are trying to get the phy block number of b.txt through ext4_mb_new_blocks() in mballoc.c where actually you get the starting phy block number..we were getting phy blk no. when we are overwriting in b.txt through cat...
Now we are using vim since we were getting problem through cat...
Do you know the name of the buffer that vim uses ?..I want to edit its buffer size, since it is by default set to 8192 bytes..I am using Fedora 14...

rknichols 01-25-2013 11:23 AM

If you are checking during the write() call, it sounds like you are experiencing ext4 delayed allocation.

I've never looked into the internals of vim. Sorry.


All times are GMT -5. The time now is 09:29 PM.