Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 00/11] Inode type conversion
@ 2024-06-24 16:22 David Sterba
  2024-06-24 16:23 ` [PATCH 01/11] btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items() David Sterba
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:22 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

A small batch converting inode to btrfs_inode for internal functions and
data structures.

David Sterba (11):
  btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items()
  btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items()
  btrfs: pass a btrfs_inode to is_data_inode()
  btrfs: switch btrfs_block_group::inode to struct btrfs_inode
  btrfs: pass a btrfs_inode to btrfs_ioctl_send()
  btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode
  btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode
  btrfs: pass a btrfs_inode to btrfs_compress_heuristic()
  btrfs: pass a btrfs_inode to btrfs_set_prop()
  btrfs: pass a btrfs_inode to btrfs_load_inode_props()
  btrfs: pass a btrfs_inode to btrfs_inode_inherit_props()

 fs/btrfs/bio.c              |  2 +-
 fs/btrfs/block-group.c      |  4 ++--
 fs/btrfs/block-group.h      |  2 +-
 fs/btrfs/btrfs_inode.h      |  4 ++--
 fs/btrfs/compression.c      |  6 +++---
 fs/btrfs/compression.h      |  2 +-
 fs/btrfs/delayed-inode.c    | 12 +++++------
 fs/btrfs/delayed-inode.h    |  4 ++--
 fs/btrfs/extent_io.c        |  2 +-
 fs/btrfs/free-space-cache.c |  4 ++--
 fs/btrfs/inode.c            | 18 ++++++++--------
 fs/btrfs/ioctl.c            | 16 +++++++-------
 fs/btrfs/ordered-data.c     | 22 +++++++++----------
 fs/btrfs/ordered-data.h     |  2 +-
 fs/btrfs/props.c            | 43 ++++++++++++++++++-------------------
 fs/btrfs/props.h            |  8 +++----
 fs/btrfs/relocation.c       |  2 +-
 fs/btrfs/send.c             |  4 ++--
 fs/btrfs/send.h             |  4 ++--
 fs/btrfs/subpage.c          |  4 ++--
 fs/btrfs/transaction.c      |  2 +-
 fs/btrfs/transaction.h      |  2 +-
 fs/btrfs/xattr.c            |  2 +-
 fs/btrfs/zoned.c            |  8 +++----
 24 files changed, 89 insertions(+), 90 deletions(-)

-- 
2.45.0


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 01/11] btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 02/11] btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items() David Sterba
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to btrfs_readdir_put_delayed_items() as it's
an internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/delayed-inode.c | 4 ++--
 fs/btrfs/delayed-inode.h | 2 +-
 fs/btrfs/inode.c         | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 7b8b1bd0ca39..3a1b6e120959 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1730,7 +1730,7 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
 	return true;
 }
 
-void btrfs_readdir_put_delayed_items(struct inode *inode,
+void btrfs_readdir_put_delayed_items(struct btrfs_inode *inode,
 				     struct list_head *ins_list,
 				     struct list_head *del_list)
 {
@@ -1752,7 +1752,7 @@ void btrfs_readdir_put_delayed_items(struct inode *inode,
 	 * The VFS is going to do up_read(), so we need to downgrade back to a
 	 * read lock.
 	 */
-	downgrade_write(&inode->i_rwsem);
+	downgrade_write(&inode->vfs_inode.i_rwsem);
 }
 
 int btrfs_should_delete_dir_index(const struct list_head *del_list,
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
index 654c04d38fb3..e30ba7962d44 100644
--- a/fs/btrfs/delayed-inode.h
+++ b/fs/btrfs/delayed-inode.h
@@ -147,7 +147,7 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
 				     u64 last_index,
 				     struct list_head *ins_list,
 				     struct list_head *del_list);
-void btrfs_readdir_put_delayed_items(struct inode *inode,
+void btrfs_readdir_put_delayed_items(struct btrfs_inode *inode,
 				     struct list_head *ins_list,
 				     struct list_head *del_list);
 int btrfs_should_delete_dir_index(const struct list_head *del_list,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d6c43120c5d3..6cddc7841238 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6037,7 +6037,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
 	ret = 0;
 err:
 	if (put)
-		btrfs_readdir_put_delayed_items(inode, &ins_list, &del_list);
+		btrfs_readdir_put_delayed_items(BTRFS_I(inode), &ins_list, &del_list);
 	btrfs_free_path(path);
 	return ret;
 }
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 02/11] btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
  2024-06-24 16:23 ` [PATCH 01/11] btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items() David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 03/11] btrfs: pass a btrfs_inode to is_data_inode() David Sterba
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to btrfs_readdir_get_delayed_items() as it's
an internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/delayed-inode.c | 8 ++++----
 fs/btrfs/delayed-inode.h | 2 +-
 fs/btrfs/inode.c         | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 3a1b6e120959..508bdbae29a0 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1682,7 +1682,7 @@ int btrfs_inode_delayed_dir_index_count(struct btrfs_inode *inode)
 	return 0;
 }
 
-bool btrfs_readdir_get_delayed_items(struct inode *inode,
+bool btrfs_readdir_get_delayed_items(struct btrfs_inode *inode,
 				     u64 last_index,
 				     struct list_head *ins_list,
 				     struct list_head *del_list)
@@ -1690,7 +1690,7 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
 	struct btrfs_delayed_node *delayed_node;
 	struct btrfs_delayed_item *item;
 
-	delayed_node = btrfs_get_delayed_node(BTRFS_I(inode));
+	delayed_node = btrfs_get_delayed_node(inode);
 	if (!delayed_node)
 		return false;
 
@@ -1698,8 +1698,8 @@ bool btrfs_readdir_get_delayed_items(struct inode *inode,
 	 * We can only do one readdir with delayed items at a time because of
 	 * item->readdir_list.
 	 */
-	btrfs_inode_unlock(BTRFS_I(inode), BTRFS_ILOCK_SHARED);
-	btrfs_inode_lock(BTRFS_I(inode), 0);
+	btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
+	btrfs_inode_lock(inode, 0);
 
 	mutex_lock(&delayed_node->mutex);
 	item = __btrfs_first_delayed_insertion_item(delayed_node);
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
index e30ba7962d44..7cfefdfe54ea 100644
--- a/fs/btrfs/delayed-inode.h
+++ b/fs/btrfs/delayed-inode.h
@@ -143,7 +143,7 @@ void btrfs_kill_all_delayed_nodes(struct btrfs_root *root);
 void btrfs_destroy_delayed_inodes(struct btrfs_fs_info *fs_info);
 
 /* Used for readdir() */
-bool btrfs_readdir_get_delayed_items(struct inode *inode,
+bool btrfs_readdir_get_delayed_items(struct btrfs_inode *inode,
 				     u64 last_index,
 				     struct list_head *ins_list,
 				     struct list_head *del_list);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 6cddc7841238..cd3f1a9415c1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5947,7 +5947,7 @@ static int btrfs_real_readdir(struct file *file, struct dir_context *ctx)
 	addr = private->filldir_buf;
 	path->reada = READA_FORWARD;
 
-	put = btrfs_readdir_get_delayed_items(inode, private->last_index,
+	put = btrfs_readdir_get_delayed_items(BTRFS_I(inode), private->last_index,
 					      &ins_list, &del_list);
 
 again:
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 03/11] btrfs: pass a btrfs_inode to is_data_inode()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
  2024-06-24 16:23 ` [PATCH 01/11] btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items() David Sterba
  2024-06-24 16:23 ` [PATCH 02/11] btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items() David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 04/11] btrfs: switch btrfs_block_group::inode to struct btrfs_inode David Sterba
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to is_data_inode() as it's an
internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/bio.c         | 2 +-
 fs/btrfs/btrfs_inode.h | 4 ++--
 fs/btrfs/extent_io.c   | 2 +-
 fs/btrfs/subpage.c     | 4 ++--
 fs/btrfs/zoned.c       | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index e3a57196b0ee..f59b00be26f3 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -29,7 +29,7 @@ struct btrfs_failed_bio {
 /* Is this a data path I/O that needs storage layer checksum and repair? */
 static inline bool is_data_bbio(struct btrfs_bio *bbio)
 {
-	return bbio->inode && is_data_inode(&bbio->inode->vfs_inode);
+	return bbio->inode && is_data_inode(bbio->inode);
 }
 
 static bool bbio_has_ordered_extent(struct btrfs_bio *bbio)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index b0fe610d5940..8b45d7e85d86 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -418,9 +418,9 @@ static inline bool btrfs_is_free_space_inode(const struct btrfs_inode *inode)
 	return test_bit(BTRFS_INODE_FREE_SPACE_INODE, &inode->runtime_flags);
 }
 
-static inline bool is_data_inode(const struct inode *inode)
+static inline bool is_data_inode(const struct btrfs_inode *inode)
 {
-	return btrfs_ino(BTRFS_I(inode)) != BTRFS_BTREE_INODE_OBJECTID;
+	return btrfs_ino(inode) != BTRFS_BTREE_INODE_OBJECTID;
 }
 
 static inline void btrfs_mod_outstanding_extents(struct btrfs_inode *inode,
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 0ec87ccb372b..c7a9284e45e1 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -860,7 +860,7 @@ static void submit_extent_page(struct btrfs_bio_ctrl *bio_ctrl,
 		/* Cap to the current ordered extent boundary if there is one. */
 		if (len > bio_ctrl->len_to_oe_boundary) {
 			ASSERT(bio_ctrl->compress_type == BTRFS_COMPRESS_NONE);
-			ASSERT(is_data_inode(&inode->vfs_inode));
+			ASSERT(is_data_inode(inode));
 			len = bio_ctrl->len_to_oe_boundary;
 		}
 
diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c
index 1a4717bcce23..8ddd5fcbeb93 100644
--- a/fs/btrfs/subpage.c
+++ b/fs/btrfs/subpage.c
@@ -74,7 +74,7 @@ bool btrfs_is_subpage(const struct btrfs_fs_info *fs_info, struct address_space
 	 * mapping. And if page->mapping->host is data inode, it's subpage.
 	 * As we have ruled our sectorsize >= PAGE_SIZE case already.
 	 */
-	if (!mapping || !mapping->host || is_data_inode(mapping->host))
+	if (!mapping || !mapping->host || is_data_inode(BTRFS_I(mapping->host)))
 		return true;
 
 	/*
@@ -283,7 +283,7 @@ void btrfs_subpage_end_reader(const struct btrfs_fs_info *fs_info,
 	bool last;
 
 	btrfs_subpage_assert(fs_info, folio, start, len);
-	is_data = is_data_inode(folio->mapping->host);
+	is_data = is_data_inode(BTRFS_I(folio->mapping->host));
 
 	spin_lock_irqsave(&subpage->lock, flags);
 
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 992a5b7756ca..8a99f5187e30 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1723,7 +1723,7 @@ bool btrfs_use_zone_append(struct btrfs_bio *bbio)
 	if (!btrfs_is_zoned(fs_info))
 		return false;
 
-	if (!inode || !is_data_inode(&inode->vfs_inode))
+	if (!inode || !is_data_inode(inode))
 		return false;
 
 	if (btrfs_op(&bbio->bio) != BTRFS_MAP_WRITE)
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 04/11] btrfs: switch btrfs_block_group::inode to struct btrfs_inode
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (2 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 03/11] btrfs: pass a btrfs_inode to is_data_inode() David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 05/11] btrfs: pass a btrfs_inode to btrfs_ioctl_send() David Sterba
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The structure is internal so we should use struct btrfs_inode for that.

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

diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index 9f1d328b603e..6a9d895add25 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -4327,13 +4327,13 @@ void btrfs_put_block_group_cache(struct btrfs_fs_info *info)
 		spin_lock(&block_group->lock);
 		if (test_and_clear_bit(BLOCK_GROUP_FLAG_IREF,
 				       &block_group->runtime_flags)) {
-			struct inode *inode = block_group->inode;
+			struct btrfs_inode *inode = block_group->inode;
 
 			block_group->inode = NULL;
 			spin_unlock(&block_group->lock);
 
 			ASSERT(block_group->io_ctl.inode == NULL);
-			iput(inode);
+			iput(&inode->vfs_inode);
 		} else {
 			spin_unlock(&block_group->lock);
 		}
diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h
index 85e2d4cd12dc..084f117550f8 100644
--- a/fs/btrfs/block-group.h
+++ b/fs/btrfs/block-group.h
@@ -115,7 +115,7 @@ struct btrfs_caching_control {
 
 struct btrfs_block_group {
 	struct btrfs_fs_info *fs_info;
-	struct inode *inode;
+	struct btrfs_inode *inode;
 	spinlock_t lock;
 	u64 start;
 	u64 length;
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index ae1a987fe518..c29c8ef9bd6a 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -137,7 +137,7 @@ struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
 
 	spin_lock(&block_group->lock);
 	if (block_group->inode)
-		inode = igrab(block_group->inode);
+		inode = igrab(&block_group->inode->vfs_inode);
 	spin_unlock(&block_group->lock);
 	if (inode)
 		return inode;
@@ -156,7 +156,7 @@ struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
 	}
 
 	if (!test_and_set_bit(BLOCK_GROUP_FLAG_IREF, &block_group->runtime_flags))
-		block_group->inode = igrab(inode);
+		block_group->inode = BTRFS_I(igrab(inode));
 	spin_unlock(&block_group->lock);
 
 	return inode;
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 05/11] btrfs: pass a btrfs_inode to btrfs_ioctl_send()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (3 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 04/11] btrfs: switch btrfs_block_group::inode to struct btrfs_inode David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 06/11] btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode David Sterba
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to btrfs_ioctl_send() and _btrfs_ioctl_send()
as it's an internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c | 6 +++---
 fs/btrfs/send.c  | 4 ++--
 fs/btrfs/send.h  | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 1c31df88f19a..d4f0445c4230 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4473,7 +4473,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
 	return ret;
 }
 
-static int _btrfs_ioctl_send(struct inode *inode, void __user *argp, bool compat)
+static int _btrfs_ioctl_send(struct btrfs_inode *inode, void __user *argp, bool compat)
 {
 	struct btrfs_ioctl_send_args *arg;
 	int ret;
@@ -4795,10 +4795,10 @@ long btrfs_ioctl(struct file *file, unsigned int
 		return btrfs_ioctl_set_received_subvol_32(file, argp);
 #endif
 	case BTRFS_IOC_SEND:
-		return _btrfs_ioctl_send(inode, argp, false);
+		return _btrfs_ioctl_send(BTRFS_I(inode), argp, false);
 #if defined(CONFIG_64BIT) && defined(CONFIG_COMPAT)
 	case BTRFS_IOC_SEND_32:
-		return _btrfs_ioctl_send(inode, argp, true);
+		return _btrfs_ioctl_send(BTRFS_I(inode), argp, true);
 #endif
 	case BTRFS_IOC_GET_DEV_STATS:
 		return btrfs_ioctl_get_dev_stats(fs_info, argp);
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index bc2acda1d1bb..fb3675f5bf50 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -8065,10 +8065,10 @@ static void dedupe_in_progress_warn(const struct btrfs_root *root)
 		      btrfs_root_id(root), root->dedupe_in_progress);
 }
 
-long btrfs_ioctl_send(struct inode *inode, const struct btrfs_ioctl_send_args *arg)
+long btrfs_ioctl_send(struct btrfs_inode *inode, const struct btrfs_ioctl_send_args *arg)
 {
 	int ret = 0;
-	struct btrfs_root *send_root = BTRFS_I(inode)->root;
+	struct btrfs_root *send_root = inode->root;
 	struct btrfs_fs_info *fs_info = send_root->fs_info;
 	struct btrfs_root *clone_root;
 	struct send_ctx *sctx = NULL;
diff --git a/fs/btrfs/send.h b/fs/btrfs/send.h
index 8bd5aeafb6f5..b07f4aa66878 100644
--- a/fs/btrfs/send.h
+++ b/fs/btrfs/send.h
@@ -11,7 +11,7 @@
 #include <linux/sizes.h>
 #include <linux/align.h>
 
-struct inode;
+struct btrfs_inode;
 struct btrfs_ioctl_send_args;
 
 #define BTRFS_SEND_STREAM_MAGIC "btrfs-stream"
@@ -182,6 +182,6 @@ enum {
 	__BTRFS_SEND_A_MAX		= 35,
 };
 
-long btrfs_ioctl_send(struct inode *inode, const struct btrfs_ioctl_send_args *arg);
+long btrfs_ioctl_send(struct btrfs_inode *inode, const struct btrfs_ioctl_send_args *arg);
 
 #endif
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 06/11] btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (4 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 05/11] btrfs: pass a btrfs_inode to btrfs_ioctl_send() David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 07/11] btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode David Sterba
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The structure is internal so we should use struct btrfs_inode for that.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c       | 2 +-
 fs/btrfs/transaction.c | 2 +-
 fs/btrfs/transaction.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index d4f0445c4230..f30242066ed2 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -855,7 +855,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
 	pending_snapshot->dentry = dentry;
 	pending_snapshot->root = root;
 	pending_snapshot->readonly = readonly;
-	pending_snapshot->dir = dir;
+	pending_snapshot->dir = BTRFS_I(dir);
 	pending_snapshot->inherit = inherit;
 
 	trans = btrfs_start_transaction(root, 0);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 9590a1899b9d..cb5b5cac55e7 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1637,7 +1637,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
 	struct btrfs_root *root = pending->root;
 	struct btrfs_root *parent_root;
 	struct btrfs_block_rsv *rsv;
-	struct inode *parent_inode = pending->dir;
+	struct inode *parent_inode = &pending->dir->vfs_inode;
 	struct btrfs_path *path;
 	struct btrfs_dir_item *dir_item;
 	struct extent_buffer *tmp;
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h
index 81da655b5ee7..98c03ddc760b 100644
--- a/fs/btrfs/transaction.h
+++ b/fs/btrfs/transaction.h
@@ -172,7 +172,7 @@ struct btrfs_trans_handle {
 
 struct btrfs_pending_snapshot {
 	struct dentry *dentry;
-	struct inode *dir;
+	struct btrfs_inode *dir;
 	struct btrfs_root *root;
 	struct btrfs_root_item *root_item;
 	struct btrfs_root *snap;
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 07/11] btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (5 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 06/11] btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 08/11] btrfs: pass a btrfs_inode to btrfs_compress_heuristic() David Sterba
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The structure is internal so we should use struct btrfs_inode for that,
allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/compression.c  |  2 +-
 fs/btrfs/inode.c        |  6 +++---
 fs/btrfs/ordered-data.c | 22 +++++++++++-----------
 fs/btrfs/ordered-data.h |  2 +-
 fs/btrfs/relocation.c   |  2 +-
 fs/btrfs/zoned.c        |  6 +++---
 6 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 07b31d1c0926..de136ef3a2f8 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -374,7 +374,7 @@ void btrfs_submit_compressed_write(struct btrfs_ordered_extent *ordered,
 				   blk_opf_t write_flags,
 				   bool writeback)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+	struct btrfs_inode *inode = ordered->inode;
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct compressed_bio *cb;
 
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index cd3f1a9415c1..a6c460675a2d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3037,7 +3037,7 @@ static int insert_ordered_extent_file_extent(struct btrfs_trans_handle *trans,
 			     test_bit(BTRFS_ORDERED_ENCODED, &oe->flags) ||
 			     test_bit(BTRFS_ORDERED_TRUNCATED, &oe->flags);
 
-	return insert_reserved_file_extent(trans, BTRFS_I(oe->inode),
+	return insert_reserved_file_extent(trans, oe->inode,
 					   oe->file_offset, &stack_fi,
 					   update_inode_bytes, oe->qgroup_rsv);
 }
@@ -3049,7 +3049,7 @@ static int insert_ordered_extent_file_extent(struct btrfs_trans_handle *trans,
  */
 int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered_extent->inode);
+	struct btrfs_inode *inode = ordered_extent->inode;
 	struct btrfs_root *root = inode->root;
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct btrfs_trans_handle *trans = NULL;
@@ -3283,7 +3283,7 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
 
 int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered)
 {
-	if (btrfs_is_zoned(inode_to_fs_info(ordered->inode)) &&
+	if (btrfs_is_zoned(ordered->inode->root->fs_info) &&
 	    !test_bit(BTRFS_ORDERED_IOERR, &ordered->flags) &&
 	    list_empty(&ordered->bioc_list))
 		btrfs_finish_ordered_zoned(ordered);
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index a3343656e0a7..82a68394a89c 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -180,7 +180,7 @@ static struct btrfs_ordered_extent *alloc_ordered_extent(
 	entry->disk_num_bytes = disk_num_bytes;
 	entry->offset = offset;
 	entry->bytes_left = num_bytes;
-	entry->inode = igrab(&inode->vfs_inode);
+	entry->inode = BTRFS_I(igrab(&inode->vfs_inode));
 	entry->compress_type = compress_type;
 	entry->truncated_len = (u64)-1;
 	entry->qgroup_rsv = qgroup_rsv;
@@ -208,7 +208,7 @@ static struct btrfs_ordered_extent *alloc_ordered_extent(
 
 static void insert_ordered_extent(struct btrfs_ordered_extent *entry)
 {
-	struct btrfs_inode *inode = BTRFS_I(entry->inode);
+	struct btrfs_inode *inode = entry->inode;
 	struct btrfs_root *root = inode->root;
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	struct rb_node *node;
@@ -310,7 +310,7 @@ struct btrfs_ordered_extent *btrfs_alloc_ordered_extent(
 void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry,
 			   struct btrfs_ordered_sum *sum)
 {
-	struct btrfs_inode *inode = BTRFS_I(entry->inode);
+	struct btrfs_inode *inode = entry->inode;
 
 	spin_lock_irq(&inode->ordered_tree_lock);
 	list_add_tail(&sum->list, &entry->list);
@@ -320,7 +320,7 @@ void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry,
 void btrfs_mark_ordered_extent_error(struct btrfs_ordered_extent *ordered)
 {
 	if (!test_and_set_bit(BTRFS_ORDERED_IOERR, &ordered->flags))
-		mapping_set_error(ordered->inode->i_mapping, -EIO);
+		mapping_set_error(ordered->inode->vfs_inode.i_mapping, -EIO);
 }
 
 static void finish_ordered_fn(struct btrfs_work *work)
@@ -335,7 +335,7 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
 				      struct page *page, u64 file_offset,
 				      u64 len, bool uptodate)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+	struct btrfs_inode *inode = ordered->inode;
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 
 	lockdep_assert_held(&inode->ordered_tree_lock);
@@ -388,7 +388,7 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
 
 static void btrfs_queue_ordered_fn(struct btrfs_ordered_extent *ordered)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+	struct btrfs_inode *inode = ordered->inode;
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct btrfs_workqueue *wq = btrfs_is_free_space_inode(inode) ?
 		fs_info->endio_freespace_worker : fs_info->endio_write_workers;
@@ -401,7 +401,7 @@ void btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
 				 struct page *page, u64 file_offset, u64 len,
 				 bool uptodate)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+	struct btrfs_inode *inode = ordered->inode;
 	unsigned long flags;
 	bool ret;
 
@@ -610,14 +610,14 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
 	struct list_head *cur;
 	struct btrfs_ordered_sum *sum;
 
-	trace_btrfs_ordered_extent_put(BTRFS_I(entry->inode), entry);
+	trace_btrfs_ordered_extent_put(entry->inode, entry);
 
 	if (refcount_dec_and_test(&entry->refs)) {
 		ASSERT(list_empty(&entry->root_extent_list));
 		ASSERT(list_empty(&entry->log_list));
 		ASSERT(RB_EMPTY_NODE(&entry->rb_node));
 		if (entry->inode)
-			btrfs_add_delayed_iput(BTRFS_I(entry->inode));
+			btrfs_add_delayed_iput(entry->inode);
 		while (!list_empty(&entry->list)) {
 			cur = entry->list.next;
 			sum = list_entry(cur, struct btrfs_ordered_sum, list);
@@ -849,7 +849,7 @@ void btrfs_start_ordered_extent(struct btrfs_ordered_extent *entry)
 {
 	u64 start = entry->file_offset;
 	u64 end = start + entry->num_bytes - 1;
-	struct btrfs_inode *inode = BTRFS_I(entry->inode);
+	struct btrfs_inode *inode = entry->inode;
 	bool freespace_inode;
 
 	trace_btrfs_ordered_extent_start(inode, entry);
@@ -1208,7 +1208,7 @@ bool btrfs_try_lock_ordered_range(struct btrfs_inode *inode, u64 start, u64 end,
 struct btrfs_ordered_extent *btrfs_split_ordered_extent(
 			struct btrfs_ordered_extent *ordered, u64 len)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+	struct btrfs_inode *inode = ordered->inode;
 	struct btrfs_root *root = inode->root;
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	u64 file_offset = ordered->file_offset;
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index 4aabdff409fa..51b9e81726e2 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -130,7 +130,7 @@ struct btrfs_ordered_extent {
 	refcount_t refs;
 
 	/* the inode we belong to */
-	struct inode *inode;
+	struct btrfs_inode *inode;
 
 	/* list of checksums for insertion when the extent io is done */
 	struct list_head list;
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 6ea407255a30..1a28ec054991 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4388,7 +4388,7 @@ int btrfs_recover_relocation(struct btrfs_fs_info *fs_info)
  */
 int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+	struct btrfs_inode *inode = ordered->inode;
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	u64 disk_bytenr = ordered->file_offset + inode->reloc_block_group_start;
 	struct btrfs_root *csum_root = btrfs_csum_root(fs_info, disk_bytenr);
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 8a99f5187e30..58e724c80a06 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -1765,7 +1765,7 @@ void btrfs_record_physical_zoned(struct btrfs_bio *bbio)
 static void btrfs_rewrite_logical_zoned(struct btrfs_ordered_extent *ordered,
 					u64 logical)
 {
-	struct extent_map_tree *em_tree = &BTRFS_I(ordered->inode)->extent_tree;
+	struct extent_map_tree *em_tree = &ordered->inode->extent_tree;
 	struct extent_map *em;
 
 	ordered->disk_bytenr = logical;
@@ -1786,7 +1786,7 @@ static bool btrfs_zoned_split_ordered(struct btrfs_ordered_extent *ordered,
 	struct btrfs_ordered_extent *new;
 
 	if (!test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags) &&
-	    split_extent_map(BTRFS_I(ordered->inode), ordered->file_offset,
+	    split_extent_map(ordered->inode, ordered->file_offset,
 			     ordered->num_bytes, len, logical))
 		return false;
 
@@ -1800,7 +1800,7 @@ static bool btrfs_zoned_split_ordered(struct btrfs_ordered_extent *ordered,
 
 void btrfs_finish_ordered_zoned(struct btrfs_ordered_extent *ordered)
 {
-	struct btrfs_inode *inode = BTRFS_I(ordered->inode);
+	struct btrfs_inode *inode = ordered->inode;
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct btrfs_ordered_sum *sum;
 	u64 logical, len;
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 08/11] btrfs: pass a btrfs_inode to btrfs_compress_heuristic()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (6 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 07/11] btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 09/11] btrfs: pass a btrfs_inode to btrfs_set_prop() David Sterba
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to btrfs_compress_heuristic() as it's an
internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/compression.c | 4 ++--
 fs/btrfs/compression.h | 2 +-
 fs/btrfs/inode.c       | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index de136ef3a2f8..85eb2cadbbf6 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1507,7 +1507,7 @@ static void heuristic_collect_sample(struct inode *inode, u64 start, u64 end,
  *
  * Return non-zero if the compression should be done, 0 otherwise.
  */
-int btrfs_compress_heuristic(struct inode *inode, u64 start, u64 end)
+int btrfs_compress_heuristic(struct btrfs_inode *inode, u64 start, u64 end)
 {
 	struct list_head *ws_list = get_workspace(0, 0);
 	struct heuristic_ws *ws;
@@ -1517,7 +1517,7 @@ int btrfs_compress_heuristic(struct inode *inode, u64 start, u64 end)
 
 	ws = list_entry(ws_list, struct heuristic_ws, list);
 
-	heuristic_collect_sample(inode, start, end, ws);
+	heuristic_collect_sample(&inode->vfs_inode, start, end, ws);
 
 	if (sample_repeated_patterns(ws)) {
 		ret = 1;
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index c20c1a1b09d5..cfdc64319186 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -144,7 +144,7 @@ extern const struct btrfs_compress_op btrfs_zstd_compress;
 const char* btrfs_compress_type2str(enum btrfs_compression_type type);
 bool btrfs_compress_is_valid_type(const char *str, size_t len);
 
-int btrfs_compress_heuristic(struct inode *inode, u64 start, u64 end);
+int btrfs_compress_heuristic(struct btrfs_inode *inode, u64 start, u64 end);
 
 int btrfs_compress_filemap_get_folio(struct address_space *mapping, u64 start,
 				     struct folio **in_folio_ret);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a6c460675a2d..e9744392fe51 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -876,7 +876,7 @@ static inline int inode_need_compress(struct btrfs_inode *inode, u64 start,
 	if (btrfs_test_opt(fs_info, COMPRESS) ||
 	    inode->flags & BTRFS_INODE_COMPRESS ||
 	    inode->prop_compress)
-		return btrfs_compress_heuristic(&inode->vfs_inode, start, end);
+		return btrfs_compress_heuristic(inode, start, end);
 	return 0;
 }
 
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 09/11] btrfs: pass a btrfs_inode to btrfs_set_prop()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (7 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 08/11] btrfs: pass a btrfs_inode to btrfs_compress_heuristic() David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 10/11] btrfs: pass a btrfs_inode to btrfs_load_inode_props() David Sterba
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to btrfs_set_prop() as it's an
internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/ioctl.c |  8 ++++----
 fs/btrfs/props.c | 14 +++++++-------
 fs/btrfs/props.h |  2 +-
 fs/btrfs/xattr.c |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index f30242066ed2..83f773fe429d 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -375,15 +375,15 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
 		return PTR_ERR(trans);
 
 	if (comp) {
-		ret = btrfs_set_prop(trans, inode, "btrfs.compression", comp,
-				     strlen(comp), 0);
+		ret = btrfs_set_prop(trans, BTRFS_I(inode), "btrfs.compression",
+				     comp, strlen(comp), 0);
 		if (ret) {
 			btrfs_abort_transaction(trans, ret);
 			goto out_end_trans;
 		}
 	} else {
-		ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL,
-				     0, 0);
+		ret = btrfs_set_prop(trans, BTRFS_I(inode), "btrfs.compression",
+				     NULL, 0, 0);
 		if (ret && ret != -ENODATA) {
 			btrfs_abort_transaction(trans, ret);
 			goto out_end_trans;
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index 5c8e64eaf48b..b8fa34e16abb 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -104,7 +104,7 @@ bool btrfs_ignore_prop(const struct btrfs_inode *inode, const char *name)
 	return handler->ignore(inode);
 }
 
-int btrfs_set_prop(struct btrfs_trans_handle *trans, struct inode *inode,
+int btrfs_set_prop(struct btrfs_trans_handle *trans, struct btrfs_inode *inode,
 		   const char *name, const char *value, size_t value_len,
 		   int flags)
 {
@@ -116,29 +116,29 @@ int btrfs_set_prop(struct btrfs_trans_handle *trans, struct inode *inode,
 		return -EINVAL;
 
 	if (value_len == 0) {
-		ret = btrfs_setxattr(trans, inode, handler->xattr_name,
+		ret = btrfs_setxattr(trans, &inode->vfs_inode, handler->xattr_name,
 				     NULL, 0, flags);
 		if (ret)
 			return ret;
 
-		ret = handler->apply(inode, NULL, 0);
+		ret = handler->apply(&inode->vfs_inode, NULL, 0);
 		ASSERT(ret == 0);
 
 		return ret;
 	}
 
-	ret = btrfs_setxattr(trans, inode, handler->xattr_name, value,
+	ret = btrfs_setxattr(trans, &inode->vfs_inode, handler->xattr_name, value,
 			     value_len, flags);
 	if (ret)
 		return ret;
-	ret = handler->apply(inode, value, value_len);
+	ret = handler->apply(&inode->vfs_inode, value, value_len);
 	if (ret) {
-		btrfs_setxattr(trans, inode, handler->xattr_name, NULL,
+		btrfs_setxattr(trans, &inode->vfs_inode, handler->xattr_name, NULL,
 			       0, flags);
 		return ret;
 	}
 
-	set_bit(BTRFS_INODE_HAS_PROPS, &BTRFS_I(inode)->runtime_flags);
+	set_bit(BTRFS_INODE_HAS_PROPS, &inode->runtime_flags);
 
 	return 0;
 }
diff --git a/fs/btrfs/props.h b/fs/btrfs/props.h
index 24131b29d842..63546d0a9444 100644
--- a/fs/btrfs/props.h
+++ b/fs/btrfs/props.h
@@ -15,7 +15,7 @@ struct btrfs_trans_handle;
 
 int __init btrfs_props_init(void);
 
-int btrfs_set_prop(struct btrfs_trans_handle *trans, struct inode *inode,
+int btrfs_set_prop(struct btrfs_trans_handle *trans, struct btrfs_inode *inode,
 		   const char *name, const char *value, size_t value_len,
 		   int flags);
 int btrfs_validate_prop(const struct btrfs_inode *inode, const char *name,
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index 0288fe541dca..738c7bb8ea7c 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -451,7 +451,7 @@ static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
 	if (IS_ERR(trans))
 		return PTR_ERR(trans);
 
-	ret = btrfs_set_prop(trans, inode, name, value, size, flags);
+	ret = btrfs_set_prop(trans, BTRFS_I(inode), name, value, size, flags);
 	if (!ret) {
 		inode_inc_iversion(inode);
 		inode_set_ctime_current(inode);
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 10/11] btrfs: pass a btrfs_inode to btrfs_load_inode_props()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (8 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 09/11] btrfs: pass a btrfs_inode to btrfs_set_prop() David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 16:23 ` [PATCH 11/11] btrfs: pass a btrfs_inode to btrfs_inode_inherit_props() David Sterba
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to btrfs_load_inode_props() as it's an
internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c | 2 +-
 fs/btrfs/props.c | 6 +++---
 fs/btrfs/props.h | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e9744392fe51..ed0275cee649 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3953,7 +3953,7 @@ static int btrfs_read_locked_inode(struct inode *inode,
 			btrfs_ino(BTRFS_I(inode)), &first_xattr_slot);
 	if (first_xattr_slot != -1) {
 		path->slots[0] = first_xattr_slot;
-		ret = btrfs_load_inode_props(inode, path);
+		ret = btrfs_load_inode_props(BTRFS_I(inode), path);
 		if (ret)
 			btrfs_err(fs_info,
 				  "error loading props for ino %llu (root %llu): %d",
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index b8fa34e16abb..f6dba783d66b 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -273,10 +273,10 @@ static void inode_prop_iterator(void *ctx,
 		set_bit(BTRFS_INODE_HAS_PROPS, &BTRFS_I(inode)->runtime_flags);
 }
 
-int btrfs_load_inode_props(struct inode *inode, struct btrfs_path *path)
+int btrfs_load_inode_props(struct btrfs_inode *inode, struct btrfs_path *path)
 {
-	struct btrfs_root *root = BTRFS_I(inode)->root;
-	u64 ino = btrfs_ino(BTRFS_I(inode));
+	struct btrfs_root *root = inode->root;
+	u64 ino = btrfs_ino(inode);
 
 	return iterate_object_props(root, path, ino, inode_prop_iterator, inode);
 }
diff --git a/fs/btrfs/props.h b/fs/btrfs/props.h
index 63546d0a9444..4f401e890db8 100644
--- a/fs/btrfs/props.h
+++ b/fs/btrfs/props.h
@@ -22,7 +22,7 @@ int btrfs_validate_prop(const struct btrfs_inode *inode, const char *name,
 			const char *value, size_t value_len);
 bool btrfs_ignore_prop(const struct btrfs_inode *inode, const char *name);
 
-int btrfs_load_inode_props(struct inode *inode, struct btrfs_path *path);
+int btrfs_load_inode_props(struct btrfs_inode *inode, struct btrfs_path *path);
 
 int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
 			      struct inode *inode,
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 11/11] btrfs: pass a btrfs_inode to btrfs_inode_inherit_props()
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (9 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 10/11] btrfs: pass a btrfs_inode to btrfs_load_inode_props() David Sterba
@ 2024-06-24 16:23 ` David Sterba
  2024-06-24 18:41 ` [PATCH 00/11] Inode type conversion Boris Burkov
  2024-06-26 14:06 ` Filipe Manana
  12 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-24 16:23 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Pass a struct btrfs_inode to btrfs_inode_inherit_props() as it's an
internal interface, allowing to remove some use of BTRFS_I.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/inode.c |  4 ++--
 fs/btrfs/props.c | 23 +++++++++++------------
 fs/btrfs/props.h |  4 ++--
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ed0275cee649..e50f97c138f6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6406,11 +6406,11 @@ int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
 		if (IS_ERR(parent)) {
 			ret = PTR_ERR(parent);
 		} else {
-			ret = btrfs_inode_inherit_props(trans, inode, parent);
+			ret = btrfs_inode_inherit_props(trans, BTRFS_I(inode), BTRFS_I(parent));
 			iput(parent);
 		}
 	} else {
-		ret = btrfs_inode_inherit_props(trans, inode, dir);
+		ret = btrfs_inode_inherit_props(trans, BTRFS_I(inode), BTRFS_I(dir));
 	}
 	if (ret) {
 		btrfs_err(fs_info,
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index f6dba783d66b..5f805703aedc 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -385,16 +385,16 @@ static struct prop_handler prop_handlers[] = {
 };
 
 int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
-			      struct inode *inode, const struct inode *parent)
+			      struct btrfs_inode *inode,
+			      const struct btrfs_inode *parent)
 {
-	struct btrfs_root *root = BTRFS_I(inode)->root;
+	struct btrfs_root *root = inode->root;
 	struct btrfs_fs_info *fs_info = root->fs_info;
 	int ret;
 	int i;
 	bool need_reserve = false;
 
-	if (!test_bit(BTRFS_INODE_HAS_PROPS,
-		      &BTRFS_I(parent)->runtime_flags))
+	if (!test_bit(BTRFS_INODE_HAS_PROPS, &parent->runtime_flags))
 		return 0;
 
 	for (i = 0; i < ARRAY_SIZE(prop_handlers); i++) {
@@ -405,10 +405,10 @@ int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
 		if (!h->inheritable)
 			continue;
 
-		if (h->ignore(BTRFS_I(inode)))
+		if (h->ignore(inode))
 			continue;
 
-		value = h->extract(parent);
+		value = h->extract(&parent->vfs_inode);
 		if (!value)
 			continue;
 
@@ -416,7 +416,7 @@ int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
 		 * This is not strictly necessary as the property should be
 		 * valid, but in case it isn't, don't propagate it further.
 		 */
-		ret = h->validate(BTRFS_I(inode), value, strlen(value));
+		ret = h->validate(inode, value, strlen(value));
 		if (ret)
 			continue;
 
@@ -436,16 +436,15 @@ int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
 				return ret;
 		}
 
-		ret = btrfs_setxattr(trans, inode, h->xattr_name, value,
+		ret = btrfs_setxattr(trans, &inode->vfs_inode, h->xattr_name, value,
 				     strlen(value), 0);
 		if (!ret) {
-			ret = h->apply(inode, value, strlen(value));
+			ret = h->apply(&inode->vfs_inode, value, strlen(value));
 			if (ret)
-				btrfs_setxattr(trans, inode, h->xattr_name,
+				btrfs_setxattr(trans, &inode->vfs_inode, h->xattr_name,
 					       NULL, 0, 0);
 			else
-				set_bit(BTRFS_INODE_HAS_PROPS,
-					&BTRFS_I(inode)->runtime_flags);
+				set_bit(BTRFS_INODE_HAS_PROPS, &inode->runtime_flags);
 		}
 
 		if (need_reserve) {
diff --git a/fs/btrfs/props.h b/fs/btrfs/props.h
index 4f401e890db8..6e12cb1d24da 100644
--- a/fs/btrfs/props.h
+++ b/fs/btrfs/props.h
@@ -25,7 +25,7 @@ bool btrfs_ignore_prop(const struct btrfs_inode *inode, const char *name);
 int btrfs_load_inode_props(struct btrfs_inode *inode, struct btrfs_path *path);
 
 int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
-			      struct inode *inode,
-			      const struct inode *dir);
+			      struct btrfs_inode *inode,
+			      const struct btrfs_inode *dir);
 
 #endif
-- 
2.45.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/11] Inode type conversion
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (10 preceding siblings ...)
  2024-06-24 16:23 ` [PATCH 11/11] btrfs: pass a btrfs_inode to btrfs_inode_inherit_props() David Sterba
@ 2024-06-24 18:41 ` Boris Burkov
  2024-06-26 14:06 ` Filipe Manana
  12 siblings, 0 replies; 15+ messages in thread
From: Boris Burkov @ 2024-06-24 18:41 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On Mon, Jun 24, 2024 at 06:22:56PM +0200, David Sterba wrote:
> A small batch converting inode to btrfs_inode for internal functions and
> data structures.

Reviewed-by: Boris Burkov <boris@bur.io>

> 
> David Sterba (11):
>   btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items()
>   btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items()
>   btrfs: pass a btrfs_inode to is_data_inode()
>   btrfs: switch btrfs_block_group::inode to struct btrfs_inode
>   btrfs: pass a btrfs_inode to btrfs_ioctl_send()
>   btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode
>   btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode
>   btrfs: pass a btrfs_inode to btrfs_compress_heuristic()
>   btrfs: pass a btrfs_inode to btrfs_set_prop()
>   btrfs: pass a btrfs_inode to btrfs_load_inode_props()
>   btrfs: pass a btrfs_inode to btrfs_inode_inherit_props()
> 
>  fs/btrfs/bio.c              |  2 +-
>  fs/btrfs/block-group.c      |  4 ++--
>  fs/btrfs/block-group.h      |  2 +-
>  fs/btrfs/btrfs_inode.h      |  4 ++--
>  fs/btrfs/compression.c      |  6 +++---
>  fs/btrfs/compression.h      |  2 +-
>  fs/btrfs/delayed-inode.c    | 12 +++++------
>  fs/btrfs/delayed-inode.h    |  4 ++--
>  fs/btrfs/extent_io.c        |  2 +-
>  fs/btrfs/free-space-cache.c |  4 ++--
>  fs/btrfs/inode.c            | 18 ++++++++--------
>  fs/btrfs/ioctl.c            | 16 +++++++-------
>  fs/btrfs/ordered-data.c     | 22 +++++++++----------
>  fs/btrfs/ordered-data.h     |  2 +-
>  fs/btrfs/props.c            | 43 ++++++++++++++++++-------------------
>  fs/btrfs/props.h            |  8 +++----
>  fs/btrfs/relocation.c       |  2 +-
>  fs/btrfs/send.c             |  4 ++--
>  fs/btrfs/send.h             |  4 ++--
>  fs/btrfs/subpage.c          |  4 ++--
>  fs/btrfs/transaction.c      |  2 +-
>  fs/btrfs/transaction.h      |  2 +-
>  fs/btrfs/xattr.c            |  2 +-
>  fs/btrfs/zoned.c            |  8 +++----
>  24 files changed, 89 insertions(+), 90 deletions(-)
> 
> -- 
> 2.45.0
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/11] Inode type conversion
  2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
                   ` (11 preceding siblings ...)
  2024-06-24 18:41 ` [PATCH 00/11] Inode type conversion Boris Burkov
@ 2024-06-26 14:06 ` Filipe Manana
  2024-06-26 14:39   ` David Sterba
  12 siblings, 1 reply; 15+ messages in thread
From: Filipe Manana @ 2024-06-26 14:06 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On Mon, Jun 24, 2024 at 5:24 PM David Sterba <dsterba@suse.com> wrote:
>
> A small batch converting inode to btrfs_inode for internal functions and
> data structures.
>
> David Sterba (11):
>   btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items()
>   btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items()
>   btrfs: pass a btrfs_inode to is_data_inode()
>   btrfs: switch btrfs_block_group::inode to struct btrfs_inode
>   btrfs: pass a btrfs_inode to btrfs_ioctl_send()
>   btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode
>   btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode
>   btrfs: pass a btrfs_inode to btrfs_compress_heuristic()
>   btrfs: pass a btrfs_inode to btrfs_set_prop()
>   btrfs: pass a btrfs_inode to btrfs_load_inode_props()
>   btrfs: pass a btrfs_inode to btrfs_inode_inherit_props()

One of these changes to the properties is broken.
btrfs/048 triggers this:

[74513.242475] BUG: kernel NULL pointer dereference, address: 0000000000000208
[74513.242651] #PF: supervisor read access in kernel mode
[74513.242796] #PF: error_code(0x0000) - not-present page
[74513.242935] PGD 0 P4D 0
[74513.243073] Oops: Oops: 0000 [#1] PREEMPT SMP PTI
[74513.243217] CPU: 1 PID: 254085 Comm: btrfs Not tainted
6.10.0-rc5-btrfs-next-164+ #1
[74513.243363] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014
[74513.243511] RIP: 0010:prop_compression_apply+0x2f/0x150 [btrfs]
[74513.243724] Code: 53 48 89 fb 48 85 d2 0f 84 e7 00 00 00 48 89 f0
48 83 fa 02 74 44 48 83 fa 04 0f 84 f4 00 00 00 48 8b 93 78 fe ff ff
80 38 6c <4c> 8b 82 08 02 00 00 75 53 80 78 01 7a 75 4d 80 78 02 6f 75
47 48
[74513.244038] RSP: 0018:ffffa8a3850c79e0 EFLAGS: 00010246
[74513.244195] RAX: ffff893e8111b468 RBX: ffff893e91f12448 RCX: 0000000000000003
[74513.244353] RDX: 0000000000000000 RSI: ffff893e8111b468 RDI: ffff893e91f12448
[74513.244510] RBP: ffffffffc0c94c00 R08: 000000000000007a R09: 000000000000006f
[74513.244668] R10: ffffa8a3850c7a10 R11: 6e6f697373657270 R12: 0000000000000000
[74513.244827] R13: ffff893e8111b468 R14: ffff893e803ca560 R15: 0000000000000003
[74513.244992] FS:  00007fcaf745c380(0000) GS:ffff8941afc40000(0000)
knlGS:0000000000000000
[74513.245147] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[74513.245302] CR2: 0000000000000208 CR3: 0000000117120006 CR4: 0000000000370ef0
[74513.245464] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[74513.245626] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[74513.245789] Call Trace:
[74513.245955]  <TASK>
[74513.246126]  ? __die_body+0x1b/0x60
[74513.246295]  ? page_fault_oops+0x158/0x4e0
[74513.246463]  ? do_user_addr_fault+0x63/0x820
[74513.246629]  ? exc_page_fault+0x73/0x170
[74513.246796]  ? asm_exc_page_fault+0x22/0x30
[74513.246967]  ? prop_compression_apply+0x2f/0x150 [btrfs]
[74513.247195]  inode_prop_iterator+0x22/0x70 [btrfs]
[74513.247420]  btrfs_load_inode_props+0x2c0/0x330 [btrfs]
[74513.247648]  btrfs_iget_path+0x497/0x700 [btrfs]
[74513.247872]  btrfs_lookup_dentry+0x355/0x5d0 [btrfs]
[74513.248097]  ? d_alloc_parallel+0x2a5/0x400
[74513.248281]  btrfs_lookup+0xe/0x30 [btrfs]
[74513.248509]  __lookup_slow+0x82/0x130
[74513.248703]  walk_component+0xe5/0x160
[74513.248900]  path_lookupat.isra.0+0x6e/0x150
[74513.249092]  filename_lookup+0xc7/0x190
[74513.249285]  ? do_pte_missing+0x86d/0xc50
[74513.249478]  ? __pte_offset_map+0x17/0x140
[74513.249674]  ? preempt_count_add+0x47/0xa0
(...)


>
>  fs/btrfs/bio.c              |  2 +-
>  fs/btrfs/block-group.c      |  4 ++--
>  fs/btrfs/block-group.h      |  2 +-
>  fs/btrfs/btrfs_inode.h      |  4 ++--
>  fs/btrfs/compression.c      |  6 +++---
>  fs/btrfs/compression.h      |  2 +-
>  fs/btrfs/delayed-inode.c    | 12 +++++------
>  fs/btrfs/delayed-inode.h    |  4 ++--
>  fs/btrfs/extent_io.c        |  2 +-
>  fs/btrfs/free-space-cache.c |  4 ++--
>  fs/btrfs/inode.c            | 18 ++++++++--------
>  fs/btrfs/ioctl.c            | 16 +++++++-------
>  fs/btrfs/ordered-data.c     | 22 +++++++++----------
>  fs/btrfs/ordered-data.h     |  2 +-
>  fs/btrfs/props.c            | 43 ++++++++++++++++++-------------------
>  fs/btrfs/props.h            |  8 +++----
>  fs/btrfs/relocation.c       |  2 +-
>  fs/btrfs/send.c             |  4 ++--
>  fs/btrfs/send.h             |  4 ++--
>  fs/btrfs/subpage.c          |  4 ++--
>  fs/btrfs/transaction.c      |  2 +-
>  fs/btrfs/transaction.h      |  2 +-
>  fs/btrfs/xattr.c            |  2 +-
>  fs/btrfs/zoned.c            |  8 +++----
>  24 files changed, 89 insertions(+), 90 deletions(-)
>
> --
> 2.45.0
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 00/11] Inode type conversion
  2024-06-26 14:06 ` Filipe Manana
@ 2024-06-26 14:39   ` David Sterba
  0 siblings, 0 replies; 15+ messages in thread
From: David Sterba @ 2024-06-26 14:39 UTC (permalink / raw)
  To: Filipe Manana; +Cc: David Sterba, linux-btrfs

On Wed, Jun 26, 2024 at 03:06:29PM +0100, Filipe Manana wrote:
> On Mon, Jun 24, 2024 at 5:24 PM David Sterba <dsterba@suse.com> wrote:
> >
> > A small batch converting inode to btrfs_inode for internal functions and
> > data structures.
> >
> > David Sterba (11):
> >   btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items()
> >   btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items()
> >   btrfs: pass a btrfs_inode to is_data_inode()
> >   btrfs: switch btrfs_block_group::inode to struct btrfs_inode
> >   btrfs: pass a btrfs_inode to btrfs_ioctl_send()
> >   btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode
> >   btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode
> >   btrfs: pass a btrfs_inode to btrfs_compress_heuristic()
> >   btrfs: pass a btrfs_inode to btrfs_set_prop()
> >   btrfs: pass a btrfs_inode to btrfs_load_inode_props()
> >   btrfs: pass a btrfs_inode to btrfs_inode_inherit_props()
> 
> One of these changes to the properties is broken.
> btrfs/048 triggers this:

Thanks for the report, I'll take a look.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-06-26 14:39 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-24 16:22 [PATCH 00/11] Inode type conversion David Sterba
2024-06-24 16:23 ` [PATCH 01/11] btrfs: pass a btrfs_inode to btrfs_readdir_put_delayed_items() David Sterba
2024-06-24 16:23 ` [PATCH 02/11] btrfs: pass a btrfs_inode to btrfs_readdir_get_delayed_items() David Sterba
2024-06-24 16:23 ` [PATCH 03/11] btrfs: pass a btrfs_inode to is_data_inode() David Sterba
2024-06-24 16:23 ` [PATCH 04/11] btrfs: switch btrfs_block_group::inode to struct btrfs_inode David Sterba
2024-06-24 16:23 ` [PATCH 05/11] btrfs: pass a btrfs_inode to btrfs_ioctl_send() David Sterba
2024-06-24 16:23 ` [PATCH 06/11] btrfs: switch btrfs_pending_snapshot::dir to btrfs_inode David Sterba
2024-06-24 16:23 ` [PATCH 07/11] btrfs: switch btrfs_ordered_extent::inode to struct btrfs_inode David Sterba
2024-06-24 16:23 ` [PATCH 08/11] btrfs: pass a btrfs_inode to btrfs_compress_heuristic() David Sterba
2024-06-24 16:23 ` [PATCH 09/11] btrfs: pass a btrfs_inode to btrfs_set_prop() David Sterba
2024-06-24 16:23 ` [PATCH 10/11] btrfs: pass a btrfs_inode to btrfs_load_inode_props() David Sterba
2024-06-24 16:23 ` [PATCH 11/11] btrfs: pass a btrfs_inode to btrfs_inode_inherit_props() David Sterba
2024-06-24 18:41 ` [PATCH 00/11] Inode type conversion Boris Burkov
2024-06-26 14:06 ` Filipe Manana
2024-06-26 14:39   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox