From: "Yan Zheng" <yanzheng@21cn.com>
To: "Sage Weil" <sage@newdream.net>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: inode data not getting included in commits?
Date: Fri, 19 Dec 2008 09:26:49 +0800 [thread overview]
Message-ID: <3d0408630812181726g7b1be6ey787ff0e6105cfa80@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0812181536060.10446@cobra.newdream.net>
2008/12/19 Sage Weil <sage@newdream.net>:
> Hi Chris-
>
> I noticed some data and metadata getting out of sync on disk, despite
> wrapping my writes with btrfs transactions. After digging into it a bit,
> it appears to be a larger problem with inode size/data getting written
> during a regular commit.
>
> I have a test program append a few bytes at a time to a few different
> files, in a loop. I let it run until I see a btrfs transaction commit
> (via a printk at the bottom of btrfs_commit_transaction). Then 'reboot -f
> -n'. After remounting, all files exist but are 0 bytes, and debug-tree
> shows a bunch of empty files. I would expect to see either the sizes when
> the commit happend (a few hundred KB in my case), or no files at all;
> there was actually no point in time when any of the files were 0 bytes.
>
> Similarly, if I do the same but wait for a few commits to happen, after
> remount the file sizes reflect the size from around the next-to-last
> commit, not the last commit.
>
> This is probably more information than you need, but my original test was
> a bit more complicated, with weirder results. Append to each file, then
> write it's size to an xattr on another file. Wrap both operations in a
> transaction. Start it up, run 'sync', then reboot -f -n. When I remount
> the size and xattr are out of sync by exactly one iteration: the xattr
> reflects the size that resulted from _two_ writes back, not the
> immediately preceeding write. If anything I would expect to see a larger
> actual size than xattr value (for example if the start/end transaction
> ioctls weren't working)...
>
> sage
>
>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
>
> int main(int argc, char **argv)
> {
> while (1) {
> int r, fd, pos, i = rand() % 10;
> char a[20];
>
> sprintf(a, "%d.log", i);
> fd = open(a, O_CREAT|O_APPEND|O_WRONLY, 0600);
> r = write(fd, "foobarfoo\n", 10);
> pos = lseek(fd, 0, SEEK_CUR);
> printf("write %s = %d, size = %d\n", a, r, pos);
> close(fd);
> }
> }
>
This is the desired behaviour of data=ordered. Btrfs transaction commit
don't flush data, and metadata wont get updated until data IO complete.
http://article.gmane.org/gmane.comp.file-systems.btrfs/869/match=new+data+ordered+code
Regards
Yan Zheng
next prev parent reply other threads:[~2008-12-19 1:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-19 0:22 inode data not getting included in commits? Sage Weil
2008-12-19 1:26 ` Yan Zheng [this message]
2008-12-19 5:21 ` Sage Weil
2008-12-19 14:12 ` Chris Mason
2008-12-19 18:48 ` Sage Weil
2008-12-19 19:07 ` Chris Mason
2008-12-19 20:08 ` Sage Weil
2008-12-20 0:11 ` Chris Mason
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=3d0408630812181726g7b1be6ey787ff0e6105cfa80@mail.gmail.com \
--to=yanzheng@21cn.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=sage@newdream.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox