f2fs: compress: don't handle non-compressed data in workqueue
authorChao Yu <yuchao0@huawei.com>
Tue, 21 Apr 2020 11:36:21 +0000 (19:36 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 12 May 2020 03:37:13 +0000 (20:37 -0700)
If bio has no compressed data, we don't need to handle end_io work in
workqueue, instead, it should just let interrupter handle it directly
to speed up IO response.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index ff8a92df8d9956fee6798f41a27c338049deee9b..8607c02e8f9606b4a8852484dcce84065d653163 100644 (file)
@@ -114,7 +114,8 @@ static enum count_type __read_io_type(struct page *page)
 /* postprocessing steps for read bios */
 enum bio_post_read_step {
        STEP_DECRYPT,
-       STEP_DECOMPRESS,
+       STEP_DECOMPRESS_NOWQ,           /* handle normal cluster data inplace */
+       STEP_DECOMPRESS,                /* handle compressed cluster data in workqueue */
        STEP_VERITY,
 };
 
@@ -990,7 +991,7 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
        if (f2fs_encrypted_file(inode))
                post_read_steps |= 1 << STEP_DECRYPT;
        if (f2fs_compressed_file(inode))
-               post_read_steps |= 1 << STEP_DECOMPRESS;
+               post_read_steps |= 1 << STEP_DECOMPRESS_NOWQ;
        if (f2fs_need_verity(inode, first_idx))
                post_read_steps |= 1 << STEP_VERITY;
 
@@ -2189,6 +2190,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
        for (i = 0; i < dic->nr_cpages; i++) {
                struct page *page = dic->cpages[i];
                block_t blkaddr;
+               struct bio_post_read_ctx *ctx;
 
                blkaddr = data_blkaddr(dn.inode, dn.node_page,
                                                dn.ofs_in_node + i + 1);
@@ -2225,6 +2227,11 @@ submit_and_realloc:
                if (bio_add_page(bio, page, blocksize, 0) < blocksize)
                        goto submit_and_realloc;
 
+               /* tag STEP_DECOMPRESS to handle IO in wq */
+               ctx = bio->bi_private;
+               if (!(ctx->enabled_steps & (1 << STEP_DECOMPRESS)))
+                       ctx->enabled_steps |= 1 << STEP_DECOMPRESS;
+
                inc_page_count(sbi, F2FS_RD_DATA);
                f2fs_update_iostat(sbi, FS_DATA_READ_IO, F2FS_BLKSIZE);
                ClearPageError(page);