btrfs: make btrfs_readdir_delayed_dir_index() return a bool instead
authorFilipe Manana <fdmanana@suse.com>
Sat, 31 May 2025 14:56:46 +0000 (15:56 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:53:30 +0000 (23:53 +0200)
There's no need to return errors, all we do is return 1 or 0 depending
on whether we should or should not stop iterating over delayed dir
indexes. So change the function to return bool instead of an int.

Reviewed-by: Boris Burkov <boris@bur.io>
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/delayed-inode.c
fs/btrfs/delayed-inode.h
fs/btrfs/inode.c

index 050723ade9420d39405af52e28b353b0fc96fb5e..0f8d8e275143b2344cb785b15f1cc691e376baa2 100644 (file)
@@ -1753,15 +1753,14 @@ bool btrfs_should_delete_dir_index(const struct list_head *del_list, u64 index)
 /*
  * Read dir info stored in the delayed tree.
  */
-int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
-                                   const struct list_head *ins_list)
+bool btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
+                                    const struct list_head *ins_list)
 {
        struct btrfs_dir_item *di;
        struct btrfs_delayed_item *curr, *next;
        struct btrfs_key location;
        char *name;
        int name_len;
-       int over = 0;
        unsigned char d_type;
 
        /*
@@ -1770,6 +1769,8 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
         * directory, nobody can delete any directory indexes now.
         */
        list_for_each_entry_safe(curr, next, ins_list, readdir_list) {
+               bool over;
+
                list_del(&curr->readdir_list);
 
                if (curr->index < ctx->pos) {
@@ -1787,17 +1788,16 @@ int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
                d_type = fs_ftype_to_dtype(btrfs_dir_flags_to_ftype(di->type));
                btrfs_disk_key_to_cpu(&location, &di->location);
 
-               over = !dir_emit(ctx, name, name_len,
-                              location.objectid, d_type);
+               over = !dir_emit(ctx, name, name_len, location.objectid, d_type);
 
                if (refcount_dec_and_test(&curr->refs))
                        kfree(curr);
 
                if (over)
-                       return 1;
+                       return true;
                ctx->pos++;
        }
-       return 0;
+       return false;
 }
 
 static void fill_stack_inode_item(struct btrfs_trans_handle *trans,
index 73d13fac89171759d78315ae31dff5fa303cd43d..e6e763ad2d421ffff8abdf01074deeefcf4bfc9b 100644 (file)
@@ -151,8 +151,8 @@ void btrfs_readdir_put_delayed_items(struct btrfs_inode *inode,
                                     struct list_head *ins_list,
                                     struct list_head *del_list);
 bool btrfs_should_delete_dir_index(const struct list_head *del_list, u64 index);
-int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
-                                   const struct list_head *ins_list);
+bool btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
+                                    const struct list_head *ins_list);
 
 /* Used during directory logging. */
 void btrfs_log_get_delayed_items(struct btrfs_inode *inode,
index 474cb40a42f7f51edc05d47373f634a33b75d11d..cbc95bceb7ff177c9e864f37643330c9d80dd418 100644 (file)
@@ -6170,8 +6170,7 @@ again:
        if (ret)
                goto nopos;
 
-       ret = btrfs_readdir_delayed_dir_index(ctx, &ins_list);
-       if (ret)
+       if (btrfs_readdir_delayed_dir_index(ctx, &ins_list))
                goto nopos;
 
        /*