2

ioctl() and FIBMAP can be used to determine the physical blocks occupied by a file, given logical blocks obtainable via stat(); however, root access is required. Why is root access necessary for ascertainment of the disk location of a file, and are there any non-root-requiring mechanisms for obtaining the same information? For the use case that motivates this question, the files are small (about 1 block on average) so knowledge of the physical location of the first block alone would suffice (indirect blocks are certainly unnecessary). On the order of 100,000 such files must be accessed in short order (as fast as possible), and I would like to pre-sort based on disk location before delivery to the I/O scheduler's queue. Sorting by inode is a possibility that does not require root privileges, but the degree of correspondence between inode number and disk location is probabilistic, implying variation of performance with the strength of that correspondence.

  • 1
    Can you use FIEMAP instead? It was added some time during the 2.6.x series. – Mark Plotnick Sep 2 '18 at 11:59
  • @MarkPlotnick: Thanks for pointing out FIEMAP; it does appear to satisfy my requirements. – user001 Sep 2 '18 at 21:29
  • @MarkPlotnick Wouldn't that be an answer then? – Fabby Sep 5 '18 at 0:35
  • @Fabby It would be an answer to just one of the two questions OP asked. – Mark Plotnick Sep 5 '18 at 1:35
  • 1
    I am close to tracking down an answer to the "why" question. lkml.org/lkml/2007/11/22/163 – Mark Plotnick Sep 7 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.