All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: Sage Weil <sage@inktank.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
	"j.michael.lowe@gmail.com" <j.michael.lowe@gmail.com>,
	"billk@iinet.net.au" <billk@iinet.net.au>
Subject: Re: corrupted file size on inline extent conversion?
Date: Tue, 29 Jan 2013 09:54:29 -0500	[thread overview]
Message-ID: <20130129145429.GD3660@localhost.localdomain> (raw)
In-Reply-To: <alpine.DEB.2.00.1301281602060.8729@cobra.newdream.net>

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


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;
 	}
 
 	/*

  reply	other threads:[~2013-01-29 14:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-29  0:12 corrupted file size on inline extent conversion? Sage Weil
2013-01-29 14:54 ` Josef Bacik [this message]
2013-01-30 18:17   ` Mike Lowe
2013-01-30 18:22     ` Josef Bacik
2013-01-30 18:30       ` Mike Lowe
2013-01-30 19:09         ` Josef Bacik
2013-02-05  0:04           ` Sage Weil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130129145429.GD3660@localhost.localdomain \
    --to=jbacik@fusionio.com \
    --cc=billk@iinet.net.au \
    --cc=j.michael.lowe@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sage@inktank.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.