/* give up write locks. the i/o lock cannot be held nested if it is being demoted.  */
void xfs_ilock_demote(xfs_inode_t *ip, uint lock_flags)
/* give up write locks. the i/o lock cannot be held nested if it is being demoted.  */
void xfs_ilock_demote(xfs_inode_t *ip, uint lock_flags)
{
	ASSERT(lock_flags & (XFS_IOLOCK_EXCL|XFS_ILOCK_EXCL));
	ASSERT((lock_flags & ~(XFS_IOLOCK_EXCL|XFS_ILOCK_EXCL)) == 0);
	if (lock_flags & XFS_ILOCK_EXCL)
		mrdemote(&ip->i_lock);
	if (lock_flags & XFS_IOLOCK_EXCL)
		mrdemote(&ip->i_iolock);
	trace_xfs_ilock_demote(ip, lock_flags, _RET_IP_);
}