Message ID | 20240226013208.2389246-1-chao@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-80377-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1816172dyb; Sun, 25 Feb 2024 17:32:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUKDTqxEzd+w/vBhTn8gQnNe2SqAzN+YxSldS0vLic+8kZ59041JHBoO2cV66p//GpJKBE845uV1Hqj6orbMw+6eDPriw== X-Google-Smtp-Source: AGHT+IFT8JtI/FgcqVNwtT3fo5Ngv/04Pki8msR5BvVrDYEghQoKawAK2UtS9Jl9/fP9qqbYQOZF X-Received: by 2002:a2e:910f:0:b0:2d2:4def:a7bd with SMTP id m15-20020a2e910f000000b002d24defa7bdmr2978002ljg.24.1708911158346; Sun, 25 Feb 2024 17:32:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708911158; cv=pass; d=google.com; s=arc-20160816; b=ASbjJZr0FFCOIb60dXjGn7HY6hR8FhHEkHfeY/8q49Kd/MiDeg+4KPEXUbjfflf35K uv9OSujCv3zGUuwKpX6fkmQKdJmpzvXEIedsMZE9K48KonJpWTnSXddbiWCgrur9A62i AW5bnJea/h2rC502IKLF2E40aWK846gaK2IeJR8MgKLS+Ni8MvTbSMJn0kcz10etrrta kSG64zFOx8mVrfr8F/vx+uKQa9bZxHgV9AIRSxBwZJW+N1wt8+nDPmg/SO8P29YkfvbN 8VODXGziewnPVxrj6dUxMeP4WV+cHE2Jp4p/dKqVHSKa1EZebp3mHv5U3X4P8a2dAeeG Ub7g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=uIDhPLNiisO8kLje9+ppC9Q2Qs4N6ZNlTlkoeo5OPkw=; fh=X1/oBJvTGJUQ0YtRp03u+3tPfRw/dXXALWynfOSlfQQ=; b=sc/R3E2T5pI7NnC8yxTlKaADWbifsxCoMM3lF5iHW9sdCFOEhKju8a5Rxiv3Ef4Nbc tPh3O2iWyeTGEmw3PMCyxpMKVlGouBgSyG9ZwNArVY92jIOVAFhQ8VXrdsBeo/b7z+/f tcXyLfBrz238xkeGod96P57mkcxLyjZuyRvt90qdU8FwNxnFpa+6b9VLW2SB/G60+IiY rxOP/Aq0my1yllrrcmdkjaAi5ZYW7dtVqzD37WnjJVSXbJGCm67E8VRvdPFO/QMVohSX ECoiUXa8VHaI14+aDE8Kat4iOrXgwT63sllrM+qlegOUQTGyUAT5gfRB7SSHwQKLM7e9 Gjkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sz8sjKAE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80377-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 28-20020a508e5c000000b005660464aa50si149824edx.685.2024.02.25.17.32.38 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 17:32:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80377-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sz8sjKAE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80377-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80377-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EBAC71F219A8 for <ouuuleilei@gmail.com>; Mon, 26 Feb 2024 01:32:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 44420FBEF; Mon, 26 Feb 2024 01:32:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sz8sjKAE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99B8F4C91 for <linux-kernel@vger.kernel.org>; Mon, 26 Feb 2024 01:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708911140; cv=none; b=DdfKZFRpIvm++ivQYVy6OsXsfOqSgwrL3Z4Cz5FetwKyNyywZ9cEW2xIcH2DHDY3Vrgwoasxab7Khnp4+TLbHK4x48iA1l7uN5nfSW7cOvtW1Wt5GZG8Mpmb48gEYprwfIlJOdwyYeOcYRyqRuw69ia4QtbvJXJumaeWgoqIJVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708911140; c=relaxed/simple; bh=JC2tKZVI/N9NKXwRhcw37ItMYVdb46EEQNkTvwv2vU0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=p9EhI/S2+KAhhiyBYUm4SSMDD6ZQBg/pPfigi8n4AkZhkUc/ucm+QEVBxPzWr8wK7pcj37IJ55qMbVZ4966ImIDBd4qKIOu9BlYKeaGW0sdlMuEZitQ/rbrmtKj43EQWJtWd08OtCpFqzEkyF6BpAMULku6Z8rIoFjWyNMqxx4M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sz8sjKAE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E958C433C7; Mon, 26 Feb 2024 01:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708911140; bh=JC2tKZVI/N9NKXwRhcw37ItMYVdb46EEQNkTvwv2vU0=; h=From:To:Cc:Subject:Date:From; b=Sz8sjKAET+isPNL/4a4fFdhhgcMkhiNGh9nDOKbXa6M+bIqIqS/gJVLGUZt6kfd7U SM6tD2+qQrobZhW2CxqSvTkKSogfCArlGO5sLq10ZoNJ4ftQcU3PHCNZkcdMUjQRLT Rt5u70cfST75BOH4CAKDNkOdDeWq35f8VPOcUS8UMFQoi4eI+Xto7tlwLPA7XaS9qF qrt/yiu4dFYNzVNu1+2LcnQ7WFDzX1zUzcnE76vkZV4XPaNvyV1A9Ki0dJZqU0Bvzh hJKKTjm9B3Ol/u/2KtJPswTuPIFu6dGqdsdIO7zNpPTumy2iHJ7pj+zQVSZvE0tL81 LogR/jchMm3Wg== From: Chao Yu <chao@kernel.org> To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org> Subject: [PATCH 1/4] f2fs: fix blkofs_end correctly in f2fs_migrate_blocks() Date: Mon, 26 Feb 2024 09:32:05 +0800 Message-Id: <20240226013208.2389246-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791923227143554789 X-GMAIL-MSGID: 1791923227143554789 |
Series |
[1/4] f2fs: fix blkofs_end correctly in f2fs_migrate_blocks()
|
|
Commit Message
Chao Yu
Feb. 26, 2024, 1:32 a.m. UTC
In f2fs_migrate_blocks(), when traversing blocks in last section,
blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it.
Signed-off-by: Chao Yu <chao@kernel.org>
---
fs/f2fs/data.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
Jaegeuk, Daeho, Any comments on this serials? Thanks, On 2024/2/26 9:32, Chao Yu wrote: > In f2fs_migrate_blocks(), when traversing blocks in last section, > blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it. > > Signed-off-by: Chao Yu <chao@kernel.org> > --- > fs/f2fs/data.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index c21b92f18463..0c728e82d936 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, > struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > unsigned int blkofs; > unsigned int blk_per_sec = BLKS_PER_SEC(sbi); > + unsigned int end_blk = start_blk + blkcnt - 1; > unsigned int secidx = start_blk / blk_per_sec; > unsigned int end_sec; > int ret = 0; > > if (!blkcnt) > return 0; > - end_sec = secidx + (blkcnt - 1) / blk_per_sec; > + end_sec = end_blk / blk_per_sec; > > f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); > filemap_invalidate_lock(inode->i_mapping); > @@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, > > for (; secidx <= end_sec; secidx++) { > unsigned int blkofs_end = secidx == end_sec ? > - (blkcnt - 1) % blk_per_sec : blk_per_sec - 1; > + end_blk % blk_per_sec : blk_per_sec - 1; > > f2fs_down_write(&sbi->pin_sem); >
On Thu, Feb 29, 2024 at 2:11 AM Chao Yu <chao@kernel.org> wrote: > > Jaegeuk, Daeho, > > Any comments on this serials? > > Thanks, No functional difference here, since start_blk is always aligned with the section address. However, this is more clear in itself. Reviewed-by: Daeho Jeong <daehojeong@google.com> Thanks, > > On 2024/2/26 9:32, Chao Yu wrote: > > In f2fs_migrate_blocks(), when traversing blocks in last section, > > blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it. > > > > Signed-off-by: Chao Yu <chao@kernel.org> > > --- > > fs/f2fs/data.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > index c21b92f18463..0c728e82d936 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, > > struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > > unsigned int blkofs; > > unsigned int blk_per_sec = BLKS_PER_SEC(sbi); > > + unsigned int end_blk = start_blk + blkcnt - 1; > > unsigned int secidx = start_blk / blk_per_sec; > > unsigned int end_sec; > > int ret = 0; > > > > if (!blkcnt) > > return 0; > > - end_sec = secidx + (blkcnt - 1) / blk_per_sec; > > + end_sec = end_blk / blk_per_sec; > > > > f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); > > filemap_invalidate_lock(inode->i_mapping); > > @@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, > > > > for (; secidx <= end_sec; secidx++) { > > unsigned int blkofs_end = secidx == end_sec ? > > - (blkcnt - 1) % blk_per_sec : blk_per_sec - 1; > > + end_blk % blk_per_sec : blk_per_sec - 1; > > > > f2fs_down_write(&sbi->pin_sem); > > > > > _______________________________________________ > Linux-f2fs-devel mailing list > Linux-f2fs-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On 2024/3/1 1:41, Daeho Jeong wrote: > On Thu, Feb 29, 2024 at 2:11 AM Chao Yu <chao@kernel.org> wrote: >> >> Jaegeuk, Daeho, >> >> Any comments on this serials? >> >> Thanks, > > No functional difference here, since start_blk is always aligned with > the section address. You're right. > However, this is more clear in itself. Thanks for the review! One more thing is, I found that fallocate() on pinned file will preallocate aligned w/ section-size which is about several hundred megabyte for ZUFS case, since commit e1175f022911 ("f2fs: fix to align to section for fallocate() on pinned file"). It looks not make sense, especially for logcat case which actually want to preallocate 2MB space, so, what about reverting commit e1175f022911 and looking for other solution to avoid GCing on fragmented pinned file. What do you think? Thanks, > > Reviewed-by: Daeho Jeong <daehojeong@google.com> > > Thanks, > >> >> On 2024/2/26 9:32, Chao Yu wrote: >>> In f2fs_migrate_blocks(), when traversing blocks in last section, >>> blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it. >>> >>> Signed-off-by: Chao Yu <chao@kernel.org> >>> --- >>> fs/f2fs/data.c | 5 +++-- >>> 1 file changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>> index c21b92f18463..0c728e82d936 100644 >>> --- a/fs/f2fs/data.c >>> +++ b/fs/f2fs/data.c >>> @@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, >>> struct f2fs_sb_info *sbi = F2FS_I_SB(inode); >>> unsigned int blkofs; >>> unsigned int blk_per_sec = BLKS_PER_SEC(sbi); >>> + unsigned int end_blk = start_blk + blkcnt - 1; >>> unsigned int secidx = start_blk / blk_per_sec; >>> unsigned int end_sec; >>> int ret = 0; >>> >>> if (!blkcnt) >>> return 0; >>> - end_sec = secidx + (blkcnt - 1) / blk_per_sec; >>> + end_sec = end_blk / blk_per_sec; >>> >>> f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); >>> filemap_invalidate_lock(inode->i_mapping); >>> @@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, >>> >>> for (; secidx <= end_sec; secidx++) { >>> unsigned int blkofs_end = secidx == end_sec ? >>> - (blkcnt - 1) % blk_per_sec : blk_per_sec - 1; >>> + end_blk % blk_per_sec : blk_per_sec - 1; >>> >>> f2fs_down_write(&sbi->pin_sem); >>> >> >> >> _______________________________________________ >> Linux-f2fs-devel mailing list >> Linux-f2fs-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
On 03/01, Chao Yu wrote: > On 2024/3/1 1:41, Daeho Jeong wrote: > > On Thu, Feb 29, 2024 at 2:11 AM Chao Yu <chao@kernel.org> wrote: > > > > > > Jaegeuk, Daeho, > > > > > > Any comments on this serials? > > > > > > Thanks, > > > > No functional difference here, since start_blk is always aligned with > > the section address. > > You're right. > > > However, this is more clear in itself. > > Thanks for the review! > > One more thing is, I found that fallocate() on pinned file will preallocate > aligned w/ section-size which is about several hundred megabyte for ZUFS case, > since commit e1175f022911 ("f2fs: fix to align to section for fallocate() on > pinned file"). > > It looks not make sense, especially for logcat case which actually want to > preallocate 2MB space, so, what about reverting commit e1175f022911 and > looking for other solution to avoid GCing on fragmented pinned file. I remember we removed the logcat case. > > What do you think? > > Thanks, > > > > > Reviewed-by: Daeho Jeong <daehojeong@google.com> > > > > Thanks, > > > > > > > > On 2024/2/26 9:32, Chao Yu wrote: > > > > In f2fs_migrate_blocks(), when traversing blocks in last section, > > > > blkofs_end should be (start_blk + blkcnt - 1) % blk_per_sec, fix it. > > > > > > > > Signed-off-by: Chao Yu <chao@kernel.org> > > > > --- > > > > fs/f2fs/data.c | 5 +++-- > > > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > > > index c21b92f18463..0c728e82d936 100644 > > > > --- a/fs/f2fs/data.c > > > > +++ b/fs/f2fs/data.c > > > > @@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, > > > > struct f2fs_sb_info *sbi = F2FS_I_SB(inode); > > > > unsigned int blkofs; > > > > unsigned int blk_per_sec = BLKS_PER_SEC(sbi); > > > > + unsigned int end_blk = start_blk + blkcnt - 1; > > > > unsigned int secidx = start_blk / blk_per_sec; > > > > unsigned int end_sec; > > > > int ret = 0; > > > > > > > > if (!blkcnt) > > > > return 0; > > > > - end_sec = secidx + (blkcnt - 1) / blk_per_sec; > > > > + end_sec = end_blk / blk_per_sec; > > > > > > > > f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); > > > > filemap_invalidate_lock(inode->i_mapping); > > > > @@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, > > > > > > > > for (; secidx <= end_sec; secidx++) { > > > > unsigned int blkofs_end = secidx == end_sec ? > > > > - (blkcnt - 1) % blk_per_sec : blk_per_sec - 1; > > > > + end_blk % blk_per_sec : blk_per_sec - 1; > > > > > > > > f2fs_down_write(&sbi->pin_sem); > > > > > > > > > > > > > _______________________________________________ > > > Linux-f2fs-devel mailing list > > > Linux-f2fs-devel@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index c21b92f18463..0c728e82d936 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3841,13 +3841,14 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, struct f2fs_sb_info *sbi = F2FS_I_SB(inode); unsigned int blkofs; unsigned int blk_per_sec = BLKS_PER_SEC(sbi); + unsigned int end_blk = start_blk + blkcnt - 1; unsigned int secidx = start_blk / blk_per_sec; unsigned int end_sec; int ret = 0; if (!blkcnt) return 0; - end_sec = secidx + (blkcnt - 1) / blk_per_sec; + end_sec = end_blk / blk_per_sec; f2fs_down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]); filemap_invalidate_lock(inode->i_mapping); @@ -3857,7 +3858,7 @@ static int f2fs_migrate_blocks(struct inode *inode, block_t start_blk, for (; secidx <= end_sec; secidx++) { unsigned int blkofs_end = secidx == end_sec ? - (blkcnt - 1) % blk_per_sec : blk_per_sec - 1; + end_blk % blk_per_sec : blk_per_sec - 1; f2fs_down_write(&sbi->pin_sem);