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.

gfs2: Avoid unnecessary transactions in evict_linked_inode

In evict_linked_inode(), the truncate_inode_pages() calls are carried
out inside a transaction. This code was added to what was then function
gfs2_delete_inode() in commit 16615be18cadf ("[GFS2] Clean up journaled
data writing").

These transactions are only used for creating revokes for the jdata
buffers in the journal, so don't create such transactions when we know
that the address space doesn't contain any jdata buffers for this inode
and truncate the metadata address space outside of the transaction.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>

+30 -5
+30 -5
fs/gfs2/super.c
··· 1324 1324 return ret; 1325 1325 } 1326 1326 1327 + static int gfs2_truncate_inode_pages(struct inode *inode) 1328 + { 1329 + struct gfs2_inode *ip = GFS2_I(inode); 1330 + struct gfs2_sbd *sdp = GFS2_SB(inode); 1331 + struct address_space *mapping = &inode->i_data; 1332 + bool need_trans = gfs2_is_jdata(ip) && mapping->nrpages; 1333 + int ret; 1334 + 1335 + /* 1336 + * Truncating a jdata inode address space may create revokes in 1337 + * truncate_inode_pages() -> gfs2_invalidate_folio() -> ... -> 1338 + * gfs2_remove_from_journal(), so we need a transaction here. 1339 + * 1340 + * FIXME: During a withdraw, no new transactions can be created. 1341 + * In that case, we skip the truncate, but that doesn't help because 1342 + * truncate_inode_pages_final() will then call gfs2_invalidate_folio() 1343 + * again, and outside of a transaction. 1344 + */ 1345 + if (need_trans) { 1346 + ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); 1347 + if (ret) 1348 + return ret; 1349 + } 1350 + truncate_inode_pages(mapping, 0); 1351 + if (need_trans) 1352 + gfs2_trans_end(sdp); 1353 + return 0; 1354 + } 1355 + 1327 1356 /* 1328 1357 * evict_linked_inode - evict an inode whose dinode has not been unlinked 1329 1358 * @inode: The inode to evict ··· 1375 1346 write_inode_now(inode, 1); 1376 1347 gfs2_ail_flush(ip->i_gl, 0); 1377 1348 1378 - ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); 1349 + ret = gfs2_truncate_inode_pages(inode); 1379 1350 if (ret) 1380 1351 return ret; 1381 - 1382 - /* Needs to be done before glock release & also in a transaction */ 1383 - truncate_inode_pages(&inode->i_data, 0); 1384 1352 truncate_inode_pages(metamapping, 0); 1385 - gfs2_trans_end(sdp); 1386 1353 return 0; 1387 1354 } 1388 1355