Bug in NFS

4 views
Skip to first unread message

Feng Shuo

unread,
Apr 8, 2011, 6:03:44 AM4/8/11
to darwin...@lists.apple.com, liuguoliang
Hi all,

I found a bug in NFS client namespace management. The scenario would like to be:
  1. If there is a "a.mov" in the NFS share, on client side open a finder to display the share, then close the finder window.
  2. Rename the "a.mov" to "b.mov" in the NFS server.
  3. On client side, open the same directory/share with finder again, you will see "b.mov".
  4. Double click "b.mov", you might find you can not play it.
This issue at least can be reproduced in Mac OS X 10.6.7 (and older 10.6.x systems). I did some trace:
  • In #1, a.mov will be loaded to the nfs file handle cache.
  • In #2, only the name of the file is changed, but not the file handle.
  • In #3, nfs_vnop_readdir will find the directory be updated and reload all the name cache, but vnode.v_name is not updated because cache_purge will not handle this.
  • In #4, if you do a "lookup" to "b.mov", the same vnode will be returned because the file handle is not changed. But if you do a "getattrlist", which is largely called by Quicktime and many Mac OS X applications, the "ATTR_CMN_NAME" will still return the old v_name (a.mov). This will make applications unable to open it if they what to use the CMN_NAME.
Attached is a patch for this issue. I use vnode_update_identity() to update the v_name. :-)

Any comments?

--
Feng Shuo
Tel: (86)10-59851155-2116
Fax: (86)10-59851155-2008
Tianjin Zhongke Blue Whale Information Technologies Co., Ltd
Postcode 100080
10th Floor, Tower A, The GATE building, No. 19 Zhong-guan-cun Avenue
Haidian District, Beijing
nfs_v_name.patch

Shantonu Sen

unread,
Apr 8, 2011, 12:42:04 PM4/8/11
to Feng Shuo, liuguoliang, darwin...@lists.apple.com
Great!

This list is not a bug reporting facility, though. Please report this http://bugreporter.apple.com.

Shantonu Sen



<nfs_v_name.patch> _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list      (Darwin...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-kernel/ssen%40apple.com

This email sent to ss...@apple.com

Feng Shuo

unread,
Apr 9, 2011, 8:59:37 AM4/9/11
to Shantonu Sen, liuguoliang, darwin...@lists.apple.com
Thank you. The Bug ID is # 9261749.

Feng Shuo

unread,
Jan 20, 2012, 4:50:41 AM1/20/12
to Shantonu Sen, lidexiong, lioupa...@gmail.com, liuguoliang, darwin...@lists.apple.com
Hi folks,

The bug was closed but I don't think it's already fixed even in the latest 10.7.2. We get some time to make a cleaner patch as below and also attached just in case anybody might need it. ---- The scenario is:
  1. You have some cached NFS file in Mac OS X, like you open a finder to show those files.
  2. The name space of those files are changed outside this Mac, such as renamed, moved (drag to another directory in the same nfs mount ) in another Mac.
  3. Some applications like quick time will not be able to open the file in the new position.
The problems is the v_name and also v_parent are not updated in this Mac box during nfs_nget.

diff -urp xnu-1699.24.8/bsd/nfs/nfs_node.c xnu-1699.24.8-fengshuo//bsd/nfs/nfs_node.c
--- xnu-1699.24.8/bsd/nfs/nfs_node.c 2011-02-09 06:06:24.000000000 +0800
+++ xnu-1699.24.8-fengshuo//bsd/nfs/nfs_node.c 2012-01-20 17:13:17.000000000 +0800
@@ -233,6 +233,16 @@ loop:
  } else {
  if (dnp && cnp && (flags & NG_MAKEENTRY))
  cache_enter(NFSTOV(dnp), vp, cnp);
+
+ if (dnp && cnp && (vp != NFSTOV(dnp))) {
+ int update_flags = 0;
+ if (vp->v_name != cnp->cn_nameptr)
+ update_flags |= VNODE_UPDATE_NAME;
+ if (vp->v_parent != NFSTOV(dnp))
+ update_flags |= VNODE_UPDATE_PARENT;
+ if (update_flags)
+ vnode_update_identity(vp, NFSTOV(dnp), cnp->cn_nameptr, cnp->cn_namelen, 0, update_flags);
+ }
  *npp = np;
  }
  FSDBG_BOT(263, dnp, *npp, 0xcace0000, error);

Haidian District, Beijing, China
Postcode 100080

nfs_v_name_v2.patch
Reply all
Reply to author
Forward
0 new messages