Commit 059c0103 authored by Shin'ichiro Kawasaki's avatar Shin'ichiro Kawasaki Committed by Damien Le Moal
Browse files

zonefs: Fix file size of zones in full condition



Per ZBC/ZAC/ZNS specifications, write pointers may not have valid values
when zones are in full condition. However, when zonefs mounts a zoned
block device, zonefs refers write pointers to set file size even when
the zones are in full condition. This results in wrong file size. To fix
this, refer maximum file size in place of write pointers for zones in
full condition.

Signed-off-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fixes: 8dcc1a9d ("fs: New zonefs file system")
Cc: <stable@vger.kernel.org> # 5.6+
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
parent 62ab1aad
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -256,6 +256,9 @@ static loff_t zonefs_check_zone_condition(struct inode *inode,
		}
		}
		inode->i_mode &= ~0222;
		inode->i_mode &= ~0222;
		return i_size_read(inode);
		return i_size_read(inode);
	case BLK_ZONE_COND_FULL:
		/* The write pointer of full zones is invalid. */
		return zi->i_max_size;
	default:
	default:
		if (zi->i_ztype == ZONEFS_ZTYPE_CNV)
		if (zi->i_ztype == ZONEFS_ZTYPE_CNV)
			return zi->i_max_size;
			return zi->i_max_size;