Skip to content

Commit db58653

Browse files
author
Damien Le Moal
committed
zonefs: Fix active zone accounting
If a file zone transitions to the offline or readonly state from an active state, we must clear the zone active flag and decrement the active seq file counter. Do so in zonefs_account_active() using the new zonefs inode flags ZONEFS_ZONE_OFFLINE and ZONEFS_ZONE_READONLY. These flags are set if necessary in zonefs_check_zone_condition() based on the result of report zones operation after an IO error. Fixes: 87c9ce3 ("zonefs: Add active seq file accounting") Cc: [email protected] Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]>
1 parent 4e45886 commit db58653

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

fs/zonefs/super.c

Lines changed: 11 additions & 0 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:

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)