From patchwork Wed Aug 20 14:48:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Mason X-Patchwork-Id: 4752141 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A5D5B9F375 for ; Wed, 20 Aug 2014 14:50:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9B9982017A for ; Wed, 20 Aug 2014 14:50:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB16420179 for ; Wed, 20 Aug 2014 14:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751829AbaHTOtd (ORCPT ); Wed, 20 Aug 2014 10:49:33 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:20331 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916AbaHTOtc (ORCPT ); Wed, 20 Aug 2014 10:49:32 -0400 Received: from pps.filterd (m0004060 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s7KEjLlH017375; Wed, 20 Aug 2014 07:49:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=message-id : date : from : mime-version : to : subject : references : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=rWTloYmZTzOBH3jiqEIrgYA/1P5pEB4GgsdwpZEXV6s=; b=NVV1pf4sFp6S+5phSLpPrtac5k8DgZrtMuIRSYXErj3HoER64c0M/erOVkmQE6D+928v i8e11zhwLUHV3Me2+tJD6uii/mirp684IwIJpkV2O9y+CmZjqKWYUOf/o/rNn4gNRL4H tZwEjSMO0fxiExrIzSZhfn7AQv6uliJyU0g= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0b-00082601.pphosted.com with ESMTP id 1nvg3nj4mh-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Wed, 20 Aug 2014 07:49:00 -0700 Received: from [172.20.34.140] (192.168.16.4) by mail.thefacebook.com (192.168.16.11) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 20 Aug 2014 07:48:57 -0700 Message-ID: <53F4B555.7060403@fb.com> Date: Wed, 20 Aug 2014 10:48:53 -0400 From: Chris Mason User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: , , Fengguang Wu , Dave Hansen , LKML , , "linux-btrfs@vger.kernel.org" , Abhay Sachan Subject: [PATCH] Btrfs: fix filemap_flush call in btrfs_file_release References: <20140816075233.GA26842@localhost> <20140819115820.GA21418@localhost> <20140819142348.GU1553@twin.jikos.cz> <53F36601.5020609@fb.com> <53F47E07.3080807@cn.fujitsu.com> In-Reply-To: <53F47E07.3080807@cn.fujitsu.com> X-Originating-IP: [192.168.16.4] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52, 1.0.27, 0.0.0000 definitions=2014-08-20_05:2014-08-20, 2014-08-20, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=6.49436060484732e-12 kscore.compositescore=0 circleOfTrustscore=0 compositescore=0.533125042697551 urlsuspect_oldscore=0.533125042697551 suspectscore=0 recipient_domain_to_sender_totalscore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=1996008 rbsscore=0.533125042697551 spamscore=0 recipient_to_sender_domain_totalscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1408200152 X-FB-Internal: deliver Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should only be flushing on close if the file was flagged as needing it during truncate. I broke this with my ordered data vs transaction commit deadlock fix. Thanks to Miao Xie for catching this. Signed-off-by: Chris Mason Reported-by: Miao Xie Reported-by: Fengguang Wu --- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index f15c13f..36861b7 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1840,7 +1840,15 @@ int btrfs_release_file(struct inode *inode, struct file *filp) { if (filp->private_data) btrfs_ioctl_trans_end(filp); - filemap_flush(inode->i_mapping); + /* + * ordered_data_close is set by settattr when we are about to truncate + * a file from a non-zero size to a zero size. This tries to + * flush down new bytes that may have been written if the + * application were using truncate to replace a file in place. + */ + if (test_and_clear_bit(BTRFS_INODE_ORDERED_DATA_CLOSE, + &BTRFS_I(inode)->runtime_flags)) + filemap_flush(inode->i_mapping); return 0; }