diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index ecb8e05b8b84..e9d99a7ba0ab 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c @@ -902,6 +902,18 @@ int diFree(struct inode *ip) } iagp = (struct iag *) mp->data; + /* We will deadlock if due to inconsistency + * the iag has no free inodes but is + * head of the free list + */ + if (iagp->nfreeinos == 0 && imap->im_agctl[agno].inofree == iagno) { + IREAD_UNLOCK(ipimap); + AG_UNLOCK(imap, agno); + release_metapage(mp); + jfs_error(ip->i_sb, "nfreeinos = 0, but iag is head of freelist\n"); + return -EIO; + } + /* get the inode number and extent number of the inode within * the iag and the inode number within the extent. */