Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nilfs2: treat missing cpfile header block as metadata corruption

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.

Link: https://lkml.kernel.org/r/20240821154627.11848-3-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ryusuke Konishi and committed by
Andrew Morton
d07d8ba4 62e6e784

+12 -10
+12 -10
fs/nilfs2/cpfile.c
··· 125 125 } 126 126 } 127 127 128 - static inline int nilfs_cpfile_get_header_block(struct inode *cpfile, 129 - struct buffer_head **bhp) 128 + static int nilfs_cpfile_get_header_block(struct inode *cpfile, 129 + struct buffer_head **bhp) 130 130 { 131 - return nilfs_mdt_get_block(cpfile, 0, 0, NULL, bhp); 131 + int err = nilfs_mdt_get_block(cpfile, 0, 0, NULL, bhp); 132 + 133 + if (unlikely(err == -ENOENT)) { 134 + nilfs_error(cpfile->i_sb, 135 + "missing header block in checkpoint metadata"); 136 + err = -EIO; 137 + } 138 + return err; 132 139 } 133 140 134 141 static inline int nilfs_cpfile_get_checkpoint_block(struct inode *cpfile, ··· 290 283 291 284 down_write(&NILFS_MDT(cpfile)->mi_sem); 292 285 ret = nilfs_cpfile_get_header_block(cpfile, &header_bh); 293 - if (unlikely(ret < 0)) { 294 - if (ret == -ENOENT) { 295 - nilfs_error(cpfile->i_sb, 296 - "checkpoint creation failed due to metadata corruption."); 297 - ret = -EIO; 298 - } 286 + if (unlikely(ret < 0)) 299 287 goto out_sem; 300 - } 288 + 301 289 ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 1, &cp_bh); 302 290 if (unlikely(ret < 0)) 303 291 goto out_header;