ext4: replace opencoded ext4_end_io_end() in ext4_put_io_end()
authorBaokun Li <libaokun1@huawei.com>
Wed, 22 Jan 2025 11:05:25 +0000 (19:05 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 13 Mar 2025 14:08:08 +0000 (10:08 -0400)
This reduces duplicate code and ensures that a “potential data loss”
warning is available if the unwritten conversion fails.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20250122110533.4116662-2-libaokun@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/page-io.c

index 69b8a7221a2b19cf14a0a701cb06488f5bdbd478..f53b018ea259b2534d9963ee3c9b602df442c96e 100644 (file)
@@ -299,18 +299,13 @@ void ext4_put_io_end_defer(ext4_io_end_t *io_end)
 
 int ext4_put_io_end(ext4_io_end_t *io_end)
 {
-       int err = 0;
-
        if (refcount_dec_and_test(&io_end->count)) {
-               if (io_end->flag & EXT4_IO_END_UNWRITTEN) {
-                       err = ext4_convert_unwritten_io_end_vec(io_end->handle,
-                                                               io_end);
-                       io_end->handle = NULL;
-                       ext4_clear_io_unwritten_flag(io_end);
-               }
+               if (io_end->flag & EXT4_IO_END_UNWRITTEN)
+                       return ext4_end_io_end(io_end);
+
                ext4_release_io_end(io_end);
        }
-       return err;
+       return 0;
 }
 
 ext4_io_end_t *ext4_get_io_end(ext4_io_end_t *io_end)