Message ID | 1443148681-3015-2-git-send-email-quwenruo@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Sep 25, 2015 at 10:38:00AM +0800, Qu Wenruo wrote: > +static inline void btrfs_stack_item_key(char *stack_leaf, > + struct btrfs_disk_key *disk_key, > + int nr) > +static inline void btrfs_stack_item_key_to_cpu(char *stack_leaf, > + struct btrfs_key *key, > + int nr) The functions do not follow the pattern of btrfs_stack_* , also passing 'char *' is not right, it should be 'struct extent_buffer *'. IOW the manually created structure accessors must match the prototypes that would result from BTRFS_STACK_FUNCS and BTRFS_SETGET_STACK_FUNCS. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
? 2015?10?02? 00:46, David Sterba ??: > On Fri, Sep 25, 2015 at 10:38:00AM +0800, Qu Wenruo wrote: >> +static inline void btrfs_stack_item_key(char *stack_leaf, >> + struct btrfs_disk_key *disk_key, >> + int nr) > >> +static inline void btrfs_stack_item_key_to_cpu(char *stack_leaf, >> + struct btrfs_key *key, >> + int nr) > > The functions do not follow the pattern of btrfs_stack_*, The extent buffer version is btrfs_item_key() and btrfs_item_key_to_cpu() So I don't see the problem with the naming. Would you please pointing out what's wrong with the naming? > also passing > 'char *' is not right, it should be 'struct extent_buffer *'. The problem is, extent_buffer is not some thing we can operate directly in memory. It uses page pointer to do read/write. So we read out the real extent buffer content and do operation. I can change the struct name to btrfs_header, but not extent_buffer. > > IOW the manually created structure accessors must match the prototypes > that would result from BTRFS_STACK_FUNCS and BTRFS_SETGET_STACK_FUNCS. Unfortunately, the original btrfs_item_key() and its variants are not from BTRFS_STACK_FCUNS. Thanks, Qu > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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)
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(+)