linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] zonefs: add support zone capacity support
@ 2020-07-16 10:16 Johannes Thumshirn
  2020-07-16 10:16 ` [PATCH 1/2] zonefs: add zone-capacity support Johannes Thumshirn
  2020-07-16 10:16 ` [PATCH 2/2] zonefs: update documentation to reflect zone size vs capacity Johannes Thumshirn
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2020-07-16 10:16 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: linux-fsdevel, Johannes Thumshirn

Add support for zone capacity to zonefs. For devices which expose a zone capacity
that is different to the zone's size, the maximum zonefs file size will be set
to the zone's (usable) capacity, not the zone size.

Johannes Thumshirn (2):
  zonefs: add zone-capacity support
  zonefs: update documentation to reflect zone size vs capacity

 Documentation/filesystems/zonefs.rst | 17 +++++++++--------
 fs/zonefs/super.c                    |  9 +++++----
 fs/zonefs/zonefs.h                   |  3 +++
 3 files changed, 17 insertions(+), 12 deletions(-)

-- 
2.26.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] zonefs: add zone-capacity support
  2020-07-16 10:16 [PATCH 0/2] zonefs: add support zone capacity support Johannes Thumshirn
@ 2020-07-16 10:16 ` Johannes Thumshirn
  2020-07-17  9:04   ` Damien Le Moal
  2020-07-16 10:16 ` [PATCH 2/2] zonefs: update documentation to reflect zone size vs capacity Johannes Thumshirn
  1 sibling, 1 reply; 4+ messages in thread
From: Johannes Thumshirn @ 2020-07-16 10:16 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: linux-fsdevel, Johannes Thumshirn

In the zoned storage model, the sectors within a zone are typically all
writeable. With the introduction of the Zoned Namespace (ZNS) Command
Set in the NVM Express organization, the model was extended to have a
specific writeable capacity.

This zone capacity can be less than the overall zone size for a NVMe ZNS
device. For other zoned block devices like ZBC or null_blk in zoned-mode
the zone capacity is always equal to the zone size.

Use the zone capacity field instead from blk_zone for determining the
maximum inode size and inode blocks in zonefs.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/zonefs/super.c  | 9 +++++----
 fs/zonefs/zonefs.h | 3 +++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index 07bc42d62673..5b7ced5c643b 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -335,7 +335,7 @@ static void zonefs_io_error(struct inode *inode, bool write)
 	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
 	unsigned int noio_flag;
 	unsigned int nr_zones =
-		zi->i_max_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
+		zi->i_zone_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
 	struct zonefs_ioerr_data err = {
 		.inode = inode,
 		.write = write,
@@ -398,7 +398,7 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize)
 		goto unlock;
 
 	ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
-			       zi->i_max_size >> SECTOR_SHIFT, GFP_NOFS);
+			       zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
 	if (ret) {
 		zonefs_err(inode->i_sb,
 			   "Zone management operation at %llu failed %d",
@@ -1050,14 +1050,15 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
 
 	zi->i_ztype = type;
 	zi->i_zsector = zone->start;
+	zi->i_zone_size = zone->len << SECTOR_SHIFT;
 	zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
-			       zone->len << SECTOR_SHIFT);
+			       zone->capacity << SECTOR_SHIFT);
 	zi->i_wpoffset = zonefs_check_zone_condition(inode, zone, true, true);
 
 	inode->i_uid = sbi->s_uid;
 	inode->i_gid = sbi->s_gid;
 	inode->i_size = zi->i_wpoffset;
-	inode->i_blocks = zone->len;
+	inode->i_blocks = zi->i_max_size >> SECTOR_SHIFT;
 
 	inode->i_op = &zonefs_file_inode_operations;
 	inode->i_fop = &zonefs_file_operations;
diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
index ad17fef7ce91..55b39970acb2 100644
--- a/fs/zonefs/zonefs.h
+++ b/fs/zonefs/zonefs.h
@@ -56,6 +56,9 @@ struct zonefs_inode_info {
 	/* File maximum size */
 	loff_t			i_max_size;
 
+	/* File zone size */
+	loff_t			i_zone_size;
+
 	/*
 	 * To serialise fully against both syscall and mmap based IO and
 	 * sequential file truncation, two locks are used. For serializing
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] zonefs: update documentation to reflect zone size vs capacity
  2020-07-16 10:16 [PATCH 0/2] zonefs: add support zone capacity support Johannes Thumshirn
  2020-07-16 10:16 ` [PATCH 1/2] zonefs: add zone-capacity support Johannes Thumshirn
@ 2020-07-16 10:16 ` Johannes Thumshirn
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2020-07-16 10:16 UTC (permalink / raw)
  To: Damien Le Moal; +Cc: linux-fsdevel, Johannes Thumshirn

Update the zonefs documentation to reflect the difference between a zone's
size and it's capacity.

The maximum file size in zonefs is the zones capacity, for ZBC and ZAC
based devices, which do not have a separate zone capacity, the zone
capacity is equal to the zone size.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 Documentation/filesystems/zonefs.rst | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/Documentation/filesystems/zonefs.rst b/Documentation/filesystems/zonefs.rst
index 71d845c6a700..6c18bc8ce332 100644
--- a/Documentation/filesystems/zonefs.rst
+++ b/Documentation/filesystems/zonefs.rst
@@ -110,14 +110,14 @@ contain files named "0", "1", "2", ... The file numbers also represent
 increasing zone start sector on the device.
 
 All read and write operations to zone files are not allowed beyond the file
-maximum size, that is, beyond the zone size. Any access exceeding the zone
-size is failed with the -EFBIG error.
+maximum size, that is, beyond the zone capacity. Any access exceeding the zone
+capacity is failed with the -EFBIG error.
 
 Creating, deleting, renaming or modifying any attribute of files and
 sub-directories is not allowed.
 
 The number of blocks of a file as reported by stat() and fstat() indicates the
-size of the file zone, or in other words, the maximum file size.
+capacity of the zone file, or in other words, the maximum file size.
 
 Conventional zone files
 -----------------------
@@ -156,8 +156,8 @@ all accepted.
 
 Truncating sequential zone files is allowed only down to 0, in which case, the
 zone is reset to rewind the file zone write pointer position to the start of
-the zone, or up to the zone size, in which case the file's zone is transitioned
-to the FULL state (finish zone operation).
+the zone, or up to the zone capacity, in which case the file's zone is
+transitioned to the FULL state (finish zone operation).
 
 Format options
 --------------
@@ -324,7 +324,7 @@ file size set to 0. This is necessary as the write pointer of read-only zones
 is defined as invalib by the ZBC and ZAC standards, making it impossible to
 discover the amount of data that has been written to the zone. In the case of a
 read-only zone discovered at run-time, as indicated in the previous section.
-the size of the zone file is left unchanged from its last updated value.
+The size of the zone file is left unchanged from its last updated value.
 
 Zonefs User Space Tools
 =======================
@@ -401,8 +401,9 @@ append-writes to the file::
     # ls -l /mnt/seq/0
     -rw-r----- 1 root root 0 Nov 25 13:49 /mnt/seq/0
 
-Since files are statically mapped to zones on the disk, the number of blocks of
-a file as reported by stat() and fstat() indicates the size of the file zone::
+Since files are statically mapped to zones on the disk, the number of blocks
+of a file as reported by stat() and fstat() indicates the capacity of the file
+zone::
 
     # stat /mnt/seq/0
     File: /mnt/seq/0
@@ -416,5 +417,6 @@ a file as reported by stat() and fstat() indicates the size of the file zone::
 
 The number of blocks of the file ("Blocks") in units of 512B blocks gives the
 maximum file size of 524288 * 512 B = 256 MB, corresponding to the device zone
-size in this example. Of note is that the "IO block" field always indicates the
-minimum I/O size for writes and corresponds to the device physical sector size.
+capacity in this example. Of note is that the "IO block" field always
+indicates the minimum I/O size for writes and corresponds to the device
+physical sector size.
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] zonefs: add zone-capacity support
  2020-07-16 10:16 ` [PATCH 1/2] zonefs: add zone-capacity support Johannes Thumshirn
@ 2020-07-17  9:04   ` Damien Le Moal
  0 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2020-07-17  9:04 UTC (permalink / raw)
  To: Johannes Thumshirn; +Cc: linux-fsdevel

On 2020/07/16 19:16, Johannes Thumshirn wrote:
> In the zoned storage model, the sectors within a zone are typically all
> writeable. With the introduction of the Zoned Namespace (ZNS) Command
> Set in the NVM Express organization, the model was extended to have a
> specific writeable capacity.
> 
> This zone capacity can be less than the overall zone size for a NVMe ZNS
> device. For other zoned block devices like ZBC or null_blk in zoned-mode
> the zone capacity is always equal to the zone size.
> 
> Use the zone capacity field instead from blk_zone for determining the
> maximum inode size and inode blocks in zonefs.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/zonefs/super.c  | 9 +++++----
>  fs/zonefs/zonefs.h | 3 +++
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index 07bc42d62673..5b7ced5c643b 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -335,7 +335,7 @@ static void zonefs_io_error(struct inode *inode, bool write)
>  	struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
>  	unsigned int noio_flag;
>  	unsigned int nr_zones =
> -		zi->i_max_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
> +		zi->i_zone_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
>  	struct zonefs_ioerr_data err = {
>  		.inode = inode,
>  		.write = write,
> @@ -398,7 +398,7 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize)
>  		goto unlock;
>  
>  	ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
> -			       zi->i_max_size >> SECTOR_SHIFT, GFP_NOFS);
> +			       zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
>  	if (ret) {
>  		zonefs_err(inode->i_sb,
>  			   "Zone management operation at %llu failed %d",
> @@ -1050,14 +1050,15 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
>  
>  	zi->i_ztype = type;
>  	zi->i_zsector = zone->start;
> +	zi->i_zone_size = zone->len << SECTOR_SHIFT;
>  	zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
> -			       zone->len << SECTOR_SHIFT);
> +			       zone->capacity << SECTOR_SHIFT);

For conventional zones with the aggr_cnv format option, zone->len has the total
size of the aggregated zones. zone->capacity needs to have this value too. So
may be add something like:

	zi->i_zone_size = zone->len << SECTOR_SHIFT;
	if (type == ZONEFS_ZTYPE_CNV)
		zone->capacity = zone->len;

here.

Also, you should check in zonefs_create_zgroup() that for conventional zones,
the zone capacity must be equal to the zone size when the aggr_cnv option is
enabled. And you can addup the capacities in that funtion too in place of the
above change.

>  	zi->i_wpoffset = zonefs_check_zone_condition(inode, zone, true, true);
>  
>  	inode->i_uid = sbi->s_uid;
>  	inode->i_gid = sbi->s_gid;
>  	inode->i_size = zi->i_wpoffset;
> -	inode->i_blocks = zone->len;
> +	inode->i_blocks = zi->i_max_size >> SECTOR_SHIFT;
>  
>  	inode->i_op = &zonefs_file_inode_operations;
>  	inode->i_fop = &zonefs_file_operations;
> diff --git a/fs/zonefs/zonefs.h b/fs/zonefs/zonefs.h
> index ad17fef7ce91..55b39970acb2 100644
> --- a/fs/zonefs/zonefs.h
> +++ b/fs/zonefs/zonefs.h
> @@ -56,6 +56,9 @@ struct zonefs_inode_info {
>  	/* File maximum size */
>  	loff_t			i_max_size;
>  
> +	/* File zone size */
> +	loff_t			i_zone_size;
> +
>  	/*
>  	 * To serialise fully against both syscall and mmap based IO and
>  	 * sequential file truncation, two locks are used. For serializing
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-17  9:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 10:16 [PATCH 0/2] zonefs: add support zone capacity support Johannes Thumshirn
2020-07-16 10:16 ` [PATCH 1/2] zonefs: add zone-capacity support Johannes Thumshirn
2020-07-17  9:04   ` Damien Le Moal
2020-07-16 10:16 ` [PATCH 2/2] zonefs: update documentation to reflect zone size vs capacity Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).