Skip to content

Commit 57d528b

Browse files
committed
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
2 parents bb5baaa + 4c96870 commit 57d528b

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

Documentation/filesystems/zonefs.rst

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@ contain files named "0", "1", "2", ... The file numbers also represent
110110
increasing zone start sector on the device.
111111

112112
All read and write operations to zone files are not allowed beyond the file
113-
maximum size, that is, beyond the zone size. Any access exceeding the zone
114-
size is failed with the -EFBIG error.
113+
maximum size, that is, beyond the zone capacity. Any access exceeding the zone
114+
capacity is failed with the -EFBIG error.
115115

116116
Creating, deleting, renaming or modifying any attribute of files and
117117
sub-directories is not allowed.
118118

119119
The number of blocks of a file as reported by stat() and fstat() indicates the
120-
size of the file zone, or in other words, the maximum file size.
120+
capacity of the zone file, or in other words, the maximum file size.
121121

122122
Conventional zone files
123123
-----------------------
@@ -156,8 +156,8 @@ all accepted.
156156

157157
Truncating sequential zone files is allowed only down to 0, in which case, the
158158
zone is reset to rewind the file zone write pointer position to the start of
159-
the zone, or up to the zone size, in which case the file's zone is transitioned
160-
to the FULL state (finish zone operation).
159+
the zone, or up to the zone capacity, in which case the file's zone is
160+
transitioned to the FULL state (finish zone operation).
161161

162162
Format options
163163
--------------
@@ -324,7 +324,7 @@ file size set to 0. This is necessary as the write pointer of read-only zones
324324
is defined as invalib by the ZBC and ZAC standards, making it impossible to
325325
discover the amount of data that has been written to the zone. In the case of a
326326
read-only zone discovered at run-time, as indicated in the previous section.
327-
the size of the zone file is left unchanged from its last updated value.
327+
The size of the zone file is left unchanged from its last updated value.
328328

329329
Zonefs User Space Tools
330330
=======================
@@ -401,8 +401,9 @@ append-writes to the file::
401401
# ls -l /mnt/seq/0
402402
-rw-r----- 1 root root 0 Nov 25 13:49 /mnt/seq/0
403403

404-
Since files are statically mapped to zones on the disk, the number of blocks of
405-
a file as reported by stat() and fstat() indicates the size of the file zone::
404+
Since files are statically mapped to zones on the disk, the number of blocks
405+
of a file as reported by stat() and fstat() indicates the capacity of the file
406+
zone::
406407

407408
# stat /mnt/seq/0
408409
File: /mnt/seq/0
@@ -416,5 +417,6 @@ a file as reported by stat() and fstat() indicates the size of the file zone::
416417

417418
The number of blocks of the file ("Blocks") in units of 512B blocks gives the
418419
maximum file size of 524288 * 512 B = 256 MB, corresponding to the device zone
419-
size in this example. Of note is that the "IO block" field always indicates the
420-
minimum I/O size for writes and corresponds to the device physical sector size.
420+
capacity in this example. Of note is that the "IO block" field always
421+
indicates the minimum I/O size for writes and corresponds to the device
422+
physical sector size.

fs/zonefs/super.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static void zonefs_io_error(struct inode *inode, bool write)
335335
struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
336336
unsigned int noio_flag;
337337
unsigned int nr_zones =
338-
zi->i_max_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
338+
zi->i_zone_size >> (sbi->s_zone_sectors_shift + SECTOR_SHIFT);
339339
struct zonefs_ioerr_data err = {
340340
.inode = inode,
341341
.write = write,
@@ -398,7 +398,7 @@ static int zonefs_file_truncate(struct inode *inode, loff_t isize)
398398
goto unlock;
399399

400400
ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
401-
zi->i_max_size >> SECTOR_SHIFT, GFP_NOFS);
401+
zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
402402
if (ret) {
403403
zonefs_err(inode->i_sb,
404404
"Zone management operation at %llu failed %d",
@@ -1053,14 +1053,16 @@ static void zonefs_init_file_inode(struct inode *inode, struct blk_zone *zone,
10531053

10541054
zi->i_ztype = type;
10551055
zi->i_zsector = zone->start;
1056+
zi->i_zone_size = zone->len << SECTOR_SHIFT;
1057+
10561058
zi->i_max_size = min_t(loff_t, MAX_LFS_FILESIZE,
1057-
zone->len << SECTOR_SHIFT);
1059+
zone->capacity << SECTOR_SHIFT);
10581060
zi->i_wpoffset = zonefs_check_zone_condition(inode, zone, true, true);
10591061

10601062
inode->i_uid = sbi->s_uid;
10611063
inode->i_gid = sbi->s_gid;
10621064
inode->i_size = zi->i_wpoffset;
1063-
inode->i_blocks = zone->len;
1065+
inode->i_blocks = zi->i_max_size >> SECTOR_SHIFT;
10641066

10651067
inode->i_op = &zonefs_file_inode_operations;
10661068
inode->i_fop = &zonefs_file_operations;
@@ -1167,12 +1169,18 @@ static int zonefs_create_zgroup(struct zonefs_zone_data *zd,
11671169
if (zonefs_zone_type(next) != type)
11681170
break;
11691171
zone->len += next->len;
1172+
zone->capacity += next->capacity;
11701173
if (next->cond == BLK_ZONE_COND_READONLY &&
11711174
zone->cond != BLK_ZONE_COND_OFFLINE)
11721175
zone->cond = BLK_ZONE_COND_READONLY;
11731176
else if (next->cond == BLK_ZONE_COND_OFFLINE)
11741177
zone->cond = BLK_ZONE_COND_OFFLINE;
11751178
}
1179+
if (zone->capacity != zone->len) {
1180+
zonefs_err(sb, "Invalid conventional zone capacity\n");
1181+
ret = -EINVAL;
1182+
goto free;
1183+
}
11761184
}
11771185

11781186
/*

fs/zonefs/zonefs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ struct zonefs_inode_info {
5656
/* File maximum size */
5757
loff_t i_max_size;
5858

59+
/* File zone size */
60+
loff_t i_zone_size;
61+
5962
/*
6063
* To serialise fully against both syscall and mmap based IO and
6164
* sequential file truncation, two locks are used. For serializing

0 commit comments

Comments
 (0)