Commit 57d528bf authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'zonefs-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs

Pull zonefs update from Damien Le Moal:
 "A single change for this cycle adding support for zone capacities
  smaller than the zone size, from Johannes"

* tag 'zonefs-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
  zonefs: update documentation to reflect zone size vs capacity
  zonefs: add zone-capacity support
parents bb5baaa9 4c96870e
...@@ -110,14 +110,14 @@ contain files named "0", "1", "2", ... The file numbers also represent ...@@ -110,14 +110,14 @@ contain files named "0", "1", "2", ... The file numbers also represent
increasing zone start sector on the device. increasing zone start sector on the device.
All read and write operations to zone files are not allowed beyond the file 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 maximum size, that is, beyond the zone capacity. Any access exceeding the zone
size is failed with the -EFBIG error. capacity is failed with the -EFBIG error.
Creating, deleting, renaming or modifying any attribute of files and Creating, deleting, renaming or modifying any attribute of files and
sub-directories is not allowed. sub-directories is not allowed.
The number of blocks of a file as reported by stat() and fstat() indicates the 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 Conventional zone files
----------------------- -----------------------
...@@ -156,8 +156,8 @@ all accepted. ...@@ -156,8 +156,8 @@ all accepted.
Truncating sequential zone files is allowed only down to 0, in which case, the 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 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 the zone, or up to the zone capacity, in which case the file's zone is
to the FULL state (finish zone operation). transitioned to the FULL state (finish zone operation).
Format options Format options
-------------- --------------
...@@ -324,7 +324,7 @@ file size set to 0. This is necessary as the write pointer of read-only zones ...@@ -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 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 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. 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 Zonefs User Space Tools
======================= =======================
...@@ -401,8 +401,9 @@ append-writes to the file:: ...@@ -401,8 +401,9 @@ append-writes to the file::
# ls -l /mnt/seq/0 # ls -l /mnt/seq/0
-rw-r----- 1 root root 0 Nov 25 13:49 /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 Since files are statically mapped to zones on the disk, the number of blocks
a file as reported by stat() and fstat() indicates the size of the file zone:: of a file as reported by stat() and fstat() indicates the capacity of the file
zone::
# stat /mnt/seq/0 # stat /mnt/seq/0
File: /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:: ...@@ -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 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 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 capacity in this example. Of note is that the "IO block" field always
minimum I/O size for writes and corresponds to the device physical sector size. indicates the minimum I/O size for writes and corresponds to the device
physical sector size.
...@@ -335,7 +335,7 @@ static void zonefs_io_error(struct inode *inode, bool write) ...@@ -335,7 +335,7 @@ static void zonefs_io_error(struct inode *inode, bool write)
struct zonefs_sb_info *sbi = ZONEFS_SB(sb); struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
unsigned int noio_flag; unsigned int noio_flag;
unsigned int nr_zones = 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 = { struct zonefs_ioerr_data err = {
.inode = inode, .inode = inode,
.write = write, .write = write,
...@@ -398,7 +398,7 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize) ...@@ -398,7 +398,7 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize)
goto unlock; goto unlock;
ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector, 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) { if (ret) {
zonefs_err(inode->i_sb, zonefs_err(inode->i_sb,
"Zone management operation at %llu failed %d", "Zone management operation at %llu failed %d",
...@@ -1053,14 +1053,16 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone, ...@@ -1053,14 +1053,16 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
zi->i_ztype = type; zi->i_ztype = type;
zi->i_zsector = zone->start; zi->i_zsector = zone->start;
zi->i_zone_size = zone->len << SECTOR_SHIFT;
zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE, 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); zi->i_wpoffset = zonefs_check_zone_condition(inode, zone, true, true);
inode->i_uid = sbi->s_uid; inode->i_uid = sbi->s_uid;
inode->i_gid = sbi->s_gid; inode->i_gid = sbi->s_gid;
inode->i_size = zi->i_wpoffset; 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_op = &zonefs_file_inode_operations;
inode->i_fop = &zonefs_file_operations; inode->i_fop = &zonefs_file_operations;
...@@ -1167,12 +1169,18 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd, ...@@ -1167,12 +1169,18 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
if (zonefs_zone_type(next) != type) if (zonefs_zone_type(next) != type)
break; break;
zone->len += next->len; zone->len += next->len;
zone->capacity += next->capacity;
if (next->cond == BLK_ZONE_COND_READONLY && if (next->cond == BLK_ZONE_COND_READONLY &&
zone->cond != BLK_ZONE_COND_OFFLINE) zone->cond != BLK_ZONE_COND_OFFLINE)
zone->cond = BLK_ZONE_COND_READONLY; zone->cond = BLK_ZONE_COND_READONLY;
else if (next->cond == BLK_ZONE_COND_OFFLINE) else if (next->cond == BLK_ZONE_COND_OFFLINE)
zone->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;
goto free;
}
} }
/* /*
......
...@@ -56,6 +56,9 @@ struct zonefs_inode_info { ...@@ -56,6 +56,9 @@ struct zonefs_inode_info {
/* File maximum size */ /* File maximum size */
loff_t i_max_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 * To serialise fully against both syscall and mmap based IO and
* sequential file truncation, two locks are used. For serializing * sequential file truncation, two locks are used. For serializing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment