<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/bcachefs/journal.c, branch linux-6.7.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.7.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.7.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2023-12-10T21:53:46Z</updated>
<entry>
<title>bcachefs: Close journal entry if necessary when flushing all pins</title>
<updated>2023-12-10T21:53:46Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2023-12-10T20:23:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a66ff26b0f31189e413a87065c25949c359e4bef'/>
<id>urn:sha1:a66ff26b0f31189e413a87065c25949c359e4bef</id>
<content type='text'>
Since outstanding journal buffers hold a journal pin, when flushing all
pins we need to close the current journal entry if necessary so its pin
can be released.

Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: move journal seq assertion</title>
<updated>2023-11-29T03:58:22Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2023-11-27T05:53:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ef0beeb8dd343a57cf8ad4967b508b8e7452f347'/>
<id>urn:sha1:ef0beeb8dd343a57cf8ad4967b508b8e7452f347</id>
<content type='text'>
journal_cur_seq() can legitimately be used outside of the journal lock,
where this assert can race

Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: Kill journal pre-reservations</title>
<updated>2023-11-15T04:44:43Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2023-11-05T02:54:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=006ccc3090e2f30f5f97857f3946312692a5279e'/>
<id>urn:sha1:006ccc3090e2f30f5f97857f3946312692a5279e</id>
<content type='text'>
This deletes the complicated and somewhat expensive journal
pre-reservation machinery in favor of just using journal watermarks:
when the journal is more than half full, we run journal reclaim more
aggressively, and when the journal is more than 3/4s full we only allow
journal reclaim to get new journal reservations.

Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: Ensure devices are always correctly initialized</title>
<updated>2023-10-31T16:18:37Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2023-10-21T17:54:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bbe682c76789d679cb75effd7792d41b09efea00'/>
<id>urn:sha1:bbe682c76789d679cb75effd7792d41b09efea00</id>
<content type='text'>
We can't mark device superblocks or allocate journal on a device that
isn't online.

That means we may need to do this on every mount, because we may have
formatted a new filesystem and then done the first mount
(bch2_fs_initialize()) in degraded mode.

Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: bch2_sb_field_get() refactoring</title>
<updated>2023-10-22T21:10:16Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2023-09-26T21:49:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4637429e3946d083eedde1668c17a4fadaf3c0b1'/>
<id>urn:sha1:4637429e3946d083eedde1668c17a4fadaf3c0b1</id>
<content type='text'>
Instead of using token pasting to generate methods for each superblock
section, just make the type a parameter to bch2_sb_field_get().

Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: fix race between journal entry close and pin set</title>
<updated>2023-10-22T21:10:14Z</updated>
<author>
<name>Brian Foster</name>
</author>
<published>2023-09-15T12:51:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3e55189b504f961e68e631b72a2ed71991397ef9'/>
<id>urn:sha1:3e55189b504f961e68e631b72a2ed71991397ef9</id>
<content type='text'>
bcachefs freeze testing via fstests generic/390 occasionally
reproduces the following BUG from bch2_fs_read_only():

  BUG_ON(atomic_long_read(&amp;c-&gt;btree_key_cache.nr_dirty));

This indicates that one or more dirty key cache keys still exist
after the attempt to flush and quiesce the fs. The sequence that
leads to this problem actually occurs on unfreeze (ro-&gt;rw), and
looks something like the following:

- Task A begins a transaction commit and acquires journal_res for
  the current seq. This transaction intends to perform key cache
  insertion.
- Task B begins a bch2_journal_flush() via bch2_sync_fs(). This ends
  up in journal_entry_want_write(), which closes the current journal
  entry and drops the reference to the pin list created on entry open.
  The pin put pops the front of the journal via fast reclaim since the
  reference count has dropped to 0.
- Task A attempts to set the journal pin for the associated cached
  key, but bch2_journal_pin_set() skips the pin insert because the
  seq of the transaction reservation is behind the front of the pin
  list fifo.

The end result is that the pin associated with the cached key is not
added, which prevents a subsequent reclaim from processing the key
and thus leaves it dangling at freeze time. The fundamental cause of
this problem is that the front of the journal is allowed to pop
before a transaction with outstanding reservation on the associated
journal seq is able to add a pin. The count for the pin list
associated with the seq drops to zero and is prematurely reclaimed
as a result.

The logical fix for this problem lies in how the journal buffer is
managed in similar scenarios where the entry might have been closed
before a transaction with outstanding reservations happens to be
committed.

When a journal entry is opened, the current sequence number is
bumped, the associated pin list is initialized with a reference
count of 1, and the journal buffer reference count is bumped (via
journal_state_inc()). When a journal reservation is acquired, the
reservation also acquires a reference on the associated buffer. If
the journal entry is closed in the meantime, it drops both the pin
and buffer references held by the open entry, but the buffer still
has references held by outstanding reservation. After the associated
transaction commits, the reservation release drops the associated
buffer references and the buffer is written out once the reference
count has dropped to zero.

The fundamental problem here is that the lifecycle of the pin list
reference held by an open journal entry is too short to cover the
processing of transactions with outstanding reservations. The
simplest way to address this is to expand the pin list reference to
the lifecycle of the buffer vs. the shorter lifecycle of the open
journal entry. This ensures the pin list for a seq with outstanding
reservation cannot be popped and reclaimed before all outstanding
reservations have been released, even if the associated journal
entry has been closed for further reservations.

Move the pin put from journal entry close to where final processing
of the journal buffer occurs. Create a duplicate helper to cover the
case where the caller doesn't already hold the journal lock. This
allows generic/390 to pass reliably.

Signed-off-by: Brian Foster &lt;bfoster@redhat.com&gt;
Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: prepare journal buf put to handle pin put</title>
<updated>2023-10-22T21:10:14Z</updated>
<author>
<name>Brian Foster</name>
</author>
<published>2023-09-15T12:51:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fc08031bb84b2b4660406faf9f30db8cdd09d022'/>
<id>urn:sha1:fc08031bb84b2b4660406faf9f30db8cdd09d022</id>
<content type='text'>
bcachefs freeze testing has uncovered some raciness between journal
entry open/close and pin list reference count management. The
details of the problem are described in a separate patch. In
preparation for the associated fix, refactor the journal buffer put
path a bit to allow it to eventually handle dropping the pin list
reference currently held by an open journal entry.

Retain the journal write dispatch helper since the closure code is
inlined and we don't want to increase the amount of inline code in
the transaction commit path, but rename the function to reflect
the purpose of final processing of the journal buffer.

Signed-off-by: Brian Foster &lt;bfoster@redhat.com&gt;
Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: refactor pin put helpers</title>
<updated>2023-10-22T21:10:14Z</updated>
<author>
<name>Brian Foster</name>
</author>
<published>2023-09-15T12:51:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=92b63f5bf0774eab2e62b86f85bb4efb915edef1'/>
<id>urn:sha1:92b63f5bf0774eab2e62b86f85bb4efb915edef1</id>
<content type='text'>
We have a couple journal pin put helpers to handle cases where the
journal lock is already held or not. Refactor the helpers to lock
and reclaim from the highest level and open code the reclaim from
the one caller of the internal variant. The latter call will be
moved into the journal buf release helper in a later patch.

Signed-off-by: Brian Foster &lt;bfoster@redhat.com&gt;
Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: Heap allocate btree_trans</title>
<updated>2023-10-22T21:10:13Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2023-09-12T21:16:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6bd68ec266ad71827ef940151067b67b62fb8fed'/>
<id>urn:sha1:6bd68ec266ad71827ef940151067b67b62fb8fed</id>
<content type='text'>
We're using more stack than we'd like in a number of functions, and
btree_trans is the biggest object that we stack allocate.

But we have to do a heap allocatation to initialize it anyways, so
there's no real downside to heap allocating the entire thing.

Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
<entry>
<title>bcachefs: Fix W=12 build errors</title>
<updated>2023-10-22T21:10:13Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2023-09-12T22:41:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=96dea3d599dbc31f59eb786af2ac5079122beb88'/>
<id>urn:sha1:96dea3d599dbc31f59eb786af2ac5079122beb88</id>
<content type='text'>
Signed-off-by: Kent Overstreet &lt;kent.overstreet@linux.dev&gt;
</content>
</entry>
</feed>
