Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742070 > unrolled thread

[RESEND PATCH] fs: add RWF_APPEND

Started byJürg Billeter <j@bitron.ch>
First post2017-09-29 14:10 +0200
Last post2017-10-01 10:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [RESEND PATCH] fs: add RWF_APPEND Jürg Billeter <j@bitron.ch> - 2017-09-29 14:10 +0200
    Re: [RESEND PATCH] fs: add RWF_APPEND Goldwyn Rodrigues <rgoldwyn@suse.de> - 2017-10-01 02:40 +0200
    Re: [RESEND PATCH] fs: add RWF_APPEND Christoph Hellwig <hch@infradead.org> - 2017-10-01 10:30 +0200

#1742070 — [RESEND PATCH] fs: add RWF_APPEND

FromJürg Billeter <j@bitron.ch>
Date2017-09-29 14:10 +0200
Subject[RESEND PATCH] fs: add RWF_APPEND
Message-ID<uv2hb-60A-5@gated-at.bofh.it>
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.

Signed-off-by: Jürg Billeter <j@bitron.ch>
---
 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 */
-- 
2.14.1

[toc] | [next] | [standalone]


#1742718

FromGoldwyn Rodrigues <rgoldwyn@suse.de>
Date2017-10-01 02:40 +0200
Message-ID<uvAsy-3at-13@gated-at.bofh.it>
In reply to#1742070

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 <rgoldwyn@suse.com>

> Signed-off-by: Jürg Billeter <j@bitron.ch>
> ---
>  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

[toc] | [prev] | [next] | [standalone]


#1742750

FromChristoph Hellwig <hch@infradead.org>
Date2017-10-01 10:30 +0200
Message-ID<uvHNo-87X-3@gated-at.bofh.it>
In reply to#1742070
Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web