* [PATCH 00/22] More inode type cleanups
@ 2025-02-20 10:00 David Sterba
2025-02-20 10:00 ` [PATCH 01/22] btrfs: pass struct btrfs_inode to can_nocow_extent() David Sterba
` (22 more replies)
0 siblings, 23 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Continued work to convert struct inode to struct btrfs_inode in the
internal interfaces. No functional changes.
David Sterba (22):
btrfs: pass struct btrfs_inode to can_nocow_extent()
btrfs: pass struct btrfs_inode to extent_range_clear_dirty_for_io()
btrfs: pass struct btrfs_inode to btrfs_read_locked_inode()
btrfs: pass struct btrfs_inode to btrfs_iget_locked()
btrfs: pass struct btrfs_inode to new_simple_dir()
btrfs: pass struct btrfs_inode to btrfs_inode_type()
btrfs: pass struct btrfs_inode to btrfs_defrag_file()
btrfs: use struct btrfs_inode inside create_pending_snapshot()
btrfs: pass struct btrfs_inode to fill_stack_inode_item()
btrfs: pass struct btrfs_inode to btrfs_fill_inode()
btrfs: pass struct btrfs_inode to btrfs_load_inode_props()
btrfs: pass struct btrfs_inode to btrfs_inode_inherit_props()
btrfs: props: switch prop_handler::apply to struct btrfs_inode
btrfs: props: switch prop_handler::extract to struct btrfs_inode
btrfs: pass struct btrfs_inode to clone_copy_inline_extent()
btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock()
btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock()
btrfs: pass struct btrfs_inode to btrfs_extent_same_range()
btrfs: use struct btrfs_inode inside btrfs_remap_file_range()
btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep()
btrfs: use struct btrfs_inode inside btrfs_get_parent()
btrfs: use struct btrfs_inode inside btrfs_get_name()
fs/btrfs/btrfs_inode.h | 2 +-
fs/btrfs/defrag.c | 44 ++++----
fs/btrfs/defrag.h | 4 +-
fs/btrfs/delayed-inode.c | 95 ++++++++--------
fs/btrfs/delayed-inode.h | 2 +-
fs/btrfs/direct-io.c | 3 +-
fs/btrfs/export.c | 26 ++---
fs/btrfs/file.c | 3 +-
fs/btrfs/inode.c | 232 ++++++++++++++++++++-------------------
fs/btrfs/ioctl.c | 2 +-
fs/btrfs/props.c | 66 +++++------
fs/btrfs/props.h | 7 +-
fs/btrfs/reflink.c | 100 ++++++++---------
fs/btrfs/transaction.c | 24 ++--
14 files changed, 309 insertions(+), 301 deletions(-)
--
2.47.1
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 01/22] btrfs: pass struct btrfs_inode to can_nocow_extent()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
@ 2025-02-20 10:00 ` David Sterba
2025-02-20 10:00 ` [PATCH 02/22] btrfs: pass struct btrfs_inode to extent_range_clear_dirty_for_io() David Sterba
` (21 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to can_nocow_extent() as it's an internal
interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/btrfs_inode.h | 2 +-
fs/btrfs/direct-io.c | 3 ++-
fs/btrfs/file.c | 3 +--
fs/btrfs/inode.c | 18 +++++++++---------
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 029fba82b81d..ca1cd600f5d2 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -532,7 +532,7 @@ int btrfs_check_sector_csum(struct btrfs_fs_info *fs_info, struct page *page,
u32 pgoff, u8 *csum, const u8 * const csum_expected);
bool btrfs_data_csum_ok(struct btrfs_bio *bbio, struct btrfs_device *dev,
u32 bio_offset, struct bio_vec *bv);
-noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+noinline int can_nocow_extent(struct btrfs_inode *inode, u64 offset, u64 *len,
struct btrfs_file_extent *file_extent,
bool nowait);
diff --git a/fs/btrfs/direct-io.c b/fs/btrfs/direct-io.c
index c98db5058967..fb6df17fb55c 100644
--- a/fs/btrfs/direct-io.c
+++ b/fs/btrfs/direct-io.c
@@ -248,7 +248,8 @@ static int btrfs_get_blocks_direct_write(struct extent_map **map,
len = min(len, em->len - (start - em->start));
block_start = extent_map_block_start(em) + (start - em->start);
- if (can_nocow_extent(inode, start, &len, &file_extent, false) == 1) {
+ if (can_nocow_extent(BTRFS_I(inode), start, &len, &file_extent,
+ false) == 1) {
bg = btrfs_inc_nocow_writers(fs_info, block_start);
if (bg)
can_nocow = true;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 3603d9bbc17a..dd4b6c0c4542 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1013,8 +1013,7 @@ int btrfs_check_nocow_lock(struct btrfs_inode *inode, loff_t pos,
btrfs_lock_and_flush_ordered_range(inode, lockstart, lockend,
&cached_state);
}
- ret = can_nocow_extent(&inode->vfs_inode, lockstart, &num_bytes,
- NULL, nowait);
+ ret = can_nocow_extent(inode, lockstart, &num_bytes, NULL, nowait);
if (ret <= 0)
btrfs_drew_write_unlock(&root->snapshot_lock);
else
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index fdc03e84fa46..4f53f50a324b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7068,17 +7068,17 @@ static bool btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr)
* NOTE: This only checks the file extents, caller is responsible to wait for
* any ordered extents.
*/
-noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
+noinline int can_nocow_extent(struct btrfs_inode *inode, u64 offset, u64 *len,
struct btrfs_file_extent *file_extent,
bool nowait)
{
- struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+ struct btrfs_root *root = inode->root;
+ struct btrfs_fs_info *fs_info = root->fs_info;
struct can_nocow_file_extent_args nocow_args = { 0 };
struct btrfs_path *path;
int ret;
struct extent_buffer *leaf;
- struct btrfs_root *root = BTRFS_I(inode)->root;
- struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
+ struct extent_io_tree *io_tree = &inode->io_tree;
struct btrfs_file_extent_item *fi;
struct btrfs_key key;
int found_type;
@@ -7088,8 +7088,8 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
return -ENOMEM;
path->nowait = nowait;
- ret = btrfs_lookup_file_extent(NULL, root, path,
- btrfs_ino(BTRFS_I(inode)), offset, 0);
+ ret = btrfs_lookup_file_extent(NULL, root, path, btrfs_ino(inode),
+ offset, 0);
if (ret < 0)
goto out;
@@ -7104,7 +7104,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
ret = 0;
leaf = path->nodes[0];
btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
- if (key.objectid != btrfs_ino(BTRFS_I(inode)) ||
+ if (key.objectid != btrfs_ino(inode) ||
key.type != BTRFS_EXTENT_DATA_KEY) {
/* not our file or wrong item type, must cow */
goto out;
@@ -7125,7 +7125,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
nocow_args.end = offset + *len - 1;
nocow_args.free_path = true;
- ret = can_nocow_file_extent(path, &key, BTRFS_I(inode), &nocow_args);
+ ret = can_nocow_file_extent(path, &key, inode, &nocow_args);
/* can_nocow_file_extent() has freed the path. */
path = NULL;
@@ -7141,7 +7141,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
nocow_args.file_extent.offset))
goto out;
- if (!(BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW) &&
+ if (!(inode->flags & BTRFS_INODE_NODATACOW) &&
found_type == BTRFS_FILE_EXTENT_PREALLOC) {
u64 range_end;
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 02/22] btrfs: pass struct btrfs_inode to extent_range_clear_dirty_for_io()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
2025-02-20 10:00 ` [PATCH 01/22] btrfs: pass struct btrfs_inode to can_nocow_extent() David Sterba
@ 2025-02-20 10:00 ` David Sterba
2025-02-20 10:00 ` [PATCH 03/22] btrfs: pass struct btrfs_inode to btrfs_read_locked_inode() David Sterba
` (20 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to extent_range_clear_dirty_for_io() 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 | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4f53f50a324b..2311d1b0d5a9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -819,7 +819,7 @@ static inline void inode_should_defrag(struct btrfs_inode *inode,
btrfs_add_inode_defrag(inode, small_write);
}
-static int extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end)
+static int extent_range_clear_dirty_for_io(struct btrfs_inode *inode, u64 start, u64 end)
{
unsigned long end_index = end >> PAGE_SHIFT;
struct folio *folio;
@@ -827,13 +827,13 @@ static int extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 e
for (unsigned long index = start >> PAGE_SHIFT;
index <= end_index; index++) {
- folio = filemap_get_folio(inode->i_mapping, index);
+ folio = filemap_get_folio(inode->vfs_inode.i_mapping, index);
if (IS_ERR(folio)) {
if (!ret)
ret = PTR_ERR(folio);
continue;
}
- btrfs_folio_clamp_clear_dirty(inode_to_fs_info(inode), folio, start,
+ btrfs_folio_clamp_clear_dirty(inode->root->fs_info, folio, start,
end + 1 - start);
folio_put(folio);
}
@@ -881,7 +881,7 @@ static void compress_file_range(struct btrfs_work *work)
* Otherwise applications with the file mmap'd can wander in and change
* the page contents while we are compressing them.
*/
- ret = extent_range_clear_dirty_for_io(&inode->vfs_inode, start, end);
+ ret = extent_range_clear_dirty_for_io(inode, start, end);
/*
* All the folios should have been locked thus no failure.
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 03/22] btrfs: pass struct btrfs_inode to btrfs_read_locked_inode()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
2025-02-20 10:00 ` [PATCH 01/22] btrfs: pass struct btrfs_inode to can_nocow_extent() David Sterba
2025-02-20 10:00 ` [PATCH 02/22] btrfs: pass struct btrfs_inode to extent_range_clear_dirty_for_io() David Sterba
@ 2025-02-20 10:00 ` David Sterba
2025-02-20 10:00 ` [PATCH 04/22] btrfs: pass struct btrfs_inode to btrfs_iget_locked() David Sterba
` (19 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_read_locked_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/inode.c | 117 +++++++++++++++++++++++------------------------
1 file changed, 57 insertions(+), 60 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2311d1b0d5a9..01fd8a5fc21c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3846,12 +3846,13 @@ static int btrfs_add_inode_to_root(struct btrfs_inode *inode, bool prealloc)
*
* On failure clean up the inode.
*/
-static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
+static int btrfs_read_locked_inode(struct btrfs_inode *inode, struct btrfs_path *path)
{
- struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+ struct btrfs_root *root = inode->root;
+ struct btrfs_fs_info *fs_info = root->fs_info;
struct extent_buffer *leaf;
struct btrfs_inode_item *inode_item;
- struct btrfs_root *root = BTRFS_I(inode)->root;
+ struct inode *vfs_inode = &inode->vfs_inode;
struct btrfs_key location;
unsigned long ptr;
int maybe_acls;
@@ -3860,17 +3861,17 @@ static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
bool filled = false;
int first_xattr_slot;
- ret = btrfs_init_file_extent_tree(BTRFS_I(inode));
+ ret = btrfs_init_file_extent_tree(inode);
if (ret)
goto out;
- ret = btrfs_fill_inode(inode, &rdev);
+ ret = btrfs_fill_inode(vfs_inode, &rdev);
if (!ret)
filled = true;
ASSERT(path);
- btrfs_get_inode_key(BTRFS_I(inode), &location);
+ btrfs_get_inode_key(inode, &location);
ret = btrfs_lookup_inode(NULL, root, path, &location, 0);
if (ret) {
@@ -3890,42 +3891,41 @@ static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
inode_item = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_inode_item);
- inode->i_mode = btrfs_inode_mode(leaf, inode_item);
- set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
- i_uid_write(inode, btrfs_inode_uid(leaf, inode_item));
- i_gid_write(inode, btrfs_inode_gid(leaf, inode_item));
- btrfs_i_size_write(BTRFS_I(inode), btrfs_inode_size(leaf, inode_item));
- btrfs_inode_set_file_extent_range(BTRFS_I(inode), 0,
- round_up(i_size_read(inode), fs_info->sectorsize));
+ vfs_inode->i_mode = btrfs_inode_mode(leaf, inode_item);
+ set_nlink(vfs_inode, btrfs_inode_nlink(leaf, inode_item));
+ i_uid_write(vfs_inode, btrfs_inode_uid(leaf, inode_item));
+ i_gid_write(vfs_inode, btrfs_inode_gid(leaf, inode_item));
+ btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
+ btrfs_inode_set_file_extent_range(inode, 0,
+ round_up(i_size_read(vfs_inode), fs_info->sectorsize));
- inode_set_atime(inode, btrfs_timespec_sec(leaf, &inode_item->atime),
+ inode_set_atime(vfs_inode, btrfs_timespec_sec(leaf, &inode_item->atime),
btrfs_timespec_nsec(leaf, &inode_item->atime));
- inode_set_mtime(inode, btrfs_timespec_sec(leaf, &inode_item->mtime),
+ inode_set_mtime(vfs_inode, btrfs_timespec_sec(leaf, &inode_item->mtime),
btrfs_timespec_nsec(leaf, &inode_item->mtime));
- inode_set_ctime(inode, btrfs_timespec_sec(leaf, &inode_item->ctime),
+ inode_set_ctime(vfs_inode, btrfs_timespec_sec(leaf, &inode_item->ctime),
btrfs_timespec_nsec(leaf, &inode_item->ctime));
- BTRFS_I(inode)->i_otime_sec = btrfs_timespec_sec(leaf, &inode_item->otime);
- BTRFS_I(inode)->i_otime_nsec = btrfs_timespec_nsec(leaf, &inode_item->otime);
+ inode->i_otime_sec = btrfs_timespec_sec(leaf, &inode_item->otime);
+ inode->i_otime_nsec = btrfs_timespec_nsec(leaf, &inode_item->otime);
- inode_set_bytes(inode, btrfs_inode_nbytes(leaf, inode_item));
- BTRFS_I(inode)->generation = btrfs_inode_generation(leaf, inode_item);
- BTRFS_I(inode)->last_trans = btrfs_inode_transid(leaf, inode_item);
+ inode_set_bytes(vfs_inode, btrfs_inode_nbytes(leaf, inode_item));
+ inode->generation = btrfs_inode_generation(leaf, inode_item);
+ inode->last_trans = btrfs_inode_transid(leaf, inode_item);
- inode_set_iversion_queried(inode,
- btrfs_inode_sequence(leaf, inode_item));
- inode->i_generation = BTRFS_I(inode)->generation;
- inode->i_rdev = 0;
+ inode_set_iversion_queried(vfs_inode, btrfs_inode_sequence(leaf, inode_item));
+ vfs_inode->i_generation = inode->generation;
+ vfs_inode->i_rdev = 0;
rdev = btrfs_inode_rdev(leaf, inode_item);
- if (S_ISDIR(inode->i_mode))
- BTRFS_I(inode)->index_cnt = (u64)-1;
+ if (S_ISDIR(vfs_inode->i_mode))
+ inode->index_cnt = (u64)-1;
btrfs_inode_split_flags(btrfs_inode_flags(leaf, inode_item),
- &BTRFS_I(inode)->flags, &BTRFS_I(inode)->ro_flags);
- btrfs_update_inode_mapping_flags(BTRFS_I(inode));
+ &inode->flags, &inode->ro_flags);
+ btrfs_update_inode_mapping_flags(inode);
cache_index:
/*
@@ -3937,9 +3937,8 @@ static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
* This is required for both inode re-read from disk and delayed inode
* in the delayed_nodes xarray.
*/
- if (BTRFS_I(inode)->last_trans == btrfs_get_fs_generation(fs_info))
- set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
- &BTRFS_I(inode)->runtime_flags);
+ if (inode->last_trans == btrfs_get_fs_generation(fs_info))
+ set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags);
/*
* We don't persist the id of the transaction where an unlink operation
@@ -3968,7 +3967,7 @@ static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
* transaction commits on fsync if our inode is a directory, or if our
* inode is not a directory, logging its parent unnecessarily.
*/
- BTRFS_I(inode)->last_unlink_trans = BTRFS_I(inode)->last_trans;
+ inode->last_unlink_trans = inode->last_trans;
/*
* Same logic as for last_unlink_trans. We don't persist the generation
@@ -3976,15 +3975,15 @@ static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
* operation, so after eviction and reloading the inode we must be
* pessimistic and assume the last transaction that modified the inode.
*/
- BTRFS_I(inode)->last_reflink_trans = BTRFS_I(inode)->last_trans;
+ inode->last_reflink_trans = inode->last_trans;
path->slots[0]++;
- if (inode->i_nlink != 1 ||
+ if (vfs_inode->i_nlink != 1 ||
path->slots[0] >= btrfs_header_nritems(leaf))
goto cache_acl;
btrfs_item_key_to_cpu(leaf, &location, path->slots[0]);
- if (location.objectid != btrfs_ino(BTRFS_I(inode)))
+ if (location.objectid != btrfs_ino(inode))
goto cache_acl;
ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
@@ -3992,13 +3991,12 @@ static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
struct btrfs_inode_ref *ref;
ref = (struct btrfs_inode_ref *)ptr;
- BTRFS_I(inode)->dir_index = btrfs_inode_ref_index(leaf, ref);
+ inode->dir_index = btrfs_inode_ref_index(leaf, ref);
} else if (location.type == BTRFS_INODE_EXTREF_KEY) {
struct btrfs_inode_extref *extref;
extref = (struct btrfs_inode_extref *)ptr;
- BTRFS_I(inode)->dir_index = btrfs_inode_extref_index(leaf,
- extref);
+ inode->dir_index = btrfs_inode_extref_index(leaf, extref);
}
cache_acl:
/*
@@ -4006,50 +4004,49 @@ static int btrfs_read_locked_inode(struct inode *inode, struct btrfs_path *path)
* any xattrs or acls
*/
maybe_acls = acls_after_inode_item(leaf, path->slots[0],
- btrfs_ino(BTRFS_I(inode)), &first_xattr_slot);
+ btrfs_ino(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(vfs_inode, path);
if (ret)
btrfs_err(fs_info,
"error loading props for ino %llu (root %llu): %d",
- btrfs_ino(BTRFS_I(inode)),
- btrfs_root_id(root), ret);
+ btrfs_ino(inode), btrfs_root_id(root), ret);
}
if (!maybe_acls)
- cache_no_acl(inode);
+ cache_no_acl(vfs_inode);
- switch (inode->i_mode & S_IFMT) {
+ switch (vfs_inode->i_mode & S_IFMT) {
case S_IFREG:
- inode->i_mapping->a_ops = &btrfs_aops;
- inode->i_fop = &btrfs_file_operations;
- inode->i_op = &btrfs_file_inode_operations;
+ vfs_inode->i_mapping->a_ops = &btrfs_aops;
+ vfs_inode->i_fop = &btrfs_file_operations;
+ vfs_inode->i_op = &btrfs_file_inode_operations;
break;
case S_IFDIR:
- inode->i_fop = &btrfs_dir_file_operations;
- inode->i_op = &btrfs_dir_inode_operations;
+ vfs_inode->i_fop = &btrfs_dir_file_operations;
+ vfs_inode->i_op = &btrfs_dir_inode_operations;
break;
case S_IFLNK:
- inode->i_op = &btrfs_symlink_inode_operations;
- inode_nohighmem(inode);
- inode->i_mapping->a_ops = &btrfs_aops;
+ vfs_inode->i_op = &btrfs_symlink_inode_operations;
+ inode_nohighmem(vfs_inode);
+ vfs_inode->i_mapping->a_ops = &btrfs_aops;
break;
default:
- inode->i_op = &btrfs_special_inode_operations;
- init_special_inode(inode, inode->i_mode, rdev);
+ vfs_inode->i_op = &btrfs_special_inode_operations;
+ init_special_inode(vfs_inode, vfs_inode->i_mode, rdev);
break;
}
- btrfs_sync_inode_flags_to_i_flags(inode);
+ btrfs_sync_inode_flags_to_i_flags(vfs_inode);
- ret = btrfs_add_inode_to_root(BTRFS_I(inode), true);
+ ret = btrfs_add_inode_to_root(inode, true);
if (ret)
goto out;
return 0;
out:
- iget_failed(inode);
+ iget_failed(vfs_inode);
return ret;
}
@@ -5636,7 +5633,7 @@ struct inode *btrfs_iget_path(u64 ino, struct btrfs_root *root,
if (!(inode->i_state & I_NEW))
return inode;
- ret = btrfs_read_locked_inode(inode, path);
+ ret = btrfs_read_locked_inode(BTRFS_I(inode), path);
if (ret)
return ERR_PTR(ret);
@@ -5664,7 +5661,7 @@ struct inode *btrfs_iget(u64 ino, struct btrfs_root *root)
if (!path)
return ERR_PTR(-ENOMEM);
- ret = btrfs_read_locked_inode(inode, path);
+ ret = btrfs_read_locked_inode(BTRFS_I(inode), path);
btrfs_free_path(path);
if (ret)
return ERR_PTR(ret);
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 04/22] btrfs: pass struct btrfs_inode to btrfs_iget_locked()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (2 preceding siblings ...)
2025-02-20 10:00 ` [PATCH 03/22] btrfs: pass struct btrfs_inode to btrfs_read_locked_inode() David Sterba
@ 2025-02-20 10:00 ` David Sterba
2025-02-20 10:00 ` [PATCH 05/22] btrfs: pass struct btrfs_inode to new_simple_dir() David Sterba
` (18 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_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/inode.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 01fd8a5fc21c..d726e655974d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5601,7 +5601,7 @@ static int btrfs_find_actor(struct inode *inode, void *opaque)
args->root == BTRFS_I(inode)->root;
}
-static struct inode *btrfs_iget_locked(u64 ino, struct btrfs_root *root)
+static struct btrfs_inode *btrfs_iget_locked(u64 ino, struct btrfs_root *root)
{
struct inode *inode;
struct btrfs_iget_args args;
@@ -5613,7 +5613,9 @@ static struct inode *btrfs_iget_locked(u64 ino, struct btrfs_root *root)
inode = iget5_locked_rcu(root->fs_info->sb, hashval, btrfs_find_actor,
btrfs_init_locked_inode,
(void *)&args);
- return inode;
+ if (!inode)
+ return NULL;
+ return BTRFS_I(inode);
}
/*
@@ -5623,22 +5625,22 @@ static struct inode *btrfs_iget_locked(u64 ino, struct btrfs_root *root)
struct inode *btrfs_iget_path(u64 ino, struct btrfs_root *root,
struct btrfs_path *path)
{
- struct inode *inode;
+ struct btrfs_inode *inode;
int ret;
inode = btrfs_iget_locked(ino, root);
if (!inode)
return ERR_PTR(-ENOMEM);
- if (!(inode->i_state & I_NEW))
- return inode;
+ if (!(inode->vfs_inode.i_state & I_NEW))
+ return &inode->vfs_inode;
- ret = btrfs_read_locked_inode(BTRFS_I(inode), path);
+ ret = btrfs_read_locked_inode(inode, path);
if (ret)
return ERR_PTR(ret);
- unlock_new_inode(inode);
- return inode;
+ unlock_new_inode(&inode->vfs_inode);
+ return &inode->vfs_inode;
}
/*
@@ -5646,7 +5648,7 @@ struct inode *btrfs_iget_path(u64 ino, struct btrfs_root *root,
*/
struct inode *btrfs_iget(u64 ino, struct btrfs_root *root)
{
- struct inode *inode;
+ struct btrfs_inode *inode;
struct btrfs_path *path;
int ret;
@@ -5654,20 +5656,20 @@ struct inode *btrfs_iget(u64 ino, struct btrfs_root *root)
if (!inode)
return ERR_PTR(-ENOMEM);
- if (!(inode->i_state & I_NEW))
- return inode;
+ if (!(inode->vfs_inode.i_state & I_NEW))
+ return &inode->vfs_inode;
path = btrfs_alloc_path();
if (!path)
return ERR_PTR(-ENOMEM);
- ret = btrfs_read_locked_inode(BTRFS_I(inode), path);
+ ret = btrfs_read_locked_inode(inode, path);
btrfs_free_path(path);
if (ret)
return ERR_PTR(ret);
- unlock_new_inode(inode);
- return inode;
+ unlock_new_inode(&inode->vfs_inode);
+ return &inode->vfs_inode;
}
static struct inode *new_simple_dir(struct inode *dir,
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 05/22] btrfs: pass struct btrfs_inode to new_simple_dir()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (3 preceding siblings ...)
2025-02-20 10:00 ` [PATCH 04/22] btrfs: pass struct btrfs_inode to btrfs_iget_locked() David Sterba
@ 2025-02-20 10:00 ` David Sterba
2025-02-20 10:01 ` [PATCH 06/22] btrfs: pass struct btrfs_inode to btrfs_inode_type() David Sterba
` (17 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:00 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to new_simple_dir() 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 | 55 +++++++++++++++++++++++++++---------------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d726e655974d..ac4dfb896d0f 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5672,39 +5672,42 @@ struct inode *btrfs_iget(u64 ino, struct btrfs_root *root)
return &inode->vfs_inode;
}
-static struct inode *new_simple_dir(struct inode *dir,
- struct btrfs_key *key,
- struct btrfs_root *root)
+static struct btrfs_inode *new_simple_dir(struct inode *dir,
+ struct btrfs_key *key,
+ struct btrfs_root *root)
{
struct timespec64 ts;
- struct inode *inode = new_inode(dir->i_sb);
+ struct inode *vfs_inode;
+ struct btrfs_inode *inode;
- if (!inode)
+ vfs_inode = new_inode(dir->i_sb);
+ if (!vfs_inode)
return ERR_PTR(-ENOMEM);
- BTRFS_I(inode)->root = btrfs_grab_root(root);
- BTRFS_I(inode)->ref_root_id = key->objectid;
- set_bit(BTRFS_INODE_ROOT_STUB, &BTRFS_I(inode)->runtime_flags);
- set_bit(BTRFS_INODE_DUMMY, &BTRFS_I(inode)->runtime_flags);
+ inode = BTRFS_I(vfs_inode);
+ inode->root = btrfs_grab_root(root);
+ inode->ref_root_id = key->objectid;
+ set_bit(BTRFS_INODE_ROOT_STUB, &inode->runtime_flags);
+ set_bit(BTRFS_INODE_DUMMY, &inode->runtime_flags);
- btrfs_set_inode_number(BTRFS_I(inode), BTRFS_EMPTY_SUBVOL_DIR_OBJECTID);
+ btrfs_set_inode_number(inode, BTRFS_EMPTY_SUBVOL_DIR_OBJECTID);
/*
* We only need lookup, the rest is read-only and there's no inode
* associated with the dentry
*/
- inode->i_op = &simple_dir_inode_operations;
- inode->i_opflags &= ~IOP_XATTR;
- inode->i_fop = &simple_dir_operations;
- inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
+ vfs_inode->i_op = &simple_dir_inode_operations;
+ vfs_inode->i_opflags &= ~IOP_XATTR;
+ vfs_inode->i_fop = &simple_dir_operations;
+ vfs_inode->i_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
- ts = inode_set_ctime_current(inode);
- inode_set_mtime_to_ts(inode, ts);
- inode_set_atime_to_ts(inode, inode_get_atime(dir));
- BTRFS_I(inode)->i_otime_sec = ts.tv_sec;
- BTRFS_I(inode)->i_otime_nsec = ts.tv_nsec;
+ ts = inode_set_ctime_current(vfs_inode);
+ inode_set_mtime_to_ts(vfs_inode, ts);
+ inode_set_atime_to_ts(vfs_inode, inode_get_atime(dir));
+ inode->i_otime_sec = ts.tv_sec;
+ inode->i_otime_nsec = ts.tv_nsec;
- inode->i_uid = dir->i_uid;
- inode->i_gid = dir->i_gid;
+ vfs_inode->i_uid = dir->i_uid;
+ vfs_inode->i_gid = dir->i_gid;
return inode;
}
@@ -5760,10 +5763,14 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
ret = fixup_tree_root_location(fs_info, BTRFS_I(dir), dentry,
&location, &sub_root);
if (ret < 0) {
- if (ret != -ENOENT)
+ if (ret != -ENOENT) {
inode = ERR_PTR(ret);
- else
- inode = new_simple_dir(dir, &location, root);
+ } else {
+ struct btrfs_inode *b_inode;
+
+ b_inode = new_simple_dir(dir, &location, root);
+ inode = &b_inode->vfs_inode;
+ }
} else {
inode = btrfs_iget(location.objectid, sub_root);
btrfs_put_root(sub_root);
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 06/22] btrfs: pass struct btrfs_inode to btrfs_inode_type()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (4 preceding siblings ...)
2025-02-20 10:00 ` [PATCH 05/22] btrfs: pass struct btrfs_inode to new_simple_dir() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 07/22] btrfs: pass struct btrfs_inode to btrfs_defrag_file() David Sterba
` (16 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_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/inode.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ac4dfb896d0f..ef02ba48522a 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5721,9 +5721,9 @@ static_assert(BTRFS_FT_FIFO == FT_FIFO);
static_assert(BTRFS_FT_SOCK == FT_SOCK);
static_assert(BTRFS_FT_SYMLINK == FT_SYMLINK);
-static inline u8 btrfs_inode_type(struct inode *inode)
+static inline u8 btrfs_inode_type(const struct btrfs_inode *inode)
{
- return fs_umode_to_ftype(inode->i_mode);
+ return fs_umode_to_ftype(inode->vfs_inode.i_mode);
}
struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
@@ -5749,10 +5749,10 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
return inode;
/* Do extra check against inode mode with di_type */
- if (btrfs_inode_type(inode) != di_type) {
+ if (btrfs_inode_type(BTRFS_I(inode)) != di_type) {
btrfs_crit(fs_info,
"inode mode mismatch with dir: inode mode=0%o btrfs type=%u dir type=%u",
- inode->i_mode, btrfs_inode_type(inode),
+ inode->i_mode, btrfs_inode_type(BTRFS_I(inode)),
di_type);
iput(inode);
return ERR_PTR(-EUCLEAN);
@@ -6553,7 +6553,7 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
return ret;
ret = btrfs_insert_dir_item(trans, name, parent_inode, &key,
- btrfs_inode_type(&inode->vfs_inode), index);
+ btrfs_inode_type(inode), index);
if (ret == -EEXIST || ret == -EOVERFLOW)
goto fail_dir_item;
else if (ret) {
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 07/22] btrfs: pass struct btrfs_inode to btrfs_defrag_file()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (5 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 06/22] btrfs: pass struct btrfs_inode to btrfs_inode_type() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 08/22] btrfs: use struct btrfs_inode inside create_pending_snapshot() David Sterba
` (15 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_defrag_file() as it's an internal
interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/defrag.c | 44 ++++++++++++++++++++++----------------------
fs/btrfs/defrag.h | 4 ++--
fs/btrfs/ioctl.c | 2 +-
3 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
index d1330c138054..4b89094da3de 100644
--- a/fs/btrfs/defrag.c
+++ b/fs/btrfs/defrag.c
@@ -264,8 +264,8 @@ static int btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,
file_ra_state_init(ra, inode->i_mapping);
sb_start_write(fs_info->sb);
- ret = btrfs_defrag_file(inode, ra, &range, defrag->transid,
- BTRFS_DEFRAG_BATCH);
+ ret = btrfs_defrag_file(BTRFS_I(inode), ra, &range, defrag->transid,
+ BTRFS_DEFRAG_BATCH);
sb_end_write(fs_info->sb);
iput(inode);
@@ -1352,13 +1352,13 @@ static int defrag_one_cluster(struct btrfs_inode *inode,
* (Mostly for autodefrag, which sets @max_to_defrag thus we may exit early without
* defragging all the range).
*/
-int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
+int btrfs_defrag_file(struct btrfs_inode *inode, struct file_ra_state *ra,
struct btrfs_ioctl_defrag_range_args *range,
u64 newer_than, unsigned long max_to_defrag)
{
- struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+ struct btrfs_fs_info *fs_info = inode->root->fs_info;
unsigned long sectors_defragged = 0;
- u64 isize = i_size_read(inode);
+ u64 isize = i_size_read(&inode->vfs_inode);
u64 cur;
u64 last_byte;
bool do_compress = (range->flags & BTRFS_DEFRAG_RANGE_COMPRESS);
@@ -1402,8 +1402,8 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
* defrag range can be written sequentially.
*/
start_index = cur >> PAGE_SHIFT;
- if (start_index < inode->i_mapping->writeback_index)
- inode->i_mapping->writeback_index = start_index;
+ if (start_index < inode->vfs_inode.i_mapping->writeback_index)
+ inode->vfs_inode.i_mapping->writeback_index = start_index;
while (cur < last_byte) {
const unsigned long prev_sectors_defragged = sectors_defragged;
@@ -1420,27 +1420,27 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
(SZ_256K >> PAGE_SHIFT)) << PAGE_SHIFT) - 1;
cluster_end = min(cluster_end, last_byte);
- btrfs_inode_lock(BTRFS_I(inode), 0);
- if (IS_SWAPFILE(inode)) {
+ btrfs_inode_lock(inode, 0);
+ if (IS_SWAPFILE(&inode->vfs_inode)) {
ret = -ETXTBSY;
- btrfs_inode_unlock(BTRFS_I(inode), 0);
+ btrfs_inode_unlock(inode, 0);
break;
}
- if (!(inode->i_sb->s_flags & SB_ACTIVE)) {
- btrfs_inode_unlock(BTRFS_I(inode), 0);
+ if (!(inode->vfs_inode.i_sb->s_flags & SB_ACTIVE)) {
+ btrfs_inode_unlock(inode, 0);
break;
}
if (do_compress)
- BTRFS_I(inode)->defrag_compress = compress_type;
- ret = defrag_one_cluster(BTRFS_I(inode), ra, cur,
+ inode->defrag_compress = compress_type;
+ ret = defrag_one_cluster(inode, ra, cur,
cluster_end + 1 - cur, extent_thresh,
newer_than, do_compress, §ors_defragged,
max_to_defrag, &last_scanned);
if (sectors_defragged > prev_sectors_defragged)
- balance_dirty_pages_ratelimited(inode->i_mapping);
+ balance_dirty_pages_ratelimited(inode->vfs_inode.i_mapping);
- btrfs_inode_unlock(BTRFS_I(inode), 0);
+ btrfs_inode_unlock(inode, 0);
if (ret < 0)
break;
cur = max(cluster_end + 1, last_scanned);
@@ -1462,10 +1462,10 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
* need to be written back immediately.
*/
if (range->flags & BTRFS_DEFRAG_RANGE_START_IO) {
- filemap_flush(inode->i_mapping);
+ filemap_flush(inode->vfs_inode.i_mapping);
if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
- &BTRFS_I(inode)->runtime_flags))
- filemap_flush(inode->i_mapping);
+ &inode->runtime_flags))
+ filemap_flush(inode->vfs_inode.i_mapping);
}
if (range->compress_type == BTRFS_COMPRESS_LZO)
btrfs_set_fs_incompat(fs_info, COMPRESS_LZO);
@@ -1474,9 +1474,9 @@ int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
ret = sectors_defragged;
}
if (do_compress) {
- btrfs_inode_lock(BTRFS_I(inode), 0);
- BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE;
- btrfs_inode_unlock(BTRFS_I(inode), 0);
+ btrfs_inode_lock(inode, 0);
+ inode->defrag_compress = BTRFS_COMPRESS_NONE;
+ btrfs_inode_unlock(inode, 0);
}
return ret;
}
diff --git a/fs/btrfs/defrag.h b/fs/btrfs/defrag.h
index 6b7596c4f0dc..a7f917a38dbf 100644
--- a/fs/btrfs/defrag.h
+++ b/fs/btrfs/defrag.h
@@ -6,14 +6,14 @@
#include <linux/types.h>
#include <linux/compiler_types.h>
-struct inode;
struct file_ra_state;
+struct btrfs_inode;
struct btrfs_fs_info;
struct btrfs_root;
struct btrfs_trans_handle;
struct btrfs_ioctl_defrag_range_args;
-int btrfs_defrag_file(struct inode *inode, struct file_ra_state *ra,
+int btrfs_defrag_file(struct btrfs_inode *inode, struct file_ra_state *ra,
struct btrfs_ioctl_defrag_range_args *range,
u64 newer_than, unsigned long max_to_defrag);
int __init btrfs_auto_defrag_init(void);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 45b087011324..f3ce82d113be 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2572,7 +2572,7 @@ static int btrfs_ioctl_defrag(struct file *file, void __user *argp)
/* the rest are all set to zero by kzalloc */
range.len = (u64)-1;
}
- ret = btrfs_defrag_file(file_inode(file), &file->f_ra,
+ ret = btrfs_defrag_file(BTRFS_I(file_inode(file)), &file->f_ra,
&range, BTRFS_OLDEST_GENERATION, 0);
if (ret > 0)
ret = 0;
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 08/22] btrfs: use struct btrfs_inode inside create_pending_snapshot()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (6 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 07/22] btrfs: pass struct btrfs_inode to btrfs_defrag_file() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 09/22] btrfs: pass struct btrfs_inode to fill_stack_inode_item() David Sterba
` (14 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Use a struct btrfs_inode in create_pending_snapshot() as it's an
internal helper, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/transaction.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 47b2f7172374..db8fe291d010 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1635,7 +1635,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->vfs_inode;
+ struct btrfs_inode *parent_inode = pending->dir;
struct btrfs_path *path;
struct btrfs_dir_item *dir_item;
struct extent_buffer *tmp;
@@ -1661,7 +1661,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
* filesystem.
*/
nofs_flags = memalloc_nofs_save();
- pending->error = fscrypt_setup_filename(parent_inode,
+ pending->error = fscrypt_setup_filename(&parent_inode->vfs_inode,
&pending->dentry->d_name, 0,
&fname);
memalloc_nofs_restore(nofs_flags);
@@ -1699,16 +1699,16 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
trace_btrfs_space_reservation(fs_info, "transaction",
trans->transid,
trans->bytes_reserved, 1);
- parent_root = BTRFS_I(parent_inode)->root;
+ parent_root = parent_inode->root;
ret = record_root_in_trans(trans, parent_root, 0);
if (ret)
goto fail;
- cur_time = current_time(parent_inode);
+ cur_time = current_time(&parent_inode->vfs_inode);
/*
* insert the directory item
*/
- ret = btrfs_set_inode_index(BTRFS_I(parent_inode), &index);
+ ret = btrfs_set_inode_index(parent_inode, &index);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto fail;
@@ -1716,7 +1716,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
/* check if there is a file/dir which has the same name. */
dir_item = btrfs_lookup_dir_item(NULL, parent_root, path,
- btrfs_ino(BTRFS_I(parent_inode)),
+ btrfs_ino(parent_inode),
&fname.disk_name, 0);
if (dir_item != NULL && !IS_ERR(dir_item)) {
pending->error = -EEXIST;
@@ -1817,7 +1817,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
*/
ret = btrfs_add_root_ref(trans, objectid,
btrfs_root_id(parent_root),
- btrfs_ino(BTRFS_I(parent_inode)), index,
+ btrfs_ino(parent_inode), index,
&fname.disk_name);
if (ret) {
btrfs_abort_transaction(trans, ret);
@@ -1855,18 +1855,18 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
goto fail;
ret = btrfs_insert_dir_item(trans, &fname.disk_name,
- BTRFS_I(parent_inode), &key, BTRFS_FT_DIR,
+ parent_inode, &key, BTRFS_FT_DIR,
index);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto fail;
}
- btrfs_i_size_write(BTRFS_I(parent_inode), parent_inode->i_size +
+ btrfs_i_size_write(parent_inode, parent_inode->vfs_inode.i_size +
fname.disk_name.len * 2);
- inode_set_mtime_to_ts(parent_inode,
- inode_set_ctime_current(parent_inode));
- ret = btrfs_update_inode_fallback(trans, BTRFS_I(parent_inode));
+ inode_set_mtime_to_ts(&parent_inode->vfs_inode,
+ inode_set_ctime_current(&parent_inode->vfs_inode));
+ ret = btrfs_update_inode_fallback(trans, parent_inode);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto fail;
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 09/22] btrfs: pass struct btrfs_inode to fill_stack_inode_item()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (7 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 08/22] btrfs: use struct btrfs_inode inside create_pending_snapshot() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 10/22] btrfs: pass struct btrfs_inode to btrfs_fill_inode() David Sterba
` (13 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to fill_stack_inode_item() 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 | 46 +++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 24 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index 0b4933c6a889..bcafbb5ba61d 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1817,44 +1817,43 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
struct btrfs_inode_item *inode_item,
- struct inode *inode)
+ struct btrfs_inode *inode)
{
+ struct inode *vfs_inode = &inode->vfs_inode;
u64 flags;
- btrfs_set_stack_inode_uid(inode_item, i_uid_read(inode));
- btrfs_set_stack_inode_gid(inode_item, i_gid_read(inode));
- btrfs_set_stack_inode_size(inode_item, BTRFS_I(inode)->disk_i_size);
- btrfs_set_stack_inode_mode(inode_item, inode->i_mode);
- btrfs_set_stack_inode_nlink(inode_item, inode->i_nlink);
- btrfs_set_stack_inode_nbytes(inode_item, inode_get_bytes(inode));
- btrfs_set_stack_inode_generation(inode_item,
- BTRFS_I(inode)->generation);
+ btrfs_set_stack_inode_uid(inode_item, i_uid_read(vfs_inode));
+ btrfs_set_stack_inode_gid(inode_item, i_gid_read(vfs_inode));
+ btrfs_set_stack_inode_size(inode_item, inode->disk_i_size);
+ btrfs_set_stack_inode_mode(inode_item, vfs_inode->i_mode);
+ btrfs_set_stack_inode_nlink(inode_item, vfs_inode->i_nlink);
+ btrfs_set_stack_inode_nbytes(inode_item, inode_get_bytes(vfs_inode));
+ btrfs_set_stack_inode_generation(inode_item, inode->generation);
btrfs_set_stack_inode_sequence(inode_item,
- inode_peek_iversion(inode));
+ inode_peek_iversion(vfs_inode));
btrfs_set_stack_inode_transid(inode_item, trans->transid);
- btrfs_set_stack_inode_rdev(inode_item, inode->i_rdev);
- flags = btrfs_inode_combine_flags(BTRFS_I(inode)->flags,
- BTRFS_I(inode)->ro_flags);
+ btrfs_set_stack_inode_rdev(inode_item, vfs_inode->i_rdev);
+ flags = btrfs_inode_combine_flags(inode->flags, inode->ro_flags);
btrfs_set_stack_inode_flags(inode_item, flags);
btrfs_set_stack_inode_block_group(inode_item, 0);
btrfs_set_stack_timespec_sec(&inode_item->atime,
- inode_get_atime_sec(inode));
+ inode_get_atime_sec(vfs_inode));
btrfs_set_stack_timespec_nsec(&inode_item->atime,
- inode_get_atime_nsec(inode));
+ inode_get_atime_nsec(vfs_inode));
btrfs_set_stack_timespec_sec(&inode_item->mtime,
- inode_get_mtime_sec(inode));
+ inode_get_mtime_sec(vfs_inode));
btrfs_set_stack_timespec_nsec(&inode_item->mtime,
- inode_get_mtime_nsec(inode));
+ inode_get_mtime_nsec(vfs_inode));
btrfs_set_stack_timespec_sec(&inode_item->ctime,
- inode_get_ctime_sec(inode));
+ inode_get_ctime_sec(vfs_inode));
btrfs_set_stack_timespec_nsec(&inode_item->ctime,
- inode_get_ctime_nsec(inode));
+ inode_get_ctime_nsec(vfs_inode));
- btrfs_set_stack_timespec_sec(&inode_item->otime, BTRFS_I(inode)->i_otime_sec);
- btrfs_set_stack_timespec_nsec(&inode_item->otime, BTRFS_I(inode)->i_otime_nsec);
+ btrfs_set_stack_timespec_sec(&inode_item->otime, inode->i_otime_sec);
+ btrfs_set_stack_timespec_nsec(&inode_item->otime, inode->i_otime_nsec);
}
int btrfs_fill_inode(struct inode *inode, u32 *rdev)
@@ -1928,8 +1927,7 @@ int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
mutex_lock(&delayed_node->mutex);
if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) {
- fill_stack_inode_item(trans, &delayed_node->inode_item,
- &inode->vfs_inode);
+ fill_stack_inode_item(trans, &delayed_node->inode_item, inode);
goto release_node;
}
@@ -1937,7 +1935,7 @@ int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
if (ret)
goto release_node;
- fill_stack_inode_item(trans, &delayed_node->inode_item, &inode->vfs_inode);
+ fill_stack_inode_item(trans, &delayed_node->inode_item, inode);
set_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags);
delayed_node->count++;
atomic_inc(&root->fs_info->delayed_root->items);
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 10/22] btrfs: pass struct btrfs_inode to btrfs_fill_inode()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (8 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 09/22] btrfs: pass struct btrfs_inode to fill_stack_inode_item() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 11:26 ` Johannes Thumshirn
2025-02-20 10:01 ` [PATCH 11/22] btrfs: pass struct btrfs_inode to btrfs_load_inode_props() David Sterba
` (12 subsequent siblings)
22 siblings, 1 reply; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_fill_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/delayed-inode.c | 49 ++++++++++++++++++++--------------------
fs/btrfs/delayed-inode.h | 2 +-
fs/btrfs/inode.c | 2 +-
3 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index bcafbb5ba61d..b18052213a5d 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -1856,13 +1856,14 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
btrfs_set_stack_timespec_nsec(&inode_item->otime, inode->i_otime_nsec);
}
-int btrfs_fill_inode(struct inode *inode, u32 *rdev)
+int btrfs_fill_inode(struct btrfs_inode *inode, u32 *rdev)
{
- struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
+ struct btrfs_fs_info *fs_info = inode->root->fs_info;
struct btrfs_delayed_node *delayed_node;
struct btrfs_inode_item *inode_item;
+ struct inode *vfs_inode = &inode->vfs_inode;
- delayed_node = btrfs_get_delayed_node(BTRFS_I(inode));
+ delayed_node = btrfs_get_delayed_node(inode);
if (!delayed_node)
return -ENOENT;
@@ -1875,39 +1876,39 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev)
inode_item = &delayed_node->inode_item;
- i_uid_write(inode, btrfs_stack_inode_uid(inode_item));
- i_gid_write(inode, btrfs_stack_inode_gid(inode_item));
- btrfs_i_size_write(BTRFS_I(inode), btrfs_stack_inode_size(inode_item));
- btrfs_inode_set_file_extent_range(BTRFS_I(inode), 0,
- round_up(i_size_read(inode), fs_info->sectorsize));
- inode->i_mode = btrfs_stack_inode_mode(inode_item);
- set_nlink(inode, btrfs_stack_inode_nlink(inode_item));
- inode_set_bytes(inode, btrfs_stack_inode_nbytes(inode_item));
- BTRFS_I(inode)->generation = btrfs_stack_inode_generation(inode_item);
- BTRFS_I(inode)->last_trans = btrfs_stack_inode_transid(inode_item);
+ i_uid_write(vfs_inode, btrfs_stack_inode_uid(inode_item));
+ i_gid_write(vfs_inode, btrfs_stack_inode_gid(inode_item));
+ btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item));
+ btrfs_inode_set_file_extent_range(inode, 0,
+ round_up(i_size_read(vfs_inode), fs_info->sectorsize));
+ vfs_inode->i_mode = btrfs_stack_inode_mode(inode_item);
+ set_nlink(vfs_inode, btrfs_stack_inode_nlink(inode_item));
+ inode_set_bytes(vfs_inode, btrfs_stack_inode_nbytes(inode_item));
+ inode->generation = btrfs_stack_inode_generation(inode_item);
+ inode->last_trans = btrfs_stack_inode_transid(inode_item);
- inode_set_iversion_queried(inode,
+ inode_set_iversion_queried(vfs_inode,
btrfs_stack_inode_sequence(inode_item));
- inode->i_rdev = 0;
+ vfs_inode->i_rdev = 0;
*rdev = btrfs_stack_inode_rdev(inode_item);
btrfs_inode_split_flags(btrfs_stack_inode_flags(inode_item),
- &BTRFS_I(inode)->flags, &BTRFS_I(inode)->ro_flags);
+ &inode->flags, &inode->ro_flags);
- inode_set_atime(inode, btrfs_stack_timespec_sec(&inode_item->atime),
+ inode_set_atime(vfs_inode, btrfs_stack_timespec_sec(&inode_item->atime),
btrfs_stack_timespec_nsec(&inode_item->atime));
- inode_set_mtime(inode, btrfs_stack_timespec_sec(&inode_item->mtime),
+ inode_set_mtime(vfs_inode, btrfs_stack_timespec_sec(&inode_item->mtime),
btrfs_stack_timespec_nsec(&inode_item->mtime));
- inode_set_ctime(inode, btrfs_stack_timespec_sec(&inode_item->ctime),
+ inode_set_ctime(vfs_inode, btrfs_stack_timespec_sec(&inode_item->ctime),
btrfs_stack_timespec_nsec(&inode_item->ctime));
- BTRFS_I(inode)->i_otime_sec = btrfs_stack_timespec_sec(&inode_item->otime);
- BTRFS_I(inode)->i_otime_nsec = btrfs_stack_timespec_nsec(&inode_item->otime);
+ inode->i_otime_sec = btrfs_stack_timespec_sec(&inode_item->otime);
+ inode->i_otime_nsec = btrfs_stack_timespec_nsec(&inode_item->otime);
- inode->i_generation = BTRFS_I(inode)->generation;
- if (S_ISDIR(inode->i_mode))
- BTRFS_I(inode)->index_cnt = (u64)-1;
+ vfs_inode->i_generation = inode->generation;
+ if (S_ISDIR(vfs_inode->i_mode))
+ inode->index_cnt = (u64)-1;
mutex_unlock(&delayed_node->mutex);
btrfs_release_delayed_node(delayed_node);
diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
index f4d9feac0d0e..c4b4ba122beb 100644
--- a/fs/btrfs/delayed-inode.h
+++ b/fs/btrfs/delayed-inode.h
@@ -133,7 +133,7 @@ int btrfs_commit_inode_delayed_inode(struct btrfs_inode *inode);
int btrfs_delayed_update_inode(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode);
-int btrfs_fill_inode(struct inode *inode, u32 *rdev);
+int btrfs_fill_inode(struct btrfs_inode *inode, u32 *rdev);
int btrfs_delayed_delete_inode_ref(struct btrfs_inode *inode);
/* Used for drop dead root */
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ef02ba48522a..c21d60de936d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3865,7 +3865,7 @@ static int btrfs_read_locked_inode(struct btrfs_inode *inode, struct btrfs_path
if (ret)
goto out;
- ret = btrfs_fill_inode(vfs_inode, &rdev);
+ ret = btrfs_fill_inode(inode, &rdev);
if (!ret)
filled = true;
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 11/22] btrfs: pass struct btrfs_inode to btrfs_load_inode_props()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (9 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 10/22] btrfs: pass struct btrfs_inode to btrfs_fill_inode() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 12/22] btrfs: pass struct btrfs_inode to btrfs_inode_inherit_props() David Sterba
` (11 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 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 | 9 +++++----
fs/btrfs/props.h | 2 +-
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c21d60de936d..8be41aec8dc6 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4007,7 +4007,7 @@ static int btrfs_read_locked_inode(struct btrfs_inode *inode, struct btrfs_path
btrfs_ino(inode), &first_xattr_slot);
if (first_xattr_slot != -1) {
path->slots[0] = first_xattr_slot;
- ret = btrfs_load_inode_props(vfs_inode, path);
+ ret = btrfs_load_inode_props(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..74d3217fc686 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -273,12 +273,13 @@ 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);
+ return iterate_object_props(root, path, ino, inode_prop_iterator,
+ &inode->vfs_inode);
}
static int prop_compression_validate(const struct btrfs_inode *inode,
diff --git a/fs/btrfs/props.h b/fs/btrfs/props.h
index 86849d4e7938..a0cc2a7a1e2e 100644
--- a/fs/btrfs/props.h
+++ b/fs/btrfs/props.h
@@ -23,7 +23,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.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 12/22] btrfs: pass struct btrfs_inode to btrfs_inode_inherit_props()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (10 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 11/22] btrfs: pass struct btrfs_inode to btrfs_load_inode_props() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 13/22] btrfs: props: switch prop_handler::apply to struct btrfs_inode David Sterba
` (10 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_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 | 6 ++++--
fs/btrfs/props.c | 23 +++++++++++------------
fs/btrfs/props.h | 5 ++---
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8be41aec8dc6..a1ea93bad80e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6451,11 +6451,13 @@ 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 74d3217fc686..16e84a2e24f4 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -386,16 +386,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++) {
@@ -406,10 +406,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;
@@ -417,7 +417,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;
@@ -437,16 +437,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 a0cc2a7a1e2e..15d9a025c923 100644
--- a/fs/btrfs/props.h
+++ b/fs/btrfs/props.h
@@ -9,7 +9,6 @@
#include <linux/types.h>
#include <linux/compiler_types.h>
-struct inode;
struct btrfs_inode;
struct btrfs_path;
struct btrfs_trans_handle;
@@ -26,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.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 13/22] btrfs: props: switch prop_handler::apply to struct btrfs_inode
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (11 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 12/22] btrfs: pass struct btrfs_inode to btrfs_inode_inherit_props() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 14/22] btrfs: props: switch prop_handler::extract " David Sterba
` (9 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to the apply() callback as it's an internal
interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/props.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index 16e84a2e24f4..10af7088e7ab 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -26,7 +26,7 @@ struct prop_handler {
const char *xattr_name;
int (*validate)(const struct btrfs_inode *inode, const char *value,
size_t len);
- int (*apply)(struct inode *inode, const char *value, size_t len);
+ int (*apply)(struct btrfs_inode *inode, const char *value, size_t len);
const char *(*extract)(const struct inode *inode);
bool (*ignore)(const struct btrfs_inode *inode);
int inheritable;
@@ -121,7 +121,7 @@ int btrfs_set_prop(struct btrfs_trans_handle *trans, struct btrfs_inode *inode,
if (ret)
return ret;
- ret = handler->apply(&inode->vfs_inode, NULL, 0);
+ ret = handler->apply(inode, NULL, 0);
ASSERT(ret == 0);
return ret;
@@ -131,7 +131,7 @@ int btrfs_set_prop(struct btrfs_trans_handle *trans, struct btrfs_inode *inode,
value_len, flags);
if (ret)
return ret;
- ret = handler->apply(&inode->vfs_inode, value, value_len);
+ ret = handler->apply(inode, value, value_len);
if (ret) {
btrfs_setxattr(trans, &inode->vfs_inode, handler->xattr_name, NULL,
0, flags);
@@ -263,7 +263,7 @@ static void inode_prop_iterator(void *ctx,
struct btrfs_root *root = BTRFS_I(inode)->root;
int ret;
- ret = handler->apply(inode, value, len);
+ ret = handler->apply(BTRFS_I(inode), value, len);
if (unlikely(ret))
btrfs_warn(root->fs_info,
"error applying prop %s to ino %llu (root %llu): %d",
@@ -301,26 +301,26 @@ static int prop_compression_validate(const struct btrfs_inode *inode,
return -EINVAL;
}
-static int prop_compression_apply(struct inode *inode, const char *value,
+static int prop_compression_apply(struct btrfs_inode *inode, const char *value,
size_t len)
{
- struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+ struct btrfs_fs_info *fs_info = inode->root->fs_info;
int type;
/* Reset to defaults */
if (len == 0) {
- BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
- BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS;
- BTRFS_I(inode)->prop_compress = BTRFS_COMPRESS_NONE;
+ inode->flags &= ~BTRFS_INODE_COMPRESS;
+ inode->flags &= ~BTRFS_INODE_NOCOMPRESS;
+ inode->prop_compress = BTRFS_COMPRESS_NONE;
return 0;
}
/* Set NOCOMPRESS flag */
if ((len == 2 && strncmp("no", value, 2) == 0) ||
(len == 4 && strncmp("none", value, 4) == 0)) {
- BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS;
- BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
- BTRFS_I(inode)->prop_compress = BTRFS_COMPRESS_NONE;
+ inode->flags |= BTRFS_INODE_NOCOMPRESS;
+ inode->flags &= ~BTRFS_INODE_COMPRESS;
+ inode->prop_compress = BTRFS_COMPRESS_NONE;
return 0;
}
@@ -337,9 +337,9 @@ static int prop_compression_apply(struct inode *inode, const char *value,
return -EINVAL;
}
- BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS;
- BTRFS_I(inode)->flags |= BTRFS_INODE_COMPRESS;
- BTRFS_I(inode)->prop_compress = type;
+ inode->flags &= ~BTRFS_INODE_NOCOMPRESS;
+ inode->flags |= BTRFS_INODE_COMPRESS;
+ inode->prop_compress = type;
return 0;
}
@@ -440,7 +440,7 @@ int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
ret = btrfs_setxattr(trans, &inode->vfs_inode, h->xattr_name, value,
strlen(value), 0);
if (!ret) {
- ret = h->apply(&inode->vfs_inode, value, strlen(value));
+ ret = h->apply(inode, value, strlen(value));
if (ret)
btrfs_setxattr(trans, &inode->vfs_inode, h->xattr_name,
NULL, 0, 0);
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 14/22] btrfs: props: switch prop_handler::extract to struct btrfs_inode
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (12 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 13/22] btrfs: props: switch prop_handler::apply to struct btrfs_inode David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 15/22] btrfs: pass struct btrfs_inode to clone_copy_inline_extent() David Sterba
` (8 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to the extract() callback as it's an internal
interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/props.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c
index 10af7088e7ab..adc956432d2f 100644
--- a/fs/btrfs/props.c
+++ b/fs/btrfs/props.c
@@ -27,7 +27,7 @@ struct prop_handler {
int (*validate)(const struct btrfs_inode *inode, const char *value,
size_t len);
int (*apply)(struct btrfs_inode *inode, const char *value, size_t len);
- const char *(*extract)(const struct inode *inode);
+ const char *(*extract)(const struct btrfs_inode *inode);
bool (*ignore)(const struct btrfs_inode *inode);
int inheritable;
};
@@ -360,13 +360,13 @@ static bool prop_compression_ignore(const struct btrfs_inode *inode)
return false;
}
-static const char *prop_compression_extract(const struct inode *inode)
+static const char *prop_compression_extract(const struct btrfs_inode *inode)
{
- switch (BTRFS_I(inode)->prop_compress) {
+ switch (inode->prop_compress) {
case BTRFS_COMPRESS_ZLIB:
case BTRFS_COMPRESS_LZO:
case BTRFS_COMPRESS_ZSTD:
- return btrfs_compress_type2str(BTRFS_I(inode)->prop_compress);
+ return btrfs_compress_type2str(inode->prop_compress);
default:
break;
}
@@ -409,7 +409,7 @@ int btrfs_inode_inherit_props(struct btrfs_trans_handle *trans,
if (h->ignore(inode))
continue;
- value = h->extract(&parent->vfs_inode);
+ value = h->extract(parent);
if (!value)
continue;
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 15/22] btrfs: pass struct btrfs_inode to clone_copy_inline_extent()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (13 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 14/22] btrfs: props: switch prop_handler::extract " David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 16/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock() David Sterba
` (7 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to clone_copy_inline_extent() as it's an
internal interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/reflink.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index f0824c948cb7..8640dbf1aefa 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -165,7 +165,7 @@ static int copy_inline_to_page(struct btrfs_inode *inode,
* the source inode to destination inode when possible. When not possible we
* copy the inline extent's data into the respective page of the inode.
*/
-static int clone_copy_inline_extent(struct inode *dst,
+static int clone_copy_inline_extent(struct btrfs_inode *inode,
struct btrfs_path *path,
struct btrfs_key *new_key,
const u64 drop_start,
@@ -175,8 +175,8 @@ static int clone_copy_inline_extent(struct inode *dst,
char *inline_data,
struct btrfs_trans_handle **trans_out)
{
- struct btrfs_fs_info *fs_info = inode_to_fs_info(dst);
- struct btrfs_root *root = BTRFS_I(dst)->root;
+ struct btrfs_root *root = inode->root;
+ struct btrfs_fs_info *fs_info = root->fs_info;
const u64 aligned_end = ALIGN(new_key->offset + datal,
fs_info->sectorsize);
struct btrfs_trans_handle *trans = NULL;
@@ -185,12 +185,12 @@ static int clone_copy_inline_extent(struct inode *dst,
struct btrfs_key key;
if (new_key->offset > 0) {
- ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset,
+ ret = copy_inline_to_page(inode, new_key->offset,
inline_data, size, datal, comp_type);
goto out;
}
- key.objectid = btrfs_ino(BTRFS_I(dst));
+ key.objectid = btrfs_ino(inode);
key.type = BTRFS_EXTENT_DATA_KEY;
key.offset = 0;
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
@@ -205,7 +205,7 @@ static int clone_copy_inline_extent(struct inode *dst,
goto copy_inline_extent;
}
btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
- if (key.objectid == btrfs_ino(BTRFS_I(dst)) &&
+ if (key.objectid == btrfs_ino(inode) &&
key.type == BTRFS_EXTENT_DATA_KEY) {
/*
* There's an implicit hole at file offset 0, copy the
@@ -214,7 +214,7 @@ static int clone_copy_inline_extent(struct inode *dst,
ASSERT(key.offset > 0);
goto copy_to_page;
}
- } else if (i_size_read(dst) <= datal) {
+ } else if (i_size_read(&inode->vfs_inode) <= datal) {
struct btrfs_file_extent_item *ei;
ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
@@ -236,7 +236,7 @@ static int clone_copy_inline_extent(struct inode *dst,
* We have no extent items, or we have an extent at offset 0 which may
* or may not be inlined. All these cases are dealt the same way.
*/
- if (i_size_read(dst) > datal) {
+ if (i_size_read(&inode->vfs_inode) > datal) {
/*
* At the destination offset 0 we have either a hole, a regular
* extent or an inline extent larger then the one we want to
@@ -270,7 +270,7 @@ static int clone_copy_inline_extent(struct inode *dst,
drop_args.start = drop_start;
drop_args.end = aligned_end;
drop_args.drop_cache = true;
- ret = btrfs_drop_extents(trans, root, BTRFS_I(dst), &drop_args);
+ ret = btrfs_drop_extents(trans, root, inode, &drop_args);
if (ret)
goto out;
ret = btrfs_insert_empty_item(trans, root, path, new_key, size);
@@ -281,9 +281,9 @@ static int clone_copy_inline_extent(struct inode *dst,
btrfs_item_ptr_offset(path->nodes[0],
path->slots[0]),
size);
- btrfs_update_inode_bytes(BTRFS_I(dst), datal, drop_args.bytes_found);
- btrfs_set_inode_full_sync(BTRFS_I(dst));
- ret = btrfs_inode_set_file_extent_range(BTRFS_I(dst), 0, aligned_end);
+ btrfs_update_inode_bytes(inode, datal, drop_args.bytes_found);
+ btrfs_set_inode_full_sync(inode);
+ ret = btrfs_inode_set_file_extent_range(inode, 0, aligned_end);
out:
if (!ret && !trans) {
/*
@@ -318,7 +318,7 @@ static int clone_copy_inline_extent(struct inode *dst,
*/
btrfs_release_path(path);
- ret = copy_inline_to_page(BTRFS_I(dst), new_key->offset,
+ ret = copy_inline_to_page(inode, new_key->offset,
inline_data, size, datal, comp_type);
goto out;
}
@@ -526,7 +526,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
goto out;
}
- ret = clone_copy_inline_extent(inode, path, &new_key,
+ ret = clone_copy_inline_extent(BTRFS_I(inode), path, &new_key,
drop_start, datal, size,
comp, buf, &trans);
if (ret)
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 16/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (14 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 15/22] btrfs: pass struct btrfs_inode to clone_copy_inline_extent() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 17/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock() David Sterba
` (6 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_double_mmap_lock() as it's an
internal interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/reflink.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 8640dbf1aefa..2e000e96d026 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -617,12 +617,12 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
return ret;
}
-static void btrfs_double_mmap_lock(struct inode *inode1, struct inode *inode2)
+static void btrfs_double_mmap_lock(struct btrfs_inode *inode1, struct btrfs_inode *inode2)
{
if (inode1 < inode2)
swap(inode1, inode2);
- down_write(&BTRFS_I(inode1)->i_mmap_lock);
- down_write_nested(&BTRFS_I(inode2)->i_mmap_lock, SINGLE_DEPTH_NESTING);
+ down_write(&inode1->i_mmap_lock);
+ down_write_nested(&inode2->i_mmap_lock, SINGLE_DEPTH_NESTING);
}
static void btrfs_double_mmap_unlock(struct inode *inode1, struct inode *inode2)
@@ -875,7 +875,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
btrfs_inode_lock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
} else {
lock_two_nondirectories(src_inode, dst_inode);
- btrfs_double_mmap_lock(src_inode, dst_inode);
+ btrfs_double_mmap_lock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
}
ret = btrfs_remap_file_range_prep(src_file, off, dst_file, destoff,
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 17/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (15 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 16/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 18/22] btrfs: pass struct btrfs_inode to btrfs_extent_same_range() David Sterba
` (5 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_double_mmap_unlock() as it's an
internal interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/reflink.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 2e000e96d026..f3aa3f4e9684 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -625,10 +625,10 @@ static void btrfs_double_mmap_lock(struct btrfs_inode *inode1, struct btrfs_inod
down_write_nested(&inode2->i_mmap_lock, SINGLE_DEPTH_NESTING);
}
-static void btrfs_double_mmap_unlock(struct inode *inode1, struct inode *inode2)
+static void btrfs_double_mmap_unlock(struct btrfs_inode *inode1, struct btrfs_inode *inode2)
{
- up_write(&BTRFS_I(inode1)->i_mmap_lock);
- up_write(&BTRFS_I(inode2)->i_mmap_lock);
+ up_write(&inode1->i_mmap_lock);
+ up_write(&inode2->i_mmap_lock);
}
static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,
@@ -892,7 +892,7 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
if (same_inode) {
btrfs_inode_unlock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
} else {
- btrfs_double_mmap_unlock(src_inode, dst_inode);
+ btrfs_double_mmap_unlock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
unlock_two_nondirectories(src_inode, dst_inode);
}
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 18/22] btrfs: pass struct btrfs_inode to btrfs_extent_same_range()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (16 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 17/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 19/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range() David Sterba
` (4 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Pass a struct btrfs_inode to btrfs_extent_same_range() as it's an
internal interface, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/reflink.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index f3aa3f4e9684..63d4a4d22801 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -631,12 +631,12 @@ static void btrfs_double_mmap_unlock(struct btrfs_inode *inode1, struct btrfs_in
up_write(&inode2->i_mmap_lock);
}
-static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,
- struct inode *dst, u64 dst_loff)
+static int btrfs_extent_same_range(struct btrfs_inode *src, u64 loff, u64 len,
+ struct btrfs_inode *dst, u64 dst_loff)
{
const u64 end = dst_loff + len - 1;
struct extent_state *cached_state = NULL;
- struct btrfs_fs_info *fs_info = BTRFS_I(src)->root->fs_info;
+ struct btrfs_fs_info *fs_info = src->root->fs_info;
const u64 bs = fs_info->sectorsize;
int ret;
@@ -646,9 +646,10 @@ static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,
* because we have already locked the inode's i_mmap_lock in exclusive
* mode.
*/
- lock_extent(&BTRFS_I(dst)->io_tree, dst_loff, end, &cached_state);
- ret = btrfs_clone(src, dst, loff, len, ALIGN(len, bs), dst_loff, 1);
- unlock_extent(&BTRFS_I(dst)->io_tree, dst_loff, end, &cached_state);
+ lock_extent(&dst->io_tree, dst_loff, end, &cached_state);
+ ret = btrfs_clone(&src->vfs_inode, &dst->vfs_inode, loff, len,
+ ALIGN(len, bs), dst_loff, 1);
+ unlock_extent(&dst->io_tree, dst_loff, end, &cached_state);
btrfs_btree_balance_dirty(fs_info);
@@ -678,8 +679,8 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
chunk_count = div_u64(olen, BTRFS_MAX_DEDUPE_LEN);
for (i = 0; i < chunk_count; i++) {
- ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN,
- dst, dst_loff);
+ ret = btrfs_extent_same_range(BTRFS_I(src), loff, BTRFS_MAX_DEDUPE_LEN,
+ BTRFS_I(dst), dst_loff);
if (ret)
goto out;
@@ -688,7 +689,8 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
}
if (tail_len > 0)
- ret = btrfs_extent_same_range(src, loff, tail_len, dst, dst_loff);
+ ret = btrfs_extent_same_range(BTRFS_I(src), loff, tail_len,
+ BTRFS_I(dst), dst_loff);
out:
spin_lock(&root_dst->root_item_lock);
root_dst->dedupe_in_progress--;
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 19/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (17 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 18/22] btrfs: pass struct btrfs_inode to btrfs_extent_same_range() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 20/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep() David Sterba
` (3 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Use a struct btrfs_inode to btrfs_remap_file_range() as it's an internal
helper, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/reflink.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index 63d4a4d22801..f63f92e176c8 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -865,8 +865,8 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
struct file *dst_file, loff_t destoff, loff_t len,
unsigned int remap_flags)
{
- struct inode *src_inode = file_inode(src_file);
- struct inode *dst_inode = file_inode(dst_file);
+ struct btrfs_inode *src_inode = BTRFS_I(file_inode(src_file));
+ struct btrfs_inode *dst_inode = BTRFS_I(file_inode(dst_file));
bool same_inode = dst_inode == src_inode;
int ret;
@@ -874,10 +874,10 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
return -EINVAL;
if (same_inode) {
- btrfs_inode_lock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
+ btrfs_inode_lock(src_inode, BTRFS_ILOCK_MMAP);
} else {
- lock_two_nondirectories(src_inode, dst_inode);
- btrfs_double_mmap_lock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
+ lock_two_nondirectories(&src_inode->vfs_inode, &dst_inode->vfs_inode);
+ btrfs_double_mmap_lock(src_inode, dst_inode);
}
ret = btrfs_remap_file_range_prep(src_file, off, dst_file, destoff,
@@ -886,16 +886,18 @@ loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
goto out_unlock;
if (remap_flags & REMAP_FILE_DEDUP)
- ret = btrfs_extent_same(src_inode, off, len, dst_inode, destoff);
+ ret = btrfs_extent_same(&src_inode->vfs_inode, off, len,
+ &dst_inode->vfs_inode, destoff);
else
ret = btrfs_clone_files(dst_file, src_file, off, len, destoff);
out_unlock:
if (same_inode) {
- btrfs_inode_unlock(BTRFS_I(src_inode), BTRFS_ILOCK_MMAP);
+ btrfs_inode_unlock(src_inode, BTRFS_ILOCK_MMAP);
} else {
- btrfs_double_mmap_unlock(BTRFS_I(src_inode), BTRFS_I(dst_inode));
- unlock_two_nondirectories(src_inode, dst_inode);
+ btrfs_double_mmap_unlock(src_inode, dst_inode);
+ unlock_two_nondirectories(&src_inode->vfs_inode,
+ &dst_inode->vfs_inode);
}
/*
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 20/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (18 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 19/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:01 ` [PATCH 21/22] btrfs: use struct btrfs_inode inside btrfs_get_parent() David Sterba
` (2 subsequent siblings)
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Use a struct btrfs_inode in btrfs_remap_file_range_prep() as it's an
internal helper, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/reflink.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index f63f92e176c8..15c296cb4dac 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -777,24 +777,24 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
struct file *file_out, loff_t pos_out,
loff_t *len, unsigned int remap_flags)
{
- struct inode *inode_in = file_inode(file_in);
- struct inode *inode_out = file_inode(file_out);
- u64 bs = BTRFS_I(inode_out)->root->fs_info->sectorsize;
+ struct btrfs_inode *inode_in = BTRFS_I(file_inode(file_in));
+ struct btrfs_inode *inode_out = BTRFS_I(file_inode(file_out));
+ u64 bs = inode_out->root->fs_info->sectorsize;
u64 wb_len;
int ret;
if (!(remap_flags & REMAP_FILE_DEDUP)) {
- struct btrfs_root *root_out = BTRFS_I(inode_out)->root;
+ struct btrfs_root *root_out = inode_out->root;
if (btrfs_root_readonly(root_out))
return -EROFS;
- ASSERT(inode_in->i_sb == inode_out->i_sb);
+ ASSERT(inode_in->vfs_inode.i_sb == inode_out->vfs_inode.i_sb);
}
/* Don't make the dst file partly checksummed */
- if ((BTRFS_I(inode_in)->flags & BTRFS_INODE_NODATASUM) !=
- (BTRFS_I(inode_out)->flags & BTRFS_INODE_NODATASUM)) {
+ if ((inode_in->flags & BTRFS_INODE_NODATASUM) !=
+ (inode_out->flags & BTRFS_INODE_NODATASUM)) {
return -EINVAL;
}
@@ -813,7 +813,7 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
* to complete so that new file extent items are in the fs tree.
*/
if (*len == 0 && !(remap_flags & REMAP_FILE_DEDUP))
- wb_len = ALIGN(inode_in->i_size, bs) - ALIGN_DOWN(pos_in, bs);
+ wb_len = ALIGN(inode_in->vfs_inode.i_size, bs) - ALIGN_DOWN(pos_in, bs);
else
wb_len = ALIGN(*len, bs);
@@ -834,16 +834,14 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
* Also we don't need to check ASYNC_EXTENT, as async extent will be
* CoWed anyway, not affecting nocow part.
*/
- ret = filemap_flush(inode_in->i_mapping);
+ ret = filemap_flush(inode_in->vfs_inode.i_mapping);
if (ret < 0)
return ret;
- ret = btrfs_wait_ordered_range(BTRFS_I(inode_in), ALIGN_DOWN(pos_in, bs),
- wb_len);
+ ret = btrfs_wait_ordered_range(inode_in, ALIGN_DOWN(pos_in, bs), wb_len);
if (ret < 0)
return ret;
- ret = btrfs_wait_ordered_range(BTRFS_I(inode_out), ALIGN_DOWN(pos_out, bs),
- wb_len);
+ ret = btrfs_wait_ordered_range(inode_out, ALIGN_DOWN(pos_out, bs), wb_len);
if (ret < 0)
return ret;
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 21/22] btrfs: use struct btrfs_inode inside btrfs_get_parent()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (19 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 20/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep() David Sterba
@ 2025-02-20 10:01 ` David Sterba
2025-02-20 10:02 ` [PATCH 22/22] btrfs: use struct btrfs_inode inside btrfs_get_name() David Sterba
2025-02-20 15:19 ` [PATCH 00/22] More inode type cleanups Johannes Thumshirn
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:01 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Use a struct btrfs_inode to btrfs_get_parent() as it's an internal
helper, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/export.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index c087424ac067..ab4d8625ad55 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -145,9 +145,9 @@ static struct dentry *btrfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
struct dentry *btrfs_get_parent(struct dentry *child)
{
- struct inode *dir = d_inode(child);
- struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
- struct btrfs_root *root = BTRFS_I(dir)->root;
+ struct btrfs_inode *dir = BTRFS_I(d_inode(child));
+ struct btrfs_root *root = dir->root;
+ struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_path *path;
struct extent_buffer *leaf;
struct btrfs_root_ref *ref;
@@ -159,13 +159,13 @@ struct dentry *btrfs_get_parent(struct dentry *child)
if (!path)
return ERR_PTR(-ENOMEM);
- if (btrfs_ino(BTRFS_I(dir)) == BTRFS_FIRST_FREE_OBJECTID) {
+ if (btrfs_ino(dir) == BTRFS_FIRST_FREE_OBJECTID) {
key.objectid = btrfs_root_id(root);
key.type = BTRFS_ROOT_BACKREF_KEY;
key.offset = (u64)-1;
root = fs_info->tree_root;
} else {
- key.objectid = btrfs_ino(BTRFS_I(dir));
+ key.objectid = btrfs_ino(dir);
key.type = BTRFS_INODE_REF_KEY;
key.offset = (u64)-1;
}
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 22/22] btrfs: use struct btrfs_inode inside btrfs_get_name()
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (20 preceding siblings ...)
2025-02-20 10:01 ` [PATCH 21/22] btrfs: use struct btrfs_inode inside btrfs_get_parent() David Sterba
@ 2025-02-20 10:02 ` David Sterba
2025-02-20 15:19 ` [PATCH 00/22] More inode type cleanups Johannes Thumshirn
22 siblings, 0 replies; 25+ messages in thread
From: David Sterba @ 2025-02-20 10:02 UTC (permalink / raw)
To: linux-btrfs; +Cc: David Sterba
Use a struct btrfs_inode in btrfs_get_name() as it's an internal
helper, allowing to remove some use of BTRFS_I.
Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/export.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index ab4d8625ad55..0c0b8db82df6 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -219,11 +219,11 @@ struct dentry *btrfs_get_parent(struct dentry *child)
static int btrfs_get_name(struct dentry *parent, char *name,
struct dentry *child)
{
- struct inode *inode = d_inode(child);
- struct inode *dir = d_inode(parent);
- struct btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+ struct btrfs_inode *inode = BTRFS_I(d_inode(child));
+ struct btrfs_inode *dir = BTRFS_I(d_inode(parent));
+ struct btrfs_root *root = dir->root;
+ struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_path *path;
- struct btrfs_root *root = BTRFS_I(dir)->root;
struct btrfs_inode_ref *iref;
struct btrfs_root_ref *rref;
struct extent_buffer *leaf;
@@ -233,24 +233,24 @@ static int btrfs_get_name(struct dentry *parent, char *name,
int ret;
u64 ino;
- if (!S_ISDIR(dir->i_mode))
+ if (!S_ISDIR(dir->vfs_inode.i_mode))
return -EINVAL;
- ino = btrfs_ino(BTRFS_I(inode));
+ ino = btrfs_ino(inode);
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
if (ino == BTRFS_FIRST_FREE_OBJECTID) {
- key.objectid = btrfs_root_id(BTRFS_I(inode)->root);
+ key.objectid = btrfs_root_id(inode->root);
key.type = BTRFS_ROOT_BACKREF_KEY;
key.offset = (u64)-1;
root = fs_info->tree_root;
} else {
key.objectid = ino;
key.type = BTRFS_INODE_REF_KEY;
- key.offset = btrfs_ino(BTRFS_I(dir));
+ key.offset = btrfs_ino(dir);
}
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
--
2.47.1
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH 10/22] btrfs: pass struct btrfs_inode to btrfs_fill_inode()
2025-02-20 10:01 ` [PATCH 10/22] btrfs: pass struct btrfs_inode to btrfs_fill_inode() David Sterba
@ 2025-02-20 11:26 ` Johannes Thumshirn
0 siblings, 0 replies; 25+ messages in thread
From: Johannes Thumshirn @ 2025-02-20 11:26 UTC (permalink / raw)
To: David Sterba, linux-btrfs@vger.kernel.org
This one gives checkpatch wanings:
ERROR:CODE_INDENT: code indent should use tabs where possible
#48: FILE: fs/btrfs/delayed-inode.c:1888:
+ inode->last_trans = btrfs_stack_inode_transid(inode_item);$
WARNING:LEADING_SPACE: please, no spaces at the start of a line
#48: FILE: fs/btrfs/delayed-inode.c:1888:
+ inode->last_trans = btrfs_stack_inode_transid(inode_item);$
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 00/22] More inode type cleanups
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
` (21 preceding siblings ...)
2025-02-20 10:02 ` [PATCH 22/22] btrfs: use struct btrfs_inode inside btrfs_get_name() David Sterba
@ 2025-02-20 15:19 ` Johannes Thumshirn
22 siblings, 0 replies; 25+ messages in thread
From: Johannes Thumshirn @ 2025-02-20 15:19 UTC (permalink / raw)
To: David Sterba, linux-btrfs@vger.kernel.org
On 20.02.25 11:04, David Sterba wrote:
> Continued work to convert struct inode to struct btrfs_inode in the
> internal interfaces. No functional changes.
>
Apart from some checkpatch warnings:
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2025-02-20 15:19 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-20 10:00 [PATCH 00/22] More inode type cleanups David Sterba
2025-02-20 10:00 ` [PATCH 01/22] btrfs: pass struct btrfs_inode to can_nocow_extent() David Sterba
2025-02-20 10:00 ` [PATCH 02/22] btrfs: pass struct btrfs_inode to extent_range_clear_dirty_for_io() David Sterba
2025-02-20 10:00 ` [PATCH 03/22] btrfs: pass struct btrfs_inode to btrfs_read_locked_inode() David Sterba
2025-02-20 10:00 ` [PATCH 04/22] btrfs: pass struct btrfs_inode to btrfs_iget_locked() David Sterba
2025-02-20 10:00 ` [PATCH 05/22] btrfs: pass struct btrfs_inode to new_simple_dir() David Sterba
2025-02-20 10:01 ` [PATCH 06/22] btrfs: pass struct btrfs_inode to btrfs_inode_type() David Sterba
2025-02-20 10:01 ` [PATCH 07/22] btrfs: pass struct btrfs_inode to btrfs_defrag_file() David Sterba
2025-02-20 10:01 ` [PATCH 08/22] btrfs: use struct btrfs_inode inside create_pending_snapshot() David Sterba
2025-02-20 10:01 ` [PATCH 09/22] btrfs: pass struct btrfs_inode to fill_stack_inode_item() David Sterba
2025-02-20 10:01 ` [PATCH 10/22] btrfs: pass struct btrfs_inode to btrfs_fill_inode() David Sterba
2025-02-20 11:26 ` Johannes Thumshirn
2025-02-20 10:01 ` [PATCH 11/22] btrfs: pass struct btrfs_inode to btrfs_load_inode_props() David Sterba
2025-02-20 10:01 ` [PATCH 12/22] btrfs: pass struct btrfs_inode to btrfs_inode_inherit_props() David Sterba
2025-02-20 10:01 ` [PATCH 13/22] btrfs: props: switch prop_handler::apply to struct btrfs_inode David Sterba
2025-02-20 10:01 ` [PATCH 14/22] btrfs: props: switch prop_handler::extract " David Sterba
2025-02-20 10:01 ` [PATCH 15/22] btrfs: pass struct btrfs_inode to clone_copy_inline_extent() David Sterba
2025-02-20 10:01 ` [PATCH 16/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_lock() David Sterba
2025-02-20 10:01 ` [PATCH 17/22] btrfs: pass struct btrfs_inode to btrfs_double_mmap_unlock() David Sterba
2025-02-20 10:01 ` [PATCH 18/22] btrfs: pass struct btrfs_inode to btrfs_extent_same_range() David Sterba
2025-02-20 10:01 ` [PATCH 19/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range() David Sterba
2025-02-20 10:01 ` [PATCH 20/22] btrfs: use struct btrfs_inode inside btrfs_remap_file_range_prep() David Sterba
2025-02-20 10:01 ` [PATCH 21/22] btrfs: use struct btrfs_inode inside btrfs_get_parent() David Sterba
2025-02-20 10:02 ` [PATCH 22/22] btrfs: use struct btrfs_inode inside btrfs_get_name() David Sterba
2025-02-20 15:19 ` [PATCH 00/22] More inode type cleanups Johannes Thumshirn
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.