Skip to content

Commit 3e0d88f

Browse files
committed
Merge tag 'zonefs-6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs
Pull zonefs fixes from Damien Le Moal: - Fix a race between zonefs module initialization of sysfs attribute directory and mounting a drive (from Xiaoxu). - Fix active zone accounting in the rare case of an IO error due to a zone transition to offline or read-only state (from me). * tag 'zonefs-6.1-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs: zonefs: Fix active zone accounting zonefs: Fix race between modprobe and mount
2 parents f10b439 + db58653 commit 3e0d88f

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

fs/zonefs/super.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ static void zonefs_account_active(struct inode *inode)
4040
if (zi->i_ztype != ZONEFS_ZTYPE_SEQ)
4141
return;
4242

43+
/*
44+
* For zones that transitioned to the offline or readonly condition,
45+
* we only need to clear the active state.
46+
*/
47+
if (zi->i_flags & (ZONEFS_ZONE_OFFLINE | ZONEFS_ZONE_READONLY))
48+
goto out;
49+
4350
/*
4451
* If the zone is active, that is, if it is explicitly open or
4552
* partially written, check if it was already accounted as active.
@@ -53,6 +60,7 @@ static void zonefs_account_active(struct inode *inode)
5360
return;
5461
}
5562

63+
out:
5664
/* The zone is not active. If it was, update the active count */
5765
if (zi->i_flags & ZONEFS_ZONE_ACTIVE) {
5866
zi->i_flags &= ~ZONEFS_ZONE_ACTIVE;
@@ -324,6 +332,7 @@ static loff_t zonefs_check_zone_condition(struct inode *inode,
324332
inode->i_flags |= S_IMMUTABLE;
325333
inode->i_mode &= ~0777;
326334
zone->wp = zone->start;
335+
zi->i_flags |= ZONEFS_ZONE_OFFLINE;
327336
return 0;
328337
case BLK_ZONE_COND_READONLY:
329338
/*
@@ -342,8 +351,10 @@ static loff_t zonefs_check_zone_condition(struct inode *inode,
342351
zone->cond = BLK_ZONE_COND_OFFLINE;
343352
inode->i_mode &= ~0777;
344353
zone->wp = zone->start;
354+
zi->i_flags |= ZONEFS_ZONE_OFFLINE;
345355
return 0;
346356
}
357+
zi->i_flags |= ZONEFS_ZONE_READONLY;
347358
inode->i_mode &= ~0222;
348359
return i_size_read(inode);
349360
case BLK_ZONE_COND_FULL:
@@ -1922,18 +1933,18 @@ static int __init zonefs_init(void)
19221933
if (ret)
19231934
return ret;
19241935

1925-
ret = register_filesystem(&zonefs_type);
1936+
ret = zonefs_sysfs_init();
19261937
if (ret)
19271938
goto destroy_inodecache;
19281939

1929-
ret = zonefs_sysfs_init();
1940+
ret = register_filesystem(&zonefs_type);
19301941
if (ret)
1931-
goto unregister_fs;
1942+
goto sysfs_exit;
19321943

19331944
return 0;
19341945

1935-
unregister_fs:
1936-
unregister_filesystem(&zonefs_type);
1946+
sysfs_exit:
1947+
zonefs_sysfs_exit();
19371948
destroy_inodecache:
19381949
zonefs_destroy_inodecache();
19391950

@@ -1942,9 +1953,9 @@ static int __init zonefs_init(void)
19421953

19431954
static void __exit zonefs_exit(void)
19441955
{
1956+
unregister_filesystem(&zonefs_type);
19451957
zonefs_sysfs_exit();
19461958
zonefs_destroy_inodecache();
1947-
unregister_filesystem(&zonefs_type);
19481959
}
19491960

19501961
MODULE_AUTHOR("Damien Le Moal");

fs/zonefs/zonefs.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ static inline enum zonefs_ztype zonefs_zone_type(struct blk_zone *zone)
3939
return ZONEFS_ZTYPE_SEQ;
4040
}
4141

42-
#define ZONEFS_ZONE_OPEN (1 << 0)
43-
#define ZONEFS_ZONE_ACTIVE (1 << 1)
42+
#define ZONEFS_ZONE_OPEN (1U << 0)
43+
#define ZONEFS_ZONE_ACTIVE (1U << 1)
44+
#define ZONEFS_ZONE_OFFLINE (1U << 2)
45+
#define ZONEFS_ZONE_READONLY (1U << 3)
4446

4547
/*
4648
* In-memory inode data.

0 commit comments

Comments
 (0)