]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: stop checking for greater then zero return values in btrfs_sync_file()
authorFilipe Manana <fdmanana@suse.com>
Mon, 27 Apr 2026 10:42:35 +0000 (11:42 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 8 Jun 2026 13:53:34 +0000 (15:53 +0200)
The value of 'ret' can never be greater than zero when we reach the end of
btrfs_sync_file() but we have this ternary operator converting any such
value into -EIO. This logic exists since the first fsync implementation,
added in 2007 by commit 8fd17795b226 ("Btrfs: early fsync support"), when
all that fsync did was simply to commit a transaction, but even a call to
btrfs_commit_transaction() could never return a value greater than zero.

So stop checking for a greater than zero value and assert that 'ret' is
never greater than zero, to catch any eventual regression during future
development.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/file.c

index 43792d5a792c166c6c449b1cb1ac5810730d3394..42914c9785e54c3cc5f4249eddcf2f432f495cff 100644 (file)
@@ -1810,10 +1810,11 @@ out:
        free_extent_buffer(ctx.scratch_eb);
        ASSERT(list_empty(&ctx.list));
        ASSERT(list_empty(&ctx.conflict_inodes));
+       ASSERT(ret <= 0, "ret=%d", ret);
        err = file_check_and_advance_wb_err(file);
        if (!ret)
                ret = err;
-       return ret > 0 ? -EIO : ret;
+       return ret;
 
 out_release_extents:
        btrfs_release_log_ctx_extents(&ctx);