From: Dave Chinner <david@fromorbit.com>
To: olivier@ajeux.com
Cc: xfs@oss.sgi.com
Subject: Re: Get file using a specific sector number
Date: Tue, 10 Jan 2012 08:46:30 +1100 [thread overview]
Message-ID: <20120109214630.GG4198@dastard> (raw)
In-Reply-To: <CAPPqfY1DOesJGfpZfnukr6PGo-KsGQ3u3tnF8UdVTZgWn2=HKA@mail.gmail.com>
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
prev parent reply other threads:[~2012-01-09 21:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-09 18:14 Get file using a specific sector number Olivier Doucet
2012-01-09 21:46 ` Dave Chinner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120109214630.GG4198@dastard \
--to=david@fromorbit.com \
--cc=olivier@ajeux.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox