+ /*
+ * Make sure we don't add duplicates
+ */
+
+ /* Search primary cache by CNID */
+ key.d_vid = dir->d_vid;
+ key.d_did = dir->d_did;
+ if ((hn = hash_lookup(dircache, &key))) {
+ /* Found an entry with the same CNID, delete it */
+ dir_remove(vol, hnode_get(hn));
+ dircache_stat.expunged++;
+ }
+ key.d_vid = vol->v_vid;
+ key.d_pdid = dir->d_did;
+ key.d_u_name = dir->d_u_name;
+ if ((hn = hash_lookup(index_didname, &key))) {
+ /* Found an entry with the same DID/name, delete it */
+ dir_remove(vol, hnode_get(hn));
+ dircache_stat.expunged++;
+ }
+