From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f41.google.com ([74.125.83.41]:33086 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755448AbcKVIZV (ORCPT ); Tue, 22 Nov 2016 03:25:21 -0500 Received: by mail-pg0-f41.google.com with SMTP id 3so5378858pgd.0 for ; Tue, 22 Nov 2016 00:25:21 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org Cc: linux-api@vger.kernel.org, kernel-team@fb.com, Xi Wang Subject: [RFC PATCH 0/3] fs: add AT_REPLACE flag for linkat() Date: Tue, 22 Nov 2016 00:25:00 -0800 Message-Id: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Omar Sandoval This is a proof-of-concept patch series implementing an AT_REPLACE flag for linkat(2) which allows us to replace the target. This is a nice primitive on its own, but it's most interesting when combined with O_TMPFILE, as it allows you to do an atomic update of a file with an O_TMPFILE. 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. Patch 2 adds a dcache helper for filesystem implementations of AT_REPLACE. I'm not entirely convinced that it's 100% correct. Patch 3 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. Any comments are welcome. Cc: Xi Wang Omar Sandoval (3): fs: add AT_REPLACE flag for linkat() which replaces the target vfs: add d_replace() Btrfs: add support for linkat() AT_REPLACE fs/btrfs/inode.c | 59 ++++++++++++++- fs/dcache.c | 68 +++++++++++++++-- fs/ecryptfs/inode.c | 2 +- fs/namei.c | 180 +++++++++++++++++++++++++++++++++++---------- fs/nfsd/vfs.c | 2 +- fs/overlayfs/overlayfs.h | 2 +- include/linux/dcache.h | 1 + include/linux/fs.h | 3 +- include/uapi/linux/fcntl.h | 1 + 9 files changed, 267 insertions(+), 51 deletions(-) -- 2.10.2