Attention is currently required from: Frank Filz.

Vamsi Mulpuri <vamsimulpuri@google.com> would like Frank Filz to review this change.

View Change

FSAL_VFS: Sync parent directory after namespace changes

FSAL_VFS creates, links, renames and removes directory entries and
replies as soon as the syscall returns, but nothing forces the
directory change to disk. RFC 1813 (section 1.6) lists CREATE, MKDIR,
SYMLINK, MKNOD, REMOVE, RMDIR, RENAME and LINK as synchronous, and
clients do not replay them after a server reboot, so a host crash
right after the reply can undo a change the client was told had
succeeded.

We hit this in a crash test. NFSv4.1 clients wrote files to a
temporary name, fsynced them and renamed them into place while the
server host was reset with sysrq-b. After reboot and ext4 journal
recovery, 2 of 375 acknowledged renames were gone: the data was
intact under the temporary names, but the final names did not exist.

Add vfs_sync_dir(), which opens the parent directory by handle and
fsyncs it. Call it after each successful mkdir, mknod, symlink, link,
rename, unlink/rmdir and open with O_CREAT, before replying. Rename
syncs both directories when they differ. If the sync fails, return
the error instead of reporting success. knfsd commits the parent
directory at the same points through commit_metadata() on sync
exports; unlike knfsd, this change does not also commit the new
inode or SETATTR.

The cost is a directory fsync per namespace change, two for a
cross-directory rename. On our test setup, ext4 on a 3-way replicated
block device, the median write-fsync-rename time per file went from
33 ms to 41-47 ms. With this change, two crash runs lost none of 609
acknowledged files.

Change-Id: I9b873f773d8074eebc86628cd1320501ac047441
Signed-off-by: Vamsi Mulpuri <vamsimulpuri@google.com>
---
M src/FSAL/FSAL_VFS/file.c
M src/FSAL/FSAL_VFS/handle.c
M src/FSAL/FSAL_VFS/vfs_methods.h
3 files changed, 67 insertions(+), 0 deletions(-)

git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/35/1256335/1

To view, visit change 1256335. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: I9b873f773d8074eebc86628cd1320501ac047441
Gerrit-Change-Number: 1256335
Gerrit-PatchSet: 1
Gerrit-Owner: Vamsi Mulpuri <vamsimulpuri@google.com>
Gerrit-Reviewer: Frank Filz <ffilzlnx@mindspring.com>
Gerrit-CC: Jim Chen <czcbangkai@google.com>
Gerrit-Attention: Frank Filz <ffilzlnx@mindspring.com>