LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 04-24-2010, 09:23 AM   #1
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 402

Rep: Reputation: 51
How to determine name of file which owns a block number on a FS?


I need to monitor file reads&writes by all the apps. I have found a kernel feature /proc/sys/vm/block_dump. But it only gives me block numbers while i would like to know file names. How can i convert these block numbers to file names (if the blocks belong to a file, of course)?
 
Old 04-25-2010, 04:03 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,003
Blog Entries: 54

Rep: Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763
Quote:
Originally Posted by 10110111 View Post
How can i convert these block numbers to file names (if the blocks belong to a file, of course)?
Code:
# asserting ext file-system:
# for b_block
BLOCKNR="4000001"
# the inode is
INODE=$(echo "icheck ${BLOCKNR}"|debugfs /dev/devicename 2>/dev/null| awk '/^[0-9]/ {print $2}')
# which translates to file
FILENAME=$(find /mountpoint -inum "${INODE}" 2>/dev/null)

Quote:
Originally Posted by 10110111 View Post
I need to monitor file reads&writes by all the apps.
Using the above kludge is WAY SLOW. To be able to suggest possible other methods please tell us: why do you need to track all reads and writes? And why for all applications?
 
Old 04-26-2010, 09:30 AM   #3
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 402

Original Poster
Rep: Reputation: 51
Quote:
why do you need to track all reads and writes? And why for all applications?
I'm trying to understand why my desktop starts so slow. As i see, all the time hard drive is busy while startup. So, i decided to look what files access needs to be optimised.
strace will not suffice for this (and it would be even more hard to convert file handles in read()/write() to file names).

Last edited by 10110111; 04-26-2010 at 10:44 AM.
 
Old 04-27-2010, 02:27 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,003
Blog Entries: 54

Rep: Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763Reputation: 2763
Why not try ready-made tools like http://www.bootchart.org/ first?
 
  


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
why sector number not match block number? bitzsk Linux - Kernel 1 06-09-2009 05:32 AM
why block number changed after change of file? bitzsk Linux - Kernel 2 06-05-2009 07:10 AM
how to determine block size when using dd kav Linux - Software 2 12-22-2007 07:16 PM
How to determine file system block size? provo1234 Linux - Newbie 2 02-14-2005 09:30 AM
How do you determine which package owns a particular file? davidas Debian 2 04-05-2004 06:06 PM


All times are GMT -5. The time now is 10:56 PM.

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