linux-dentry-delete-so-unlinked-files-die-nicely-20020718

"d_delete: needs to call iput() to decrement i_count, which
you get by returning 1 instead of 0.

looking at the other fs schemes (actually its pretty clear in the
nfs code too) i see that they return 1 for 'is_bad_inode()'."
This commit is contained in:
Chas Williams 2002-07-18 13:27:48 +00:00 committed by Derrick Brashear
parent d53f4f14e1
commit cabd0bbd4f
3 changed files with 19 additions and 6 deletions

View File

@ -329,7 +329,7 @@ void osi_linux_free_inode_pages(void)
void osi_clear_inode(struct inode *ip)
{
cred_t *credp = crref();
struct vcache *vc = ITOAFS(ip);
struct vcache *vcp = ITOAFS(ip);
#if defined(AFS_LINUX24_ENV)
if (atomic_read(&ip->i_count) > 1)
@ -338,15 +338,15 @@ void osi_clear_inode(struct inode *ip)
#endif
printf("afs_put_inode: ino %d (0x%x) has count %d\n", ip->i_ino, ip);
ObtainWriteLock(&vc->lock, 504);
afs_InactiveVCache(vc, credp);
ReleaseWriteLock(&vc->lock);
afs_InactiveVCache(vcp, credp);
ObtainWriteLock(&vcp->lock, 504);
#if defined(AFS_LINUX24_ENV)
atomic_set(&ip->i_count, 0);
#else
ip->i_count = 0;
#endif
ip->i_nlink = 0; /* iput checks this after calling this routine. */
ReleaseWriteLock(&vcp->lock);
crfree(credp);
}

View File

@ -920,10 +920,22 @@ static void afs_dentry_iput(struct dentry *dp, struct inode *ip)
osi_iput(ip);
}
static int afs_dentry_delete(struct dentry *dp)
{
if (dp->d_inode && (ITOAFS(dp->d_inode)->states & CUnlinked))
return 1; /* bad inode? */
afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYDELETE, ICL_TYPE_POINTER,
dp->d_inode, ICL_TYPE_STRING, dp->d_parent->d_name.name,
ICL_TYPE_STRING, dp->d_name.name);
return 0;
}
#if defined(AFS_LINUX24_ENV)
struct dentry_operations afs_dentry_operations = {
d_revalidate: afs_linux_dentry_revalidate,
d_iput: afs_dentry_iput,
d_delete: afs_dentry_delete,
};
struct dentry_operations *afs_dops = &afs_dentry_operations;
#else
@ -1086,7 +1098,6 @@ int afs_linux_unlink(struct inode *dip, struct dentry *dp)
int code;
cred_t *credp = crref();
const char *name = dp->d_name.name;
int putback = 0;
AFS_GLOCK();
code = afs_remove(ITOAFS(dip), name, credp);

View File

@ -156,6 +156,8 @@ error_table 2 ZCM
ec CM_TRACE_DCACHEWAIT, "%s line %d: sleeping or waiting for 0x%x flags 0x%x"
ec CM_TRACE_VNODEREAD, "UFSRead: tdc 0x%x, offset (0x%x, 0x%x) len (0x%x 0x%x)"
ec CM_TRACE_SLEEP, "Sleep: evp 0x%x, count %d seq 0x%x evp->seq 0x%x"
ec CM_TRACE_WAKE, "Wapeup: evp 0x%x, evp->seq 0x%x"
ec CM_TRACE_WAKE, "Wakeup: evp 0x%x, evp->seq 0x%x"
ec CM_TRACE_DENTRYDELETE, "dentry_delete inode 0x%x d_name %s/%s"
ec CM_TRACE_TRYFLUSHDCACHECHILDREN, "TryFlushDcacheChildren tvc 0x%x"
end