Patch "btrfs: fix dirty_metadata_bytes for redirtied buffers" has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    btrfs: fix dirty_metadata_bytes for redirtied buffers

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     btrfs-fix-dirty_metadata_bytes-for-redirtied-buffers.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From f18cc97845aa4ae0e795c088c979fe1642b3b8e5 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@xxxxxx>
Date: Mon, 8 May 2023 07:58:38 -0700
Subject: btrfs: fix dirty_metadata_bytes for redirtied buffers

From: Christoph Hellwig <hch@xxxxxx>

commit f18cc97845aa4ae0e795c088c979fe1642b3b8e5 upstream.

dirty_metadata_bytes is decremented in both places that clear the dirty
bit in a buffer, but only incremented in btrfs_mark_buffer_dirty, which
means that a buffer that is redirtied using btrfs_redirty_list_add won't
be added to dirty_metadata_bytes, but it will be subtracted when written
out, leading an inconsistency in the counter.

Move the dirty_metadata_bytes from btrfs_mark_buffer_dirty into
set_extent_buffer_dirty to also account for the redirty case, and remove
the now unused set_extent_buffer_dirty return value.

Fixes: d3575156f662 ("btrfs: zoned: redirty released extent buffers")
CC: stable@xxxxxxxxxxxxxxx # 5.15+
Reviewed-by: Naohiro Aota <naohiro.aota@xxxxxxx>
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
Signed-off-by: David Sterba <dsterba@xxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/btrfs/disk-io.c   |    7 +------
 fs/btrfs/extent_io.c |    7 ++++---
 fs/btrfs/extent_io.h |    2 +-
 3 files changed, 6 insertions(+), 10 deletions(-)

--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4683,7 +4683,6 @@ void btrfs_mark_buffer_dirty(struct exte
 {
 	struct btrfs_fs_info *fs_info = buf->fs_info;
 	u64 transid = btrfs_header_generation(buf);
-	int was_dirty;
 
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 	/*
@@ -4698,11 +4697,7 @@ void btrfs_mark_buffer_dirty(struct exte
 	if (transid != fs_info->generation)
 		WARN(1, KERN_CRIT "btrfs transid mismatch buffer %llu, found %llu running %llu\n",
 			buf->start, transid, fs_info->generation);
-	was_dirty = set_extent_buffer_dirty(buf);
-	if (!was_dirty)
-		percpu_counter_add_batch(&fs_info->dirty_metadata_bytes,
-					 buf->len,
-					 fs_info->dirty_metadata_batch);
+	set_extent_buffer_dirty(buf);
 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
 	/*
 	 * Since btrfs_mark_buffer_dirty() can be called with item pointer set
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4064,7 +4064,7 @@ void btrfs_clear_buffer_dirty(struct btr
 	WARN_ON(atomic_read(&eb->refs) == 0);
 }
 
-bool set_extent_buffer_dirty(struct extent_buffer *eb)
+void set_extent_buffer_dirty(struct extent_buffer *eb)
 {
 	int i;
 	int num_pages;
@@ -4099,13 +4099,14 @@ bool set_extent_buffer_dirty(struct exte
 					     eb->start, eb->len);
 		if (subpage)
 			unlock_page(eb->pages[0]);
+		percpu_counter_add_batch(&eb->fs_info->dirty_metadata_bytes,
+					 eb->len,
+					 eb->fs_info->dirty_metadata_batch);
 	}
 #ifdef CONFIG_BTRFS_DEBUG
 	for (i = 0; i < num_pages; i++)
 		ASSERT(PageDirty(eb->pages[i]));
 #endif
-
-	return was_dirty;
 }
 
 void clear_extent_buffer_uptodate(struct extent_buffer *eb)
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -263,7 +263,7 @@ void extent_buffer_bitmap_set(const stru
 void extent_buffer_bitmap_clear(const struct extent_buffer *eb,
 				unsigned long start, unsigned long pos,
 				unsigned long len);
-bool set_extent_buffer_dirty(struct extent_buffer *eb);
+void set_extent_buffer_dirty(struct extent_buffer *eb);
 void set_extent_buffer_uptodate(struct extent_buffer *eb);
 void clear_extent_buffer_uptodate(struct extent_buffer *eb);
 int extent_buffer_under_io(const struct extent_buffer *eb);


Patches currently in stable-queue which might be from hch@xxxxxx are

queue-6.4/block-fix-the-type-of-the-second-bdev_op_is_zoned_wr.patch
queue-6.4/btrfs-don-t-fail-writeback-when-allocating-the-compr.patch
queue-6.4/btrfs-fix-dirty_metadata_bytes-for-redirtied-buffers.patch
queue-6.4/btrfs-don-t-treat-zoned-writeback-as-being-from-an-a.patch
queue-6.4/nvme-core-fix-dev_pm_qos-memleak.patch
queue-6.4/btrfs-always-read-the-entire-extent_buffer.patch
queue-6.4/btrfs-fix-file_offset-for-req_btrfs_one_ordered-bios.patch
queue-6.4/block-change-all-__u32-annotations-to-__be32-in-affs_hardblocks.h.patch
queue-6.4/nvme-core-add-missing-fault-injection-cleanup.patch
queue-6.4/writeback-account-the-number-of-pages-written-back.patch
queue-6.4/nvme-core-fix-memory-leak-in-dhchap_secret_store.patch
queue-6.4/btrfs-submit-a-writeback-bio-per-extent_buffer.patch
queue-6.4/btrfs-fix-range_end-calculation-in-extent_write_lock.patch
queue-6.4/btrfs-return-bool-from-lock_extent_buffer_for_io.patch
queue-6.4/block-fix-blktrace-debugfs-entries-leakage.patch
queue-6.4/splice-fix-filemap_splice_read-to-use-the-correct-in.patch
queue-6.4/btrfs-only-call-__extent_writepage_io-from-extent_wr.patch
queue-6.4/blk-mq-don-t-queue-plugged-passthrough-requests-into.patch
queue-6.4/mm-damon-ops-common-atomically-test-and-clear-young-on-ptes-and-pmds.patch
queue-6.4/btrfs-don-t-use-btrfs_bio_ctrl-for-extent-buffer-rea.patch
queue-6.4/splice-don-t-call-file_accessed-in-copy_splice_read.patch
queue-6.4/vfio-mdev-move-the-compat_class-initialization-to-mo.patch
queue-6.4/block-fix-signed-int-overflow-in-amiga-partition-support.patch
queue-6.4/fsverity-use-shash-api-instead-of-ahash-api.patch
queue-6.4/nvme-core-fix-memory-leak-in-dhchap_ctrl_secret.patch
queue-6.4/block-increment-diskseq-on-all-media-change-events.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux