All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Peter Gervai <grinapo@gmail.com>
Cc: xfs@oss.sgi.com
Subject: Re: how to sync / commit data to disk?
Date: Tue, 23 Jan 2007 15:43:29 -0600	[thread overview]
Message-ID: <45B68181.2010707@sandeen.net> (raw)
In-Reply-To: <d55656c10701231233kf7faf02xbdd59ec1e218afa4@mail.gmail.com>

Peter Gervai wrote:
> Thanks for the very informative replies!
> 
> I try to address some questions, and maybe ask some more.
> 
> The original question was:
>> > What is the recommended way to make sure that a file is written
>> > physically to the disk? (apart from the cache of the disk.)
> 
> On 1/23/07, Eric Sandeen <sandeen@sandeen.net> wrote:
> 
>> Another issue that I've seen with grub is that it seems to like to write
>> directly to the block device WHILE THE FILESYSTEM IS MOUNTED.
> 
> It does not seem to do evil in this case:
> 
> 3243  open("//boot/grub/stage2", O_RDWR) = 5
> 3243  fstat64(0x5, 0xf7c2e9f4)          = 0
> 3243  mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
> MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff7bc4000
> 3243  _llseek(5, 0, [0], SEEK_SET)      = 0
> 3243  read(5, 
> "RV\276\3\201\350(\1^\277\370\201f\213-\203}\4\0\17\204\312\0\200|\377\0t>f\213\35f1\300\260\1779E\4\177\3\213E\4)E\4f\1\5\307\4\20\0\211D\2f\211\ 
> 
> \\10\307D\6\0pPf1\300\211D\4f\211D\f\264B\315\23\17\202\237\0\273\0p\353Vf\213\5f1\322f\3674\210T\nf1"..., 
> 
> 512) = 512
> 3243  write(5, 
> "\352p\202\0\0\0\3\2\377\377\377\0\0\0\0\0\0\0000.97\0/boot/grub/menu.lst\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 
> 
> \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3721\300\216\330\216\320\216\300g"..., 
> 
> 512) = 512
> 3243  close(5)                          = 0
> 
> Now, for me it seems to be a very interesting question that why people
> would CARE whether it's synced or not, since they write it by the
> filesystem layer anyway? I do not know, and investigating the reason
> why 'grub-install' would worry about sync is beyond my available time.
> 
> The original problem was because grub-install froze xfs, then tried to
> do the above, which magically fail on the frozen filesystem, hanging
> the install till the cows come home. I tried to fix this, then started
> wondering how to do it properly, and now that you mentioned and I
> checked the trace I really start wondering about why to care... :-o

The other thing I've seen grub do is to go ahead & write nicely through 
the filesystem, then do a verification step of trying to go read 
directly from the block device while the filesystem is still mounted.

Again, not treating the filesystem well; until you unmount the fs 
there's not a lot to guarantee that all your data is where you expect it 
on disk (especially w/ a journalling fs, where metadata in the journal 
is really enough for safety, even if its not in its final disk location 
- and of course grub doesn't replay the journal....)

When I saw it hanging, I saw it hanging in this verification step, for 
the above reasons.  it wandered into unwritten metadata blocks. 
Skipping that verification  step would probably be a better idea, it's 
causing many more problems than it's likely to catch (unless you can 
unmount or otherwise quiesce the filesystem first...)

-Eric

  reply	other threads:[~2007-01-23 21:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-23 15:16 how to sync / commit data to disk? Peter Gervai
2007-01-23 15:58 ` Geir A. Myrestrand
2007-01-23 16:08 ` Eric Sandeen
2007-01-23 20:33   ` Peter Gervai
2007-01-23 21:43     ` Eric Sandeen [this message]
2007-01-24  6:21     ` Chris Wedgwood
2007-01-23 16:50 ` Chris Wedgwood
2007-01-23 22:24   ` Nathan Scott
2007-01-23 22:58     ` Chris Wedgwood
2007-01-23 16:58 ` Iustin Pop
  -- strict thread matches above, loose matches on Subject: below --
2007-01-24 16:28 James Pearson

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=45B68181.2010707@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=grinapo@gmail.com \
    --cc=xfs@oss.sgi.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.