]> www.infradead.org Git - users/hch/configfs.git/commitdiff
btrfs: use a btrfs_inode in the log context (struct btrfs_log_ctx)
authorFilipe Manana <fdmanana@suse.com>
Sat, 18 May 2024 13:09:41 +0000 (14:09 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 11 Jul 2024 13:33:18 +0000 (15:33 +0200)
Instead of using a inode pointer, use a btrfs_inode pointer in the log
context structure, as this is generally what we need and allows for some
internal APIs to take a btrfs_inode instead, making them more consistent
with most of the code base. This will later allow to help to remove a lot
of BTRFS_I() calls in btrfs_sync_file().

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c
fs/btrfs/tree-log.c
fs/btrfs/tree-log.h

index d90138683a0a3031ed9e04060d6d1fc0c84a03ce..455a1f3866d0b23550579d55d5d5b517384ef43c 100644 (file)
@@ -1758,7 +1758,7 @@ static int start_ordered_ops(struct inode *inode, loff_t start, loff_t end)
 
 static inline bool skip_inode_logging(const struct btrfs_log_ctx *ctx)
 {
-       struct btrfs_inode *inode = BTRFS_I(ctx->inode);
+       struct btrfs_inode *inode = ctx->inode;
        struct btrfs_fs_info *fs_info = inode->root->fs_info;
 
        if (btrfs_inode_in_log(inode, btrfs_get_fs_generation(fs_info)) &&
@@ -1805,7 +1805,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 
        trace_btrfs_sync_file(file, datasync);
 
-       btrfs_init_log_ctx(&ctx, inode);
+       btrfs_init_log_ctx(&ctx, BTRFS_I(inode));
 
        /*
         * Always set the range to a full range, otherwise we can get into
index a2384455413e4d41abea5c074d45e59fc764b0c3..1dc98cb573737a4c97c271c0bd807e38b3399dd8 100644 (file)
@@ -2840,7 +2840,7 @@ static void wait_for_writer(struct btrfs_root *root)
        finish_wait(&root->log_writer_wait, &wait);
 }
 
-void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, struct inode *inode)
+void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, struct btrfs_inode *inode)
 {
        ctx->log_ret = 0;
        ctx->log_transid = 0;
@@ -2859,7 +2859,7 @@ void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, struct inode *inode)
 
 void btrfs_init_log_ctx_scratch_eb(struct btrfs_log_ctx *ctx)
 {
-       struct btrfs_inode *inode = BTRFS_I(ctx->inode);
+       struct btrfs_inode *inode = ctx->inode;
 
        if (!test_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &inode->runtime_flags) &&
            !test_bit(BTRFS_INODE_COPY_EVERYTHING, &inode->runtime_flags))
@@ -2877,7 +2877,7 @@ void btrfs_release_log_ctx_extents(struct btrfs_log_ctx *ctx)
        struct btrfs_ordered_extent *ordered;
        struct btrfs_ordered_extent *tmp;
 
-       ASSERT(inode_is_locked(ctx->inode));
+       ASSERT(inode_is_locked(&ctx->inode->vfs_inode));
 
        list_for_each_entry_safe(ordered, tmp, &ctx->ordered_extents, log_list) {
                list_del_init(&ordered->log_list);
@@ -5930,7 +5930,7 @@ again:
                        if (ret < 0) {
                                return ret;
                        } else if (ret > 0 &&
-                                  other_ino != btrfs_ino(BTRFS_I(ctx->inode))) {
+                                  other_ino != btrfs_ino(ctx->inode)) {
                                if (ins_nr > 0) {
                                        ins_nr++;
                                } else {
@@ -7588,7 +7588,7 @@ void btrfs_log_new_name(struct btrfs_trans_handle *trans,
                        goto out;
        }
 
-       btrfs_init_log_ctx(&ctx, &inode->vfs_inode);
+       btrfs_init_log_ctx(&ctx, inode);
        ctx.logging_new_name = true;
        btrfs_init_log_ctx_scratch_eb(&ctx);
        /*
index 22e9cbc8157742bff8175748d52edf74b47fdfd1..fa0a689259b12f8d29c2f3ebe070c8acf5ad0b9e 100644 (file)
@@ -37,7 +37,7 @@ struct btrfs_log_ctx {
        bool logging_new_delayed_dentries;
        /* Indicate if the inode being logged was logged before. */
        bool logged_before;
-       struct inode *inode;
+       struct btrfs_inode *inode;
        struct list_head list;
        /* Only used for fast fsyncs. */
        struct list_head ordered_extents;
@@ -55,7 +55,7 @@ struct btrfs_log_ctx {
        struct extent_buffer *scratch_eb;
 };
 
-void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, struct inode *inode);
+void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, struct btrfs_inode *inode);
 void btrfs_init_log_ctx_scratch_eb(struct btrfs_log_ctx *ctx);
 void btrfs_release_log_ctx_extents(struct btrfs_log_ctx *ctx);