Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757383AbdIIIaX convert rfc822-to-8bit (ORCPT ); Sat, 9 Sep 2017 04:30:23 -0400 Received: from nov-007-i584.relay.mailchannels.net ([46.232.183.138]:5457 "EHLO nov-007-i584.relay.mailchannels.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753302AbdIIIaT (ORCPT ); Sat, 9 Sep 2017 04:30:19 -0400 X-Greylist: delayed 364 seconds by postgrey-1.27 at vger.kernel.org; Sat, 09 Sep 2017 04:30:18 EDT X-Sender-Id: novatrend|x-authuser|juerg@bitron.ch X-Sender-Id: novatrend|x-authuser|juerg@bitron.ch X-MC-Relay: Neutral X-MailChannels-SenderId: novatrend|x-authuser|juerg@bitron.ch X-MailChannels-Auth-Id: novatrend X-Name-Thoughtful: 3a9652543c21845f_1504945449604_2813164852 X-MC-Loop-Signature: 1504945449604:3816353000 X-MC-Ingress-Time: 1504945449603 From: =?UTF-8?q?J=C3=BCrg=20Billeter?= To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=BCrg=20Billeter?= Subject: [PATCH] fs: add RWF_APPEND Date: Sat, 9 Sep 2017 10:23:49 +0200 Message-Id: <20170909082349.56636-1-j@bitron.ch> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-AuthUser: juerg@bitron.ch Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1547 Lines: 45 This is the per-I/O equivalent of O_APPEND to support atomic append operations on any open file. On Linux, if a file is opened with O_APPEND, pwrite() ignores the offset and always appends data to the end of the file. RWF_APPEND enables atomic append and pwrite() with offset on a single file descriptor. Signed-off-by: Jürg Billeter --- include/linux/fs.h | 2 ++ include/uapi/linux/fs.h | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index e723b62c4b81..5f27ef9cce17 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3187,6 +3187,8 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags) ki->ki_flags |= IOCB_DSYNC; if (flags & RWF_SYNC) ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC); + if (flags & RWF_APPEND) + ki->ki_flags |= IOCB_APPEND; return 0; } diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index ea84938da405..5477480d0502 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -330,7 +330,11 @@ typedef int __bitwise __kernel_rwf_t; /* per-IO, return -EAGAIN if operation would block */ #define RWF_NOWAIT ((__force __kernel_rwf_t)0x00000008) +/* per-IO O_APPEND */ +#define RWF_APPEND ((__force __kernel_rwf_t)0x00000010) + /* mask of flags supported by the kernel */ -#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT) +#define RWF_SUPPORTED \ + (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT | RWF_APPEND) #endif /* _UAPI_LINUX_FS_H */ -- 2.14.1