All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>
Subject: [PATCH 3/6] btrfs: remove embedded block_group_cache::item
Date: Wed, 23 Oct 2019 18:48:15 +0200	[thread overview]
Message-ID: <925c46538656d1b46146e09d19882e9c5038658c.1571848791.git.dsterba@suse.com> (raw)
In-Reply-To: <cover.1571848791.git.dsterba@suse.com>

The members ::used and ::flags are now in the block group cache
structure, the last one is chunk_objectid, but that's set to a fixed
value and otherwise unused. The item is constructed from a local
variable before write, so we can remove the embedded one from block
group.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/block-group.c | 16 +++++-----------
 fs/btrfs/block-group.h |  1 -
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 52e2a05c8345..0bb1cc5f3263 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1752,8 +1752,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
 		read_extent_buffer(leaf, &bgi,
 				   btrfs_item_ptr_offset(leaf, path->slots[0]),
 				   sizeof(bgi));
-		/* Duplicate as the item is still partially used */
-		memcpy(&cache->item, &bgi, sizeof(bgi));
+		/* cache::chunk_objectid is unused */
 		cache->used = btrfs_block_group_used(&bgi);
 		cache->flags = btrfs_block_group_flags(&bgi);
 		if (!mixed &&
@@ -1879,12 +1878,9 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans)
 			goto next;
 
 		spin_lock(&block_group->lock);
-		/*
-		 * Copy partially filled item from the cache and ovewrite used
-		 * that has the correct value
-		 */
-		memcpy(&item, &block_group->item, sizeof(item));
 		btrfs_set_block_group_used(&item, block_group->used);
+		btrfs_set_block_group_chunk_objectid(&item,
+				BTRFS_FIRST_CHUNK_TREE_OBJECTID);
 		btrfs_set_block_group_flags(&item, block_group->flags);
 		memcpy(&key, &block_group->key, sizeof(key));
 		spin_unlock(&block_group->lock);
@@ -1919,8 +1915,6 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
 		return -ENOMEM;
 
 	cache->used = bytes_used;
-	btrfs_set_block_group_chunk_objectid(&cache->item,
-					     BTRFS_FIRST_CHUNK_TREE_OBJECTID);
 	cache->flags = type;
 	cache->last_byte_to_unpin = (u64)-1;
 	cache->cached = BTRFS_CACHE_FINISHED;
@@ -2136,9 +2130,9 @@ static int write_one_cache_group(struct btrfs_trans_handle *trans,
 
 	leaf = path->nodes[0];
 	bi = btrfs_item_ptr_offset(leaf, path->slots[0]);
-	/* Partial copy of item, update the rest from memory */
-	memcpy(&bgi, &cache->item, sizeof(bgi));
 	btrfs_set_block_group_used(&bgi, cache->used);
+	btrfs_set_block_group_chunk_objectid(&bgi,
+			BTRFS_FIRST_CHUNK_TREE_OBJECTID);
 	btrfs_set_block_group_flags(&bgi, cache->flags);
 	write_extent_buffer(leaf, &bgi, bi, sizeof(bgi));
 	btrfs_mark_buffer_dirty(leaf);
diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
index 8fa4a70228ee..d78fce7cd3a4 100644
--- a/fs/btrfs/block-group.h
+++ b/fs/btrfs/block-group.h
@@ -44,7 +44,6 @@ struct btrfs_caching_control {
 
 struct btrfs_block_group_cache {
 	struct btrfs_key key;
-	struct btrfs_block_group_item item;
 	struct btrfs_fs_info *fs_info;
 	struct inode *inode;
 	spinlock_t lock;
-- 
2.23.0


  parent reply	other threads:[~2019-10-23 16:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-23 16:48 [PATCH 0/6] Block group structure cleanups David Sterba
2019-10-23 16:48 ` [PATCH 1/6] btrfs: move block_group_item::used to block group David Sterba
2019-10-24  8:22   ` Johannes Thumshirn
2019-10-23 16:48 ` [PATCH 2/6] btrfs: move block_group_item::flags " David Sterba
2019-10-24  8:30   ` Johannes Thumshirn
2019-10-23 16:48 ` David Sterba [this message]
2019-10-24  8:33   ` [PATCH 3/6] btrfs: remove embedded block_group_cache::item Johannes Thumshirn
2019-10-23 16:48 ` [PATCH 4/6] btrfs: rename block_group_item on-stack accessors to follow naming David Sterba
2019-10-24  8:34   ` Johannes Thumshirn
2019-10-23 16:48 ` [PATCH 5/6] btrfs: rename extent buffer block group item accessors David Sterba
2019-10-24  8:35   ` Johannes Thumshirn
2019-10-23 16:48 ` [PATCH 6/6] btrfs: add dedicated members for start and length of a block group David Sterba
2019-10-24  9:15   ` Johannes Thumshirn
2019-10-24 12:09   ` Nikolay Borisov
2019-10-24  1:48 ` [PATCH 0/6] Block group structure cleanups Qu Wenruo
2019-10-24 12:09 ` Nikolay Borisov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=925c46538656d1b46146e09d19882e9c5038658c.1571848791.git.dsterba@suse.com \
    --to=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.