From patchwork Wed Apr 15 18:33:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 6222401 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 613399F313 for ; Wed, 15 Apr 2015 18:33:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7961C201C0 for ; Wed, 15 Apr 2015 18:33:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8BE20200E1 for ; Wed, 15 Apr 2015 18:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964872AbbDOSd0 (ORCPT ); Wed, 15 Apr 2015 14:33:26 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:25587 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964862AbbDOSdY (ORCPT ); Wed, 15 Apr 2015 14:33:24 -0400 Received: from pps.filterd (m0004077 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id t3FIWeci025433 for ; Wed, 15 Apr 2015 11:33:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : mime-version : content-type; s=facebook; bh=gcmNjZXN631QoDfc6lm6o1obv07cAsY9wvUfl8n0ZNk=; b=XHUswzaa3PBNnxxMcV55ID82V484tjI8wBwHnGvQPrQbd6JQavGfN4CmPz8BRAen200B dgoqFIO1UzXHzMMoOk5vHjUn2SEU+tGK+8JCfmeC+gx4rZltoIgmlzdh6rH4xIgl+YP9 U6NEyEl9frwXHrPFm4PJtpGv3EsRzKG0Bf8= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0b-00082601.pphosted.com with ESMTP id 1tsvqb85fr-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Wed, 15 Apr 2015 11:33:24 -0700 Received: from localhost (192.168.54.13) by mail.thefacebook.com (192.168.16.13) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 15 Apr 2015 11:33:22 -0700 From: Josef Bacik To: Subject: [PATCH] Btrfs: log entire range for FULL_SYNC Date: Wed, 15 Apr 2015 14:33:21 -0400 Message-ID: <1429122801-3096-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68, 1.0.33, 0.0.0000 definitions=2015-04-15_06:2015-04-15, 2015-04-15, 1970-01-01 signatures=0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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 My log writes test uncovered a corruption that could happen with fsx'es mmap write. It does an msync(MS_SYNC) after every mmap write, which turns into a vfs_fsync_range() for the range we wrote. However if we've truncated before this we will set FULL_SYNC on the inode, so if we've truncated up and then only log up to the range we've inlcluded then fsck complains because i_size is > the last extent in the flie. Fix this by making sure we log the entire file and not just the range requested. With this patch we now pass the log writes test. Thanks, Signed-off-by: Josef Bacik --- fs/btrfs/file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 23b6e03..46c7227 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -1901,8 +1901,13 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) * start and finish before we start logging the inode, so that * all extents are persisted and the respective file extent * items are in the fs/subvol btree. + * + * We also need to do the whole range, we set FULL_SYNC if we + * truncated, and we could have some previous version of the + * inode in the log, so we need to write and log all the things. */ - ret = btrfs_wait_ordered_range(inode, start, end - start + 1); + end = (u64)-1; + ret = btrfs_wait_ordered_range(inode, start, end); } else { /* * Start any new ordered operations before starting to log the