@@ -1515,13 +1515,24 @@ __xfs_icache_free_eofblocks(
void *args),
int tag)
{
- int flags = SYNC_TRYLOCK;
+ int flags = SYNC_TRYLOCK;
+ int error;
if (eofb && (eofb->eof_flags & XFS_EOF_FLAGS_SYNC))
flags = SYNC_WAIT;
- return xfs_inode_ag_iterator_tag(mp, execute, flags,
- eofb, tag);
+ /*
+ * freeze waits on background scanner jobs to complete so we cannot
+ * block on write protection here. Bail if the transaction subsystem is
+ * already freezing, returning -EAGAIN to notify other callers.
+ */
+ if (!sb_start_write_trylock(mp->m_super))
+ return -EAGAIN;
+
+ error = xfs_inode_ag_iterator_tag(mp, execute, flags, eofb, tag);
+ sb_end_write(mp->m_super);
+
+ return error;
}
int