From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145592; b=TUm1IxMFiOW4f1/55xBXd5+rTGgwWFd8eRT+Q8QQa5Lsv7RZbllyHHparDYZowTnDxGi UF0CsYS4h7feQ9wndbgppdsp70m27cM+oqhIAH5/HRpoLo2UPLKWPGvOq+ipRXNGzcpDy OLtUyMcWliHbjPOU1NbN16JxRl9BczjGDNbo+yH3+RRCsct8i5nSSzjNm7YqvJAv2qVvr 9XM89L8LtS3lI4uCTeNtYK24aIT1321+0rjCrFJQoKWTUGJGfSsd2JKWflx06eIc5zgIC cqSUo110DtjrKZXNW4V8YRWFroemUBcU36SDa9JzQrGZAmdCnYvRW4WE90Bi9rVB4bg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145592; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=EF8TOZnjbL9ADZVaJHa0DGDJTCqP3o1X01NyHaKGR7w=; b=NuBFmkQN/DNyEDhIHjalwSLjzhGWagoofLVNubLRk+L1jCK8ZdrCA4bCjIUsxikeOTS4 ZXNFTqSI/hPidYGgQFkZnzEiMsY1WAEuJ4KlQNuOqylSl0F/39VhjYgS6shn4rILnYkV+ 7Z1KlARYpWd3N3FI68zU/N+KY6X2bf8ThGB5/n+qeL0XbvZg2YVAKPoWQY07pdRk+uHOo hzLsQ7VtXQdx3l+GRNNvPxIQT79tBM7iLCneIrvGgWlrhD6vh1YS2HlnxegrxhjbDDEfw +vYmLlEuFdyYrRYk4BQ8VAW89Bi+T8g4i1XQafoKuG8L5GBjQ4+caJ3dVGzZByiU9yQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZRJrsASI; arc=none smtp.remote-ip=209.85.210.179 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E527B606A339 for ; Tue, 1 Dec 2026 17:19:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E527B606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ZRJrsASI Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-8a052aff9e9so8589459b3a.0 for ; Tue, 01 Dec 2026 09:19:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796145591; x=1796750391; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=EF8TOZnjbL9ADZVaJHa0DGDJTCqP3o1X01NyHaKGR7w=; b=ZRJrsASIPVC0B37Ty4FTKrOaeTCO1PHYvRwBx26mvK4K1u9euDLTLqZb0SvymRTCqR ej4cr/IF/3InP9meGVlqc6jFgQTgqX2pVYUCRW9yxO+8ReMf3U8d6lSbbQKRyrLfeA6B qD6W5lf7G73VqYJNuHP5DSObCJF8TGH0GxH0cCRFDZgcr03Ste46mJEahVCnbCReLdci cXQHfCQYw4w8yfs+MfFpBPw7EweqNmTOVcAyZucGL8ZPtzoBdWMQM4c6s6ccIlmsGQx5 OGa6s5XSQ0AqtCaPIP5zSveI8eljtKaIPGfNU2IYOObk+6/4oBtdY+fazE9dnbOt4Ltp wGzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796145591; x=1796750391; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EF8TOZnjbL9ADZVaJHa0DGDJTCqP3o1X01NyHaKGR7w=; b=MLpCdXJlf6ODJnTmhtaRbB1aFrr/g1kjQMz7tG6pT8gcE9YsUY3QoRp4t5BoWfak3M IRB/+6a6TzJG/NGp2VLSN2XVqLIGrCZNX8xsO4H9X4zLq866YTkj/YZwtuvRPX9bwWsK zbpRlDK4THaqJgB3hwLYa7bEwWTCsYhhYrMyPjl4a+tw4Y2nX+b3nzdxzz89EpaL5d7q w99yTlx6S9iiLFhFN4tUEoBdTu+qKGO/IUox+UvyFv1SAv/IltVVXHYwEMJGgy9tFeYg GWZPmAbqVH2AH3SiiMCzQJcn5mc9n3IckjlFPu39dtdgoPzn/szl7/Fa4ZUZq8Rb6n+6 gxWg== X-Gm-Message-State: APuU4Z9316hDnSpQoQ85X9+HovYEKRjutvDS893qiVXPH52+fkCVLCLG qjfA50Ejrbb5dgEbsYTeyOwd3F3HqwQw+3O4eWpIqTEsuxNB6XBNiHLt8AEf/Q== X-Gm-Gg: AZFdTZf3n43SPbsZ0CC27Y2UZnj6Rr8eMz81aqQOVSVn/0uJ6gNectuJi4/ldI7osLr cg4R1PBbJ2UnlrHFm8HxAuaCzDqRCWGut1+9ksVA0Xx3l0QSzx1AQ9hF66U91jrTjCbX4OVwJkE dDBWQo31duxnoQSVc6SCYlJMFoc+iRPIiGrGw5sprFd54ftavF7NjCC66VlWN6rzEegqYT04Qkn FN7f5fUs9rXVg3rnEILL9o9gckvteiueX7hD1VDo3qivn/97JLF+pzMvfRj1B1ZmGmhB2JSeYMV OKMX/Kk8Eoe3oHpHeZg0tCHlg1GY06WblRPLIi1e9N2z9Jin5iLHEdW9VOBiCMhAa6tksnSLtYi JEd7tNS/RA+/7cmXrn6IRIX/BE7AohNYLWuauQrtnrqglKCRpp7GL2m0tCef9S+ZZcM/LxrjfOT u/KW6RMqx8BerodfoQwKkQKBGAo8Pulc9XXcLwdmJVGmq2qcEy5eOiK6NRegZVgi5Q+1gmY14Dl zzgK0ksR02u3azwpkokTz9J5eGEx4rZ14PL/U+bns92f7FM8BthmjQmg2exPpiRf7bRmCxtyL1Z osxF/+66nlSXsQl6ZBzy6jzzOlbDyEUnv833nqBnUOuU2rE5rlLEUYbFfATcRTKwMkGV9Dyu3bp j9XFhGV1iCQZZ8+GoqR5dYcWbc6NN5xsyb1s+Raty1iKpiw== X-Received: by 2002:a05:6a00:17a3:b0:8bb:1b05:dd39 with SMTP id d2e1a72fcca58-8c87bdb43aemr38184069b3a.11.1796145590953; Tue, 01 Dec 2026 09:19:50 -0800 (PST) Received: from f2fs-test.c.googlers.com.com (193.67.125.34.bc.googleusercontent.com. [34.125.67.193]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87420be40sm19997191b3a.57.2026.12.01.09.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 09:19:50 -0800 (PST) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong , stable@vger.kernel.org, Chao Yu Subject: [PATCH v2] f2fs: cover the checkpoint of device aliasing ioctls with gc_lock Date: Tue, 1 Dec 2026 09:19:44 -0800 Message-ID: <20261201171944.3919669-1-daeho43@gmail.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog 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 Content-Transfer-Encoding: 8bit From: Daeho Jeong f2fs_ioc_reserve_dev_alias() and f2fs_ioc_release_dev_alias() write the checkpoint at their end after they released gc_lock. All the other callers of f2fs_write_checkpoint() on a mounted filesystem hold gc_lock, so only these two checkpoints can run while another task holds gc_lock. f2fs_ioc_reserve_dev_alias() is such a task: it moves the cursegs out of the range of the alias device with gc_lock held, before it takes f2fs_lock_op(). do_checkpoint() copies the positions of the cursegs into the checkpoint first and writes their summaries later. If the checkpoint of another alias ioctl is in progress and a curseg is moved in between, the checkpoint does not match it. Hold gc_lock for the checkpoint in both ioctls, as the other callers do. 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 reserve ioctl waits for the checkpoint and moves the curseg after it. Fixes: eae3faf210bd ("f2fs: support dynamic reserve/release for device aliasing") Cc: stable@vger.kernel.org Suggested-by: Chao Yu Signed-off-by: Daeho Jeong --- v2: - cover the checkpoint of the two ioctls with gc_lock instead of taking f2fs_lock_op() before the cursegs are moved, as Chao suggested. With gc_lock held for every checkpoint, the cursegs cannot be moved during a checkpoint, so the change of v1 is not needed. - v1 was "f2fs: block checkpoint before moving cursegs for device aliasing", which is in dev-test. This one is based on dev and replaces it. With the same debug patch, F2FS_IOC_GARBAGE_COLLECT started f2fs_gc() during the checkpoint of the release ioctl with v1, and waits for the checkpoint with v2. v1: https://lore.kernel.org/linux-f2fs-devel/20261116000019.2299222-1-daeho43@gmail.com/ fs/f2fs/file.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c80dbbe76f8f..4f6e6d611642 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4160,7 +4160,12 @@ static int f2fs_ioc_reserve_dev_alias(struct file *filp) inode_unlock(inode); mnt_drop_write_file(filp); - return f2fs_write_checkpoint(sbi, &cpc); + /* Hold gc_lock for the checkpoint, as the other callers do. */ + f2fs_down_write_trace(&sbi->gc_lock, &glc); + err = f2fs_write_checkpoint(sbi, &cpc); + f2fs_up_write_trace(&sbi->gc_lock, &glc); + + return err; out_gc_unlock: spin_lock(&sbi->stat_lock); @@ -4250,7 +4255,12 @@ static int f2fs_ioc_release_dev_alias(struct file *filp) inode_unlock(inode); mnt_drop_write_file(filp); - return f2fs_write_checkpoint(sbi, &cpc); + /* Hold gc_lock for the checkpoint, as the other callers do. */ + f2fs_down_write_trace(&sbi->gc_lock, &glc); + err = f2fs_write_checkpoint(sbi, &cpc); + f2fs_up_write_trace(&sbi->gc_lock, &glc); + + return err; out_inode_unlock: inode_unlock(inode); -- 2.56.1.839.g22a8290db9-goog From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB15C606A33B for ; Tue, 1 Dec 2026 17:20:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.a=rsa-sha256 header.s=beta header.b=jngQOHHz; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.a=rsa-sha256 header.s=x header.b=NdV6aw5A; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.a=rsa-sha256 header.s=x header.b=aFETyMB8; dkim=neutral header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Rnt68lxI DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:Message-ID:Date:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Unsubscribe-Post:List-Owner; bh=ohdlEuRmZdBm6UcaMeAJypstGmrk8/Y/tAkhYVa0V3k=; b=jngQOHHz3LQJ/0CWE62JMrM09z A8Ro8Cx06L01apuVyDpwk8xHWaZR9TtFEn2n/KNJSEpEsv8xLrj89+qKNUudcUlW39gamUa9G1ItT FXtVY+TxdoiU+KtVeiUtm9Pdd516Y0LbdSiLDqkpBwOCIXP5PcGR0lxwzS4Qw3aqSeno=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xYRWK-000000005BR-17VI; Tue, 01 Dec 2026 17:20:00 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xYRWJ-000000005BL-2krp for linux-f2fs-devel@lists.sourceforge.net; Tue, 01 Dec 2026 17:19:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EF8TOZnjbL9ADZVaJHa0DGDJTCqP3o1X01NyHaKGR7w=; b=NdV6aw5AOWB+szMezYedB3JEGN sqmSmE+qfEzWGmB/TfUBVwERYJFb6EoFwR7Fw1TJBzWAF8KnaTF0rvGYSrN+Ibrdd7JZ0gxM3EhVa 2UUBnJ4Ami7AkY+LvkawF5P/8ch3oqv+RT9vePThPAQpp3xI14HsglTHOZHkepIYazdw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=EF8TOZnjbL9ADZVaJHa0DGDJTCqP3o1X01NyHaKGR7w=; b=aFETyMB8Sa7U2QWE5j9uGsXLHh 8Ok32pRlfp/o8NfxgPJ4P1LZmxK/x8civdACspAbKSKk0ynbnqE3rpO1wrSibV/L06q+2nKRzst0G d8miEG74nsYQdp95OMtezqVSc5cUqANU6Kr3Gfe3osv794kZdruqgyJ1VIPBkivLdhyg=; Received: from mail-pf1-f174.google.com ([209.85.210.174]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.100.1) id 1xYRWG-000000005zQ-3Rm4 for linux-f2fs-devel@lists.sourceforge.net; Tue, 01 Dec 2026 17:19:59 +0000 Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-8a052aff9e9so8589460b3a.0 for ; Tue, 01 Dec 2026 09:19:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796145591; x=1796750391; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=EF8TOZnjbL9ADZVaJHa0DGDJTCqP3o1X01NyHaKGR7w=; b=Rnt68lxI593GfNrch4wjZuCwz4/Lanphha3TdOt6kVUA2ZnJJ1AApAVl0Z4KCMs3iX bZ5SkFRiQdwozjCuDVujy2DGQoOoYUlfR32G1e2bEmTAx21+cA1YSOVoc8K6wbI43yJW YBdgSQGrsoupqMDGhASbyJGqe6tKB/6DEChwHqSspg2u2E1EAiaSRQ5xyNwuRRLAd44v JINxMHEfbGNNBfjRWGPfqb8rBH/W7R4nXsE51cqGp7H2R/oIwrBYzKZ5pJYGnCRBC67t 8SYm4mHo9+JuOXIwPRM6D7JEPGCttmiqrZohet4Y7R/NP4aECf2emcSBuIUVaxgW0r/S +Fhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796145591; x=1796750391; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EF8TOZnjbL9ADZVaJHa0DGDJTCqP3o1X01NyHaKGR7w=; b=jHXE7qGXlI4EfD2qsLxmTeLIV/gM2eZVL9ZQpgchEIT0HbP5tnkm1eCYUve3r5lJsy MVFCo6on5aKlmhBDNWZ9VcBI2iqLDEoFzRXbgwF1kN5B0H2fABEl60jcOL1RwK+c+2fk M7uDxAy2ITPQ2GDVAEMH+bDMvv1zaLjKtTZo+SoNP0EPkfmBeDpXkvaJOw347ByWA0DK nc5qjhLaHe6vDz+E0iniE3X6AGhNFHLnG45wYH0LewZlskHTJKGiar98XEWbg+LX57mA dfdE+f9ge8/P0l5RvSGFAkxK14fyr+g0RMoFjItHWJd3FRtJikX7/5GOfGd8Ni+ilHxX F6Pw== X-Forwarded-Encrypted: i=1; AL+hErGrI9+/8lUg8MxixWZpFP/IELMk+Cz82JtBRZbwha9siu/rQh5PxJUJXN8LJeLTf0NH6zfJg6r1irO9XomniosL@lists.sourceforge.net X-Gm-Message-State: APuU4Z+2vIhqEUWnf3U9JMw4WJo6GyrYxa2GGoj/eKQItJwowauMFwJq 91egD9lIVSTAHeWEUuMsphY3nyZK18AOgNM3sF3z5IG2h7QR4X7Ct3T/ X-Gm-Gg: AZFdTZfFB2E2nWjqWbMbVSyRwZqLuZxDx4GFCq6VSOr6FJtrieKOMr2dhduc+A11TJi tlh3tyBkoUq3AhDNYzhHitxQznaWIr80DQ6wOhkxA/hLZdVODQtr2b/Bolr+o2iqokZGgWNIag8 qFVMJcF1j87kdA832tLza2H9QzHvmu6+y+bqAZlFg5Ytm5o5hCPGkhNMs/EAzaEoPQohhoNslgA UG+R4bFAO7pO8QFxaXMT0nKuptS3giegez3d6+dPmrsVy/RxPMT9/Us2TB6DVLHclbvatz6qr70 qTQvIBg/Ns17McLBv02GjZJOO6EePbU0R8NrDqO2OU4Iqnl9BDLrO1ioUMxqyuLngcuLYkkp9Yr BUjuFTi9YW/O7da05PfIZTseyunAU7fga3ZF6W8+D2WoPMZKFUAGP1ge0WH+/0aspFgXrIb8TV/ ecPS0gCStuzsf5N7o3B8TZplnTTGuC+n2y6Z7Rebn2wMsGodXQciXtzeo4VYnua/S8z5jmt1p3L Kh/gkV57uVkd1SWTceYR7qBPsyEhQfaQdiSHcvHLJPOmlLCHhoJ4NJSqZuZzhxD7rszULEMt5ek 2ww+2vLXVjHLfjIn/5ta6/uH22Thw6/KbJ2XeYYMqP8qQEWlgWtAlHPXqgtk8C6b/CsJWQ582zN 2mExIkVg2EKA+jdC9XVE+iHv+DaV7lC1swBINWbd2FMcpcA== X-Received: by 2002:a05:6a00:17a3:b0:8bb:1b05:dd39 with SMTP id d2e1a72fcca58-8c87bdb43aemr38184069b3a.11.1796145590953; Tue, 01 Dec 2026 09:19:50 -0800 (PST) Received: from f2fs-test.c.googlers.com.com (193.67.125.34.bc.googleusercontent.com. [34.125.67.193]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c87420be40sm19997191b3a.57.2026.12.01.09.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 09:19:50 -0800 (PST) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Tue, 1 Dec 2026 09:19:44 -0800 Message-ID: <20261201171944.3919669-1-daeho43@gmail.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog X-Archived-By: MIME-Version: 1.0 X-Spam-Score: 1.1 (+) X-Headers-End: 1xYRWG-000000005zQ-3Rm4 Subject: [f2fs-dev] [PATCH v2] f2fs: cover the checkpoint of device aliasing ioctls with gc_lock X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daeho Jeong , stable@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Daeho Jeong f2fs_ioc_reserve_dev_alias() and f2fs_ioc_release_dev_alias() write the checkpoint at their end after they released gc_lock. All the other callers of f2fs_write_checkpoint() on a mounted filesystem hold gc_lock, so only these two checkpoints can run while another task holds gc_lock. f2fs_ioc_reserve_dev_alias() is such a task: it moves the cursegs out of the range of the alias device with gc_lock held, before it takes f2fs_lock_op(). do_checkpoint() copies the positions of the cursegs into the checkpoint first and writes their summaries later. If the checkpoint of another alias ioctl is in progress and a curseg is moved in between, the checkpoint does not match it. Hold gc_lock for the checkpoint in both ioctls, as the other callers do. 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 reserve ioctl waits for the checkpoint and moves the curseg after it. Fixes: eae3faf210bd ("f2fs: support dynamic reserve/release for device aliasing") Cc: stable@vger.kernel.org Suggested-by: Chao Yu Signed-off-by: Daeho Jeong --- v2: - cover the checkpoint of the two ioctls with gc_lock instead of taking f2fs_lock_op() before the cursegs are moved, as Chao suggested. With gc_lock held for every checkpoint, the cursegs cannot be moved during a checkpoint, so the change of v1 is not needed. - v1 was "f2fs: block checkpoint before moving cursegs for device aliasing", which is in dev-test. This one is based on dev and replaces it. With the same debug patch, F2FS_IOC_GARBAGE_COLLECT started f2fs_gc() during the checkpoint of the release ioctl with v1, and waits for the checkpoint with v2. v1: https://lore.kernel.org/linux-f2fs-devel/20261116000019.2299222-1-daeho43@gmail.com/ fs/f2fs/file.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c80dbbe76f8f..4f6e6d611642 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4160,7 +4160,12 @@ static int f2fs_ioc_reserve_dev_alias(struct file *filp) inode_unlock(inode); mnt_drop_write_file(filp); - return f2fs_write_checkpoint(sbi, &cpc); + /* Hold gc_lock for the checkpoint, as the other callers do. */ + f2fs_down_write_trace(&sbi->gc_lock, &glc); + err = f2fs_write_checkpoint(sbi, &cpc); + f2fs_up_write_trace(&sbi->gc_lock, &glc); + + return err; out_gc_unlock: spin_lock(&sbi->stat_lock); @@ -4250,7 +4255,12 @@ static int f2fs_ioc_release_dev_alias(struct file *filp) inode_unlock(inode); mnt_drop_write_file(filp); - return f2fs_write_checkpoint(sbi, &cpc); + /* Hold gc_lock for the checkpoint, as the other callers do. */ + f2fs_down_write_trace(&sbi->gc_lock, &glc); + err = f2fs_write_checkpoint(sbi, &cpc); + f2fs_up_write_trace(&sbi->gc_lock, &glc); + + return err; out_inode_unlock: inode_unlock(inode); -- 2.56.1.839.g22a8290db9-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel