* [f2fs-dev] [bug report] f2fs: avoid reading already updated pages during GC
@ 2026-04-10 10:15 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-04-10 10:15 UTC (permalink / raw)
To: Jianan Huang; +Cc: linux-f2fs-devel
Hello Jianan Huang,
Commit 570e2ccc7cb3 ("f2fs: avoid reading already updated pages
during GC") from Mar 5, 2026 (linux-next), leads to the following
Smatch static checker warning:
fs/f2fs/gc.c:1291 ra_data_block()
warn: missing error code 'err'
fs/f2fs/gc.c
1220 static int ra_data_block(struct inode *inode, pgoff_t index)
1221 {
1222 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
1223 struct address_space *mapping = f2fs_is_cow_file(inode) ?
1224 F2FS_I(inode)->atomic_inode->i_mapping : inode->i_mapping;
1225 struct dnode_of_data dn;
1226 struct folio *folio, *efolio;
1227 struct f2fs_io_info fio = {
1228 .sbi = sbi,
1229 .ino = inode->i_ino,
1230 .type = DATA,
1231 .temp = COLD,
1232 .op = REQ_OP_READ,
1233 .op_flags = 0,
1234 .encrypted_page = NULL,
1235 .in_list = 0,
1236 };
1237 int err = 0;
1238
1239 folio = f2fs_grab_cache_folio(mapping, index, true);
1240 if (IS_ERR(folio))
1241 return PTR_ERR(folio);
1242
1243 if (f2fs_lookup_read_extent_cache_block(inode, index,
1244 &dn.data_blkaddr)) {
1245 if (unlikely(!f2fs_is_valid_blkaddr(sbi, dn.data_blkaddr,
1246 DATA_GENERIC_ENHANCE_READ))) {
1247 err = -EFSCORRUPTED;
1248 goto put_folio;
1249 }
1250 goto got_it;
1251 }
1252
1253 set_new_dnode(&dn, inode, NULL, NULL, 0);
1254 err = f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE);
1255 if (err)
1256 goto put_folio;
1257 f2fs_put_dnode(&dn);
1258
1259 if (!__is_valid_data_blkaddr(dn.data_blkaddr)) {
1260 err = -ENOENT;
1261 goto put_folio;
1262 }
1263 if (unlikely(!f2fs_is_valid_blkaddr(sbi, dn.data_blkaddr,
1264 DATA_GENERIC_ENHANCE))) {
1265 err = -EFSCORRUPTED;
1266 goto put_folio;
1267 }
1268 got_it:
1269 /* read folio */
1270 fio.folio = folio;
1271 fio.new_blkaddr = fio.old_blkaddr = dn.data_blkaddr;
1272
1273 /*
1274 * don't cache encrypted data into meta inode until previous dirty
1275 * data were writebacked to avoid racing between GC and flush.
1276 */
1277 f2fs_folio_wait_writeback(folio, DATA, true, true);
1278
1279 f2fs_wait_on_block_writeback(inode, dn.data_blkaddr);
1280
1281 efolio = f2fs_filemap_get_folio(META_MAPPING(sbi), dn.data_blkaddr,
1282 FGP_LOCK | FGP_CREAT, GFP_NOFS);
1283 if (IS_ERR(efolio)) {
1284 err = PTR_ERR(efolio);
1285 goto put_folio;
1286 }
1287
1288 fio.encrypted_page = &efolio->page;
1289
1290 if (folio_test_uptodate(efolio))
--> 1291 goto put_encrypted_page;
Should we set an error code here?
1292
1293 err = f2fs_submit_page_bio(&fio);
1294 if (err)
1295 goto put_encrypted_page;
1296 f2fs_put_page(fio.encrypted_page, false);
1297 f2fs_folio_put(folio, true);
1298
1299 f2fs_update_iostat(sbi, inode, FS_DATA_READ_IO, F2FS_BLKSIZE);
1300 f2fs_update_iostat(sbi, NULL, FS_GDATA_READ_IO, F2FS_BLKSIZE);
1301
1302 return 0;
1303 put_encrypted_page:
1304 f2fs_put_page(fio.encrypted_page, true);
1305 put_folio:
1306 f2fs_folio_put(folio, true);
1307 return err;
1308 }
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-10 10:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 10:15 [f2fs-dev] [bug report] f2fs: avoid reading already updated pages during GC Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox