From mboxrd@z Thu Jan 1 00:00:00 1970 From: Waiman Long Subject: Re: [PATCH v2 1/4] dcache: Don't take unnecessary lock in d_count update Date: Fri, 05 Apr 2013 16:26:27 -0400 Message-ID: <515F3373.40302@hp.com> References: <1365181061-30787-1-git-send-email-Waiman.Long@hp.com> <1365181061-30787-2-git-send-email-Waiman.Long@hp.com> <20130405171220.GD4068@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Jeff Layton , Miklos Szeredi , Ian Kent , Sage Weil , Steve French , Trond Myklebust , Eric Paris , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, autofs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org, linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Chandramouleeswaran, Aswin" , "Norton, Scott J" , Andi Kleen , Dave Chinner To: Al Viro Return-path: In-Reply-To: <20130405171220.GD4068-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> Sender: linux-nfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org On 04/05/2013 01:12 PM, Al Viro wrote: >> @@ -635,22 +640,14 @@ struct dentry *dget_parent(struct dentry *dentry) >> { >> struct dentry *ret; >> >> -repeat: >> - /* >> - * Don't need rcu_dereference because we re-check it was correct under >> - * the lock. >> - */ >> rcu_read_lock(); >> - ret = dentry->d_parent; >> - spin_lock(&ret->d_lock); >> - if (unlikely(ret != dentry->d_parent)) { >> - spin_unlock(&ret->d_lock); >> - rcu_read_unlock(); >> - goto repeat; >> - } >> + ret = rcu_dereference(dentry->d_parent); >> rcu_read_unlock(); >> + if (dcount_inc_cmpxchg(ret)) >> + return ret; >> + spin_lock(&ret->d_lock); > And WTF is going to protect your "ret" from being freed just as you'd done > rcu_read_unlock()? I think I had made a mistake here. I should move the rcu_read_unlock() down to before the return statement as well as after the spin_lock(). Thank for pointing this out. I will fix that in the next version. Anything else that needs to be fixed? Regards, Longman -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html