LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 01-17-2013, 11:17 AM   #1
vinay18.patil
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Rep: Reputation: Disabled
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...
 
Old 01-20-2013, 08:57 AM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,533

Rep: Reputation: 148Reputation: 148
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?
 
Old 01-20-2013, 09:12 AM   #3
vinay18.patil
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-20-2013, 02:26 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,339

Rep: Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574
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.
 
1 members found this post helpful.
Old 01-23-2013, 01:12 PM   #5
vinay18.patil
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
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???
 
Old 01-23-2013, 03:39 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,339

Rep: Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574
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.
 
Old 01-24-2013, 08:05 AM   #7
vinay18.patil
LQ Newbie
 
Registered: Jan 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rknichols View Post
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...
 
Old 01-25-2013, 11:23 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 1,339

Rep: Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574Reputation: 574
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
store a block device information in sb_info struct of ext4 file system shwety1085 Linux - Newbie 0 09-05-2011 09:09 PM
How to determine name of file which owns a block number on a FS? 10110111 Linux - Software 3 04-27-2010 02:27 AM
why block number changed after change of file? bitzsk Linux - Kernel 2 06-05-2009 07:10 AM
how to map a physical disk block to a file squarecmb Linux - General 2 04-12-2007 09:06 PM
Using cat, tr and echo AlexSapec Linux - Newbie 7 02-17-2006 10:03 AM


All times are GMT -5. The time now is 11:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration