[RFC PATCH v3 0/2] fs: add AT_REPLACE flag for linkat()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Omar Sandoval <osandov@xxxxxx>

Hi, Al,

This is a respin of my linkat() AT_REPLACE series, previously posted
here:

https://patchwork.kernel.org/patch/9636735/
https://patchwork.kernel.org/patch/9636733/

There are no changes since v2, only a rebase onto v4.17-rc2 and some
minor additions to the commit messages.

The goal is to allow for updating a file atomically in-place with an
O_TMPFILE like so:

- open temporary file with O_TMPFILE
- write temporary file contents
- fsync temporary file
- atomically replace permanent location with the temporary file
- fsync parent directory

Patch 1 implements the VFS support for this flag. The implementation
resembles sys_renameat2(), and I took care to preserve all of the
original error cases and make the new error cases consistent with
rename.

Previously, we discussed extending renameat2() instead of linkat() for
this, but this makes a mess of rename and also forces us to special-case
the parent directory for O_TMPFILEs in implementations of
i_op->rename(), so I still think linkat() is a better fit.

Patch 2 adds support for AT_REPLACE to Btrfs. That's the codebase I'm
most familiar with so that's where I started, but it should be
straightforward to implement for other filesystems. v1 of this series
had some incorrect dentry fiddling, so now I just unhash the replaced
dentry for simplicity.

Please take a look.

Thanks!

Cc: Xi Wang <xi@xxxxxxxxxxxxxxxxx>

Omar Sandoval (2):
  fs: add AT_REPLACE flag for linkat() which replaces the target
  Btrfs: add support for linkat() AT_REPLACE

 fs/btrfs/inode.c           |  65 ++++++++++++-
 fs/ecryptfs/inode.c        |   2 +-
 fs/namei.c                 | 181 +++++++++++++++++++++++++++++--------
 fs/nfsd/vfs.c              |   2 +-
 fs/overlayfs/overlayfs.h   |   2 +-
 include/linux/fs.h         |   3 +-
 include/uapi/linux/fcntl.h |   1 +
 7 files changed, 211 insertions(+), 45 deletions(-)

-- 
2.17.0




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux