__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.244: ~ $
<!DOCTYPE html>

<html lang="en" data-content_root="../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>The Linux Journalling API &#8212; The Linux Kernel  documentation</title>
    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=fa44fd50" />
    <link rel="stylesheet" type="text/css" href="../_static/alabaster.css?v=3918102e" />
    <script src="../_static/documentation_options.js?v=5929fcd5"></script>
    <script src="../_static/doctools.js?v=9bcbadda"></script>
    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="Filesystem-level encryption (fscrypt)" href="fscrypt.html" />
    <link rel="prev" title="Buffer Heads" href="buffer.html" />
   
  <link rel="stylesheet" href="../_static/custom.css" type="text/css" />
  

  
  

  </head><body>
  <div class="document">
    
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/logo.svg" alt="Logo of The Linux Kernel"/>
            </a></p>
<h1 class="logo"><a href="../index.html">The Linux Kernel</a></h1>



<p class="blurb">6.18.50</p>







<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>


<p>
<h3 class="kernel-toc-contents">Contents</h3>
<input type="checkbox" class="kernel-toc-toggle" id = "kernel-toc-toggle" checked>
<label class="kernel-toc-title" for="kernel-toc-toggle"></label>

<div class="kerneltoc" id="kerneltoc">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../process/development-process.html">Development process</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/submitting-patches.html">Submitting patches</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/code-of-conduct.html">Code of conduct</a></li>
<li class="toctree-l1"><a class="reference internal" href="../maintainer/index.html">Maintainer handbook</a></li>
<li class="toctree-l1"><a class="reference internal" href="../process/index.html">All development-process docs</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../core-api/index.html">Core API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../driver-api/index.html">Driver APIs</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../subsystem-apis.html">Subsystems</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#core-subsystems">Core subsystems</a></li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#human-interfaces">Human interfaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#networking-interfaces">Networking interfaces</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../subsystem-apis.html#storage-interfaces">Storage interfaces</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="index.html">Filesystems in the Linux kernel</a></li>
<li class="toctree-l3"><a class="reference internal" href="../block/index.html">Block</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cdrom/index.html">CD-ROM</a></li>
<li class="toctree-l3"><a class="reference internal" href="../scsi/index.html">SCSI Subsystem</a></li>
<li class="toctree-l3"><a class="reference internal" href="../target/index.html">TCM Virtual Device</a></li>
<li class="toctree-l3"><a class="reference internal" href="../nvme/index.html">NVMe Subsystem</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../subsystem-apis.html#other-subsystems">Other subsystems</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../locking/index.html">Locking</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../process/license-rules.html">Licensing rules</a></li>
<li class="toctree-l1"><a class="reference internal" href="../doc-guide/index.html">Writing documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev-tools/index.html">Development tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../dev-tools/testing-overview.html">Testing guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../kernel-hacking/index.html">Hacking guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../trace/index.html">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fault-injection/index.html">Fault injection</a></li>
<li class="toctree-l1"><a class="reference internal" href="../livepatch/index.html">Livepatching</a></li>
<li class="toctree-l1"><a class="reference internal" href="../rust/index.html">Rust</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../admin-guide/index.html">Administration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../kbuild/index.html">Build system</a></li>
<li class="toctree-l1"><a class="reference internal" href="../admin-guide/reporting-issues.html">Reporting issues</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Userspace tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../userspace-api/index.html">Userspace API</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../firmware-guide/index.html">Firmware</a></li>
<li class="toctree-l1"><a class="reference internal" href="../devicetree/index.html">Firmware and Devicetree</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../arch/index.html">CPU architectures</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../staging/index.html">Unsorted documentation</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../translations/index.html">Translations</a></li>
</ul>

</div>

<script type="text/javascript"> <!--
  var sbar = document.getElementsByClassName("sphinxsidebar")[0];
  let currents = document.getElementsByClassName("current")
  if (currents.length) {
    sbar.scrollTop = currents[currents.length - 1].offsetTop;
  }
  --> </script>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../_sources/filesystems/journalling.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
        </div>
      </div>
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  



<section id="the-linux-journalling-api">
<h1>The Linux Journalling API<a class="headerlink" href="#the-linux-journalling-api" title="Link to this heading">¶</a></h1>
<section id="overview">
<h2>Overview<a class="headerlink" href="#overview" title="Link to this heading">¶</a></h2>
<section id="details">
<h3>Details<a class="headerlink" href="#details" title="Link to this heading">¶</a></h3>
<p>The journalling layer is easy to use. You need to first of all create a
journal_t data structure. There are two calls to do this dependent on
how you decide to allocate the physical media on which the journal
resides. The <a class="reference internal" href="#c.jbd2_journal_init_inode" title="jbd2_journal_init_inode"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_init_inode()</span></code></a> call is for journals stored in
filesystem inodes, or the <a class="reference internal" href="#c.jbd2_journal_init_dev" title="jbd2_journal_init_dev"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_init_dev()</span></code></a> call can be used
for journal stored on a raw device (in a continuous range of blocks). A
journal_t is a typedef for a <code class="xref c c-struct broken_xref docutils literal notranslate"><span class="pre">struct</span> <span class="pre">pointer</span></code>, so when you are finally
finished make sure you call <a class="reference internal" href="#c.jbd2_journal_destroy" title="jbd2_journal_destroy"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_destroy()</span></code></a> on it to free up
any used kernel memory.</p>
<p>Once you have got your journal_t object you need to ‘mount’ or load the
journal file. The journalling layer expects the space for the journal
was already allocated and initialized properly by the userspace tools.
When loading the journal you must call <a class="reference internal" href="#c.jbd2_journal_load" title="jbd2_journal_load"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_load()</span></code></a> to process
journal contents. If the client file system detects the journal contents
does not need to be processed (or even need not have valid contents), it
may call <a class="reference internal" href="#c.jbd2_journal_wipe" title="jbd2_journal_wipe"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_wipe()</span></code></a> to clear the journal contents before
calling <a class="reference internal" href="#c.jbd2_journal_load" title="jbd2_journal_load"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_load()</span></code></a>.</p>
<p>Note that jbd2_journal_wipe(..,0) calls
<a class="reference internal" href="#c.jbd2_journal_skip_recovery" title="jbd2_journal_skip_recovery"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_skip_recovery()</span></code></a> for you if it detects any outstanding
transactions in the journal and similarly <a class="reference internal" href="#c.jbd2_journal_load" title="jbd2_journal_load"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_load()</span></code></a> will
call <a class="reference internal" href="#c.jbd2_journal_recover" title="jbd2_journal_recover"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_recover()</span></code></a> if necessary. I would advise reading
<code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">ext4_load_journal()</span></code> in fs/ext4/super.c for examples on this stage.</p>
<p>Now you can go ahead and start modifying the underlying filesystem.
Almost.</p>
<p>You still need to actually journal your filesystem changes, this is done
by wrapping them into transactions. Additionally you also need to wrap
the modification of each of the buffers with calls to the journal layer,
so it knows what the modifications you are actually making are. To do
this use <a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a> which returns a transaction handle.</p>
<p><a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a> and its counterpart <a class="reference internal" href="#c.jbd2_journal_stop" title="jbd2_journal_stop"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_stop()</span></code></a>,
which indicates the end of a transaction are nestable calls, so you can
reenter a transaction if necessary, but remember you must call
<a class="reference internal" href="#c.jbd2_journal_stop" title="jbd2_journal_stop"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_stop()</span></code></a> the same number of times as
<a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a> before the transaction is completed (or more
accurately leaves the update phase). Ext4/VFS makes use of this feature to
simplify handling of inode dirtying, quota support, etc.</p>
<p>Inside each transaction you need to wrap the modifications to the
individual buffers (blocks). Before you start to modify a buffer you
need to call <a class="reference internal" href="#c.jbd2_journal_get_create_access" title="jbd2_journal_get_create_access"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_get_create_access()</span></code></a> /
<a class="reference internal" href="#c.jbd2_journal_get_write_access" title="jbd2_journal_get_write_access"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_get_write_access()</span></code></a> /
<a class="reference internal" href="#c.jbd2_journal_get_undo_access" title="jbd2_journal_get_undo_access"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_get_undo_access()</span></code></a> as appropriate, this allows the
journalling layer to copy the unmodified
data if it needs to. After all the buffer may be part of a previously
uncommitted transaction. At this point you are at last ready to modify a
buffer, and once you are have done so you need to call
<a class="reference internal" href="#c.jbd2_journal_dirty_metadata" title="jbd2_journal_dirty_metadata"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_dirty_metadata()</span></code></a>. Or if you’ve asked for access to a
buffer you now know is now longer required to be pushed back on the
device you can call <a class="reference internal" href="#c.jbd2_journal_forget" title="jbd2_journal_forget"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_forget()</span></code></a> in much the same way as you
might have used <a class="reference internal" href="buffer.html#c.bforget" title="bforget"><code class="xref c c-func docutils literal notranslate"><span class="pre">bforget()</span></code></a> in the past.</p>
<p>A <a class="reference internal" href="#c.jbd2_journal_flush" title="jbd2_journal_flush"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_flush()</span></code></a> may be called at any time to commit and
checkpoint all your transactions.</p>
<p>Then at umount time , in your <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">put_super()</span></code> you can then call
<a class="reference internal" href="#c.jbd2_journal_destroy" title="jbd2_journal_destroy"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_destroy()</span></code></a> to clean up your in-core journal object.</p>
<p>Unfortunately there a couple of ways the journal layer can cause a
deadlock. The first thing to note is that each task can only have a
single outstanding transaction at any one time, remember nothing commits
until the outermost <a class="reference internal" href="#c.jbd2_journal_stop" title="jbd2_journal_stop"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_stop()</span></code></a>. This means you must complete
the transaction at the end of each file/inode/address etc. operation you
perform, so that the journalling system isn’t re-entered on another
journal. Since transactions can’t be nested/batched across differing
journals, and another filesystem other than yours (say ext4) may be
modified in a later syscall.</p>
<p>The second case to bear in mind is that <a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a> can block
if there isn’t enough space in the journal for your transaction (based
on the passed nblocks param) - when it blocks it merely(!) needs to wait
for transactions to complete and be committed from other tasks, so
essentially we are waiting for <a class="reference internal" href="#c.jbd2_journal_stop" title="jbd2_journal_stop"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_stop()</span></code></a>. So to avoid
deadlocks you must treat <a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a> /
<a class="reference internal" href="#c.jbd2_journal_stop" title="jbd2_journal_stop"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_stop()</span></code></a> as if they were semaphores and include them in
your semaphore ordering rules to prevent
deadlocks. Note that <a class="reference internal" href="#c.jbd2_journal_extend" title="jbd2_journal_extend"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_extend()</span></code></a> has similar blocking
behaviour to <a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a> so you can deadlock here just as
easily as on <a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a>.</p>
<p>Try to reserve the right number of blocks the first time. ;-). This will
be the maximum number of blocks you are going to touch in this
transaction. I advise having a look at at least ext4_jbd.h to see the
basis on which ext4 uses to make these decisions.</p>
<p>Another wriggle to watch out for is your on-disk block allocation
strategy. Why? Because, if you do a delete, you need to ensure you
haven’t reused any of the freed blocks until the transaction freeing
these blocks commits. If you reused these blocks and crash happens,
there is no way to restore the contents of the reallocated blocks at the
end of the last fully committed transaction. One simple way of doing
this is to mark blocks as free in internal in-memory block allocation
structures only after the transaction freeing them commits. Ext4 uses
journal commit callback for this purpose.</p>
<p>With journal commit callbacks you can ask the journalling layer to call
a callback function when the transaction is finally committed to disk,
so that you can do some of your own management. You ask the journalling
layer for calling the callback by simply setting
<code class="docutils literal notranslate"><span class="pre">journal-&gt;j_commit_callback</span></code> function pointer and that function is
called after each transaction commit.</p>
<p>JBD2 also provides a way to block all transaction updates via
<a class="reference internal" href="#c.jbd2_journal_lock_updates" title="jbd2_journal_lock_updates"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_lock_updates()</span></code></a> /
<a class="reference internal" href="#c.jbd2_journal_unlock_updates" title="jbd2_journal_unlock_updates"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_unlock_updates()</span></code></a>. Ext4 uses this when it wants a
window with a clean and stable fs for a moment. E.g.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>jbd2_journal_lock_updates() //stop new stuff happening..
jbd2_journal_flush()        // checkpoint everything.
..do stuff on stable fs
jbd2_journal_unlock_updates() // carry on with filesystem use.
</pre></div>
</div>
<p>The opportunities for abuse and DOS attacks with this should be obvious,
if you allow unprivileged userspace to trigger codepaths containing
these calls.</p>
</section>
<section id="fast-commits">
<h3>Fast commits<a class="headerlink" href="#fast-commits" title="Link to this heading">¶</a></h3>
<p>JBD2 to also allows you to perform file-system specific delta commits known as
fast commits. In order to use fast commits, you will need to set following
callbacks that perform corresponding work:</p>
<p><cite>journal-&gt;j_fc_cleanup_cb</cite>: Cleanup function called after every full commit and
fast commit.</p>
<p><cite>journal-&gt;j_fc_replay_cb</cite>: Replay function called for replay of fast commit
blocks.</p>
<p>File system is free to perform fast commits as and when it wants as long as it
gets permission from JBD2 to do so by calling the function
<code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_fc_begin_commit()</span></code>. Once a fast commit is done, the client
file  system should tell JBD2 about it by calling
<code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_fc_end_commit()</span></code>. If the file system wants JBD2 to perform a full
commit immediately after stopping the fast commit it can do so by calling
<code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_fc_end_commit_fallback()</span></code>. This is useful if fast commit operation
fails for some reason and the only way to guarantee consistency is for JBD2 to
perform the full traditional commit.</p>
<p>JBD2 helper functions to manage fast commit buffers. File system can use
<code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_fc_get_buf()</span></code> and <code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_fc_wait_bufs()</span></code> to allocate
and wait on IO completion of fast commit buffers.</p>
<p>Currently, only Ext4 implements fast commits. For details of its implementation
of fast commits, please refer to the top level comments in
fs/ext4/fast_commit.c.</p>
</section>
<section id="summary">
<h3>Summary<a class="headerlink" href="#summary" title="Link to this heading">¶</a></h3>
<p>Using the journal is a matter of wrapping the different context changes,
being each mount, each modification (transaction) and each changed
buffer to tell the journalling layer about them.</p>
</section>
</section>
<section id="data-types">
<h2>Data Types<a class="headerlink" href="#data-types" title="Link to this heading">¶</a></h2>
<p>The journalling layer uses typedefs to ‘hide’ the concrete definitions
of the structures used. As a client of the JBD2 layer you can just rely
on the using the pointer as a magic cookie of some sort. Obviously the
hiding is not enforced as this is ‘C’.</p>
<section id="structures">
<h3>Structures<a class="headerlink" href="#structures" title="Link to this heading">¶</a></h3>
<dl class="c type">
<dt class="sig sig-object c" id="c.handle_t">
<span class="k"><span class="pre">type</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">handle_t</span></span></span><a class="headerlink" href="#c.handle_t" title="Link to this definition">¶</a><br /></dt>
<dd><p>The handle_t type represents a single atomic update being performed by some process.</p>
</dd></dl>

<p><strong>Description</strong></p>
<p>All filesystem modifications made by the process go
through this handle.  Recursive operations (such as quota operations)
are gathered into a single update.</p>
<p>The buffer credits field is used to account for journaled buffers
being modified by the running process.  To ensure that there is
enough log space for all outstanding operations, we need to limit the
number of outstanding buffers possible at any time.  When the
operation completes, any buffer credits not used are credited back to
the transaction, so that at all times we know how many buffers the
outstanding updates on a transaction might possibly touch.</p>
<p>This is an opaque datatype.</p>
<dl class="c type">
<dt class="sig sig-object c" id="c.journal_t">
<span class="k"><span class="pre">type</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">journal_t</span></span></span><a class="headerlink" href="#c.journal_t" title="Link to this definition">¶</a><br /></dt>
<dd><p>The journal_t maintains all of the journaling state information for a single filesystem.</p>
</dd></dl>

<p><strong>Description</strong></p>
<p>journal_t is linked to from the fs superblock structure.</p>
<p>We use the journal_t to keep track of all outstanding transaction
activity on the filesystem, and to manage the state of the log
writing process.</p>
<p>This is an opaque datatype.</p>
<dl class="c struct">
<dt class="sig sig-object c" id="c.jbd2_inode">
<span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_inode</span></span></span><a class="headerlink" href="#c.jbd2_inode" title="Link to this definition">¶</a><br /></dt>
<dd><p>The jbd_inode type is the structure linking inodes in ordered mode present in a transaction so that we can sync them during commit.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Definition</strong>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>struct jbd2_inode {
    transaction_t *i_transaction;
    transaction_t *i_next_transaction;
    struct list_head i_list;
    struct inode *i_vfs_inode;
    unsigned long i_flags;
    loff_t i_dirty_start;
    loff_t i_dirty_end;
};
</pre></div>
</div>
<p><strong>Members</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">i_transaction</span></code></dt><dd><p>Which transaction does this inode belong to? Either the running
transaction or the committing one. [j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">i_next_transaction</span></code></dt><dd><p>Pointer to the running transaction modifying inode’s data in case
there is already a committing transaction touching it. [j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">i_list</span></code></dt><dd><p>List of inodes in the i_transaction [j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">i_vfs_inode</span></code></dt><dd><p>VFS inode this inode belongs to [constant for lifetime of structure]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">i_flags</span></code></dt><dd><p>Flags of inode [j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">i_dirty_start</span></code></dt><dd><p>Offset in bytes where the dirty range for this inode starts.
[j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">i_dirty_end</span></code></dt><dd><p>Inclusive offset in bytes where the dirty range for this inode
ends. [j_list_lock]</p>
</dd>
</dl>
</div>
<dl class="c struct">
<dt class="sig sig-object c" id="c.jbd2_journal_handle">
<span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_handle</span></span></span><a class="headerlink" href="#c.jbd2_journal_handle" title="Link to this definition">¶</a><br /></dt>
<dd><p>The jbd2_journal_handle type is the concrete type associated with handle_t.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Definition</strong>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>struct jbd2_journal_handle {
    union {
        transaction_t *h_transaction;
        journal_t *h_journal;
    };
    handle_t *h_rsv_handle;
    int h_total_credits;
    int h_revoke_credits;
    int h_revoke_credits_requested;
    int h_ref;
    int h_err;
    unsigned int    h_sync:         1;
    unsigned int    h_reserved:     1;
    unsigned int    h_aborted:      1;
    unsigned int    h_type:         8;
    unsigned int    h_line_no:      16;
    unsigned long           h_start_jiffies;
    unsigned int            h_requested_credits;
    unsigned int            saved_alloc_context;
};
</pre></div>
</div>
<p><strong>Members</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">{unnamed_union}</span></code></dt><dd><p>anonymous</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_transaction</span></code></dt><dd><p>Which compound transaction is this update a part of?</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_journal</span></code></dt><dd><p>Which journal handle belongs to - used iff h_reserved set.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_rsv_handle</span></code></dt><dd><p>Handle reserved for finishing the logical operation.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_total_credits</span></code></dt><dd><p>Number of remaining buffers we are allowed to add to
journal. These are dirty buffers and revoke descriptor blocks.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_revoke_credits</span></code></dt><dd><p>Number of remaining revoke records available for handle</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_revoke_credits_requested</span></code></dt><dd><p>Holds <strong>h_revoke_credits</strong> after handle is started.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_ref</span></code></dt><dd><p>Reference count on this handle.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_err</span></code></dt><dd><p>Field for caller’s use to track errors through large fs operations.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_sync</span></code></dt><dd><p>Flag for sync-on-close.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_reserved</span></code></dt><dd><p>Flag for handle for reserved credits.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_aborted</span></code></dt><dd><p>Flag indicating fatal error on handle.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_type</span></code></dt><dd><p>For handle statistics.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_line_no</span></code></dt><dd><p>For handle statistics.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_start_jiffies</span></code></dt><dd><p>Handle Start time.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">h_requested_credits</span></code></dt><dd><p>Holds <strong>h_total_credits</strong> after handle is started.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">saved_alloc_context</span></code></dt><dd><p>Saved context while transaction is open.</p>
</dd>
</dl>
</div>
<dl class="c struct">
<dt class="sig sig-object c" id="c.journal_s">
<span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">journal_s</span></span></span><a class="headerlink" href="#c.journal_s" title="Link to this definition">¶</a><br /></dt>
<dd><p>The journal_s type is the concrete type associated with journal_t.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Definition</strong>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>struct journal_s {
    unsigned long           j_flags;
    int j_errno;
    struct mutex            j_abort_mutex;
    struct buffer_head      *j_sb_buffer;
    journal_superblock_t *j_superblock;
    rwlock_t j_state_lock;
    int j_barrier_count;
    struct mutex            j_barrier;
    transaction_t *j_running_transaction;
    transaction_t *j_committing_transaction;
    transaction_t *j_checkpoint_transactions;
    wait_queue_head_t j_wait_transaction_locked;
    wait_queue_head_t j_wait_done_commit;
    wait_queue_head_t j_wait_commit;
    wait_queue_head_t j_wait_updates;
    wait_queue_head_t j_wait_reserved;
    wait_queue_head_t j_fc_wait;
    struct mutex            j_checkpoint_mutex;
    struct buffer_head      *j_chkpt_bhs[JBD2_NR_BATCH];
    struct shrinker         *j_shrinker;
    struct percpu_counter   j_checkpoint_jh_count;
    transaction_t *j_shrink_transaction;
    unsigned long           j_head;
    unsigned long           j_tail;
    unsigned long           j_free;
    unsigned long           j_first;
    unsigned long           j_last;
    unsigned long           j_fc_first;
    unsigned long           j_fc_off;
    unsigned long           j_fc_last;
    struct block_device     *j_dev;
    int j_blocksize;
    unsigned long long      j_blk_offset;
    char j_devname[BDEVNAME_SIZE+24];
    struct block_device     *j_fs_dev;
    errseq_t j_fs_dev_wb_err;
    unsigned int            j_total_len;
    atomic_t j_reserved_credits;
    spinlock_t j_list_lock;
    struct inode            *j_inode;
    tid_t j_tail_sequence;
    tid_t j_transaction_sequence;
    tid_t j_commit_sequence;
    tid_t j_commit_request;
    __u8 j_uuid[16];
    struct task_struct      *j_task;
    int j_max_transaction_buffers;
    int j_revoke_records_per_block;
    int j_transaction_overhead_buffers;
    unsigned long           j_commit_interval;
    struct timer_list       j_commit_timer;
    spinlock_t j_revoke_lock;
    struct jbd2_revoke_table_s *j_revoke;
    struct jbd2_revoke_table_s *j_revoke_table[2];
    struct buffer_head      **j_wbuf;
    struct buffer_head      **j_fc_wbuf;
    int j_wbufsize;
    int j_fc_wbufsize;
    pid_t j_last_sync_writer;
    u64 j_average_commit_time;
    u32 j_min_batch_time;
    u32 j_max_batch_time;
    void (*j_commit_callback)(journal_t *, transaction_t *);
    int (*j_submit_inode_data_buffers) (struct jbd2_inode *);
    int (*j_finish_inode_data_buffers) (struct jbd2_inode *);
    spinlock_t j_history_lock;
    struct proc_dir_entry   *j_proc_entry;
    struct transaction_stats_s j_stats;
    unsigned int            j_failed_commit;
    void *j_private;
    __u32 j_csum_seed;
#ifdef CONFIG_DEBUG_LOCK_ALLOC;
    struct lockdep_map      j_trans_commit_map;
#endif;
    struct lock_class_key   jbd2_trans_commit_key;
    void (*j_fc_cleanup_callback)(struct journal_s *journal, int full, tid_t tid);
    int (*j_fc_replay_callback)(struct journal_s *journal, struct buffer_head *bh, enum passtype pass, int off, tid_t expected_commit_id);
    int (*j_bmap)(struct journal_s *journal, sector_t *block);
};
</pre></div>
</div>
<p><strong>Members</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">j_flags</span></code></dt><dd><p>General journaling state flags [j_state_lock,
no lock for quick racy checks]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_errno</span></code></dt><dd><p>Is there an outstanding uncleared error on the journal (from a prior
abort)? [j_state_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_abort_mutex</span></code></dt><dd><p>Lock the whole aborting procedure.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_sb_buffer</span></code></dt><dd><p>The first part of the superblock buffer.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_superblock</span></code></dt><dd><p>The second part of the superblock buffer.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_state_lock</span></code></dt><dd><p>Protect the various scalars in the journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_barrier_count</span></code></dt><dd><p>Number of processes waiting to create a barrier lock [j_state_lock,
no lock for quick racy checks]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_barrier</span></code></dt><dd><p>The barrier lock itself.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_running_transaction</span></code></dt><dd><p>Transactions: The current running transaction...
[j_state_lock, no lock for quick racy checks] [caller holding
open handle]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_committing_transaction</span></code></dt><dd><p>the transaction we are pushing to disk
[j_state_lock] [caller holding open handle]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_checkpoint_transactions</span></code></dt><dd><p>... and a linked circular list of all transactions waiting for
checkpointing. [j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_wait_transaction_locked</span></code></dt><dd><p>Wait queue for waiting for a locked transaction to start committing,
or for a barrier lock to be released.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_wait_done_commit</span></code></dt><dd><p>Wait queue for waiting for commit to complete.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_wait_commit</span></code></dt><dd><p>Wait queue to trigger commit.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_wait_updates</span></code></dt><dd><p>Wait queue to wait for updates to complete.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_wait_reserved</span></code></dt><dd><p>Wait queue to wait for reserved buffer credits to drop.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_wait</span></code></dt><dd><p>Wait queue to wait for completion of async fast commits.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_checkpoint_mutex</span></code></dt><dd><p>Semaphore for locking against concurrent checkpoints.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_chkpt_bhs</span></code></dt><dd><p>List of buffer heads used by the checkpoint routine.  This
was moved from <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">jbd2_log_do_checkpoint()</span></code> to reduce stack
usage.  Access to this array is controlled by the
<strong>j_checkpoint_mutex</strong>.  [j_checkpoint_mutex]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_shrinker</span></code></dt><dd><p>Journal head shrinker, reclaim buffer’s journal head which
has been written back.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_checkpoint_jh_count</span></code></dt><dd><p>Number of journal buffers on the checkpoint list. [j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_shrink_transaction</span></code></dt><dd><p>Record next transaction will shrink on the checkpoint list.
[j_list_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_head</span></code></dt><dd><p>Journal head: identifies the first unused block in the journal.
[j_state_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_tail</span></code></dt><dd><p>Journal tail: identifies the oldest still-used block in the journal.
[j_state_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_free</span></code></dt><dd><p>Journal free: how many free blocks are there in the journal?
[j_state_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_first</span></code></dt><dd><p>The block number of the first usable block in the journal
[j_state_lock].</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_last</span></code></dt><dd><p>The block number one beyond the last usable block in the journal
[j_state_lock].</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_first</span></code></dt><dd><p>The block number of the first fast commit block in the journal
[j_state_lock].</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_off</span></code></dt><dd><p>Number of fast commit blocks currently allocated. Accessed only
during fast commit. Currently only process can do fast commit, so
this field is not protected by any lock.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_last</span></code></dt><dd><p>The block number one beyond the last fast commit block in the journal
[j_state_lock].</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_dev</span></code></dt><dd><p>Device where we store the journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_blocksize</span></code></dt><dd><p>Block size for the location where we store the journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_blk_offset</span></code></dt><dd><p>Starting block offset into the device where we store the journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_devname</span></code></dt><dd><p>Journal device name.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fs_dev</span></code></dt><dd><p>Device which holds the client fs.  For internal journal this will be
equal to j_dev.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fs_dev_wb_err</span></code></dt><dd><p>Records the errseq of the client fs’s backing block device.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_total_len</span></code></dt><dd><p>Total maximum capacity of the journal region on disk.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_reserved_credits</span></code></dt><dd><p>Number of buffers reserved from the running transaction.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_list_lock</span></code></dt><dd><p>Protects the buffer lists and internal buffer state.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_inode</span></code></dt><dd><p>Optional inode where we store the journal.  If present, all
journal block numbers are mapped into this inode via <a class="reference internal" href="api-summary.html#c.bmap" title="bmap"><code class="xref c c-func docutils literal notranslate"><span class="pre">bmap()</span></code></a>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_tail_sequence</span></code></dt><dd><p>Sequence number of the oldest transaction in the log [j_state_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_transaction_sequence</span></code></dt><dd><p>Sequence number of the next transaction to grant [j_state_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_commit_sequence</span></code></dt><dd><p>Sequence number of the most recently committed transaction
[j_state_lock, no lock for quick racy checks]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_commit_request</span></code></dt><dd><p>Sequence number of the most recent transaction wanting commit
[j_state_lock, no lock for quick racy checks]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_uuid</span></code></dt><dd><p>Journal uuid: identifies the object (filesystem, LVM volume etc)
backed by this journal.  This will eventually be replaced by an array
of uuids, allowing us to index multiple devices within a single
journal and to perform atomic updates across them.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_task</span></code></dt><dd><p>Pointer to the current commit thread for this journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_max_transaction_buffers</span></code></dt><dd><p>Maximum number of metadata buffers to allow in a single compound
commit transaction.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_revoke_records_per_block</span></code></dt><dd><p>Number of revoke records that fit in one descriptor block.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_transaction_overhead_buffers</span></code></dt><dd><p>Number of blocks each transaction needs for its own bookkeeping</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_commit_interval</span></code></dt><dd><p>What is the maximum transaction lifetime before we begin a commit?</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_commit_timer</span></code></dt><dd><p>The timer used to wakeup the commit thread.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_revoke_lock</span></code></dt><dd><p>Protect the revoke table.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_revoke</span></code></dt><dd><p>The revoke table - maintains the list of revoked blocks in the
current transaction.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_revoke_table</span></code></dt><dd><p>Alternate revoke tables for j_revoke.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_wbuf</span></code></dt><dd><p>Array of bhs for jbd2_journal_commit_transaction.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_wbuf</span></code></dt><dd><p>Array of fast commit bhs for fast commit. Accessed only
during a fast commit. Currently only process can do fast commit, so
this field is not protected by any lock.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_wbufsize</span></code></dt><dd><p>Size of <strong>j_wbuf</strong> array.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_wbufsize</span></code></dt><dd><p>Size of <strong>j_fc_wbuf</strong> array.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_last_sync_writer</span></code></dt><dd><p>The pid of the last person to run a synchronous operation
through the journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_average_commit_time</span></code></dt><dd><p>The average amount of time in nanoseconds it takes to commit a
transaction to disk. [j_state_lock]</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_min_batch_time</span></code></dt><dd><p>Minimum time that we should wait for additional filesystem operations
to get batched into a synchronous handle in microseconds.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_max_batch_time</span></code></dt><dd><p>Maximum time that we should wait for additional filesystem operations
to get batched into a synchronous handle in microseconds.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_commit_callback</span></code></dt><dd><p>This function is called when a transaction is closed.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_submit_inode_data_buffers</span></code></dt><dd><p>This function is called for all inodes associated with the
committing transaction marked with JI_WRITE_DATA flag
before we start to write out the transaction to the journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_finish_inode_data_buffers</span></code></dt><dd><p>This function is called for all inodes associated with the
committing transaction marked with JI_WAIT_DATA flag
after we have written the transaction to the journal
but before we write out the commit block.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_history_lock</span></code></dt><dd><p>Protect the transactions statistics history.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_proc_entry</span></code></dt><dd><p>procfs entry for the jbd statistics directory.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_stats</span></code></dt><dd><p>Overall statistics.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_failed_commit</span></code></dt><dd><p>Failed journal commit ID.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_private</span></code></dt><dd><p>An opaque pointer to fs-private information.  ext3 puts its
superblock pointer here.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_csum_seed</span></code></dt><dd><p>Precomputed journal UUID checksum for seeding other checksums.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_trans_commit_map</span></code></dt><dd><p>Lockdep entity to track transaction commit dependencies. Handles
hold this “lock” for read, when we wait for commit, we acquire the
“lock” for writing. This matches the properties of jbd2 journalling
where the running transaction has to wait for all handles to be
dropped to commit that transaction and also acquiring a handle may
require transaction commit to finish.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">jbd2_trans_commit_key</span></code></dt><dd><p>“<code class="xref c c-struct broken_xref docutils literal notranslate"><span class="pre">struct</span> <span class="pre">lock_class_key</span></code>” for <strong>j_trans_commit_map</strong></p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_cleanup_callback</span></code></dt><dd><p>Clean-up after fast commit or full commit. JBD2 calls this function
after every commit operation.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_fc_replay_callback</span></code></dt><dd><p>File-system specific function that performs replay of a fast
commit. JBD2 calls this function for each fast commit block found in
the journal. This function should return JBD2_FC_REPLAY_CONTINUE
to indicate that the block was processed correctly and more fast
commit replay should continue. Return value of JBD2_FC_REPLAY_STOP
indicates the end of replay (no more blocks remaining). A negative
return value indicates error.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">j_bmap</span></code></dt><dd><p>Bmap function that should be used instead of the generic
VFS bmap function.</p>
</dd>
</dl>
</div>
</section>
</section>
<section id="functions">
<h2>Functions<a class="headerlink" href="#functions" title="Link to this heading">¶</a></h2>
<p>The functions here are split into two groups those that affect a journal
as a whole, and those which are used to manage transactions</p>
<section id="journal-level">
<h3>Journal Level<a class="headerlink" href="#journal-level" title="Link to this heading">¶</a></h3>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_force_commit_nested">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_force_commit_nested</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_force_commit_nested" title="Link to this definition">¶</a><br /></dt>
<dd><p>Force and wait upon a commit if the calling process is not within transaction.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal to force
Returns true if progress was made.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>This is used for forcing out undo-protected data which contains
bitmaps, when the fs is running out of space.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_force_commit">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_force_commit</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_force_commit" title="Link to this definition">¶</a><br /></dt>
<dd><p>force any uncommitted transactions</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal to force</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Caller want unconditional commit. We can only force the running transaction
if we don’t have an active handle, otherwise, we will deadlock.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_init_dev">
<a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_init_dev</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">block_device</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">bdev</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">block_device</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">fs_dev</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">start</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">len</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">blocksize</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_init_dev" title="Link to this definition">¶</a><br /></dt>
<dd><p>creates and initialises a journal structure</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">block_device</span> <span class="pre">*bdev</span></code></dt><dd><p>Block device on which to create the journal</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">block_device</span> <span class="pre">*fs_dev</span></code></dt><dd><p>Device which hold journalled filesystem for this journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">long</span> <span class="pre">start</span></code></dt><dd><p>Block nr Start of journal.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">len</span></code></dt><dd><p>Length of the journal in blocks.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">blocksize</span></code></dt><dd><p>blocksize of journalling device</p>
</dd>
</dl>
<p><strong>Return</strong></p>
<p>a newly created journal_t *</p>
<p><strong>Description</strong></p>
<blockquote>
<div><p>jbd2_journal_init_dev creates a journal which maps a fixed contiguous
range of blocks on an arbitrary block device.</p>
</div></blockquote>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_init_inode">
<a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_init_inode</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="#c.jbd2_journal_init_inode" title="inode"><span class="n"><span class="pre">inode</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">inode</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_init_inode" title="Link to this definition">¶</a><br /></dt>
<dd><p>creates a journal which maps to a inode.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">inode</span> <span class="pre">*inode</span></code></dt><dd><p>An inode to create the journal in</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>jbd2_journal_init_inode creates a journal which maps an on-disk inode as
the journal.  The inode must exist already, must support <a class="reference internal" href="api-summary.html#c.bmap" title="bmap"><code class="xref c c-func docutils literal notranslate"><span class="pre">bmap()</span></code></a> and
must have all data blocks preallocated.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_update_sb_errno">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_update_sb_errno</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_update_sb_errno" title="Link to this definition">¶</a><br /></dt>
<dd><p>Update error in the journal.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>The journal to update.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Update a journal’s errno.  Write updated superblock to disk waiting for IO
to complete.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_load">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_load</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_load" title="Link to this definition">¶</a><br /></dt>
<dd><p>Read journal from disk.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to act on.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Given a journal_t structure which tells us which disk blocks contain
a journal, read the journal from disk to initialise the in-memory
structures.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_destroy">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_destroy</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_destroy" title="Link to this definition">¶</a><br /></dt>
<dd><p>Release a journal_t structure.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to act on.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Release a journal_t structure once it is no longer in use by the
journaled object.
Return &lt;0 if we couldn’t clean up the journal.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_check_used_features">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_check_used_features</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">compat</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">ro</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">incompat</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_check_used_features" title="Link to this definition">¶</a><br /></dt>
<dd><p>Check if features specified are used.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to check.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">compat</span></code></dt><dd><p>bitmask of compatible features</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">ro</span></code></dt><dd><p>bitmask of features that force read-only mount</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">incompat</span></code></dt><dd><p>bitmask of incompatible features</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Check whether the journal uses all of a given set of
features.  Return true (non-zero) if it does.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_check_available_features">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_check_available_features</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">compat</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">ro</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">incompat</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_check_available_features" title="Link to this definition">¶</a><br /></dt>
<dd><p>Check feature set in journalling layer</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to check.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">compat</span></code></dt><dd><p>bitmask of compatible features</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">ro</span></code></dt><dd><p>bitmask of features that force read-only mount</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">incompat</span></code></dt><dd><p>bitmask of incompatible features</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Check whether the journaling code supports the use of
all of a given set of features on this journal.  Return true</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_set_features">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_set_features</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">compat</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">ro</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">long</span></span><span class="w"> </span><span class="n"><span class="pre">incompat</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_set_features" title="Link to this definition">¶</a><br /></dt>
<dd><p>Mark a given journal feature in the superblock</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to act on.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">compat</span></code></dt><dd><p>bitmask of compatible features</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">ro</span></code></dt><dd><p>bitmask of features that force read-only mount</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">long</span> <span class="pre">incompat</span></code></dt><dd><p>bitmask of incompatible features</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Mark a given journal feature as present on the
superblock.  Returns true if the requested features could be set.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_flush">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_flush</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">flags</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_flush" title="Link to this definition">¶</a><br /></dt>
<dd><p>Flush journal</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to act on.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span> <span class="pre">flags</span></code></dt><dd><p>optional operation on the journal blocks after the flush (see below)</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Flush all data for a given journal to disk and empty the journal.
Filesystems can use this when remounting readonly to ensure that
recovery does not need to happen on remount. Optionally, a discard or zeroout
can be issued on the journal blocks after flushing.</p>
<dl class="simple">
<dt>flags:</dt><dd><p>JBD2_JOURNAL_FLUSH_DISCARD: issues discards for the journal blocks
JBD2_JOURNAL_FLUSH_ZEROOUT: issues zeroouts for the journal blocks</p>
</dd>
</dl>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_wipe">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_wipe</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">write</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_wipe" title="Link to this definition">¶</a><br /></dt>
<dd><p>Wipe journal contents</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to act on.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">write</span></code></dt><dd><p>flag (see below)</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Wipe out all of the contents of a journal, safely.  This will produce
a warning if the journal contains any valid recovery information.
Must be called between journal_init_*() and <a class="reference internal" href="#c.jbd2_journal_load" title="jbd2_journal_load"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_load()</span></code></a>.</p>
<p>If ‘write’ is non-zero, then we wipe out the journal on disk; otherwise
we merely suppress recovery.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_abort">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_abort</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">errno</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_abort" title="Link to this definition">¶</a><br /></dt>
<dd><p>Shutdown the journal immediately.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>the journal to shutdown.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">errno</span></code></dt><dd><p>an error number to record in the journal indicating
the reason for the shutdown.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Perform a complete, immediate shutdown of the ENTIRE
journal (not of a single transaction).  This operation cannot be
undone without closing and reopening the journal.</p>
<p>The jbd2_journal_abort function is intended to support higher level error
recovery mechanisms such as the ext2/ext3 remount-readonly error
mode.</p>
<p>Journal abort has very specific semantics.  Any existing dirty,
unjournaled buffers in the main filesystem will still be written to
disk by bdflush, but the journaling mechanism will be suspended
immediately and no further transaction commits will be honoured.</p>
<p>Any dirty, journaled buffers will be written back to disk without
hitting the journal.  Atomicity cannot be guaranteed on an aborted
filesystem, but we _do_ attempt to leave as much data as possible
behind for fsck to use for cleanup.</p>
<p>Any attempt to get a new transaction handle on a journal which is in
ABORT state will just result in an -EROFS error return.  A
jbd2_journal_stop on an existing handle will return -EIO if we have
entered abort state during the update.</p>
<p>Recursive transactions are not disturbed by journal abort until the
final jbd2_journal_stop, which will receive the -EIO error.</p>
<p>Finally, the jbd2_journal_abort call allows the caller to supply an errno
which will be recorded (if possible) in the journal superblock.  This
allows a client to record failure conditions in the middle of a
transaction without having to complete the transaction to record the
failure to disk.  ext3_error, for example, now uses this
functionality.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_errno">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_errno</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_errno" title="Link to this definition">¶</a><br /></dt>
<dd><p>returns the journal’s error state.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal to examine.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>This is the errno number set with <a class="reference internal" href="#c.jbd2_journal_abort" title="jbd2_journal_abort"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_abort()</span></code></a>, the last
time the journal was mounted - if the journal was stopped
without calling abort this will be 0.</p>
<p>If the journal has been aborted on this mount time -EROFS will
be returned.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_clear_err">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_clear_err</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_clear_err" title="Link to this definition">¶</a><br /></dt>
<dd><p>clears the journal’s error state</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal to act on.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>An error must be cleared or acked to take a FS out of readonly
mode.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_ack_err">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_ack_err</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_ack_err" title="Link to this definition">¶</a><br /></dt>
<dd><p>Ack journal err.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal to act on.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>An error must be cleared or acked to take a FS out of readonly
mode.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_recover">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_recover</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_recover" title="Link to this definition">¶</a><br /></dt>
<dd><p>recovers a on-disk journal</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>the journal to recover</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>The primary function for recovering the log contents when mounting a
journaled device.</p>
<p>Recovery is done in three passes.  In the first pass, we look for the
end of the log.  In the second, we assemble the list of revoke
blocks.  In the third and final pass, we replay any un-revoked blocks
in the log.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_skip_recovery">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_skip_recovery</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_skip_recovery" title="Link to this definition">¶</a><br /></dt>
<dd><p>Start journal and wipe exiting records</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal to startup</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Locate any valid recovery information from the journal and set up the
journal structures in memory to ignore it (presumably because the
caller has evidence that it is out of date).
This function doesn’t appear to be exported..</p>
<p>We perform one pass over the journal to allow us to tell the user how
much recovery information is being erased, and to let us initialise
the journal transaction sequence numbers to the next unused ID.</p>
</div>
</section>
<section id="transaction-level">
<h3>Transaction Level<a class="headerlink" href="#transaction-level" title="Link to this heading">¶</a></h3>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_start">
<a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_start</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">nblocks</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_start" title="Link to this definition">¶</a><br /></dt>
<dd><p>Obtain a new handle.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to start transaction on.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">nblocks</span></code></dt><dd><p>number of block buffer we might modify</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>We make sure that the transaction can guarantee at least nblocks of
modified buffers in the log.  We block until the log can guarantee
that much space. Additionally, if rsv_blocks &gt; 0, we also create another
handle with rsv_blocks reserved blocks in the journal. This handle is
stored in h_rsv_handle. It is not attached to any particular transaction
and thus doesn’t block transaction commit. If the caller uses this reserved
handle, it has to set h_rsv_handle to NULL as otherwise <a class="reference internal" href="#c.jbd2_journal_stop" title="jbd2_journal_stop"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_stop()</span></code></a>
on the parent handle will dispose the reserved one. Reserved handle has to
be converted to a normal handle using <a class="reference internal" href="#c.jbd2_journal_start_reserved" title="jbd2_journal_start_reserved"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start_reserved()</span></code></a> before
it can be used.</p>
<p>Return a pointer to a newly allocated handle, or an <a class="reference internal" href="../core-api/kernel-api.html#c.ERR_PTR" title="ERR_PTR"><code class="xref c c-func docutils literal notranslate"><span class="pre">ERR_PTR()</span></code></a> value
on failure.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_start_reserved">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_start_reserved</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">type</span></span>, <span class="kt"><span class="pre">unsigned</span></span><span class="w"> </span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">line_no</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_start_reserved" title="Link to this definition">¶</a><br /></dt>
<dd><p>start reserved handle</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>handle to start</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span> <span class="pre">type</span></code></dt><dd><p>for handle statistics</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">unsigned</span> <span class="pre">int</span> <span class="pre">line_no</span></code></dt><dd><p>for handle statistics</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Start handle that has been previously reserved with <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">jbd2_journal_reserve()</span></code>.
This attaches <strong>handle</strong> to the running transaction (or creates one if there’s
not transaction running). Unlike <a class="reference internal" href="#c.jbd2_journal_start" title="jbd2_journal_start"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_start()</span></code></a> this function cannot
block on journal commit, checkpointing, or similar stuff. It can block on
memory allocation or frozen journal though.</p>
<p>Return 0 on success, non-zero on error - handle is freed in that case.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_extend">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_extend</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">nblocks</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">revoke_records</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_extend" title="Link to this definition">¶</a><br /></dt>
<dd><p>extend buffer credits.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>handle to ‘extend’</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">nblocks</span></code></dt><dd><p>nr blocks to try to extend by.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">revoke_records</span></code></dt><dd><p>number of revoke records to try to extend by.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Some transactions, such as large extends and truncates, can be done
atomically all at once or in several stages.  The operation requests
a credit for a number of buffer modifications in advance, but can
extend its credit if it needs more.</p>
<p>jbd2_journal_extend tries to give the running handle more buffer credits.
It does not guarantee that allocation - this is a best-effort only.
The calling process MUST be able to deal cleanly with a failure to
extend here.</p>
<p>Return 0 on success, non-zero on failure.</p>
<p>return code &lt; 0 implies an error
return code &gt; 0 implies normal transaction-full status.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2__journal_restart">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2__journal_restart</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">nblocks</span></span>, <span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">revoke_records</span></span>, <span class="n"><span class="pre">gfp_t</span></span><span class="w"> </span><span class="n"><span class="pre">gfp_mask</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2__journal_restart" title="Link to this definition">¶</a><br /></dt>
<dd><p>restart a handle .</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>handle to restart</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">nblocks</span></code></dt><dd><p>nr credits requested</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">int</span> <span class="pre">revoke_records</span></code></dt><dd><p>number of revoke record credits requested</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">gfp_t</span> <span class="pre">gfp_mask</span></code></dt><dd><p>memory allocation flags (for start_this_handle)</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Restart a handle for a multi-transaction filesystem
operation.</p>
<p>If the <a class="reference internal" href="#c.jbd2_journal_extend" title="jbd2_journal_extend"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_extend()</span></code></a> call above fails to grant new buffer credits
to a running handle, a call to jbd2_journal_restart will commit the
handle’s transaction so far and reattach the handle to a new
transaction capable of guaranteeing the requested number of
credits. We preserve reserved handle if there’s any attached to the
passed in handle.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_lock_updates">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_lock_updates</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_lock_updates" title="Link to this definition">¶</a><br /></dt>
<dd><p>establish a transaction barrier.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to establish a barrier on.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>This locks out any further updates from being started, and blocks
until all existing updates have completed, returning only once the
journal is in a quiescent state with no updates running.</p>
<p>The journal lock should not be held on entry.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_unlock_updates">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_unlock_updates</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_unlock_updates" title="Link to this definition">¶</a><br /></dt>
<dd><p>release barrier</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>Journal to release the barrier on.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Release a transaction barrier obtained with <a class="reference internal" href="#c.jbd2_journal_lock_updates" title="jbd2_journal_lock_updates"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_lock_updates()</span></code></a>.</p>
<p>Should be called without the journal lock held.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_get_write_access">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_get_write_access</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">buffer_head</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">bh</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_get_write_access" title="Link to this definition">¶</a><br /></dt>
<dd><p>notify intent to modify a buffer for metadata (not data) update.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>transaction to add buffer modifications to</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">buffer_head</span> <span class="pre">*bh</span></code></dt><dd><p>bh to be used for metadata writes</p>
</dd>
</dl>
<p><strong>Return</strong></p>
<p>error code or 0 on success.</p>
<p><strong>Description</strong></p>
<p>In full data journalling mode the buffer may be of type BJ_AsyncData,
because we’re <code class="docutils literal notranslate"><span class="pre">write()ing</span></code> a buffer which is also part of a shared mapping.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_get_create_access">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_get_create_access</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">buffer_head</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">bh</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_get_create_access" title="Link to this definition">¶</a><br /></dt>
<dd><p>notify intent to use newly created bh</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>transaction to new buffer to</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">buffer_head</span> <span class="pre">*bh</span></code></dt><dd><p>new buffer.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Call this if you create a new bh.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_get_undo_access">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_get_undo_access</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">buffer_head</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">bh</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_get_undo_access" title="Link to this definition">¶</a><br /></dt>
<dd><p>Notify intent to modify metadata with non-rewindable consequences</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>transaction</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">buffer_head</span> <span class="pre">*bh</span></code></dt><dd><p>buffer to undo</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Sometimes there is a need to distinguish between metadata which has
been committed to disk and that which has not.  The ext3fs code uses
this for freeing and allocating space, we have to make sure that we
do not reuse freed space until the deallocation has been committed,
since if we overwrote that space we would make the delete
un-rewindable in case of a crash.</p>
<p>To deal with that, jbd2_journal_get_undo_access requests write access to a
buffer for parts of non-rewindable operations such as delete
operations on the bitmaps.  The journaling code must keep a copy of
the buffer’s contents prior to the undo_access call until such time
as we know that the buffer has definitely been committed to disk.</p>
<p>We never need to know which transaction the committed data is part
of, buffers touched here are guaranteed to be dirtied later and so
will be committed to a new transaction in due course, at which point
we can discard the old committed data pointer.</p>
<p>Returns error number or 0 on success.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_set_triggers">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_set_triggers</span></span></span><span class="sig-paren">(</span><span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">buffer_head</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">bh</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">jbd2_buffer_trigger_type</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">type</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_set_triggers" title="Link to this definition">¶</a><br /></dt>
<dd><p>Add triggers for commit writeout</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">buffer_head</span> <span class="pre">*bh</span></code></dt><dd><p>buffer to trigger on</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">jbd2_buffer_trigger_type</span> <span class="pre">*type</span></code></dt><dd><p><code class="xref c c-struct broken_xref docutils literal notranslate"><span class="pre">struct</span> <span class="pre">jbd2_buffer_trigger_type</span></code> containing the trigger(s).</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Set any triggers on this journal_head.  This is always safe, because
triggers for a committing buffer will be saved off, and triggers for
a running transaction will match the buffer in that transaction.</p>
<p>Call with NULL to clear the triggers.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_dirty_metadata">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_dirty_metadata</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">buffer_head</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">bh</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_dirty_metadata" title="Link to this definition">¶</a><br /></dt>
<dd><p>mark a buffer as containing dirty metadata</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>transaction to add buffer to.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">buffer_head</span> <span class="pre">*bh</span></code></dt><dd><p>buffer to mark</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>mark dirty metadata which needs to be journaled as part of the current
transaction.</p>
<p>The buffer must have previously had <a class="reference internal" href="#c.jbd2_journal_get_write_access" title="jbd2_journal_get_write_access"><code class="xref c c-func docutils literal notranslate"><span class="pre">jbd2_journal_get_write_access()</span></code></a>
called so that it has a valid journal_head attached to the buffer
head.</p>
<p>The buffer is placed on the transaction’s metadata list and is marked
as belonging to the transaction.</p>
<p>Returns error number or 0 on success.</p>
<p>Special care needs to be taken if the buffer already belongs to the
current committing transaction (in which case we should have frozen
data present for that commit).  In that case, we don’t relink the
buffer: that only gets done when the old transaction finally
completes its commit.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_forget">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_forget</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><span class="n"><span class="pre">buffer_head</span></span><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">bh</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_forget" title="Link to this definition">¶</a><br /></dt>
<dd><p><a class="reference internal" href="buffer.html#c.bforget" title="bforget"><code class="xref c c-func docutils literal notranslate"><span class="pre">bforget()</span></code></a> for potentially-journaled buffers.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>transaction handle</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">buffer_head</span> <span class="pre">*bh</span></code></dt><dd><p>bh to ‘forget’</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>We can only do the bforget if there are no commits pending against the
buffer.  If the buffer is dirty in the current running transaction we
can safely unlink it.</p>
<p>bh may not be a journalled buffer at all - it may be a non-JBD
buffer which came off the hashtable.  Check for this.</p>
<p>Decrements bh-&gt;b_count by one.</p>
<p>Allow this call even if the handle has aborted --- it may be part of
the caller’s cleanup after an abort.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_stop">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_stop</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.handle_t" title="handle_t"><span class="n"><span class="pre">handle_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">handle</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_stop" title="Link to this definition">¶</a><br /></dt>
<dd><p>complete a transaction</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">handle_t</span> <span class="pre">*handle</span></code></dt><dd><p>transaction to complete.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>All done for a particular handle.</p>
<p>There is not much action needed here.  We just return any remaining
buffer credits to the transaction and remove the handle.  The only
complication is that we need to start a commit operation if the
filesystem is marked for synchronous update.</p>
<p>jbd2_journal_stop itself will not usually return an error, but it may
do so in unusual circumstances.  In particular, expect it to
return -EIO if a jbd2_journal_abort has been executed since the
transaction began.</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_try_to_free_buffers">
<span class="kt"><span class="pre">bool</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_try_to_free_buffers</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="#c.jbd2_journal_try_to_free_buffers" title="folio"><span class="n"><span class="pre">folio</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">folio</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_try_to_free_buffers" title="Link to this definition">¶</a><br /></dt>
<dd><p>try to free page buffers.</p>
</dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal for operation</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">folio</span> <span class="pre">*folio</span></code></dt><dd><p>Folio to detach data from.</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>For all the buffers on this page,
if they are fully written out ordered data, move them onto BUF_CLEAN
so <a class="reference internal" href="buffer.html#c.try_to_free_buffers" title="try_to_free_buffers"><code class="xref c c-func docutils literal notranslate"><span class="pre">try_to_free_buffers()</span></code></a> can reap them.</p>
<p>This function returns non-zero if we wish <a class="reference internal" href="buffer.html#c.try_to_free_buffers" title="try_to_free_buffers"><code class="xref c c-func docutils literal notranslate"><span class="pre">try_to_free_buffers()</span></code></a>
to be called. We do this if the page is releasable by <a class="reference internal" href="buffer.html#c.try_to_free_buffers" title="try_to_free_buffers"><code class="xref c c-func docutils literal notranslate"><span class="pre">try_to_free_buffers()</span></code></a>.
We also do it if the page has locked or dirty buffers and the caller wants
us to perform sync or async writeout.</p>
<p>This complicates JBD locking somewhat.  We aren’t protected by the
BKL here.  We wish to remove the buffer from its committing or
running transaction’s -&gt;t_datalist via __jbd2_journal_unfile_buffer.</p>
<p>This may <em>change</em> the value of transaction_t-&gt;t_datalist, so anyone
who looks at t_datalist needs to lock against this function.</p>
<p>Even worse, someone may be doing a jbd2_journal_dirty_data on this
buffer.  So we need to lock against that.  <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">jbd2_journal_dirty_data()</span></code>
will come out of the lock with the buffer dirty, which makes it
ineligible for release here.</p>
<p>Who else is affected by this?  hmm...  Really the only contender
is <code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">do_get_write_access()</span></code> - it could be looking at the buffer while
<code class="xref c c-func broken_xref docutils literal notranslate"><span class="pre">journal_try_to_free_buffer()</span></code> is changing its state.  But that
cannot happen because we never reallocate freed data as metadata
while the data is part of a transaction.  Yes?</p>
<p>Return false on failure, true on success</p>
</div>
<dl class="c function">
<dt class="sig sig-object c" id="c.jbd2_journal_invalidate_folio">
<span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">jbd2_journal_invalidate_folio</span></span></span><span class="sig-paren">(</span><a class="reference internal" href="#c.journal_t" title="journal_t"><span class="n"><span class="pre">journal_t</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">journal</span></span>, <span class="k"><span class="pre">struct</span></span><span class="w"> </span><a class="reference internal" href="#c.jbd2_journal_invalidate_folio" title="folio"><span class="n"><span class="pre">folio</span></span></a><span class="w"> </span><span class="p"><span class="pre">*</span></span><span class="n"><span class="pre">folio</span></span>, <span class="n"><span class="pre">size_t</span></span><span class="w"> </span><span class="n"><span class="pre">offset</span></span>, <span class="n"><span class="pre">size_t</span></span><span class="w"> </span><span class="n"><span class="pre">length</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.jbd2_journal_invalidate_folio" title="Link to this definition">¶</a><br /></dt>
<dd></dd></dl>

<div class="kernelindent docutils container">
<p><strong>Parameters</strong></p>
<dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">journal_t</span> <span class="pre">*journal</span></code></dt><dd><p>journal to use for flush...</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">struct</span> <span class="pre">folio</span> <span class="pre">*folio</span></code></dt><dd><p>folio to flush</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">size_t</span> <span class="pre">offset</span></code></dt><dd><p>start of the range to invalidate</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">size_t</span> <span class="pre">length</span></code></dt><dd><p>length of the range to invalidate</p>
</dd>
</dl>
<p><strong>Description</strong></p>
<p>Reap page buffers containing data after in the specified range in page.
Can return -EBUSY if buffers are part of the committing transaction and
the page is straddling i_size. Caller then has to wait for current commit
and try again.</p>
</div>
</section>
</section>
<section id="see-also">
<h2>See also<a class="headerlink" href="#see-also" title="Link to this heading">¶</a></h2>
<p><a class="reference external" href="http://kernel.org/pub/linux/kernel/people/sct/ext3/journal-design.ps.gz">Journaling the Linux ext2fs Filesystem, LinuxExpo 98, Stephen
Tweedie</a></p>
<p><a class="reference external" href="http://olstrans.sourceforge.net/release/OLS2000-ext3/OLS2000-ext3.html">Ext3 Journalling FileSystem, OLS 2000, Dr. Stephen
Tweedie</a></p>
</section>
</section>


          </div>
          
        </div>
      </div>
    <div class="clearer"></div>
  </div>
    <div class="footer">
      &#169;The kernel development community.
      
      |
      Powered by <a href="https://www.sphinx-doc.org/">Sphinx 8.1.3</a>
      &amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
      
      |
      <a href="../_sources/filesystems/journalling.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>

Filemanager

Name Type Size Permission Actions
caching Folder 0755
ext4 Folder 0755
fuse Folder 0755
iomap Folder 0755
nfs Folder 0755
smb Folder 0755
spufs Folder 0755
xfs Folder 0755
9p.html File 24.15 KB 0644
adfs.html File 13.15 KB 0644
affs.html File 18.5 KB 0644
afs.html File 19.14 KB 0644
api-summary.html File 831.83 KB 0644
autofs-mount-control.html File 32.3 KB 0644
autofs.html File 38.96 KB 0644
automount-support.html File 12.79 KB 0644
befs.html File 14.41 KB 0644
bfs.html File 10.72 KB 0644
btrfs.html File 9.7 KB 0644
buffer.html File 48.88 KB 0644
ceph.html File 18.87 KB 0644
coda.html File 65.97 KB 0644
configfs.html File 36.14 KB 0644
cramfs.html File 14.95 KB 0644
dax.html File 25.37 KB 0644
debugfs.html File 21.71 KB 0644
devpts.html File 10.61 KB 0644
directory-locking.html File 23.11 KB 0644
dlmfs.html File 14.28 KB 0644
dnotify.html File 12.09 KB 0644
ecryptfs.html File 11.96 KB 0644
efivarfs.html File 10 KB 0644
erofs.html File 29.42 KB 0644
ext2.html File 32.92 KB 0644
ext3.html File 8.29 KB 0644
f2fs.html File 67.87 KB 0644
fiemap.html File 23.32 KB 0644
files.html File 16.52 KB 0644
fscrypt.html File 107.9 KB 0644
fsverity.html File 64.53 KB 0644
gfs2-glocks.html File 21.71 KB 0644
gfs2-uevents.html File 12.88 KB 0644
gfs2.html File 10.38 KB 0644
hfs.html File 12.31 KB 0644
hfsplus.html File 10.28 KB 0644
hpfs.html File 26.83 KB 0644
idmappings.html File 74.42 KB 0644
index.html File 68.19 KB 0644
inotify.html File 12.35 KB 0644
isofs.html File 12.17 KB 0644
journalling.html File 115.17 KB 0644
locking.html File 52.92 KB 0644
locks.html File 11.91 KB 0644
mount_api.html File 49.94 KB 0644
multigrain-ts.html File 15 KB 0644
netfs_library.html File 86.81 KB 0644
nilfs2.html File 22.21 KB 0644
ntfs3.html File 13.64 KB 0644
ocfs2-online-filecheck.html File 13.13 KB 0644
ocfs2.html File 15.76 KB 0644
omfs.html File 13.12 KB 0644
orangefs.html File 35.89 KB 0644
overlayfs.html File 54.83 KB 0644
path-lookup.html File 123.09 KB 0644
porting.html File 94.09 KB 0644
proc.html File 140.32 KB 0644
qnx6.html File 16.36 KB 0644
quota.html File 12.12 KB 0644
ramfs-rootfs-initramfs.html File 27.94 KB 0644
relay.html File 40.38 KB 0644
resctrl.html File 93.99 KB 0644
romfs.html File 18.06 KB 0644
seq_file.html File 36.49 KB 0644
sharedsubtree.html File 46.25 KB 0644
splice.html File 79.36 KB 0644
squashfs.html File 24.34 KB 0644
sysfs.html File 29.32 KB 0644
tmpfs.html File 22.95 KB 0644
ubifs-authentication.html File 33.04 KB 0644
ubifs.html File 15.06 KB 0644
udf.html File 12.11 KB 0644
vfat.html File 26.07 KB 0644
vfs.html File 167.26 KB 0644
virtiofs.html File 12.16 KB 0644
zonefs.html File 35.71 KB 0644
Filemanager