]> git.hungrycats.org Git - linux/commitdiff
btrfs: stripe_alloc: share LOG data runs per log transaction
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Tue, 6 Oct 2026 04:11:38 +0000 (00:11 -0400)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 2 Nov 2026 02:16:30 +0000 (21:16 -0500)
An fsyncing inode's data goes into a private LOG-class stripe run, which
each log commit settles: the run is closed, the commit waits for all of the
run's data IO, and the extents left in its final partial stripe are
recorded for carry-forward, so the next fsync re-dirties them and moves
them into the inode's new run.  Every fsync therefore leaves one partial
stripe per inode, and a back-to-back fsync loop rewrites the previous
fsync's tail each time.

Share the runs instead:

- LOG-class runs are keyed by (subvolume, log_transid at allocation)
  instead of the inode, so the inodes logging in one log transaction fill
  the same stripes.  An allocation of a full stripe or more keeps the
  inode's private run, so small fsync extents never share the partial last
  stripe of a large one and wait for its IO.
- A log commit does not close a shared run.  It seals the stripe holding
  the end of the logged extent: the run's frontier moves to that stripe's
  end, the skipped sectors go back to the free space cache like a closed
  run's tail (the stripe's final write pads them), and the run goes on in
  the next stripe.  Nothing allocates beside the extent after its log
  commit.
- The settle kicks only the logged extent's stripes and waits until every
  allocated sector in them is written (the run's written map), rather than
  for the whole run to drain.  Writers sharing those stripes park and merge
  into the same full-stripe write, so the wait couples an fsync to them and
  to nothing else.  It has no timeout: returning while a neighbour's sector
  is unwritten would let its later partial write RMW the extent after the
  log made it durable.  Completed writes wake the waiters.
- Nothing is carried forward: a final partial stripe stays until the
  extents in it are freed or compaction moves them.

Measured on 5 x 8 GiB raid5 data with raid1 and raid5 metadata, against
private runs with carry-forward, same rep: at 16 and 64 writers and with
one fsync per inode, 1.2-2.9x the fsyncs/s (one 64-writer rep of eight:
0.8x), 3-8x fewer device bytes per fsync and less slab; one writer is at
parity on latency with 17-29% fewer device bytes.  The one workload that
can lose is two large streaming writers beside small fsync writers: a small
fsync waits for neighbours that joined its stripe and sit behind the large
IO (0.5-1.9x the fsyncs/s; the p99.9 there is dominated by a multi-second
log-commit tail that both modes, and stock raid5, show).

/sys/fs/btrfs/<uuid>/stripe_log_data_shared (default 1) switches a
filesystem back to private runs with carry-forward.  stripe_run_stats gains
log_settle_waits and log_settle_wait_ns (both), log_carry_ranges and
log_carry_bytes (private runs), and log_seals and log_seal_bytes (shared
runs).

Private LOG and NOCOW runs are matched by (subvolume root id, inode
number), since inode numbers are unique only within a subvolume (every
subvolume's first file is inode 257): matching by inode alone let
same-numbered inodes of different subvolumes join each other's runs,
breaking NOCOW isolation, and let an eviction close other subvolumes'
runs and the META_LOG run of a subvolume whose id equals the inode number.
Eviction closes only the inode's own LOG and NOCOW runs, and the shared
LOG key uses the whole root id.

btrfs_log_settle_stripes() reads stripe_log_data_shared once per settle,
and every completed write wakes the settle waiters whatever the knob says,
so a sysfs change cannot leave an fsync waiting for a run only the commit
it blocks would provide.

Assisted-by: Claude:claude-opus-5-5
fs/btrfs/block-group.c
fs/btrfs/defrag.c
fs/btrfs/disk-io.c
fs/btrfs/fs.h
fs/btrfs/sysfs.c

index e58d3e96bcc0a58034b06db4ecb92abdcee5cbdd..ce88e22f780aaa00333cd9030e01c3a2fe712884 100644 (file)
@@ -498,7 +498,14 @@ struct btrfs_open_stripe_run {
        u64 offset;                     /* next unallocated byte */
        u64 inflight_bytes;             /* reserved bytes with data IO pending */
        u64 open_seq;                   /* fs_info->stripe_retire_seq at open */
-       u64 owner;                      /* LOG class: btrfs_ino of the owner */
+       /*
+        * Private runs are found by (root, owner): root is the subvolume's
+        * root id, owner the inode number (LOG, NOCOW), a shared LOG key
+        * (bit 63 set, see stripe_run_owner()), or for META_LOG the root id
+        * again.  Inode numbers are only unique within a subvolume.
+        */
+       u64 root;
+       u64 owner;
        enum btrfs_stripe_run_class class;
        bool open;                      /* accepting allocations */
        bool persistent;                /* survives commits; see close_block_group_stripe_runs() */
@@ -978,18 +985,40 @@ out:
 }
 
 /*
- * Allocate num_bytes for a log-active inode from its private LOG-class run
- * in this block group, claiming a fresh run when the inode has none here or
- * the current one does not fit.  Private runs are never placed in the shared
- * band slots and are found by owner lookup, so no other allocation can join
- * an inode's run and one inode's log commit settles only its own stripes.
+ * The owner a private run is found by: the inode, or with
+ * stripe_log_data_shared a LOG-class run shared by every inode of the
+ * subvolume logging in the same log transaction.  An allocation of a full
+ * stripe or more keeps the inode's private run, so small fsync extents never
+ * share the partial last stripe of a large one and wait for its IO.  Bit 63
+ * keeps the shared keys apart from inode numbers; the subvolume is matched
+ * separately, by run->root.
+ */
+static u64 stripe_run_owner(struct btrfs_inode *inode,
+                           enum btrfs_stripe_run_class class, u64 num_bytes,
+                           u64 fsl)
+{
+       struct btrfs_root *root = inode->root;
+
+       if (class == BTRFS_STRIPE_RUN_LOG && num_bytes < fsl &&
+           READ_ONCE(root->fs_info->stripe_log_data_shared))
+               return BIT_ULL(63) | (u32)READ_ONCE(root->log_transid);
+       return btrfs_ino(inode);
+}
+
+/*
+ * Allocate num_bytes for @inode from its private run of @class (LOG or
+ * NOCOW) in this block group, claiming a fresh run when there is none or it
+ * does not fit.  With stripe_log_data_shared, small LOG allocations use the
+ * run the subvolume shares for the current log transaction
+ * (stripe_run_owner()).  Private runs are never placed in a band slot and
+ * are found by subvolume and owner, so a log commit settles only stripes
+ * holding its own extents.  A NOCOW allocation may instead re-adopt the
+ * free tail of the inode's last partial stripe (@readopt_hint).
  *
- * A replaced run (too small for this allocation) is closed immediately: the
- * inode moves on to the fresh run, so keeping the remainder open would only
- * strand it until the commit-time retirement.  Two racing allocations for
- * the same inode can each claim a fresh run; the owner walk then serves one
- * of them and the other drains and retires at the next commit -- an
- * occasional trapped tail, not a correctness problem.
+ * A run too small for this allocation is closed at once rather than left
+ * to strand its tail until commit.  Two racing allocations for one owner
+ * may each claim a run; the spare drains at the next commit, costing a
+ * trapped tail, not correctness.
  *
  * Returns 0 and sets *ret_offset, -ENOSPC if no fully-free stripe run in
  * this block group can satisfy the allocation, or -ENOMEM.
@@ -1002,7 +1031,8 @@ int btrfs_alloc_from_inode_stripe_run(struct btrfs_block_group *bg,
 {
        struct btrfs_fs_info *fs_info = bg->fs_info;
        const u64 fsl = bg->full_stripe_len;
-       const u64 ino = btrfs_ino(inode);
+       const u64 root_id = btrfs_root_id(inode->root);
+       const u64 ino = stripe_run_owner(inode, class, num_bytes, fsl);
        struct btrfs_open_stripe_run *new_run;
        struct btrfs_open_stripe_run *run;
        unsigned long flags;
@@ -1017,7 +1047,8 @@ int btrfs_alloc_from_inode_stripe_run(struct btrfs_block_group *bg,
 
        spin_lock_irqsave(&bg->stripe_run_lock, flags);
        list_for_each_entry(run, &bg->open_stripe_runs, list) {
-               if (run->class != class || run->owner != ino || !run->open)
+               if (run->class != class || run->root != root_id ||
+                   run->owner != ino || !run->open)
                        continue;
                if (num_bytes <= run->end - run->offset) {
                        *ret_offset = run->offset;
@@ -1069,8 +1100,8 @@ int btrfs_alloc_from_inode_stripe_run(struct btrfs_block_group *bg,
                 * the re-adoption and falls through to a fresh claim below,
                 * costing this stripe's free tail, not correctness.
                 */
-               if (stripe_extents_owned_by(fs_info, btrfs_root_id(inode->root),
-                                           ino, stripe, fsl, &frontier, true) &&
+               if (stripe_extents_owned_by(fs_info, root_id, ino, stripe, fsl,
+                                           &frontier, true) &&
                    frontier > stripe && frontier < stripe + fsl &&
                    num_bytes <= stripe + fsl - frontier) {
                        tlen = stripe + fsl - frontier;
@@ -1138,6 +1169,7 @@ install:
                                BTRFS_STRIPE_RMW_PREALLOC));
        if (class == BTRFS_STRIPE_RUN_NOCOW)
                atomic64_inc(&fs_info->stripe_run_stats.nocow_run_opened);
+       new_run->root = root_id;
        new_run->owner = ino;
        new_run->start = start;
        new_run->end = start + len;
@@ -1531,7 +1563,7 @@ bool btrfs_stripe_nocow_writable(struct btrfs_inode *inode, u64 start,
                        if (cur < run->start || cur >= run->end)
                                continue;
                        if (run->class == BTRFS_STRIPE_RUN_NOCOW &&
-                           run->owner == ino)
+                           run->root == root_id && run->owner == ino)
                                verdict = 1;
                        else
                                verdict = -1;
@@ -1809,6 +1841,7 @@ static void log_carry_record(struct btrfs_inode *inode, u64 file_start,
        carry->range[carry->nr_ranges].len = file_len;
        carry->range[carry->nr_ranges].disk_bytenr = bytenr;
        carry->nr_ranges++;
+       atomic64_inc(&inode->root->fs_info->stripe_run_stats.log_carry_ranges);
 }
 
 /*
@@ -1885,15 +1918,14 @@ bool btrfs_block_group_has_stripe_runs(struct btrfs_block_group *bg)
 }
 
 /*
- * Close every private stripe run owned by @inode, of any class: called at
- * inode eviction so a persistent nocow run's claimed tail does not stay
- * unusable for the rest of the mount (log-class runs would close at the
- * next commit anyway; closing them here is merely tidy).  The runs' tails
- * return to the free space cache.
+ * Close @inode's open LOG and NOCOW runs at eviction, so a persistent NOCOW
+ * run's claimed tail does not stay unusable for the rest of the mount.  The
+ * tails return to the free space cache.
  */
 void btrfs_close_inode_stripe_runs(struct btrfs_inode *inode)
 {
        struct btrfs_fs_info *fs_info = inode->root->fs_info;
+       const u64 root_id = btrfs_root_id(inode->root);
        const u64 ino = btrfs_ino(inode);
        struct btrfs_block_group *bg;
 
@@ -1910,7 +1942,10 @@ restart:
 
                spin_lock_irqsave(&bg->stripe_run_lock, flags);
                list_for_each_entry(run, &bg->open_stripe_runs, list) {
-                       if (!run->open || run->owner != ino)
+                       if (!run->open || run->root != root_id ||
+                           run->owner != ino ||
+                           (run->class != BTRFS_STRIPE_RUN_LOG &&
+                            run->class != BTRFS_STRIPE_RUN_NOCOW))
                                continue;
                        tail_len = close_open_stripe_run(bg, run, &tail_start);
                        break;
@@ -1928,29 +1963,108 @@ restart:
        spin_unlock(&fs_info->open_stripe_lock);
 }
 
+/*
+ * A log commit on a shared LOG run: instead of closing the run, move its
+ * frontier past the stripe holding the end of the logged extent, so nothing
+ * allocates beside the extent after the log commit while the run goes on in
+ * the next stripe.  The skipped sectors are not live (the pad oracle fills
+ * them) and go back to the free space cache like a closed run's tail: inside
+ * a partly live stripe they count as trapped until the stripe frees, and a
+ * later close returns only [offset, end), which no longer includes them.
+ * Caller holds bg->stripe_run_lock.  Returns the skipped length.
+ */
+static u64 seal_log_stripe(struct btrfs_block_group *bg,
+                          struct btrfs_open_stripe_run *run, u64 ext_end,
+                          u64 *skip_start)
+{
+       const u64 fsl = bg->full_stripe_len;
+       u64 boundary;
+       u64 skip;
+
+       if (!run->open)
+               return 0;
+       boundary = bg->start + stripe_round_down(ext_end - 1 - bg->start, fsl) + fsl;
+       if (run->offset >= boundary)
+               return 0;
+       boundary = min(boundary, run->end);
+       skip = boundary - run->offset;
+       *skip_start = run->offset;
+       run->offset = boundary;
+       bg->stripe_open_remainder -= skip;
+       if (run->offset == run->end) {
+               int class;
+               int band;
+
+               for (class = 0; class < BTRFS_STRIPE_RUN_NR_CLASSES; class++)
+                       for (band = 0; band < BTRFS_STRIPE_RUN_NR_BANDS; band++)
+                               if (bg->open_stripe[class][band] == run)
+                                       bg->open_stripe[class][band] = NULL;
+               run->open = false;
+               if (open_stripe_run_drained(run) && !run->retained)
+                       free_open_stripe_run(bg, run);
+       }
+       return skip;
+}
+
+static bool run_unwritten_in(struct btrfs_open_stripe_run *run, u64 start,
+                            u64 len);
+
+/*
+ * Per-stripe settle (stripe_log_data_shared): every allocated sector of the
+ * stripes holding [bytenr, bytenr + num_bytes) has been written, or no run
+ * covers them any more.  Writers sharing those stripes park and merge into
+ * the same full-stripe write, so this waits for them and for nothing else in
+ * the run.
+ */
+static bool stripe_log_extent_written(struct btrfs_block_group *bg,
+                                     u64 bytenr, u64 num_bytes)
+{
+       const u64 fsl = bg->full_stripe_len;
+       const u64 s = bg->start + stripe_round_down(bytenr - bg->start, fsl);
+       const u64 e = bg->start +
+                     stripe_round_down(bytenr + num_bytes - bg->start + fsl - 1, fsl);
+       struct btrfs_open_stripe_run *run;
+       unsigned long flags;
+       bool written = true;
+
+       spin_lock_irqsave(&bg->stripe_run_lock, flags);
+       list_for_each_entry(run, &bg->open_stripe_runs, list) {
+               if (bytenr < run->start || bytenr >= run->offset)
+                       continue;
+               if (run_unwritten_in(run, s, e - s))
+                       written = false;
+               break;
+       }
+       spin_unlock_irqrestore(&bg->stripe_run_lock, flags);
+       return written;
+}
+
 /*
  * A log commit is about to make the extent at [bytenr, bytenr + num_bytes)
- * durable.  Once the log super lands, no later write may extend or RMW the
- * extent's stripes -- the log-window analogue of invariant I2, which the
- * commit-time retirement provides for full commits.  Close the open run
- * covering the extent so nothing further allocates into its stripes, kick
- * any parked partial writes for it, and wait for all data IO into it to
- * finish.  Extents in full or already-settled stripes cost one list walk.
+ * durable, after which no later write may extend or RMW its stripes.  Close
+ * the run covering the extent so nothing more allocates into its stripes,
+ * kick any parked partial writes there, and wait for all IO into the run to
+ * finish.  This is a pure data-IO wait (no transaction joins), bounded by
+ * bio flight time because parked writes are flushed first, and is safe
+ * under the inode log mutex and a running transaction handle.
  *
- * The drain is bounded: run inflight is counted from allocation, which
- * happens during writeback with submission following in the same pass, so
- * the wait is bio flight time plus the parked-write deadline that the flush
- * below short-circuits.  It is a pure data-IO wait (no transaction joins),
- * safe under the inode log mutex and a running transaction handle.
+ * With stripe_log_data_shared a shared LOG run is not closed: the stripe
+ * holding the end of the extent is sealed (seal_log_stripe()).  In that
+ * mode the wait, for any run, is for every allocated sector of the
+ * extent's stripes to be written (stripe_log_extent_written()) rather than
+ * for the run to drain.  Neither wait has a timeout: returning early would
+ * let a neighbour's partial write RMW the extent after it is durable.
  *
  * [file_start, file_start + file_len) is the extent's file range, recorded
- * for carry-forward when the extent sits in the run's final partial stripe;
- * file_len == 0 opts the extent out of carrying (settling still happens).
+ * for carry-forward when the extent is in the run's final partial stripe
+ * (stripe_log_data_shared clear only); file_len == 0 opts out of carrying.
  */
 void btrfs_log_settle_stripes(struct btrfs_inode *inode, u64 file_start,
                              u64 file_len, u64 bytenr, u64 num_bytes)
 {
        struct btrfs_fs_info *fs_info = inode->root->fs_info;
+       /* Once: the seal and the wait below must agree on the mode. */
+       const bool shared = READ_ONCE(fs_info->stripe_log_data_shared);
        struct btrfs_block_group *bg;
        struct btrfs_open_stripe_run *run;
        unsigned long flags;
@@ -1960,6 +2074,8 @@ void btrfs_log_settle_stripes(struct btrfs_inode *inode, u64 file_start,
        u64 flush_len = 0;
        u64 ps_start = 0;
        u64 ps_len = 0;
+       u64 seal_start = 0;
+       u64 seal_len = 0;
 
        /* stripe_alloc_allow_rmw=fsync waives the log-commit guarantee. */
        if (btrfs_stripe_allow_rmw(fs_info) & BTRFS_STRIPE_RMW_FSYNC)
@@ -1984,6 +2100,16 @@ void btrfs_log_settle_stripes(struct btrfs_inode *inode, u64 file_start,
                 */
                if (run->class == BTRFS_STRIPE_RUN_NOCOW)
                        break;
+               if (shared && (run->owner & BIT_ULL(63))) {
+                       const u64 fsl = bg->full_stripe_len;
+
+                       /* only the logged extent's stripes, not the shared run */
+                       flush_start = bg->start + stripe_round_down(bytenr - bg->start, fsl);
+                       flush_len = bg->start + stripe_round_down(bytenr + num_bytes - 1 - bg->start, fsl) +
+                                   fsl - flush_start;
+                       seal_len = seal_log_stripe(bg, run, bytenr + num_bytes, &seal_start);
+                       break;
+               }
                flush_start = run->start;
                flush_len = run->end - run->start;
                /*
@@ -2012,18 +2138,36 @@ void btrfs_log_settle_stripes(struct btrfs_inode *inode, u64 file_start,
        }
        spin_unlock_irqrestore(&bg->stripe_run_lock, flags);
 
-       log_carry_record(inode, file_start, file_len, bytenr, num_bytes,
-                        ps_start, ps_len);
+       if (!shared)
+               log_carry_record(inode, file_start, file_len, bytenr, num_bytes,
+                                ps_start, ps_len);
 
+       if (seal_len) {
+               btrfs_add_free_space(bg, seal_start, seal_len);
+               stripe_open_remainder_sync(bg);
+               atomic64_inc(&fs_info->stripe_run_stats.log_seals);
+               atomic64_add(seal_len, &fs_info->stripe_run_stats.log_seal_bytes);
+       }
        if (tail_len) {
                btrfs_add_free_space(bg, tail_start, tail_len);
                stripe_open_remainder_sync(bg);
        }
        if (flush_len) {
+               ktime_t t0;
+
                btrfs_flush_parked_rbios(fs_info, flush_start, flush_len, false);
-               wait_var_event(&bg->open_stripe_runs,
-                              stripe_log_range_settled(bg, bytenr) ||
-                              BTRFS_FS_ERROR(fs_info));
+               t0 = ktime_get();
+               if (shared)
+                       wait_var_event(&bg->open_stripe_runs,
+                                      stripe_log_extent_written(bg, bytenr, num_bytes) ||
+                                      BTRFS_FS_ERROR(fs_info));
+               else
+                       wait_var_event(&bg->open_stripe_runs,
+                                      stripe_log_range_settled(bg, bytenr) ||
+                                      BTRFS_FS_ERROR(fs_info));
+               atomic64_inc(&fs_info->stripe_run_stats.log_settle_waits);
+               atomic64_add(ktime_to_ns(ktime_sub(ktime_get(), t0)),
+                            &fs_info->stripe_run_stats.log_settle_wait_ns);
        }
        btrfs_put_block_group(bg);
 }
@@ -2242,6 +2386,8 @@ void btrfs_stripe_run_mark_written(struct btrfs_fs_info *fs_info, u64 start,
                bitmap_set(run->written, first, nr);
        }
        spin_unlock_irqrestore(&bg->stripe_run_lock, flags);
+       /* Per-stripe log settles wait on the written map, not on a drain. */
+       wake_up_var(&bg->open_stripe_runs);
        btrfs_put_block_group(bg);
        if (not_live)
                atomic64_add(not_live, &fs_info->stripe_park_stats.written_not_live);
index 9fdf94ecb5c9391ff71b0491c20a2088adca7284..b4a55cb7eeb68357e63105b78c5aa1e835c18879 100644 (file)
@@ -1411,6 +1411,9 @@ void btrfs_carry_log_tail(struct btrfs_inode *inode)
                return;
        if (!READ_ONCE(inode->log_carry))
                return;
+       /* Shared per-log-transaction runs do not carry (and record nothing). */
+       if (READ_ONCE(inode->root->fs_info->stripe_log_data_shared))
+               return;
        copy = kmalloc(sizeof(*copy), GFP_NOFS);
        if (!copy)
                return;
@@ -1424,6 +1427,9 @@ void btrfs_carry_log_tail(struct btrfs_inode *inode)
        inode->log_carry->nr_ranges = 0;
        mutex_unlock(&inode->log_mutex);
 
+       for (int i = 0; i < copy->nr_ranges; i++)
+               atomic64_add(copy->range[i].len,
+                            &inode->root->fs_info->stripe_run_stats.log_carry_bytes);
        for (int i = 0; i < copy->nr_ranges; i++)
                carry_one_range(inode, copy->range[i].start,
                                copy->range[i].len,
index 0d7906bea0c6172481d443036169373d0591d22a..870e8dd6b6eedc3ccaedd0e8a186a2cb81ce4458 100644 (file)
@@ -2805,6 +2805,7 @@ void btrfs_init_fs_info(struct btrfs_fs_info *fs_info)
        INIT_LIST_HEAD(&fs_info->delalloc_roots);
        INIT_LIST_HEAD(&fs_info->caching_block_groups);
        INIT_LIST_HEAD(&fs_info->open_stripe_bgs);
+       fs_info->stripe_log_data_shared = true;
        fs_info->stripe_park_timeout_ms = BTRFS_RBIO_PARK_TIMEOUT_MS;
        fs_info->stripe_compact = 10;
        fs_info->stripe_park_sync_timeout_ms = BTRFS_RBIO_PARK_SYNC_TIMEOUT_MS;
index cc11757f59fa16e31503ddeba918190c484670c5..54b568b419bf03ef2657f01fb43f4effe9970a99 100644 (file)
@@ -891,6 +891,16 @@ struct btrfs_fs_info {
                /* Completed-write sectors not live in their run (should be ~0). */
                atomic64_t written_not_live;
        } stripe_park_stats;
+       /*
+        * LOG-class data runs.  Set (the default): runs are shared per
+        * (subvolume, log_transid); a log commit seals the stripe holding the
+        * end of the logged extent and the run goes on, allocations of a full
+        * stripe or more stay in the inode's private run, and the commit waits
+        * only for the logged extent's own stripes.  Clear: one private run
+        * per fsyncing inode, closed at each log commit, with carry-forward of
+        * its final partial stripe.  See btrfs_log_settle_stripes().
+        */
+       bool stripe_log_data_shared;
        /* Stripe run lifecycle counters (sysfs stripe_run_stats). */
        struct {
                /* private NOCOW runs opened (they outlive commits) */
@@ -914,6 +924,15 @@ struct btrfs_fs_info {
                atomic64_t compact_stripes;
                /* live bytes compaction moved */
                atomic64_t compact_bytes;
+               /* log commits that waited to settle a logged extent, and how long */
+               atomic64_t log_settle_waits;
+               atomic64_t log_settle_wait_ns;
+               /* carry-forward: ranges recorded, bytes re-dirtied at fsync entry */
+               atomic64_t log_carry_ranges;
+               atomic64_t log_carry_bytes;
+               /* shared runs: frontier stripes sealed at log commit, bytes skipped */
+               atomic64_t log_seals;
+               atomic64_t log_seal_bytes;
        } stripe_run_stats;
        /* BTRFS_STRIPE_RMW_* masks; see btrfs_stripe_allow_rmw(). */
        u32 stripe_rmw_prop;
index 753de9e6357dacca745c99beeb35b9c70527f8d5..d90574a7f81f3b315baf4645aba017b43fa65f73 100644 (file)
@@ -1232,6 +1232,31 @@ static ssize_t btrfs_##_name##_store(struct kobject *kobj,               \
 BTRFS_ATTR_RW(, _name, btrfs_##_name##_show, btrfs_##_name##_store)
 
 BTRFS_PARK_TIMEOUT_ATTR(stripe_park_timeout_ms, stripe_park_timeout_ms);
+
+static ssize_t btrfs_stripe_log_data_shared_show(struct kobject *kobj,
+                                                struct kobj_attribute *a, char *buf)
+{
+       struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+
+       return sysfs_emit(buf, "%d\n", READ_ONCE(fs_info->stripe_log_data_shared) ? 1 : 0);
+}
+
+static ssize_t btrfs_stripe_log_data_shared_store(struct kobject *kobj,
+                                                 struct kobj_attribute *a,
+                                                 const char *buf, size_t len)
+{
+       struct btrfs_fs_info *fs_info = to_fs_info(kobj);
+       bool val;
+       int ret;
+
+       ret = kstrtobool(buf, &val);
+       if (ret)
+               return ret;
+       WRITE_ONCE(fs_info->stripe_log_data_shared, val);
+       return len;
+}
+BTRFS_ATTR_RW(, stripe_log_data_shared, btrfs_stripe_log_data_shared_show,
+             btrfs_stripe_log_data_shared_store);
 BTRFS_PARK_TIMEOUT_ATTR(stripe_park_sync_timeout_ms, stripe_park_sync_timeout_ms);
 BTRFS_PARK_TIMEOUT_ATTR(stripe_park_congestion, stripe_park_congestion);
 
@@ -1665,6 +1690,7 @@ static const struct attribute *btrfs_attrs[] = {
        BTRFS_ATTR_PTR(, stripe_park_stats),
        BTRFS_ATTR_PTR(, stripe_run_stats),
        BTRFS_ATTR_PTR(, stripe_park_timeout_ms),
+       BTRFS_ATTR_PTR(, stripe_log_data_shared),
        BTRFS_ATTR_PTR(, stripe_park_sync_timeout_ms),
        BTRFS_ATTR_PTR(, stripe_park_congestion),
        BTRFS_ATTR_PTR(, stripe_compact),