public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* Get file using a specific sector number
@ 2012-01-09 18:14 Olivier Doucet
  2012-01-09 21:46 ` Dave Chinner
  0 siblings, 1 reply; 2+ messages in thread
From: Olivier Doucet @ 2012-01-09 18:14 UTC (permalink / raw)
  To: xfs


[-- Attachment #1.1: Type: text/plain, Size: 525 bytes --]

Hello everyone,

I'm actually using xfsprogs quite heavily and I'm stuck with one problem :

I have a sector number and I want to know which file is using it. xfs_bmap
does exactly the opposite (give sector number for a specific file), but I
cannot find how to do it the other way.
I made several attempts with xfs_db but cannot find how to do it properly.
Moreover, I need to do it on a mounted filesystem (RW), and xfs_db does not
seem very friendly about that ...

Any help would be much appreciated.

Thank you,

Olivier

[-- Attachment #1.2: Type: text/html, Size: 659 bytes --]

[-- Attachment #2: Type: text/plain, Size: 121 bytes --]

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

* Re: Get file using a specific sector number
  2012-01-09 18:14 Get file using a specific sector number Olivier Doucet
@ 2012-01-09 21:46 ` Dave Chinner
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2012-01-09 21:46 UTC (permalink / raw)
  To: olivier; +Cc: xfs

On Mon, Jan 09, 2012 at 07:14:23PM +0100, Olivier Doucet wrote:
> Hello everyone,
> 
> I'm actually using xfsprogs quite heavily and I'm stuck with one problem :
> 
> I have a sector number and I want to know which file is using it. xfs_bmap
> does exactly the opposite (give sector number for a specific file), but I
> cannot find how to do it the other way.
> I made several attempts with xfs_db but cannot find how to do it properly.
> Moreover, I need to do it on a mounted filesystem (RW), and xfs_db does not
> seem very friendly about that ...
> 
> Any help would be much appreciated.

There is no easy way to do it, because XFS does not have a reverse
map btree to tell you the owner of any given block. The only way to
find this is to walk the entire metadata tree to find the owner of
the block.

You can't do that reliably just by walking the directory heirarchy
and running xfs_bmap and xfs_bmap -a on every file and directory,
because the sector you are after may be in metadata that you can't
expose via this method. e.g. it might be a block in the extent tree
that xfs_bmap walks, in the free space or inode btrees, etc.

xfs_db is really the only way you can do this right now, using the
blockget command. You can run xfs_db on a RW filesystem (run it in
read-only mode), but xfs_db is not coherent with active filesystem
changes and hence is likely to crash randomly as the filesytem
changes under it. Also, blockget takes blocks in FSB format, so you
need to convert your sector (daddr) to FSB units using the convert
command first.

FWIW, you could always freeze the filesystem while you run the xfs_db
command, but that may cause other problems for your applications...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2012-01-09 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-09 18:14 Get file using a specific sector number Olivier Doucet
2012-01-09 21:46 ` Dave Chinner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox