linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Curt Wohlgemuth <curtw@google.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: sync the directory inode in ext4_sync_parent()
Date: Tue, 5 Apr 2011 12:43:51 -0700	[thread overview]
Message-ID: <BANLkTin2VdByS23f0Gg-m77wUr3RVYgkiQ@mail.gmail.com> (raw)
In-Reply-To: <4D9B6F0A.5080705@redhat.com>

Hi Eric:

On Tue, Apr 5, 2011 at 12:35 PM, Eric Sandeen <sandeen@redhat.com> wrote:
> On 4/5/11 12:27 PM, Curt Wohlgemuth wrote:
>> ext4 has taken the stance that, in the absence of a journal,
>> when an fsync/fdatasync of an inode is done, the parent
>> directory should be sync'ed if this inode entry is new.
>> ext4_sync_parent(), which implements this, does indeed sync
>> the dirent pages for parent directories, but it does not
>> sync the directory *inode*.  This patch fixes this.
>>
>> I tested this using a power fail test, which panics a
>> machine running a file server getting requests from a
>> client.  Without this patch, on about every other test run,
>> the server is missing many, many files that had been synced.
>> With this patch, on > 6 runs, I see zero files being lost.
>>
>> Signed-off-by: Curt Wohlgemuth <curtw@google.com>
>> ---
>>  fs/ext4/fsync.c |   11 ++++++++++-
>>  1 files changed, 10 insertions(+), 1 deletions(-)
>>
>> diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
>> index 7f74019..a276348 100644
>> --- a/fs/ext4/fsync.c
>> +++ b/fs/ext4/fsync.c
>> @@ -128,6 +128,7 @@ extern int ext4_flush_completed_IO(struct inode *inode)
>>  static void ext4_sync_parent(struct inode *inode)
>>  {
>>       struct dentry *dentry = NULL;
>> +     int ret;
>>
>>       while (inode && ext4_test_inode_state(inode, EXT4_STATE_NEWENTRY)) {
>>               ext4_clear_inode_state(inode, EXT4_STATE_NEWENTRY);
>> @@ -136,7 +137,15 @@ static void ext4_sync_parent(struct inode *inode)
>>               if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode)
>>                       break;
>>               inode = dentry->d_parent->d_inode;
>> -             sync_mapping_buffers(inode->i_mapping);
>> +             ret = sync_mapping_buffers(inode->i_mapping);
>> +             if (! ret) {
>> +                     struct writeback_control wbc = {
>> +                             .sync_mode = WB_SYNC_ALL,
>> +                             .nr_to_write = 0, /* metadata-only; caller
>> +                                                  takes care of data */
>> +                     };
>> +                     (void)sync_inode(inode, &wbc);
>
> I know ext4_sync_parent was a void already, but why don't we send errors back up through ext4_sync_file?

Well, you could argue that a failure to sync the parent shouldn't
cause the inode's fsync() to fail, but I probably wouldn't :-) .  I'll
resend a patch that implements this.

Thanks,
Curt

>
> -Eric
>
>> +             }
>>       }
>>  }
>>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-04-05 19:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05 19:27 [PATCH] ext4: sync the directory inode in ext4_sync_parent() Curt Wohlgemuth
2011-04-05 19:35 ` Eric Sandeen
2011-04-05 19:43   ` Curt Wohlgemuth [this message]
2011-04-05 19:46     ` Eric Sandeen
  -- strict thread matches above, loose matches on Subject: below --
2011-04-05 23:24 Curt Wohlgemuth
2011-04-06 21:01 ` Ted Ts'o

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=BANLkTin2VdByS23f0Gg-m77wUr3RVYgkiQ@mail.gmail.com \
    --to=curtw@google.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /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;
as well as URLs for NNTP newsgroup(s).