-static int ocfs2_match_dentry(struct dentry *dentry,
- u64 parent_blkno,
- unsigned int namelen,
- const char *name)
-{
- struct inode *parent;
-
- if (!dentry->d_parent) {
- mlog(0, "Detached from parent.\n");
- return 0;
- }
-
- parent = dentry->d_parent->d_inode;
- /* Negative parent dentry? */
- if (!parent)
- return 0;
-
- /* Name is in a different directory. */
- if (OCFS2_I(parent)->ip_blkno != parent_blkno)
- return 0;
-
- if (dentry->d_name.len != namelen)
- return 0;
-
- /* comparison above guarantees this is safe. */
- if (memcmp(dentry->d_name.name, name, namelen))
- return 0;
-
- return 1;
-}
-
-static void ocfs2_process_dentry_request(struct inode *inode,
- int rename,
- unsigned int new_nlink,
- u64 parent_blkno,
- unsigned int namelen,
- const char *name)
-{
- struct dentry *dentry = NULL;
- struct list_head *p;
- struct ocfs2_inode_info *oi = OCFS2_I(inode);
-
- mlog(0, "parent %"MLFu64", namelen = %u, name = %.*s\n", parent_blkno,
- namelen, namelen, name);
-
- spin_lock(&dcache_lock);
-
- /* Another node is removing this name from the system. It is
- * up to us to find the corresponding dentry and if it exists,
- * unhash it from the dcache. */
- list_for_each(p, &inode->i_dentry) {
- dentry = list_entry(p, struct dentry, d_alias);
-
- if (ocfs2_match_dentry(dentry, parent_blkno, namelen, name)) {
- mlog(0, "dentry found: %.*s\n",
- dentry->d_name.len, dentry->d_name.name);
-
- dget_locked(dentry);
- break;
- }
-
- dentry = NULL;
- }
-
- spin_unlock(&dcache_lock);
-
- if (dentry) {
- d_delete(dentry);
- dput(dentry);
- }
-
- /* rename votes don't send link counts */
- if (!rename) {
- mlog(0, "new_nlink = %u\n", new_nlink);
-
- /* We don't have the proper locks here to directly
- * change i_nlink and besides, the vote is sent
- * *before* the operation so it may have failed on the
- * other node. This passes a hint to ocfs2_drop_inode
- * to force ocfs2_delete_inode, who will take the
- * proper cluster locks to sort things out. */
- if (new_nlink == 0) {
- spin_lock(&oi->ip_lock);
- oi->ip_flags |= OCFS2_INODE_MAYBE_ORPHANED;
- spin_unlock(&OCFS2_I(inode)->ip_lock);
- }
- }
-}
-