Doubt about ntfs code: lockmgr with LK_INTERLOCK flag

Wei Lei weilei84 at gmail.com
Sat Feb 25 06:25:58 PST 2006


Hi list,

Nice to be here =)

I am new here so just hope my first post doesn't mismatch the topic.

I have a doubt when understanding the ntfs code with freebsd 5.4:
ntfs_subr.c, function ntfs_ntget().
I understand that lockmgr() here is trying to get an exclusive lock and
release the mutex ip->i_interlock,
so that the protection can expand from use_count to the whole ntnode.

But what's the significance of having such a mechanism? What could possibly
happen if I do a
mtx_unlock first then acquire the exclusive lock?

This is the code in ntfs_subr.c

352 int
353 ntfs_ntget(ip)
354         struct ntnode *ip;
355 {
356         dprintf((*"ntfs_ntget: get ntnode %d: %p, usecount: %d\n"*,
357                 ip->i_number, ip, ip->i_usecount));
358
359         mtx_lock(&ip->i_interlock);
360         ip->i_usecount++;
361         lockmgr(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK,
&ip->i_interlock,
362             NULL);
363
364         return 0;
365 }

Regards,
Wei Lei


More information about the freebsd-fs mailing list