Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1263739ybl; Fri, 23 Aug 2019 16:29:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDdbcq6RbyIOInJkc0guG8k15Ja0GLK1PaBRxIz+v+3Q4mPEO6ZkrWj54UtsyTxW79RQOC X-Received: by 2002:a62:86cf:: with SMTP id x198mr8075775pfd.195.1566602944370; Fri, 23 Aug 2019 16:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566602944; cv=none; d=google.com; s=arc-20160816; b=GSV5oihk2tx4gwyKIlAhgjigB1bd04mkI65iNrRv+FZXUqv10Tcd9JGRpqZ3xQgs49 GCsrD7TZ9FgQT0MU5Zpei72attEs9+WX3Fjfpd8p+Uk3MAcQdNcdPwQjYv8eNa0qEFMQ NFyMOPYJcT/gVU0y5xmujXFeiSccBrt9Co3CwZo4DxUVA+Rhv49ridMcTvU86R+FtIxo 3yquaIje2cOipP7FLqI89fTjVGV3KAwf1cNc+scOMhSAX/wYlFdo7mSULfxqAaTk2m91 qjJDQ4kj6w6caoBt8+AoJVzDXmnetTzvVajWYZGpZdy+rVvH5hhDtDTgVWWykEX3YDVs n+tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+WsmhZfCA2XpWjQThfiUvWh9yNCwurD2aJSdDdDlMpc=; b=LXvVikMN+DxNyMNEH2J4ie/noIH2+++mQNB1raGgW3guH91QNlSIRUY2YTWc1MExId pWg1rNOZK29KG8lIm3JFWAYv7AaGXOVxdifEiNDdU2PXXin50q4wQ1x3/tY3Z5KQresM eKxPPLC3q1IEjXl5FacyDAe9nYNRBrKNrLuMp9zI6Gzoagg66YRSRFqZoj4rN8n9SCIg 16xkkcMSja2NaaTgKqbnW04J8ZiXI52u3i+OihM/AwyF82kwhcNwq18GVbqqRx/NIolN hyw/LNAwgjNejwxcQWWmbhAgqdmLewPNQej+A4sr18nPXxl9ZjPxncF7IvNYbYJnR8oH MbrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D55i0IXM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w190si3128296pgd.229.2019.08.23.16.28.49; Fri, 23 Aug 2019 16:29:04 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=D55i0IXM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388320AbfHWO5k (ORCPT + 99 others); Fri, 23 Aug 2019 10:57:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:37930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbfHWO5j (ORCPT ); Fri, 23 Aug 2019 10:57:39 -0400 Received: from localhost (unknown [104.132.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0C57922CEC; Fri, 23 Aug 2019 14:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566572259; bh=lUZVzj62LY1E4yZhmdisUFDLbkNHl2Ewg/KwzQn5eck=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D55i0IXM4OYqcIZA6lxzHWwEBKjkxSBCkpBSixu0Osu7AcKt9NYWzKCUlRTCVroJ6 VyZnUwoSgGFsrpK0FSnfmUuU2UuZP/JSUDEHc7Wh0LhnUaIDLpTFYvzmPWubmp3p9A p6X8oji0CLLMdSblC0oVI9Im0hxsT90NNA/xfUO8= Date: Fri, 23 Aug 2019 07:57:38 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH 1/2] f2fs: introduce {page,io}_is_mergeable() for readability Message-ID: <20190823145738.GA35310@jaegeuk-macbookpro.roam.corp.google.com> References: <20190712085542.4068-1-yuchao0@huawei.com> <28424a84-67aa-c8e9-99c3-475be89206ac@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <28424a84-67aa-c8e9-99c3-475be89206ac@huawei.com> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/23, Chao Yu wrote: > On 2019/7/12 16:55, Chao Yu wrote: > > Wrap merge condition into function for readability, no logic change. > > > > Signed-off-by: Chao Yu > > --- > > v2: remove bio validation check in page_is_mergeable(). > > fs/f2fs/data.c | 40 +++++++++++++++++++++++++++++++++------- > > 1 file changed, 33 insertions(+), 7 deletions(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > index 6a8db4abdf5f..f1e401f9fc13 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -482,6 +482,33 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) > > return 0; > > } > > > > +static bool page_is_mergeable(struct f2fs_sb_info *sbi, struct bio *bio, > > + block_t last_blkaddr, block_t cur_blkaddr) > > +{ > > + if (last_blkaddr != cur_blkaddr) > > if (last_blkaddr + 1 != cur_blkaddr) > > Merge condition is wrong here. > > > + return false; > > + return __same_bdev(sbi, cur_blkaddr, bio); > > +} > > + > > +static bool io_type_is_mergeable(struct f2fs_bio_info *io, > > + struct f2fs_io_info *fio) > > +{ > > + if (io->fio.op != fio->op) > > + return false; > > + return io->fio.op_flags == fio->op_flags; > > +} > > + > > +static bool io_is_mergeable(struct f2fs_sb_info *sbi, struct bio *bio, > > + struct f2fs_bio_info *io, > > + struct f2fs_io_info *fio, > > + block_t last_blkaddr, > > + block_t cur_blkaddr) > > +{ > > + if (!page_is_mergeable(sbi, bio, last_blkaddr, cur_blkaddr)) > > + return false; > > + return io_type_is_mergeable(io, fio); > > +} > > + > > int f2fs_merge_page_bio(struct f2fs_io_info *fio) > > { > > struct bio *bio = *fio->bio; > > @@ -495,8 +522,8 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio) > > 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))) { > > + if (bio && !page_is_mergeable(fio->sbi, bio, *fio->last_block, > > + fio->new_blkaddr)) { > > __submit_bio(fio->sbi, bio, fio->type); > > bio = NULL; > > } > > @@ -569,9 +596,8 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) > > > > inc_page_count(sbi, WB_DATA_TYPE(bio_page)); > > > > - if (io->bio && (io->last_block_in_bio != fio->new_blkaddr - 1 || > > - (io->fio.op != fio->op || io->fio.op_flags != fio->op_flags) || > > - !__same_bdev(sbi, fio->new_blkaddr, io->bio))) > > + if (io->bio && !io_is_mergeable(sbi, io->bio, io, fio, > > + io->last_block_in_bio, fio->new_blkaddr)) > > __submit_merged_bio(io); > > alloc_new: > > if (io->bio == NULL) { > > @@ -1643,8 +1669,8 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, > > * This page will go to BIO. Do we need to send this > > * BIO off first? > > */ > > - if (bio && (*last_block_in_bio != block_nr - 1 || > > - !__same_bdev(F2FS_I_SB(inode), block_nr, bio))) { > > + if (bio && !page_is_mergeable(F2FS_I_SB(inode), bio, > > + *last_block_in_bio, block_nr - 1)) { > > *last_block_in_bio, block_nr) > > Sorry, anyway, let me send v2. Fixed, thanks, > > > submit_and_realloc: > > __submit_bio(F2FS_I_SB(inode), bio, DATA); > > bio = NULL; > >