Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751757AbdJAAcF (ORCPT ); Sat, 30 Sep 2017 20:32:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:50745 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751217AbdJAAcD (ORCPT ); Sat, 30 Sep 2017 20:32:03 -0400 Subject: Re: [RESEND PATCH] fs: add RWF_APPEND To: =?UTF-8?Q?J=c3=bcrg_Billeter?= , Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170929120717.47515-1-j@bitron.ch> From: Goldwyn Rodrigues Message-ID: <5b26363b-e2cf-294e-728a-640d7820d9ae@suse.de> Date: Sat, 30 Sep 2017 19:31:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170929120717.47515-1-j@bitron.ch> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1862 Lines: 56 On 09/29/2017 07:07 AM, Jürg Billeter wrote: > This is the per-I/O equivalent of O_APPEND to support atomic append > operations on any open file. > > 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. > I think similarly we can introduce RWF_DIRECT, though I am not sure if users would want to mix buffered writes and direct writes. Reviewed-by: Goldwyn Rodrigues > 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 339e73742e73..fee24eae7523 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -3204,6 +3204,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 56235dddea7d..ac145430bcd8 100644 > --- a/include/uapi/linux/fs.h > +++ b/include/uapi/linux/fs.h > @@ -376,7 +376,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 */ > -- Goldwyn