]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: simplify code flow in btrfs_submit_dio_bio
authorChristoph Hellwig <hch@lst.de>
Thu, 26 May 2022 07:36:34 +0000 (09:36 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 25 Jul 2022 15:45:33 +0000 (17:45 +0200)
There is no exit block and cleanup and the function is reasonably short
so we can use inline return and not the goto. This makes the function
more straight forward.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index 1ac43ae3869dd78dfa3bc5614bdc3c3ccbed713a..3a2a2d4906db8a02fa7ea20d558580e8cefbd68f 100644 (file)
@@ -7983,39 +7983,33 @@ static inline blk_status_t btrfs_submit_dio_bio(struct bio *bio,
        bool write = btrfs_op(bio) == BTRFS_MAP_WRITE;
        blk_status_t ret;
 
-       /* Check btrfs_submit_bio_hook() for rules about async submit. */
-       if (async_submit)
-               async_submit = !atomic_read(&BTRFS_I(inode)->sync_writers);
-
        if (!write) {
                ret = btrfs_bio_wq_end_io(fs_info, bio, BTRFS_WQ_ENDIO_DATA);
                if (ret)
-                       goto err;
+                       return ret;
        }
 
        if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
                goto map;
 
-       if (write && async_submit) {
-               ret = btrfs_wq_submit_bio(inode, bio, 0, file_offset,
-                                         btrfs_submit_bio_start_direct_io);
-               goto err;
-       } else if (write) {
+       if (write) {
+               /* Check btrfs_submit_data_bio() for async submit rules */
+               if (async_submit && !atomic_read(&BTRFS_I(inode)->sync_writers))
+                       return btrfs_wq_submit_bio(inode, bio, 0, file_offset,
+                                       btrfs_submit_bio_start_direct_io);
                /*
                 * If we aren't doing async submit, calculate the csum of the
                 * bio now.
                 */
                ret = btrfs_csum_one_bio(BTRFS_I(inode), bio, file_offset, false);
                if (ret)
-                       goto err;
+                       return ret;
        } else {
                btrfs_bio(bio)->csum = btrfs_csum_ptr(fs_info, dip->csums,
                                                      file_offset - dip->file_offset);
        }
 map:
-       ret = btrfs_map_bio(fs_info, bio, 0);
-err:
-       return ret;
+       return btrfs_map_bio(fs_info, bio, 0);
 }
 
 static void btrfs_submit_direct(const struct iomap_iter *iter,