From patchwork Tue Mar 26 16:31:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Aur=C3=A9lien_Aptel?= X-Patchwork-Id: 10871569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A193C1390 for ; Tue, 26 Mar 2019 16:32:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CC741FFB1 for ; Tue, 26 Mar 2019 16:32:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80F7528D3A; Tue, 26 Mar 2019 16:32:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91A6F1FFB1 for ; Tue, 26 Mar 2019 16:31:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730697AbfCZQb6 (ORCPT ); Tue, 26 Mar 2019 12:31:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:42904 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730451AbfCZQb6 (ORCPT ); Tue, 26 Mar 2019 12:31:58 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AAAE3B121; Tue, 26 Mar 2019 16:31:57 +0000 (UTC) From: Aurelien Aptel To: linux-cifs@vger.kernel.org Cc: piastryyy@gmail.com, Aurelien Aptel Subject: [PATCH v1] CIFS: keep FileInfo handle around while writing pages Date: Tue, 26 Mar 2019 17:31:52 +0100 Message-Id: <20190326163152.27385-1-aaptel@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: References: Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the oplock break handler, writing pending changes from pages puts the FileInfo handle. If the refcount reaches zero it closes the handle and waits for any oplock break handler to return, thus causing a deadlock. To prevent it we keep an additionnal reference of the SMB FileInfo handle while we write/read pages so that when writepages puts the handle, it won't close it. This was triggered by xfstest 464. Signed-off-by: Aurelien Aptel --- fs/cifs/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 89006e044973..a9a515ea2e14 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -4579,12 +4579,15 @@ void cifs_oplock_break(struct work_struct *work) break_lease(inode, O_RDONLY); else break_lease(inode, O_WRONLY); + + cifsFileInfo_get(cfile); rc = filemap_fdatawrite(inode->i_mapping); if (!CIFS_CACHE_READ(cinode)) { rc = filemap_fdatawait(inode->i_mapping); mapping_set_error(inode->i_mapping, rc); cifs_zap_mapping(inode); } + cifsFileInfo_put(cfile); cifs_dbg(FYI, "Oplock flush inode %p rc %d\n", inode, rc); }