Skip to contentSkip to conversation

f2fs: zone: fix to don't trigger OPU on pinfile for direct IO

PATCH Superseded Chao Yu 3 participants 6 messages Apr 26, 2024 – Apr 27, 2024 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Chao Yu

author maintainer
#0 lore raw

PATCH 1/1 f2fs: zone: fix to don't trigger OPU on pinfile for direct IO

Otherwise, it breaks pinfile's sematics.

Cc Daeho Jeong <[email protected]>
---
 fs/f2fs/data.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -1
index bee1e45f76b8..e29000d83d52 100644
@@ -1596,7 +1596,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
 
 	/* use out-place-update for direct IO under LFS mode */
 	if (map->m_may_create &&
-	    (is_hole || (f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO))) {
+	    (is_hole || (flag == F2FS_GET_BLOCK_DIO && (f2fs_lfs_mode(sbi) &&
+	    (!f2fs_sb_has_blkzoned(sbi) || !f2fs_is_pinned_file(inode)))))) {
 		if (unlikely(f2fs_cp_error(sbi))) {
 			err = -EIO;
 			goto sync_out;
Signature · 1 line
2.40.1
#1 lore raw

Dear Chao,

Quoted 14 lines · Chao Yu

Otherwise, it breaks pinfile's sematics.

Cc Daeho Jeong <[email protected]>
---
 fs/f2fs/data.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index bee1e45f76b8..e29000d83d52 100644

fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) · line 1600

Quoted 6 lines
fs/f2fs/data.c +2 -1
@@ -1596,7 +1596,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
 
        /* use out-place-update for direct IO under LFS mode */
        if (map->m_may_create &&
-           (is_hole || (f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO))) {
+           (is_hole || (flag == F2FS_GET_BLOCK_DIO && (f2fs_lfs_mode(sbi) &&
+           (!f2fs_sb_has_blkzoned(sbi) || !f2fs_is_pinned_file(inode)))))) {

Excuse me I a little question, should pin files not be written in OPU mode regardless of device type(conventional or zone)? thanks!

Quoted 12 lines
fs/f2fs/data.c +0 -1
                if (unlikely(f2fs_cp_error(sbi))) {
                        err = -EIO;
                        goto sync_out;
--

2.40.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#2 lore raw
Quoted 18 lines · Zhiguo Niu

Dear Chao,

Quoted 15 lines · Chao Yu

Otherwise, it breaks pinfile's sematics.

Cc Daeho Jeong <[email protected]>
---
  fs/f2fs/data.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index bee1e45f76b8..e29000d83d52 100644
@@ -1596,7 +1596,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
 
Quoted 7 lines

fs/f2fs/data.c int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag) · line 1600

Quoted 5 lines
fs/f2fs/data.c +2 -1
         /* use out-place-update for direct IO under LFS mode */
         if (map->m_may_create &&
-           (is_hole || (f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO))) {
+           (is_hole || (flag == F2FS_GET_BLOCK_DIO && (f2fs_lfs_mode(sbi) &&
+           (!f2fs_sb_has_blkzoned(sbi) || !f2fs_is_pinned_file(inode)))))) {

Excuse me I a little question, should pin files not be written in OPU mode regardless of device type(conventional or zone)?

Agreed, so it looks we need remove !f2fs_sb_has_blkzoned condition here...

Thanks,

Quoted 13 lines

thanks!

Quoted 12 lines
fs/f2fs/data.c +0 -1
                 if (unlikely(f2fs_cp_error(sbi))) {
                         err = -EIO;
                         goto sync_out;
--

2.40.1

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
In reply to Chao Yu
Quoted 24 lines · Chao Yu

Otherwise, it breaks pinfile's sematics.

Cc Daeho Jeong <[email protected]>
---
 fs/f2fs/data.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -2
index bee1e45f76b8..e29000d83d52 100644
@@ -1596,7 +1596,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
 
        /* use out-place-update for direct IO under LFS mode */
        if (map->m_may_create &&
-           (is_hole || (f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO))) {
+           (is_hole || (flag == F2FS_GET_BLOCK_DIO && (f2fs_lfs_mode(sbi) &&
+           (!f2fs_sb_has_blkzoned(sbi) || !f2fs_is_pinned_file(inode)))))) {
                if (unlikely(f2fs_cp_error(sbi))) {
                        err = -EIO;
                        goto sync_out;
--
Quoted 1 line

2.40.1

So, we block overwrite io for the pinfile here.

static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)

{
...

        if (f2fs_is_pinned_file(inode) &&
            !f2fs_overwrite_io(inode, pos, count)) {
                ret = -EIO;
                goto out_unlock;
        }
Quoted 1 line
author maintainer
#4 lore raw
Quoted 16 lines · Daeho Jeong
Quoted 15 lines · Chao Yu

Otherwise, it breaks pinfile's sematics.

Cc Daeho Jeong <[email protected]>
---
  fs/f2fs/data.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index bee1e45f76b8..e29000d83d52 100644
@@ -1596,7 +1596,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
 
Quoted 12 lines
Quoted 10 lines
fs/f2fs/data.c +2 -2
         /* use out-place-update for direct IO under LFS mode */
         if (map->m_may_create &&
-           (is_hole || (f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO))) {
+           (is_hole || (flag == F2FS_GET_BLOCK_DIO && (f2fs_lfs_mode(sbi) &&
+           (!f2fs_sb_has_blkzoned(sbi) || !f2fs_is_pinned_file(inode)))))) {
                 if (unlikely(f2fs_cp_error(sbi))) {
                         err = -EIO;
                         goto sync_out;
--

2.40.1

So, we block overwrite io for the pinfile here.

I guess you mean we blocked append write for pinfile, right?

Quoted 7 lines

static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)

{
...

         if (f2fs_is_pinned_file(inode) &&
             !f2fs_overwrite_io(inode, pos, count)) {

If !f2fs_overwrite_io() is true, it means it may trigger append write on pinfile?

Thanks,

Quoted 6 lines
                 ret = -EIO;
                 goto out_unlock;
         }
Quoted 1 line
#5 lore raw
Quoted 36 lines · Chao Yu
Quoted 16 lines · Daeho Jeong
Quoted 15 lines · Chao Yu

Otherwise, it breaks pinfile's sematics.

Cc Daeho Jeong <[email protected]>
---
  fs/f2fs/data.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +0 -0
index bee1e45f76b8..e29000d83d52 100644
@@ -1596,7 +1596,8 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, int flag)
 
Quoted 12 lines
Quoted 10 lines
fs/f2fs/data.c +2 -2
         /* use out-place-update for direct IO under LFS mode */
         if (map->m_may_create &&
-           (is_hole || (f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO))) {
+           (is_hole || (flag == F2FS_GET_BLOCK_DIO && (f2fs_lfs_mode(sbi) &&
+           (!f2fs_sb_has_blkzoned(sbi) || !f2fs_is_pinned_file(inode)))))) {
                 if (unlikely(f2fs_cp_error(sbi))) {
                         err = -EIO;
                         goto sync_out;
--

2.40.1

So, we block overwrite io for the pinfile here.

I guess you mean we blocked append write for pinfile, right?

Quoted 3 lines

static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)

Quoted 7 lines
Quoted 4 lines

{
...

         if (f2fs_is_pinned_file(inode) &&
             !f2fs_overwrite_io(inode, pos, count)) {

If !f2fs_overwrite_io() is true, it means it may trigger append write on pinfile?

Yes, I missed it. Thanks~

Quoted 9 lines

Thanks,

Quoted 6 lines
                 ret = -EIO;
                 goto out_unlock;
         }
Quoted 1 line