@@ -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);
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> --- fs/zonefs/super.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)