linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Cc: "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH 1/2] zonefs: add zone-capacity support
Date: Fri, 17 Jul 2020 09:04:18 +0000	[thread overview]
Message-ID: <CY4PR04MB3751D69A4D359090952DD358E77C0@CY4PR04MB3751.namprd04.prod.outlook.com> (raw)
In-Reply-To: <20200716101614.3468-2-johannes.thumshirn@wdc.com>

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

  reply	other threads:[~2020-07-17  9:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-07-16 10:16 ` [PATCH 2/2] zonefs: update documentation to reflect zone size vs capacity Johannes Thumshirn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4PR04MB3751D69A4D359090952DD358E77C0@CY4PR04MB3751.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --subject='Re: [PATCH 1/2] zonefs: add zone-capacity support' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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