From patchwork Tue Jan 29 14:54:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 2062311 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 1E7A5E00D9 for ; Tue, 29 Jan 2013 14:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757184Ab3A2Oyh (ORCPT ); Tue, 29 Jan 2013 09:54:37 -0500 Received: from mx2.fusionio.com ([66.114.96.31]:59726 "EHLO mx2.fusionio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757089Ab3A2Oyd (ORCPT ); Tue, 29 Jan 2013 09:54:33 -0500 X-ASG-Debug-ID: 1359471271-0421b503d55aa80001-6jHSXT Received: from mail1.int.fusionio.com (mail1.int.fusionio.com [10.101.1.21]) by mx2.fusionio.com with ESMTP id ISsDRA4XuzyIxnGB (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Tue, 29 Jan 2013 07:54:31 -0700 (MST) X-Barracuda-Envelope-From: JBacik@fusionio.com Received: from localhost (98.26.82.158) by mail.fusionio.com (10.101.1.19) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 29 Jan 2013 07:54:30 -0700 Date: Tue, 29 Jan 2013 09:54:29 -0500 From: Josef Bacik To: Sage Weil CC: "linux-btrfs@vger.kernel.org" , "j.michael.lowe@gmail.com" , "billk@iinet.net.au" Subject: Re: corrupted file size on inline extent conversion? Message-ID: <20130129145429.GD3660@localhost.localdomain> X-ASG-Orig-Subj: Re: corrupted file size on inline extent conversion? References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2011-07-01) X-Barracuda-Connect: mail1.int.fusionio.com[10.101.1.21] X-Barracuda-Start-Time: 1359471271 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: http://10.101.1.181:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at fusionio.com X-Barracuda-Spam-Score: 0.12 X-Barracuda-Spam-Status: No, SCORE=0.12 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests=CN_BODY_332 X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.121239 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.12 CN_BODY_332 BODY: CN_BODY_332 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Mon, Jan 28, 2013 at 05:12:12PM -0700, Sage Weil wrote: > A ceph user observed a incorrect i_size on btrfs. The pattern looks like > this: > > - some writes at low file offsets > - a write to 4185600 len 8704 (i_size should be 4MB) > - more writes to low offsets > - a write to 4181504 len 4096 (abutts the write above) > - a bit of time goes by... > - stat returns 4186112 (4MB - 8192) > - that's a fwe bytes to the right of the top write above. > > There are some logs showing the full read/write activity to the file at > > http://tracker.newdream.net/attachments/658/object_log.txt > > on issue > > http://tracker.newdream.net/issues/3810 > > The kernel was 3.7.0-030700-generic (and probably also observed on 3.7.1). > > Is this a known bug? Not known but I took a long hard look at our ordered i size updating and I think I spotted the bug. Could you run this patch and see if you get the printk? If you do then that was the problem and you should be good to go. It definitely needs to be fixed, hopefully it's also your bug. Thanks, Josef --- 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/ordered-data.c b/fs/btrfs/ordered-data.c index cbd4838..dbd4905 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -895,8 +895,14 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, * if the disk i_size is already at the inode->i_size, or * this ordered extent is inside the disk i_size, we're done */ - if (disk_i_size == i_size || offset <= disk_i_size) { + if (disk_i_size == i_size) goto out; + + if (offset <= disk_i_size) { + if (ordered && ordered->outstanding_isize > disk_i_size) + printk(KERN_ERR "this would have bitten us in the ass\n"); + else + goto out; } /*