Signed-off-by: Johannes Thumshirn <redacted>
---
fs/zonefs/super.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 69aee3dfb660..d08d715c99de 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -628,12 +628,17 @@ static ssize_t zonefs_file_dio_write(struct kiocb *iocb, struct iov_iter *from)
goto inode_unlock;
}
- /* Enforce sequential writes (append only) in sequential zones */
mutex_lock(&zi->i_truncate_mutex);
- if (zi->i_ztype == ZONEFS_ZTYPE_SEQ && iocb->ki_pos != zi->i_wpoffset) {
- mutex_unlock(&zi->i_truncate_mutex);
- ret = -EINVAL;
- goto inode_unlock;
+ if (zi->i_ztype == ZONEFS_ZTYPE_SEQ) {
+ /* Enforce sequential writes (append only) */
+ if (iocb->ki_pos != zi->i_wpoffset) {
+ mutex_unlock(&zi->i_truncate_mutex);
+ ret = -EINVAL;
+ goto inode_unlock;
+ }
+ /* Use zone append for sync write */
+ if (is_sync_kiocb(iocb))
+ iocb->ki_flags |= IOCB_ZONE_APPEND;
}
mutex_unlock(&zi->i_truncate_mutex);
--
2.24.1