[v2,11/11] zonefs: use zone-append for sequential zones
diff mbox series

Message ID 20200324152454.4954-12-johannes.thumshirn@wdc.com
State New
Headers show
Series
  • Introduce Zone Append for writing to zoned block devices
Related show

Commit Message

Johannes Thumshirn March 24, 2020, 3:24 p.m. UTC
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/zonefs/super.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Patch
diff mbox series

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);