On 07/23/2013 01:25 PM, Sage Weil wrote: > On Tue, 23 Jul 2013, Yan, Zheng wrote: >> On 07/23/2013 09:41 AM, Sage Weil wrote: >>> On Sun, 21 Jul 2013, Yan, Zheng wrote: >>>> From: "Yan, Zheng" >>>> >>>> The MDS uses caps message to notify clients about deleted inode. >>>> when receiving a such message, invalidate any alias of the inode. >>>> This makes the kernel release the inode ASAP. >>>> >>>> Signed-off-by: Yan, Zheng >>>> --- >>>> fs/ceph/caps.c | 31 ++++++++++++++++++++++++++++++- >>>> 1 file changed, 30 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c >>>> index 25442b4..b446fdd 100644 >>>> --- a/fs/ceph/caps.c >>>> +++ b/fs/ceph/caps.c >>>> @@ -2334,6 +2334,28 @@ void ceph_put_wrbuffer_cap_refs(struct ceph_inode_info *ci, int nr, >>>> } >>>> >>>> /* >>>> + * Invalidate unlinked inode's aliases, so we can drop the inode >>>> + * from the cache ASAP. >>>> + */ >>>> +static void invalidate_aliases(struct inode *inode) >>>> +{ >>>> + struct dentry *dn; >>>> + >>>> + dout("invalidate_aliases inode %p\n", inode); >>>> + d_prune_aliases(inode); >>>> + while ((dn = d_find_alias(inode))) { >>>> + d_delete(dn); >>>> + dput(dn); >>> >>> I don't think this loop is safe. d_delete() won't unlink the inode if >>> there are other refs to the dentry, which would make this get stuck in a >>> loop. Maybe simple checking if we get the same dentry back from >>> d_find_alias() as the previous call? >>> >> >> For non-dir inode, d_find_alias() only return connected dentry. After calling >> d_delete, the dentry become disconnected. so the loop is safe. > > Oh, right. Totally misread that. > >>>> + /* >>>> + * for dir inode, d_find_alias() can return >>>> + * disconnected dentry >>>> + */ >>>> + if (S_ISDIR(inode->i_mode)) >>>> + break; >>>> + } >>> >>> If we handle the more general case, I'm not sure we need any special case >>> here for the directory... although I confess I'm not sure why disconnected >>> dentries should be treated specially at all. >>> >> >> For dir inode, d_find_alias() may disconnected dentry, that's why the special case >> is needed. how about below code. > > Right. I think either variation is okay. I'll pull in the original for > now, unless you prefer the below. Sorry for the runaround! > > sage > please apply the attached version, thanks. Yan, Zheng