Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp245211imu; Fri, 16 Nov 2018 01:47:15 -0800 (PST) X-Google-Smtp-Source: AJdET5ejCpNV+yP8KB1JqI5IhbTKnLu0nMpfuLDRdVstx/opU5j57vIFumojytmoIwUpzUTb7+lU X-Received: by 2002:a62:120b:: with SMTP id a11-v6mr10241212pfj.165.1542361635519; Fri, 16 Nov 2018 01:47:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542361635; cv=none; d=google.com; s=arc-20160816; b=sqEv8qQAxsHRcy9lpTMXuOcg5ioV8ksvp+rdHRdg8kEHcq8qg1sTjv731apy9J55HA YoIkvfHku7dnxhFSP+rRpE9HkIQP7m3yiV99F5QEcJM8wcqCiu5IyjuxEgo7oSP4/ZUI NlzAmt6feoXAH0V7D9J1QJNTW4e4EqawEGyQAcmZfmby5JTnw7jlPDhmNCNN/mSbA8+E M21NtU/hxe6glhHTR5edEnPOr5dnID2ImbGt6/Rq89TrX07PjoqGUwsganX/BxtTOpay VegnZiufxe9Il6zvDW4WbZi29Yo2Rgntl6X93mdSsQccsYQf9zXHCcVdFJ4YYHelKrcv N5KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject; bh=46eTkeVMjJ9Lsr85ffM3S/gkIS+FxmzvC1G5adEfw0Y=; b=iCW5rA/Wilccr1rweTPwOeoc/Kr9QlkKnyejTZSPEPY+wONV6YZ6B/7HmUw+WU3h7w xELrpI+/sd1R4I0aYkU/lQ/CLvM4NHpRJqR6xSLJQ44g8EnHwj+COjmkfM5P4QgWL/wi VtWiCsxaNEjBRYFmXDm539iJwD8sqiJmwpZyVBFmD9XDxbp25QGFRGDBj8EB7MrRsJyR wlaILsb0VnJv+NmT1cEyMyGDG2yld6ABNzbUqglhITw1gPRBfy62gAs5t64usi/R6PZq HBVpdJWEhwdtOgP/4GX6RnE74V/lzT1Pf2EkyyQVO+CeCGX/L2Q2BMLPyrrlYe+nsmOB orZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 205si16601214pfa.199.2018.11.16.01.47.00; Fri, 16 Nov 2018 01:47:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389375AbeKPT5z (ORCPT + 99 others); Fri, 16 Nov 2018 14:57:55 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:14679 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727398AbeKPT5z (ORCPT ); Fri, 16 Nov 2018 14:57:55 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D4B5F48A5FC82; Fri, 16 Nov 2018 17:46:18 +0800 (CST) Received: from [127.0.0.1] (10.134.22.195) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.408.0; Fri, 16 Nov 2018 17:46:20 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: add bio cache for IPU From: Chao Yu To: Jaegeuk Kim CC: , References: <20181023083817.3466-1-yuchao0@huawei.com> <20181115075226.GA83610@jaegeuk-macbookpro.roam.corp.google.com> <944355f6-49d8-f579-aad6-53c54258e90b@huawei.com> Message-ID: <0fcfcec5-7b09-603e-f8b7-1c6346dc17b3@huawei.com> Date: Fri, 16 Nov 2018 17:46:19 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <944355f6-49d8-f579-aad6-53c54258e90b@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jaegeuk, On 2018/11/15 16:32, Chao Yu wrote: > Hi Jaeguek, > > On 2018/11/15 15:52, Jaegeuk Kim wrote: >> Hi Chao, >> >> I suspect this brings a system stuck by missing bio being flushed. Please check >> the changes. > > Oh, let me check this patch. I found one corner case below, but not very sure it can avoid system stuck. if (unlikely(f2fs_cp_error(sbi))) { if (bio && *bio) { __submit_bio(sbi, *bio, DATA); *bio = NULL; } f2fs_submit_merged_write(sbi, DATA); submitted = NULL; } Anyway, let me send v2, could you please test this? Thanks, > > Thanks, > >> >> Thanks, >> >> On 10/23, Chao Yu wrote: >>> SQLite in Wal mode may trigger sequential IPU write in db-wal file, after >>> commit d1b3e72d5490 ("f2fs: submit bio of in-place-update pages"), we >>> lost the chance of merging page in inner managed bio cache, result in >>> submitting more small-sized IO. >>> >>> So let's add temporary bio in writepages() to cache mergeable write IO as >>> much as possible. >>> >>> Test case: >>> 1. xfs_io -f /mnt/f2fs/file -c "pwrite 0 65536" -c "fsync" >>> 2. xfs_io -f /mnt/f2fs/file -c "pwrite 0 65536" -c "fsync" >>> >>> Before: >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65544, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65552, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65560, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65568, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65576, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65584, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65592, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65600, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65608, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65616, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65624, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65632, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65640, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65648, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65656, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65664, size = 4096 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), NODE, sector = 57352, size = 4096 >>> >>> After: >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), DATA, sector = 65544, size = 65536 >>> f2fs_submit_write_bio: dev = (251,0)/(251,0), rw = WRITE(S), NODE, sector = 57368, size = 4096 >>> >>> Signed-off-by: Chao Yu >>> --- >>> fs/f2fs/data.c | 57 +++++++++++++++++++++++++++++++++++++++++++++-- >>> fs/f2fs/f2fs.h | 3 +++ >>> fs/f2fs/segment.c | 5 ++++- >>> 3 files changed, 62 insertions(+), 3 deletions(-) >>> >>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>> index 01b7f59523dc..0c8f18dc140d 100644 >>> --- a/fs/f2fs/data.c >>> +++ b/fs/f2fs/data.c >>> @@ -491,6 +491,49 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) >>> return 0; >>> } >>> >>> +int f2fs_merge_page_bio(struct f2fs_io_info *fio) >>> +{ >>> + struct bio *bio = *fio->bio; >>> + struct page *page = fio->encrypted_page ? >>> + fio->encrypted_page : fio->page; >>> + >>> + if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr, >>> + __is_meta_io(fio) ? META_GENERIC : DATA_GENERIC)) >>> + return -EFAULT; >>> + >>> + trace_f2fs_submit_page_bio(page, fio); >>> + f2fs_trace_ios(fio, 0); >>> + >>> + if (bio && (*fio->last_block + 1 != fio->new_blkaddr || >>> + !__same_bdev(fio->sbi, fio->new_blkaddr, bio))) { >>> + __submit_bio(fio->sbi, bio, fio->type); >>> + bio = NULL; >>> + } >>> +alloc_new: >>> + if (!bio) { >>> + bio = __bio_alloc(fio->sbi, fio->new_blkaddr, fio->io_wbc, >>> + BIO_MAX_PAGES, false, fio->type, fio->temp); >>> + *fio->last_block = fio->new_blkaddr; >>> + bio_set_op_attrs(bio, fio->op, fio->op_flags); >>> + } >>> + >>> + if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { >>> + __submit_bio(fio->sbi, bio, fio->type); >>> + bio = NULL; >>> + goto alloc_new; >>> + } >>> + >>> + if (fio->io_wbc) >>> + wbc_account_io(fio->io_wbc, page, PAGE_SIZE); >>> + >>> + *fio->last_block = fio->new_blkaddr; >>> + >>> + inc_page_count(fio->sbi, WB_DATA_TYPE(fio->page)); >>> + >>> + *fio->bio = bio; >>> + return 0; >>> +} >>> + >>> void f2fs_submit_page_write(struct f2fs_io_info *fio) >>> { >>> struct f2fs_sb_info *sbi = fio->sbi; >>> @@ -1899,6 +1942,8 @@ int f2fs_do_write_data_page(struct f2fs_io_info *fio) >>> } >>> >>> static int __write_data_page(struct page *page, bool *submitted, >>> + struct bio **bio, >>> + sector_t *last_block, >>> struct writeback_control *wbc, >>> enum iostat_type io_type) >>> { >>> @@ -1924,6 +1969,8 @@ static int __write_data_page(struct page *page, bool *submitted, >>> .need_lock = LOCK_RETRY, >>> .io_type = io_type, >>> .io_wbc = wbc, >>> + .bio = bio, >>> + .last_block = last_block, >>> }; >>> >>> trace_f2fs_writepage(page, DATA); >>> @@ -2051,7 +2098,7 @@ static int __write_data_page(struct page *page, bool *submitted, >>> static int f2fs_write_data_page(struct page *page, >>> struct writeback_control *wbc) >>> { >>> - return __write_data_page(page, NULL, wbc, FS_DATA_IO); >>> + return __write_data_page(page, NULL, NULL, NULL, wbc, FS_DATA_IO); >>> } >>> >>> /* >>> @@ -2067,6 +2114,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, >>> int done = 0; >>> struct pagevec pvec; >>> struct f2fs_sb_info *sbi = F2FS_M_SB(mapping); >>> + struct bio *bio = NULL; >>> + sector_t last_block; >>> int nr_pages; >>> pgoff_t uninitialized_var(writeback_index); >>> pgoff_t index; >>> @@ -2154,7 +2203,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping, >>> if (!clear_page_dirty_for_io(page)) >>> goto continue_unlock; >>> >>> - ret = __write_data_page(page, &submitted, wbc, io_type); >>> + ret = __write_data_page(page, &submitted, &bio, >>> + &last_block, wbc, io_type); >>> if (unlikely(ret)) { >>> /* >>> * keep nr_to_write, since vfs uses this to >>> @@ -2201,6 +2251,9 @@ static int f2fs_write_cache_pages(struct address_space *mapping, >>> if (nwritten) >>> f2fs_submit_merged_write_cond(F2FS_M_SB(mapping), mapping->host, >>> NULL, 0, DATA); >>> + /* submit cached bio of IPU write */ >>> + if (bio) >>> + __submit_bio(sbi, bio, DATA); >>> >>> return ret; >>> } >>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h >>> index 8932276015f9..6af2a105529d 100644 >>> --- a/fs/f2fs/f2fs.h >>> +++ b/fs/f2fs/f2fs.h >>> @@ -1042,6 +1042,8 @@ struct f2fs_io_info { >>> bool retry; /* need to reallocate block address */ >>> enum iostat_type io_type; /* io type */ >>> struct writeback_control *io_wbc; /* writeback control */ >>> + struct bio **bio; /* bio for ipu */ >>> + sector_t *last_block; /* last block number in bio */ >>> unsigned char version; /* version of the node */ >>> }; >>> >>> @@ -3085,6 +3087,7 @@ void f2fs_submit_merged_write_cond(struct f2fs_sb_info *sbi, >>> nid_t ino, enum page_type type); >>> void f2fs_flush_merged_writes(struct f2fs_sb_info *sbi); >>> int f2fs_submit_page_bio(struct f2fs_io_info *fio); >>> +int f2fs_merge_page_bio(struct f2fs_io_info *fio); >>> void f2fs_submit_page_write(struct f2fs_io_info *fio); >>> struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi, >>> block_t blk_addr, struct bio *bio); >>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c >>> index 3aa2f00262b3..b51b182dd7f4 100644 >>> --- a/fs/f2fs/segment.c >>> +++ b/fs/f2fs/segment.c >>> @@ -3194,7 +3194,10 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio) >>> >>> stat_inc_inplace_blocks(fio->sbi); >>> >>> - err = f2fs_submit_page_bio(fio); >>> + if (fio->bio) >>> + err = f2fs_merge_page_bio(fio); >>> + else >>> + err = f2fs_submit_page_bio(fio); >>> if (!err) >>> update_device_state(fio); >>> >>> -- >>> 2.18.0.rc1 >> >> . >> > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel > > . >