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/27"> [27]</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/27/126" onclick="this.href='/lkml/headers'+'/2005/4/27/126';">[headers]</a>聽 <a href="/lkml/bounce/2005/4/27/126">[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/27/46">Jan Hudec</a><ul><li><a href="/lkml/2005/4/27/94">Ville Herva</a><ul><li class="origin"><a href="/lkml/2005/4/27/150">Jamie Lokier</a><ul><li><a href="/lkml/2005/4/27/150">Bernd Eckenfels</a></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">Wed, 27 Apr 2005 16:17:58 +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">Ville Herva wrote:<br />&gt; &gt; How do we specify which calls belong to a transaction? By some kind of<br />&gt; &gt; extra file handle?<br />&gt; &gt; <br />&gt; &gt; I'd think having global per-process transaction is not the best way.<br />&gt; &gt; So I think we should have some kind of transaction handle (probably in<br />&gt; &gt; the file handle space) and a way to say that a syscall is done within<br />&gt; &gt; a transaction. To avoid duplicating all syscalls, we could have<br />&gt; &gt; set_active_transaction() operation.<br />&gt; <br />&gt; That's more or less what NTFS does. See the example at<br />&gt; <a href="http://blogs.msdn.com/because_we_can/">http://blogs.msdn.com/because_we_can/</a><br /><br />That's the obvious choice but it limits the usefulness quite a lot.<br /><br />If we have transactions, then I'd like to be able to do this from a shell:<br /><br /> transaction_open t<br /><br /> tar xvpSfz blahblah.tar.gz<br /> cd blahblah<br /> patch -p1 -E &lt; foo.patch<br /> # etc.<br /><br /> transaction_close $t<br /><br />I'd also like to write inside a single C program:<br /><br /> transaction * t = transaction_open ();<br /><br /> /* Ordinary complicated filesystem operations here... */<br /> link (a, b);<br /> rename (c, d);<br /> read, write, stat etc.<br /> conf = open ("/etc/blahblah.conf", O_RDONLY);<br /> read (conf, ...)<br /> close (conf);<br /> /* If /etc/blahblah.conf is changed by another program during<br /> the transaction, the transaction is invalidated, because the<br /> dbm update below is dependent on what was read... */<br /> dbm_open (...);<br /> do_dbm_stuff (...);<br /> dbm_close (...);<br /> /* Whatever this command does, I'd like to include in the transaction. */<br /> system ("perl -pi -e 's/old_value/new_value/g' /etc/another.conf");<br /><br /> transaction_close (t);<br /><br />Fundamentally, if transactions are supported in the kernel then these<br />two usages are easy to offer:<br /><br /> 1. Ordinary file system calls as part of a transaction.<br /><br /> This allows libraries which are not transaction-aware to be<br /> used, such as the dbm example above, and other things like XML<br /> parsers/writers.<br /><br /> 2. Subprocesses inherit a transaction, so a program can execute<br /> complex transactions by using other programs.<br /><br />It's useful, and there is no good reason to disallow that.<br /><br />Nonetheless, there's a need for some kind of transaction handles. A<br />file descriptor representing a transaction seems like a natural fit.<br /><br />Complex programs will want to have multiple transactions at the same<br />time: For example, any program structured using event-driven logic or<br />async I/O may have multiple independent state machines per thread,<br />each wanting to be able to have their own transactions.<br /><br />This suggests a few things:<br /><br /> - Transactions have a file descriptor to represent them.<br /><br /> - Each thread has a "current transaction" that applies to all filesystem<br /> operations.<br /><br /> - Concurrent threads will need their own current transactions, even<br /> while keeping "current directory" global to the whole process for<br /> POSIX reasons. A process wide "current transaction" is too coarse.<br /><br /> - Transactions should be automatically nestable: a program or<br /> library which uses transactions should itself be callable from a<br /> program or library which is using a transaction.<br /><br /> - Transactions should record whether they cannot provide<br /> transactions for some operation that is attempted (e.g. writing to<br /> a file on a remote filesystem), aborting the transaction.<br /><br /> - When a transaction aborts due to the actions of _another_ process<br /> (or thread) which is outside the transaction, that abort is an<br /> event which should be detectable synchronously (by polling the<br /> transaction fd) or asynchronously (by a signal - the SIGIO<br /> mechanism is fine for this).<br /><br /> - An exclusive locking period should be optional, requested by a<br /> flag when opening the transaction. Most usages will want the<br /> locking period with its default parameters.<br /><br /> - Ideally, programs or mechanisms which provide alternative views of<br /> part of a filesystem, such as search results (Beagle), tarfs, or<br /> mailfs, should be able to update synchronously with transactions<br /> that affect whatever the view is watching, so that the view<br /> changes are effectively part of the transaction. This does _not_<br /> mean that a transaction must wait for watchers to calculate<br /> anything. It does mean a transaction must synchronously and<br /> simultaneously invalidate caches held by watchers during the<br /> atomic commit.<br /><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-27 17:21 聽聽 [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