From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>, <stephane_btrfs@lesimple.fr>
Subject: [PATCH 1/2] btrfs: Add support to do stack item key operation
Date: Fri, 25 Sep 2015 10:38:00 +0800 [thread overview]
Message-ID: <1443148681-3015-2-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1443148681-3015-1-git-send-email-quwenruo@cn.fujitsu.com>
Normal btrfs_item_key_to_cpu() will need extent buffer to do it, and
there is not stack version to handle in memory leaf.
Add btrfs_stack_item_key_to_cpu() function for such operation, which
will provide the basis for later qgroup fix.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
fs/btrfs/ctree.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 938efe3..33e9d04 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2683,6 +2683,17 @@ static inline void btrfs_item_key(struct extent_buffer *eb,
read_eb_member(eb, item, struct btrfs_item, key, disk_key);
}
+static inline void btrfs_stack_item_key(char *stack_leaf,
+ struct btrfs_disk_key *disk_key,
+ int nr)
+{
+ unsigned long item_offset = btrfs_item_nr_offset(nr);
+ struct btrfs_item *item;
+
+ item = (struct btrfs_item *)(stack_leaf + item_offset);
+ memcpy(disk_key, &item->key, sizeof(*disk_key));
+}
+
static inline void btrfs_set_item_key(struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr)
{
@@ -2785,6 +2796,15 @@ static inline void btrfs_item_key_to_cpu(struct extent_buffer *eb,
btrfs_disk_key_to_cpu(key, &disk_key);
}
+static inline void btrfs_stack_item_key_to_cpu(char *stack_leaf,
+ struct btrfs_key *key,
+ int nr)
+{
+ struct btrfs_disk_key disk_key;
+ btrfs_stack_item_key(stack_leaf, &disk_key, nr);
+ btrfs_disk_key_to_cpu(key, &disk_key);
+}
+
static inline void btrfs_dir_item_key_to_cpu(struct extent_buffer *eb,
struct btrfs_dir_item *item,
struct btrfs_key *key)
--
2.5.3
next prev parent reply other threads:[~2015-09-25 2:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-25 2:37 [PATCH 0/2] Btrfs: Fix a insane extent_buffer copy behavior for qgroup Qu Wenruo
2015-09-25 2:38 ` Qu Wenruo [this message]
2015-10-01 16:46 ` [PATCH 1/2] btrfs: Add support to do stack item key operation David Sterba
2015-10-02 1:08 ` Qu Wenruo
2015-09-25 2:38 ` [PATCH 2/2] btrfs: qgroup: Don't copy extent buffer to do qgroup rescan Qu Wenruo
2015-09-25 22:35 ` [PATCH 0/2] Btrfs: Fix a insane extent_buffer copy behavior for qgroup Stéphane Lesimple
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=1443148681-3015-2-git-send-email-quwenruo@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=stephane_btrfs@lesimple.fr \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).