• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?)


  • Subject: Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?)
  • From: Mark Day <email@hidden>
  • Date: Thu, 7 Jul 2011 11:06:44 -0700

On Jul 7, 2011, at 10:24 AM, Mark Day wrote:

Hmm, databases and a a virtual memory kind of file.  Those sound like they might trigger delayed zero filling.

I was able to reproduce the same apparent behavior.  In my case, with a hard disk with a physical sector size of 512, the device offset I got back was 0xfffffffffffffe00.  With a device with 2048 bytes per sector, the device offset was 0xfffffffffffff800.  So you must have a device with 4096 bytes per sector (which is true of some recent hard disks and SSDs).

As a workaround, you might try calling fsync() on the file descriptor before you call fcntl(... F_LOG2PHYS...).  I think that will force the zero filling to happen immediately, and you should then get the real on-disk location.  Note that doing so could cause a performance problem.

It turns out that fsync() does not work around the problem.  But fcntl(... F_FULLFSYNC ...) does.  Note that fcntl(... F_FULLFSYNC ...) can be very expensive, so this is probably not a good workaround for a shipping application.

Looking at the fcntl(2) man page, there is no documentation for the case where  fcntl(F_LOG2PHYS) is called for a sparse area of a file.  I don't know whether it would be better to return an error, or some sentinel value (like -1 for the device offset).

-Mark

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?) (From: Stan Sieler <email@hidden>)
 >Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?) (From: Mark Day <email@hidden>)

  • Prev by Date: Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?)
  • Next by Date: Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?)
  • Previous by thread: Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?)
  • Next by thread: Re: Problem with fcntl/F_LOG2PHYS (was: Re: How to read files from disk directly?)
  • Index(es):
    • Date
    • Thread