site_archiver@lists.apple.com Delivered-To: Darwin-dev@lists.apple.com -- Terry On Sep 5, 2008, at 6:40 AM, Tim Schooley <tim@sbdev.net> wrote: Hi Terry, Many thanks for any help! Kind regards, Tim Good day! So here's the setup: 1) I have a kext that creates an IOBlockStorageDriver. I setup and tear down block devices from userspace with an application. 3) Using an application, and the DiskArbitration calls (namely DADiskMountWithArguments and DADiskUnmount), I mount these devices to a directory on the filesystem. The problem I have is this: 2.1) I try to unmount a mounted device using DADiskUnmount. 2.2) This fails because the device is "busy". - There are no IO operations happening. - There are no files open by users. - The only file open on the mount point is (output from lsof): fseventsd 34 root 12u REG 14,4 0 999999999 <mountpoint>/.fseventsd/0000000000006478 2.3) If I use the kDADiskUnmountOptionForce option in the call to DADiskUnmount, it corrupts the filesystem. So my questions are: Yes. 3.1) What is this fseventsd doing sticking its nose into my mountpoint? It is looking for file creations/changes on the device so it can report them to Spotlight for (re)indexing, or to other clients of fseventsd (like TimeMachine backup). It sticks it's nose in your mount point to create an event log file, which it then holds open until the disk is unmounted. The intent of the log file is to ensure that you don't have to rescan the entire disk due to last minute changes (or that last minute changes will not be indexed or backed up). Typically such changes represent events that have occurred, but for which fseventd clients have either been stopped or are not reading and reacting to events (e.g. at shutdown time, due to non-ordered shutdown of processes). It technically doesn't actually need to keep this log file open if it's not actively logging something, but it does so anyway. Yes. The mount option MNT_NOBROWSE ("-o nobrowse" on the mount command line) will prevent fseventd from listening for events on the volume. It will also disable TimeMachine, Spotlight indexing, and other clients of fseventd, so this is generally not a good idea. -- _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... Are you maybe using command line mounts and unmounts other than diskutil, which talks to DA? DA will run your command line tools under the covers after doing the right things. As long as you go through DA to do your mounts and unmount rather than explicit command line utilities or programs not going through DA, you should not need the nobrowse. As I said before, DA will notify fseventsd to stop looking. If Spolight and Time Machine are undesirable, you can explicitly disable them programattically by updating settings for "don't look here". Pretty sure this is well documented. fseventsd seems to have caused a lot of problems for our application. We have a feature allowing our device to be ejected automatically after it is idle for a specified time. Obviously, with fseventsd poking around, the timeout is not what the user would expect, and can be inaccurate by many minutes. Regarding the unmount issue - I have successfully registered an unmount approval callback function, which I can see gets called. However, more often than not, the unmount will still be prevented with a "busy" return code. Using the "nobrowse" option then seems to be the way to go. Time Machine and Spotlight are in fact undesirable features for our devices. However, if using this mount option, the Finder does not update to show the newly mounted device, nor does the Desktop (I guess Desktop and Finder are one and the same). Our application provides the user with the choice of mounting in a "standard" location (i.e. letting DA decide the mount point) and also to a specific location. The nobrowse option works great for specific locations. But for "standard" locations, we really need the mount to show in Finder and the Desktop as a volume. And again, we need fseventsd out of the way for the idle timeout functionality. Is there a way to tell the Finder/Desktop to "notice" the new disks with the "nobrowse" option? I've tried using NSNotifyByPath() with no luck. On Fri, 6 Jun 2008 14:17:59 -0700, Terry Lambert wrote: On Jun 6, 2008, at 1:44 AM, Tim Schooley wrote: 2) I format these devices by calling standard format commands, such as newfs_{hfs,msdos,...}. 3.0) Is the fseventsd causing this busy mount point issue? fseventsd registers a callback with DARegisterDiskUnmountApprovalCallback to permit it to get notification of the pending unmount. If you have failed to register an unmount completion callback, a direct call to the unmount is considered synchronous instead of asynchronous, and the unmount will fail, since it does not give fseventd time to close down the log. 3.2) Can I stop the fseventsd from doing this? 3.3) Am I missing some sort of call to the fseventsd? No, but you are missing registering an unmount completion callback with DiskArbitration so that the DADiskUnmount is not synchrnously answered with the only answer available at the time it returns ("busy"). -- Terry This email sent to site_archiver@lists.apple.com