From patchwork Mon Jul 20 12:29:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11673685 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 730D713B4 for ; Mon, 20 Jul 2020 12:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BE4722BF3 for ; Mon, 20 Jul 2020 12:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="dHPkxL4i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728506AbgGTM3K (ORCPT ); Mon, 20 Jul 2020 08:29:10 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:47819 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728471AbgGTM3J (ORCPT ); Mon, 20 Jul 2020 08:29:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1595248149; x=1626784149; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cD3MeoEIMIB0q/wYOlKOlaGoZEb1Ib0D2oLnuh3P1JI=; b=dHPkxL4iCkTCSTCXv8kGpWDTLLKCLztQwDqnIwsoG0lf3m+O4Kwp0e4M jOT0XSTpRxujrx+Xn776fltmB/hy5Ho+jAYu54JX8lz2jgMBZY3v1pZZp 3U/5I0pLxBfmg+T04N6/dmz/LMwtMB63dDYNv/Za6NHE+9VJ34gANOEfI XPfuFFaWn1hdBJc8SZmU0DnNvAQzC1H4Gcj+cdejrA7WVSdHJvZcU5VIs 425tIuGEBCyKHvlqx2rAk+C2A/XSVO39Upqsk0xBWqHcBRQGtrVZUz1T0 cvc9VGAR3A2BVJwbn/YGf5uE67kH+qSRwgO0zT2XVlSTuLNIoqdtUu2s2 w==; IronPort-SDR: dBItijofkJjVK2EBTvsiJVqMoizJMMupzZtMYU9CPU0kFG2VXzFOKoKWJF86BGH2Q0H+kxhSnd HLDO4cmkbZ8urqZ15azwigBPQ5eZE8qAv+3+MMYrw34Hect/RdOv/WLGN0q1iMooh7aZ7Fkwhd ZoUOV00re8Pnd/cvCOfyZAuXRRmgwahCVrvlKb46KDKsyMQOEYPY5AGeBYi4Z/YCKnFGgifAvZ KYWnI1GGV1weuS1hFE6U938j2GrPOkL2m2UqOG6HhfJ/85CaW1BcnjebANiZ/tJsNHtBIzjOTl cHY= X-IronPort-AV: E=Sophos;i="5.75,375,1589212800"; d="scan'208";a="142913128" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jul 2020 20:29:08 +0800 IronPort-SDR: Jo+sWW9EZhli25rVav0l3EbTziHatuRbJRDOFPyzP1E9wBjB293iq0uYD2oSPUDlCE5GBjN7Ov ZBMdgEiKPZ1qu8UeWtoCjsPt1Zlm1etHM= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 05:16:53 -0700 IronPort-SDR: 6wVYjeZfCDnTQItoXPIBqmFT74wIFo23AFds1h3hTfMlUX2+J1j58lQIiPB83ksYP2LjGH9mq/ sDLJ+tEV6Aew== WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 20 Jul 2020 05:29:08 -0700 From: Johannes Thumshirn To: Damien Le Moal Cc: linux-fsdevel@vger.kernel.org, Johannes Thumshirn Subject: [PATCH v3 1/2] zonefs: add zone-capacity support Date: Mon, 20 Jul 2020 21:29:02 +0900 Message-Id: <20200720122903.6221-2-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200720122903.6221-1-johannes.thumshirn@wdc.com> References: <20200720122903.6221-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 or null_blk in zoned-mode. For other ZBC/ZAC devices 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 --- fs/zonefs/super.c | 15 +++++++++++---- fs/zonefs/zonefs.h | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index abfb17f88f9a..b7aefb1b896f 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,16 @@ 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; @@ -1164,12 +1166,17 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd, if (zonefs_zone_type(next) != type) break; zone->len += next->len; + zone->capacity += next->capacity; if (next->cond == BLK_ZONE_COND_READONLY && zone->cond != BLK_ZONE_COND_OFFLINE) zone->cond = BLK_ZONE_COND_READONLY; else if (next->cond == BLK_ZONE_COND_OFFLINE) zone->cond = BLK_ZONE_COND_OFFLINE; } + if (zone->capacity != zone->len) { + zonefs_err(sb, "Invalid conventional zone capacity\n"); + ret = -EINVAL; + } } /* 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 From patchwork Mon Jul 20 12:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 11673687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DD6513B4 for ; Mon, 20 Jul 2020 12:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7484522B4E for ; Mon, 20 Jul 2020 12:29:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="m3mMb4O9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728532AbgGTM3L (ORCPT ); Mon, 20 Jul 2020 08:29:11 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:47819 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727989AbgGTM3L (ORCPT ); Mon, 20 Jul 2020 08:29:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1595248150; x=1626784150; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KALZF4NqHXC9qoy6I4teMnQITGGpyunub/V7H6Pi3g4=; b=m3mMb4O9e5p5RhTTFArF9oGUJlPz7N6bmqCf1wXUdMUjsD4JCKEZPJV1 db2ua8cN2l4LXMCBzrEAucTsTdheY4ZJogySRIyNMTxIMnXJdLXN0tkQY uJ8ZhS/u5slab7lg8s6bgrf3ekzY/2I9CQfIjltzTrO/6D3fUJaKYz+ry K7BCPXSzFfqz0rv1ataST825/J3EUER/8XMsZYZoFQOJjlsm2O8d8r6gl BpVL/DAMSPo5RUpS8XM7Cm9tHMcPEYA0f9xMFeYwy7GYT8or/0LheZwb+ jVHDT3FiEQB+61Y+A9iAhYNmrFVVqPDB6+cStTLiFUiLloN+IaPq+5Co8 A==; IronPort-SDR: ysLKdv55lkTtM7uVFYa7pmHRobtuvvLyOqbMRkqyEN/YatGuFGePVgUe1nNoioMwDyqlDQsrhk jOW61GPSC0a9/30/BABBQdfBITwva0H3kuMQili/qxfRlpOTrgJDSz75EPDvCWwYf6oIHm8CPy XQ5EhUzJwXC6DhzcdXqjqBAfcarsz5563vtpiPoRYD7KeF6GsozpDRgeWeaQA28qhpD3HIQ+m2 aI4DI7sJ1y7OFXXvN6X1dG3AvbRwDUpvojjEnnSGrhKlwL6mju3g5dIfYPt+K/kWBJyvq7wAJ9 o1w= X-IronPort-AV: E=Sophos;i="5.75,375,1589212800"; d="scan'208";a="142913129" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Jul 2020 20:29:09 +0800 IronPort-SDR: +CsYFt85CjRPFRV+ptHgKg5uOAfWS7nJea/7vpgep3AVkbfjg5dZKj3QMXjtiA4FQzQ/kUKJg7 xypfmVuQrH0hS9iW4Latl84xG0fXD0HpA= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2020 05:16:54 -0700 IronPort-SDR: n0mcHTyQF/59/L5ewSTPj3Sv7RdOcQbhduPOsyji3kaLK3HXKaBzYmo7m77I8a3mhCtKkURXiQ U8ddecWjW0Dg== WDCIronportException: Internal Received: from unknown (HELO redsun60.ssa.fujisawa.hgst.com) ([10.149.66.36]) by uls-op-cesaip02.wdc.com with ESMTP; 20 Jul 2020 05:29:09 -0700 From: Johannes Thumshirn To: Damien Le Moal Cc: linux-fsdevel@vger.kernel.org, Johannes Thumshirn Subject: [PATCH v3 2/2] zonefs: update documentation to reflect zone size vs capacity Date: Mon, 20 Jul 2020 21:29:03 +0900 Message-Id: <20200720122903.6221-3-johannes.thumshirn@wdc.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200720122903.6221-1-johannes.thumshirn@wdc.com> References: <20200720122903.6221-1-johannes.thumshirn@wdc.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 --- 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.