From patchwork Fri Jun 16 05:02:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9790537 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B115E60231 for ; Fri, 16 Jun 2017 05:04:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAA4828638 for ; Fri, 16 Jun 2017 05:04:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F8892863B; Fri, 16 Jun 2017 05:04:04 +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=-6.9 required=2.0 tests=BAYES_00,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 311A628638 for ; Fri, 16 Jun 2017 05:04:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751958AbdFPFEC (ORCPT ); Fri, 16 Jun 2017 01:04:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:34073 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751727AbdFPFEC (ORCPT ); Fri, 16 Jun 2017 01:04:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C6740AB09; Fri, 16 Jun 2017 05:04:00 +0000 (UTC) From: NeilBrown To: Jens Axboe Date: Fri, 16 Jun 2017 15:02:09 +1000 Subject: [PATCH 1/2] loop: use filp_close() rather than fput() Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <149758932908.10006.10765671892098302463.stgit@noble> In-Reply-To: <149758925866.10006.12779875832895865043.stgit@noble> References: <149758925866.10006.12779875832895865043.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When a loop device is being shutdown the backing file is closed with fput(). This is different from how close(2) closes files - it uses filp_close(). The difference is important for filesystems which provide a ->flush file operation such as NFS. NFS assumes a flush will always be called on last close, and gets confused otherwise. Signed-off-by: NeilBrown Reviewed-by: Christoph Hellwig --- drivers/block/loop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ebbd0c3fe0ed..9c457ca6c55e 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -682,7 +682,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, if (error) goto out_putf; - fput(old_file); + filp_close(old_file, NULL); if (lo->lo_flags & LO_FLAGS_PARTSCAN) loop_reread_partitions(lo, bdev); return 0; @@ -1071,12 +1071,12 @@ static int loop_clr_fd(struct loop_device *lo) loop_unprepare_queue(lo); mutex_unlock(&lo->lo_ctl_mutex); /* - * Need not hold lo_ctl_mutex to fput backing file. + * Need not hold lo_ctl_mutex to close backing file. * Calling fput holding lo_ctl_mutex triggers a circular * lock dependency possibility warning as fput can take * bd_mutex which is usually taken before lo_ctl_mutex. */ - fput(filp); + filp_close(filp, NULL); return 0; }