Skip to contentSkip to conversation

nilfs2-treat-missing-cpfile-header-block-as-metadata-corruption.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Sep 2, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: nilfs2: treat missing cpfile header block as metadata corruption
has been removed from the -mm tree. Its filename was
nilfs2-treat-missing-cpfile-header-block-as-metadata-corruption.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Ryusuke Konishi <[email protected]>
Subject: nilfs2: treat missing cpfile header block as metadata corruption
Date: Thu, 22 Aug 2024 00:46:24 +0900

The cpfile, a metadata file that holds metadata for checkpoint management, also has statistical information in its first block, and if reading this block fails, it receives the internal code -ENOENT and returns that code to the callers.

As with sufile, to prevent this -ENOENT from being propagated to system calls, return -EIO instead when reading the header block fails.

---

 fs/nilfs2/cpfile.c |   22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
fs/nilfs2/cpfile.c renamed from fs/nilfs2/cpfile.c~nilfs2-treat-missing-cpfile-header-block-as-metadata-corruption +12 -10
@@ -125,10 +125,17 @@ static void nilfs_cpfile_block_init(stru
 	}
 }
 
-static inline int nilfs_cpfile_get_header_block(struct inode *cpfile,
-						struct buffer_head **bhp)
+static int nilfs_cpfile_get_header_block(struct inode *cpfile,
+					 struct buffer_head **bhp)
 {
-	return nilfs_mdt_get_block(cpfile, 0, 0, NULL, bhp);
+	int err = nilfs_mdt_get_block(cpfile, 0, 0, NULL, bhp);
+
+	if (unlikely(err == -ENOENT)) {
+		nilfs_error(cpfile->i_sb,
+			    "missing header block in checkpoint metadata");
+		err = -EIO;
+	}
+	return err;
 }
 
 static inline int nilfs_cpfile_get_checkpoint_block(struct inode *cpfile,
@@ -283,14 +290,9 @@ int nilfs_cpfile_create_checkpoint(struc
 
 	down_write(&NILFS_MDT(cpfile)->mi_sem);
 	ret = nilfs_cpfile_get_header_block(cpfile, &header_bh);
-	if (unlikely(ret < 0)) {
-		if (ret == -ENOENT) {
-			nilfs_error(cpfile->i_sb,
-				    "checkpoint creation failed due to metadata corruption.");
-			ret = -EIO;
-		}
+	if (unlikely(ret < 0))
 		goto out_sem;
-	}
+
 	ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 1, &cp_bh);
 	if (unlikely(ret < 0))
 		goto out_header;

_

Patches currently in -mm which might be from [email protected] are