Skip to content

Commit 43592c4

Browse files
author
Damien Le Moal
committed
zonefs: Cache zone group directory inodes
Since looking up any zone file inode requires looking up first the inode for the directory representing the zone group of the file, ensuring that the zone group inodes are always cached is desired. To do so, take an extra reference on the zone groups directory inodes on mount, thus avoiding the eviction of these inodes from the inode cache until the volume is unmounted. Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]>
1 parent d207794 commit 43592c4

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

fs/zonefs/super.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,42 @@ static const struct super_operations zonefs_sops = {
11991199
.show_options = zonefs_show_options,
12001200
};
12011201

1202+
static int zonefs_get_zgroup_inodes(struct super_block *sb)
1203+
{
1204+
struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
1205+
struct inode *dir_inode;
1206+
enum zonefs_ztype ztype;
1207+
1208+
for (ztype = 0; ztype < ZONEFS_ZTYPE_MAX; ztype++) {
1209+
if (!sbi->s_zgroup[ztype].g_nr_zones)
1210+
continue;
1211+
1212+
dir_inode = zonefs_get_zgroup_inode(sb, ztype);
1213+
if (IS_ERR(dir_inode))
1214+
return PTR_ERR(dir_inode);
1215+
1216+
sbi->s_zgroup[ztype].g_inode = dir_inode;
1217+
}
1218+
1219+
return 0;
1220+
}
1221+
1222+
static void zonefs_release_zgroup_inodes(struct super_block *sb)
1223+
{
1224+
struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
1225+
enum zonefs_ztype ztype;
1226+
1227+
if (!sbi)
1228+
return;
1229+
1230+
for (ztype = 0; ztype < ZONEFS_ZTYPE_MAX; ztype++) {
1231+
if (sbi->s_zgroup[ztype].g_inode) {
1232+
iput(sbi->s_zgroup[ztype].g_inode);
1233+
sbi->s_zgroup[ztype].g_inode = NULL;
1234+
}
1235+
}
1236+
}
1237+
12021238
/*
12031239
* Check that the device is zoned. If it is, get the list of zones and create
12041240
* sub-directories and files according to the device zone configuration and
@@ -1297,13 +1333,22 @@ static int zonefs_fill_super(struct super_block *sb, void *data, int silent)
12971333
if (!sb->s_root)
12981334
goto cleanup;
12991335

1336+
/*
1337+
* Take a reference on the zone groups directory inodes
1338+
* to keep them in the inode cache.
1339+
*/
1340+
ret = zonefs_get_zgroup_inodes(sb);
1341+
if (ret)
1342+
goto cleanup;
1343+
13001344
ret = zonefs_sysfs_register(sb);
13011345
if (ret)
13021346
goto cleanup;
13031347

13041348
return 0;
13051349

13061350
cleanup:
1351+
zonefs_release_zgroup_inodes(sb);
13071352
zonefs_free_zgroups(sb);
13081353

13091354
return ret;
@@ -1319,6 +1364,9 @@ static void zonefs_kill_super(struct super_block *sb)
13191364
{
13201365
struct zonefs_sb_info *sbi = ZONEFS_SB(sb);
13211366

1367+
/* Release the reference on the zone group directory inodes */
1368+
zonefs_release_zgroup_inodes(sb);
1369+
13221370
kill_block_super(sb);
13231371

13241372
zonefs_sysfs_unregister(sb);

fs/zonefs/zonefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct zonefs_zone {
7676
* as files, one file per zone.
7777
*/
7878
struct zonefs_zone_group {
79+
struct inode *g_inode;
7980
unsigned int g_nr_zones;
8081
struct zonefs_zone *g_zones;
8182
};

0 commit comments

Comments
 (0)