linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Finding out where a file is stored on the disk
@ 2019-12-20 21:51 James Courtier-Dutton
  2019-12-20 22:16 ` Chris Murphy
  0 siblings, 1 reply; 2+ messages in thread
From: James Courtier-Dutton @ 2019-12-20 21:51 UTC (permalink / raw)
  To: linux-btrfs

Hi,

If I have a file on the disk that is using btrfs.
Is there an API call, IOCTL call that I can make to get from filename
to which sectors it is stored in?
If there is a command line tool, that would be ok too, because I could
find out the API calls from looking at the source code.
I have 100k files that I need to scan regularly on a HDD.
If I knew where they were on the disk, I could order the files in such
a way as to reduce seeks on the disk to read the files.
I.e. Read files from the lowest sector to the highest sector.
This would speed up the task of reading the files.

Kind Regards

James

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

* Re: Finding out where a file is stored on the disk
  2019-12-20 21:51 Finding out where a file is stored on the disk James Courtier-Dutton
@ 2019-12-20 22:16 ` Chris Murphy
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Murphy @ 2019-12-20 22:16 UTC (permalink / raw)
  To: James Courtier-Dutton; +Cc: linux-btrfs

On Fri, Dec 20, 2019 at 2:51 PM James Courtier-Dutton
<james.dutton@gmail.com> wrote:

> If I have a file on the disk that is using btrfs.
> Is there an API call, IOCTL call that I can make to get from filename
> to which sectors it is stored in?

I'm not sure of a single tool.

[chris@flap Documents]$ sudo filefrag -v UEFI_Spec_2_8_final.pdf
Filesystem type is: 9123683e
File size of UEFI_Spec_2_8_final.pdf is 18586279 (4538 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..    4537:    9798022..   9802559:   4538:             last,eof
UEFI_Spec_2_8_final.pdf: 1 extent found
[chris@flap Documents]$ sudo btrfs-map-logical -l $[9798022*4096] /dev/nvme0n1p7
mirror 1 logical 40132698112 physical 31475654656 device /dev/nvme0n1p7
[chris@flap Documents]$ sudo dd if=/dev/nvme0n1p7 bs=1
skip=31475654656 count=64 2>/dev/null | hexdump -C
00000000  25 50 44 46 2d 31 2e 36  0d 25 e2 e3 cf d3 0d 0a  |%PDF-1.6.%......|
00000010  33 30 35 35 31 39 20 30  20 6f 62 6a 0d 3c 3c 2f  |305519 0 obj.<</|
00000020  46 69 6c 74 65 72 2f 46  6c 61 74 65 44 65 63 6f  |Filter/FlateDeco|
00000030  64 65 2f 46 69 72 73 74  20 31 31 37 39 2f 4c 65  |de/First 1179/Le|
00000040
[chris@flap Documents]$



-- 
Chris Murphy

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

end of thread, other threads:[~2019-12-20 22:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 21:51 Finding out where a file is stored on the disk James Courtier-Dutton
2019-12-20 22:16 ` Chris Murphy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).