Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754545AbdLFBMS (ORCPT ); Tue, 5 Dec 2017 20:12:18 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:11514 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753798AbdLFBHK (ORCPT ); Tue, 5 Dec 2017 20:07:10 -0500 Message-ID: <5A2741B2.4040509@huawei.com> Date: Wed, 6 Dec 2017 09:02:42 +0800 From: alex chen User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Ben Hutchings , Greg Kroah-Hartman CC: piaojun , Joseph Qi , "stable@vger.kernel.org" , Changwei Ge , Mark Fasheh , Joel Becker , Junxiao Bi , Andrew Morton , Linus Torvalds , LKML Subject: Re: [PATCH 4.4 13/16] ocfs2: should wait dio before inode lock in ocfs2_setattr() References: <20171122101110.784746358@linuxfoundation.org> <20171122101111.411869812@linuxfoundation.org> <1512488994.18523.173.camel@codethink.co.uk> In-Reply-To: <1512488994.18523.173.camel@codethink.co.uk> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.26.59] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.5A2741D7.0166,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: c1d2b1f2f81ff825304ece4ace157891 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1807 Lines: 57 Hi Ben, Thanks for your reply. On 2017/12/5 23:49, Ben Hutchings wrote: > On Wed, 2017-11-22 at 11:12 +0100, Greg Kroah-Hartman wrote: >> 4.4-stable review patch. If anyone has any objections, please let me know. >> >> ------------------ >> >> From: alex chen >> >> commit 28f5a8a7c033cbf3e32277f4cc9c6afd74f05300 upstream. >> >> we should wait dio requests to finish before inode lock in >> ocfs2_setattr(), otherwise the following deadlock will happen: > [...] > > I looked at the kernel-doc for inode_dio_wait(): > > /** > * inode_dio_wait - wait for outstanding DIO requests to finish > * @inode: inode to wait for > * > * Waits for all pending direct I/O requests to finish so that we can > * proceed with a truncate or equivalent operation. > * > * Must be called under a lock that serializes taking new references > * to i_dio_count, usually by inode->i_mutex. > */ > > Now that ocfs2_setattr() calls this outside of the inode locked region, > what prevents another task adding a new dio request immediately > afterward? > In the kernel 4.6, firstly, we use the inode_lock() in do_truncate() to prevent another bio to be issued from this node. Furthermore, we use the ocfs2_rw_lock() and ocfs2_inode_lock() in ocfs2_setattr() to guarantee no more bio will be issued from the other nodes in this cluster. > Also, ocfs2_dio_end_io_write() was introduced in 4.6 and it looks like > the dio completion path didn't previously take the inode lock. So it > doesn't look this fix is needed in 3.18 or 4.4. Yes, ocfs2_dio_end_io_write() was introduced in 4.6 and the problem this patch fixes is only exist in the kernel 4.6 and above 4.6. I'm sorry that I don't clearly point out which the stable version of kernel this patch will fixes. Thanks, Alex > > Ben. >