CINXE.COM

LKML: Jamie Lokier: Re: filesystem transactions API

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Jamie Lokier: Re: filesystem transactions API</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Jamie Lokier" href="/groupie.php?aid=24792" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/4"> [Apr]</a> 聽 <a class="nb" href="/lkml/2005/4/26"> [26]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2005/4/26/192" onclick="this.href='/lkml/headers'+'/2005/4/26/192';">[headers]</a>聽 <a href="/lkml/bounce/2005/4/26/192">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2005/4/24/76">First message in thread</a></li><li><a href="/lkml/2005/4/26/172">"John Stoffel"</a><ul><li><a href="/lkml/2005/4/26/176">Lars Marowsky-Bree</a></li><li><a href="/lkml/2005/4/26/179">Trond Myklebust</a><ul><li class="origin"><a href="/lkml/2005/4/26/194">Jamie Lokier</a><ul><li><a href="/lkml/2005/4/26/194">"Artem B. Bityuckiy"</a><ul><li><a href="/lkml/2005/4/26/197">Jamie Lokier</a></li></ul></li></ul></li></ul></li><li><a href="/lkml/2005/4/26/181">Jamie Lokier</a><ul><li><a href="/lkml/2005/4/26/229">Diego Calleja</a><ul><li><a href="/lkml/2005/4/26/240">Jamie Lokier</a></li></ul></li><li><a href="/lkml/2005/4/27/46">Jan Hudec</a><ul><li><a href="/lkml/2005/4/27/94">Ville Herva</a><ul><li><a href="/lkml/2005/4/27/126">Jamie Lokier</a></li></ul></li></ul></li></ul></li></ul></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Tue, 26 Apr 2005 16:47:08 +0100</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Jamie Lokier &lt;&gt;</td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: filesystem transactions API</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">Trond Myklebust wrote:<br />&gt; &gt; Jamie&gt; No. A transaction means that _all_ processes will see the<br />&gt; &gt; Jamie&gt; whole transaction or not.<br />&gt; &gt; <br />&gt; &gt; This is really hard. How do you handle the case where process X<br />&gt; &gt; starts a transaction modifies files a, b &amp; c, but process Y has file b<br />&gt; &gt; open for writing, and never lets it go? Or the file gets unlinked? <br />&gt; <br />&gt; That is why implementing it as a form of lock makes sense.<br /><br />The problem with making them exclusive locks is that you halt the<br />system for the duration of the transaction. If it's a big transaction<br />such as updating 1000 files for a package update, that blocks a lot of<br />programs for a long time, and it's not necessary.<br /><br />And, because that's a potential denial of service, you have to limit<br />the size of transactions and their duration, especially for ordinary<br />users. That makes transactions a lot less useful than they can be.<br /><br />I would implement them as a combination of time-limited lock, and<br />abortable transaction with file &amp; directory reads establishing<br />prerequisites.<br /><br />While the transaction lock is held, everything read (i.e. read byte<br />ranges, lock byte ranges, directory lookups, and stat results) cause<br />the corresponding range or inode to be exclusively locked for this<br />transaction, and also cause them to be recorded in the prerequisite<br />set for this transaction. Everything written (i.e. byte ranges or any<br />other filesystem modifying operation) is queued.<br /><br />If the transaction lock timeout is reached before the transaction is<br />closed, all the exlusive locks for this transaction are released, and<br />the transaction lock itself is released, and the prerequisite set<br />continues to be recorded.<br /><br />If at any time, another process tries to modify any of the information<br />in the transaction's prerequisite set, then firstly: if the<br />transaction lock is held, the other process is blocked until that lock<br />is released. Secondly: if the other process successfully modifies<br />information in the transaction's prerequisite set, the transaction is<br />aborted. All further operations in this transaction will fail,<br />including reads, writes, and the final close which commits writes.<br /><br />Finally, when the transaction is closed, either it fails because<br />prerequisites were modified, or it commits all the pending filesystem<br />modifications of this transaction.<br /><br />Why two phases?<br /><br />The second phase, with no exclusive locking, is to allow ordinary<br />users to use transactions without blocking other processes or hogging<br />excessive system resources. It allows other processes to progress<br />while a big transaction is in progress. In other words, it prevents<br />some kinds of denial-of-service, allows arbitrarily large transactions<br />as long as there's enough space in the filesystem, and is generally<br />better.<br /><br />The first phase, with exlusive locking, uses a randomised timeout for<br />the lock. This is to prevent starvation of transacting processes by<br />other processes. It's analogous to the problem of readers starving<br />writers in some kinds of read-write locks. The randomised timeout is<br />to prevent mutual starvation between two or more transacting<br />processes, which might otherwise get into synchronised livelock.<br /><br />Enjoy :)<br />-- Jamie<br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo&#64;vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2005-04-26 17:56 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10