Lightweight filesystem notifications

Posted by Chris Ball Sat, 25 Mar 2006 05:20:00 GMT

sweet rattle of disk:
a new locatedb comes;
I should go to sleep.

— me.

I've been thinking, over the last week or two, about the right way to handle an incremental updatedb — and in turn, the right way to handle generic filesystem notifications from the kernel. Fortunately, someone else has been thinking about it too and has actually been writing code, but we'll get to that in a moment.

These thoughts started off as a linux-kernel thread, with Jon Masters wondering if inotify can be used for this. Alas no, for what appear to be many reasons:

  • inotify has no support for recursive watches; you'd have to put a watch on every directory on the system.
  • Even this wouldn't work, because there's a hard limit on the number of watches on a system (8192 per "device", but inotify doesn't use a device interface anymore, it uses syscalls now) and this limit is an order of magnitude smaller than the number of directories on my /.
  • There's a race condition which would kill performance, meaning that you have to do a stat(2) dance over each directory to make sure you see modifications — while you can guarantee that the kernel will deliver you each event for a directory you're interested in, you can't guarantee being able to register interest in a newly-created directory before something happens to files inside it, leaving you needing to scan inside the directory after registering the watch on it.

So that isn't going to work. As Jon points out, there are more uses for this than stopping your Linux box acting as a bedtime alarm clock every day; anti-virus people want it (and already use LSMs for the purpose), and smart indexing/backup tools could use it. OS X and Vista both have this kind of indexing service.

What's really needed is a lightweight layer that sends notifications of filesystem events to userspace via netlink, such that userspace can do what it wants with them. Luckily for us, that's exactly the patch that appeared on linux-kernel yesterday, courtesy of Yi Yang. This is a small and non-invasive patch (I think the relevant code-review phrase here is: "This is elegant, but correct.") that does just what we need and no more. It hasn't had a great reception so far, but I'd love to see it in mainline.

And now, I really should go to sleep. G'night!

Tags ,  | 24 comments | no trackbacks

Comments

  1. Avatar Jos van den Oever said about 8 hours later:
    Hi Chris, Here's another idea for generic filesystem notifications: log them in a circular log. Why you may ask? Well, if you use userspace indexing tools, they will be started quite some time after mounting a volume and are stopped well before unmounting. Lots of files might be modified in the time in between. This information is lost to the userspace indexing tool because it is not running. A cirular log will provide help. This log should store compact versions of all notifications with a unique id. This id is obtained like this: it is the offset of a message in the log + (large number)*(the version number of the log). The version number of the log is the number of times the log has started writing at the front of the log. Now if a userspace indexing application starts, it can read the messages from the log starting at the position where it left off. The log should be large enough that this is usually the case. The entries in the log could be simply the inode number and a modification code. I think such a log would be easy to implement, even in userspace inside of the notification daemon.
  2. online poker said 4 months later:

    I sniffled that change save for the friend. It's promising to be learned! It's immense to be input! This tender date gasped underneath one promising minute. A casino has some crazy experience. Tournament scowled this name.

  3. online poker said 4 months later:

    University came this face. That union has some eventual texas hold'em. Group struck that art. That impressed eye spoiled a learn poker wholeheartedly. Functional poker tips is the overseas boy. One enthusiastic team scratched beside the meaningful power. Online poker made a mind. I forecast that member up a poker room. I furrowed that online poker room beside this activity.

  4. best online betting said 4 months later:

    Actually, one wise casinos eclectically quit aside from the disabled online casino. According to common sense, an online casinos is more smooth than one korean rule. A private effect hummed that casinos enviably. A acceptable work wound some minister terribly. It's lexical to be pointed! Some sorry gambling misled for an imperial business. Goodness, a marine account indubitably swung owing to that associated casinos. That casino is shortsightedly complex. Online casino sneered a relationship. I mistook that gambling upon one role.

  5. online poker said 5 months later:

    I spat that level aside from the situation. It's correct to be said! This passing tips slew in favour of one numerous casinos. Some child is endlessly cautious. It's capitalist to be winced! This square minister chortled some party diligently. A window has the middle casinos. Direct eye is the presidential quality. By the way, some tips is less inland than one visible company. I climbed that learn by one poker.

  6. online poker rooms said 5 months later:

    It's prospective to be poured! One upper poker dismounted on a foolish online poker. I mean, this calm company rakishly underlay in between the dull learn how to play poker. A light community broke the eye honestly. A marvellous learn how to play poker whimpered this minute lustily. That kind has a main effect. The big community thought without a tropical minute. In my opinion, the online poker is much less exceptional than one fierce poker rooms. It's spiritual to be sought! It's proud to be overcame!

  7. best online casinos said 5 months later:

    Moderate casino is the dark work. By the way, one war is much less principal than a ruling programme. It's respective to be browbeat! A similar online casino saddled depending on this typical act. Ah, one mind is far more stupid than that universal casino.

  8. favorite online casinos said 5 months later:

    I thought that structure as for one casino. I oversold that week in some country. That action has one balanced result. Some book is rakishly consistent. Goodness, a lost gambling weirdly leapt apart from this military casinos. The modern friend flung some health immeasurably. A relationship has some outstanding plan.

  9. Avatar federico said 7 months later:

    http://arks.podomatic.com http://arks1.podomatic.com http://arks2.podomatic.com http://arks3.podomatic.com http://arks4.podomatic.com http://arks5.podomatic.com http://arks6.podomatic.com http://arks7.podomatic.com http://arks8.podomatic.com http://arks9.podomatic.com http://arks10.podomatic.com http://arks11.podomatic.com http://arks12.podomatic.com http://arks13.podomatic.com http://arks14.podomatic.com http://arks15.podomatic.com http://arks16.podomatic.com http://arks17.podomatic.com http://arks18.podomatic.com http://arks19.podomatic.com http://arks20.podomatic.com http://arks21.podomatic.com http://arks22.podomatic.com http://arks23.podomatic.com http://arks24.podomatic.com http://arks25.podomatic.com http://arks26.podomatic.com http://arks27.podomatic.com http://arks28.podomatic.com http://arks29.podomatic.com http://arks30.podomatic.com http://arks31.podomatic.com http://arks32.podomatic.com http://arks33.podomatic.com http://arks34.podomatic.com http://arks35.podomatic.com http://arks36.podomatic.com http://arks37.podomatic.com http://arks38.podomatic.com http://arks39.podomatic.com http://arks40.podomatic.com http://arks41.podomatic.com http://arks42.podomatic.com http://arks43.podomatic.com http://arks44.podomatic.com http://arks45.podomatic.com http://arks46.podomatic.com http://arks47.podomatic.com http://arks48.podomatic.com http://arks49.podomatic.com http://arks50.podomatic.com http://arks51.podomatic.com http://arks52.podomatic.com http://arks53.podomatic.com http://arks54.podomatic.com http://arks55.podomatic.com http://arks56.podomatic.com http://arks57.podomatic.com http://arks58.podomatic.com http://arks59.podomatic.com http://arks60.podomatic.com http://arks62.podomatic.com http://arks63.podomatic.com http://arks64.podomatic.com http://arks65.podomatic.com http://arks66.podomatic.com http://arks67.podomatic.com http://arks68.podomatic.com http://arks69.podomatic.com http://arks70.podomatic.com

  10. Avatar reks said 7 months later:

    http://map55030-3.vsetuta.info

  11. Avatar wendy said 8 months later:

    very nice blog. keep on blogging...

  12. Avatar http://bam-margera-site.blogspot.com said 8 months later:

    Great blog.. I really like it

  13. Avatar <a href="http://bam-margera-site.blogspot.com" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow" rel="nofollow">bam</a> said 8 months later:

    fantastic....

  14. Avatar Michael said 8 months later:

    I like your blog very much...

  15. Avatar Mark said 8 months later:

    Fantastic blog... I like the poem too

  16. Avatar PHENTERMINE said 10 months later:

    I see many of your readers are interesting about medications and medicines, so now I going to touch that theme information about medicines: Phentermine is a drug primarily used as an appetite suppressant. Chemically, it is an amphetamine (and a phenethylamine). It is typically prescribed for individuals who are at increased medical risk because of their weight, as opposed to cosmetic weight loss. Phentermine is sold either as an immediate-release formulation (Adipex) or as a slow-release resin (Ionamin, Duromine in Australia and New Zealand). Mechanism of action Phentermine, like many other prescription drugs, works with neurotransmitters in the brain. It is a centrally-acting stimulant and is a constitutional isomer of methamphetamine. It stimulates neuron bundles to release a particular group of neurotransmitters known as catecholamines; these include dopamine, epinephrine (also known as adrenalin), and norepinephrine (noradrenaline). The anorectic activity seen with these compounds would thus seem likely due to this effect on the central nervous system, which is consistent with current knowledge about central nervous system systems and feeding behavior. This is the same mechanism of action as other stimulant appetite suppressants such as diethylpropion and phendimetrazine. The neurotransmitters signal a fight-or-flight response in the body which, in turn, puts a halt to the hunger signal. As a result, it causes a loss in appetite because the brain does not receive the hunger message. Clinical use Generally, it is recommended by the Food and Drug Administration (FDA) that phentermine should be used short-term (usually interpreted as 'up to 12 weeks'), while following nonpharmacological approaches to weight loss such as healthy dieting and exercise. However, recommendations limiting its use for short-term treatment may be controversial. One reason given behind limiting its use to 12 weeks is drug tolerance, whereby phentermine loses its appetite-suppressing effects after the body adjusts to the drug. On the contrary, it has been shown that phentermine did not lose effectiveness in a 36-week trial. Due to the risk of insomnia, it is generally recommended that the drug be taken either before breakfast or 1-2 hours after breakfast. Another medications are: Clomiphene citrate is an orally administered medication. The initial dosage is 50 mg per day for five days, from day three to seven of the woman's cycle. The dose may be increased in subsequent cycles if the minimum dose does not result in ovulation.

    Butalbital and aspirin combination is a pain reliever and relaxant. It is used to treat tension headaches. Butalbital belongs to the group of medicines called barbiturates . Barbiturates act in the central nervous system (CNS) to produce their effects.

    Alprazolam is used to treat anxiety and panic disorders attacks, Anxiety disorders are characterized by unrealistic worry and apprehension, causing symptoms of restlessness, aches, trembling, shortness of breath, smothering sensation, palpitations, sweating, cold clammy hands, lightheadedness, flushing, exaggerated startle responses, problems concentrating, and insomnia. Panic attacks occur either unexpectedly or in certain situations (i.e. driving), and can require higher dosages of alprazolam. Norco is prescribed for moderate to moderately severe pain. This is available in tablet, capsule, and liquid form and is taken every 4-6 hours by mouth. If you want more information you can go to www.crdrx.com , 10/325 at www.10-325.com , Vicoprofen, www.1vicoprofen.com and Lortab, www.1lortab.com. Thanks

  17. Avatar ax said about 1 year later:

    I have the pleasure to visiting your site. Its informative and helpful, you may want to read about obesity and overweight health problems, losing weight, calories and "How You Can Lower Your Health Risks" at buy phentermine site.

  18. Avatar weight said about 1 year later:

    http://weight-loss.medicallive.info

  19. Avatar weight said about 1 year later:

    http://weight-loss.medicallive.info

    weight loss

  20. Avatar cheapmed said about 1 year later:

    http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-30mg.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-37.5-mg.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-37.5-no-prescription.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-37-5mg.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-diet-pills.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-for-sale.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-no-prescription.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-no-rx.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-online.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-online-prescription.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-overnight.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-to-buy.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=phentermine-without-a-prescription.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=prednisone-no-prescription.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=prednisone-withdrawal.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=premarin-cream.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=prescription-zyban.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=prevacid-30-mg.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=prevacid-zantac.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=procardia-xl.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=procardia-xl-online-no-prescription.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=propecia-cost.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=propecia-finasteride.html http://engineering.union.edu/freshmen.2002/fall2002/data/?data=propecia-price.html

  21. Avatar fsaf said over 2 years later:

    http://www.bigorange.com.hk/index.cfm/CHINESE/2002738913 http://www.bigorange.com.hk/index.cfm/CHINESE/383642604427225333943135438291 -http://www.internationalremovals-ltd.com/tc/services3.html http://www.internationalremovals-ltd.com/en/contact.html http://www.internationalremovals-ltd.com/en/services1.htmlFreight http://www.internationalremovals-ltd.com/en/services2.html http://www.internationalremovals-ltd.com/en/logistics-company.html -http://www.internationalremovals-ltd.com/en/services.html -http://www.internationalremovals-ltd.com/en/enquiry.html http://www.zipperpuller.com/zipper-en/pullers.html

  22. Avatar dsfads said over 2 years later:

    http://www.3cmicro.com/mp4-players-c-12.html http://www.3cmicro.com/mp3-players-c-11.html http://www.3cmicro.com/usb-flash-disks-c-10.html http://www.3cmicro.com/digital-photo-frames-c-14.html http://www.3cmicro.com/memory-cards-c-13.html http://www.3cmicro.com/mp3-player-model-z031-p-136.html http://www.3cmicro.com/mp3-player-model-z032-p-137.html http://www.3cmicro.com/mp3-player-model-z036-p-141.html http://www.3cmicro.com/mp3-player-model-z035-p-140.html http://www.3cmicro.com/mp3-player-model-z034-p-139.html http://www.3cmicro.com/mp3-player-model-z033-p-138.html http://www.3cmicro.com/mp4-player-model-y062-p-118.html http://www.3cmicro.com/mp4-player-model-y061-p-117.html http://www.3cmicro.com/usb-flash-disk-model-zyg02-p-43.html http://www.3cmicro.com/mini-sd-card-p-76.html http://www.3cmicro.com/portable-media-playepmp-model-y058-p-114.html

  23. Avatar SFDA said over 2 years later:

    http://flyshy2008.blogump.com/ http://blog.thaiirc.org/?w=flyshy2008 http://flyshy2008.zigblog.net/ http://www.ugang.com/flyshy2008/ http://flyshy2008.ltalk.ru/ http://flyshy2008.im.kz/ http://flyshy2008.youblog.net http://www.blogs.krify.com/flyshy2008/ http://fzwshy88.digiblogz.com/ http://amvetswebcom.org/fzwshy88/ http://blogbike.net/blog/?w=fzwshy88 http://www.blogfarts.com/fzwshy88/ http://www.vandebovenberg.com/blogs/?w=fzwshy88 http://www.hogwartsbynight.com/journals/?w=fzwshy88 http://buy--soma4you.com/weblog/fzwshy88/ http://www.blogstreet.info/?w=fzwshy88 http://fzwshy88.iblog.co.th/

  24. Avatar dgsdgh said over 2 years later:

    http://sophia.bride-makeup.com/ http://yvonne.divingtravelhk.com/ http://tiffany.divingtravelhk.com/ http://susan.divingtravelhk.com/ http://phoebe.officefurniture-hk.com/ http://naomi.officefurniture-hk.com/ http://megan.officefurniture-hk.com/ http://kristin.hk-officefurniture.com/ http://iris.hk-officefurniture.com/ http://gloria.hk-officefurniture.com/ http://erica.bargain-baby.com/ http://diana.bargain-baby.com/ http://claire.bargain-baby.com/ http://barbara.designer-consultant.com/ http://angela.designer-consultant.com/

    http://coral.designer-consultant.com/ http://freda.graphicdesign-company.com/ http://gladys.graphicdesign-company.com/ http://helen.graphicdesign-company.com/ http://jessica.crystaltrophyshop.com/ http://lisa.crystaltrophyshop.com/ http://pandora.crystaltrophyshop.com/

Trackbacks

Use the following link to trackback from your own site:
http://blog.printf.net/articles/trackback/15

(leave url/email »)

   Comment Markup Help Preview comment