From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796099528; b=pbjWcZm7kxu1xjaGOzVLKxg9L/qbtUS3I/5cHVh5ZGWIQzaRnn7l7u65GJJQUY0FhfGn S+fR+SWz6oiF5MGIWrD97o3P6OEEi5WmALp1HlmxYal0nZFe8px969RrH1J7TCR5m7ma9 o5JR7flOBHuo1DHxgYanQnnz2N/Gh3hLClQbY53IsrQ+SeFDmi5kXnLEsUsGY8/aYqfXc /GrHqAi2QS+L2WltYLMtIn8/tz6pUQ3cmXrgGVAR9O2oKnYxkZR17S4W5a4WPeKjPKyui va/Wye9Gyohr4xUTksN/wQtVcprUSO5VYH92j2YN56p2PqH/7Mfi9PWMe6j807V590g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796099528; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent:Cc: Subject:To:References:Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=fSg0ciY74p8B1zfqOC4VI55KAx80Jv5Mc3s8OdCAUD4=; b=QCjBwb1pRt29h6dp0VMV6RjMs/0jE9GI9jQmT8TD8MMf3xt+eewHUvJvvqVZdLC5w/b1 2ppJh+UNEjhNSFdlbI2RANNVCGqrUZyXeSCbDGuvmOXdG62DX21gzOs+w6Iv+bx9+RCAW hV9aiyld3bKOwyLI3e1LMohrFoDDOWr4fW0Hv1A7kQU8w7NhIwMgeOoi+61wHt4wnzf50 E9yP+0aiw0rPHZh22NYjFgUlCEk05ows5XgTrMUZvHH85DY+yQ24z4cpnFXeo0W7wZze/ UH2CdvHRI0SrGdiHvfvODj/ue4cfIyXPsqtyv30fKNHrciqUmvuRYptL2Nc1sP7rOdA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hbAemNAn; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A08D4606A31A; Tue, 1 Dec 2026 04:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hbAemNAn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12DC51F00897; Tue, 1 Dec 2026 04:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796099528; bh=fSg0ciY74p8B1zfqOC4VI55KAx80Jv5Mc3s8OdCAUD4=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=hbAemNAnPIUf1bD7LQc4gsZTC7UyXJuVAI6LRZW9kM5Hv/eYKtMxepmH/gbvGU0TH EpI0GFKxQR3D+wxQPH6E/YgUAruaZIgSk3RjjEwFpbkY0xoALVTnr0dir/JeU4vE09 2GhCNFpu/+w+4muK3YHyhrQ6Fu0YksBC+XcraVhq30vji58UU20XJjuprtAlLE1GKH LWW4rXCdbPhi1sZpx9A9pxIFyIWWePjYUUGah+0WeJwuqFHxgnRVwA0TYJ/gnTwI6l bUFsB9R7pE7K5oHkXlBNukYHF8Ye5f3YOkqkch97eYtlGcBC8JGtY/5GYlr+jicPfs PKtzo0Q+YHGqw== Message-ID: Date: Tue, 1 Dec 2026 12:32:05 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: chao@kernel.org, Daeho Jeong , stable@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH] f2fs: block checkpoint before moving cursegs for device aliasing To: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com References: <20261116000019.2299222-1-daeho43@gmail.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20261116000019.2299222-1-daeho43@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/16/26 08:00, Daeho Jeong wrote: > From: Daeho Jeong > > f2fs_ioc_reserve_dev_alias() moves the cursegs out of the range of the > alias device with gc_lock only, before it takes f2fs_lock_op(). gc_lock > does not keep every checkpoint away: f2fs_ioc_reserve_dev_alias() and > f2fs_ioc_release_dev_alias() write the checkpoint at their end after they > released gc_lock. So the cursegs can be moved while a checkpoint of > another alias ioctl is in progress. Oh, why we not cover f2fs_write_checkpoint() w/ gc_lock like we do for other cases? should we fix this first? Thanks, > > do_checkpoint() copies the positions of the cursegs into the checkpoint > first and writes their summaries later. If a curseg is moved in between, > the checkpoint does not match it. Commit b4b10061ef98 ("f2fs: refactor > resize_fs to avoid meta updates in progress") fixed the same problem in > f2fs_resize_fs() by taking f2fs_lock_op() before the cursegs are moved. > > Do the same here. Take f2fs_lock_op() first, and then move the cursegs. > > Test: two alias files, with a debug patch which makes do_checkpoint() > of the release ioctl sleep after it copied the curseg positions. A > reserve ioctl on the other alias file moved the warm data curseg during > that sleep, and the checkpoint recorded the segment the curseg had left. > With this patch, the curseg is moved after the checkpoint is done. > > Fixes: eae3faf210bd ("f2fs: support dynamic reserve/release for device aliasing") > Cc: stable@vger.kernel.org > Signed-off-by: Daeho Jeong > --- > fs/f2fs/file.c | 17 ++++++++++------- > 1 file changed, 10 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 05061254c3b2..75c51b3a4118 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -3905,13 +3905,7 @@ static int f2fs_ioc_reserve_dev_alias(struct file *filp) > /* Reset the victim information to prevent GC from targeting the range */ > f2fs_reset_gc_victim_resource(sbi, start, end); > > - /* Move out cursegs from the target range */ > - for (type = CURSEG_HOT_DATA; type < NR_CURSEG_PERSIST_TYPE; type++) { > - err = f2fs_allocate_segment_for_resize(sbi, type, start, end); > - if (err) > - goto out_gc_unlock; > - } > - > + /* stop CP before moving cursegs, as f2fs_resize_fs() does */ > f2fs_lock_op(sbi, &lc); > > if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) { > @@ -3920,6 +3914,15 @@ static int f2fs_ioc_reserve_dev_alias(struct file *filp) > goto out_gc_unlock; > } > > + /* Move out cursegs from the target range */ > + for (type = CURSEG_HOT_DATA; type < NR_CURSEG_PERSIST_TYPE; type++) { > + err = f2fs_allocate_segment_for_resize(sbi, type, start, end); > + if (err) { > + f2fs_unlock_op(sbi, &lc); > + goto out_gc_unlock; > + } > + } > + > /* do GC to move out valid blocks in the range all at once! */ > err = f2fs_gc_range(sbi, start, end, false, 0, false); > if (err) {