Commit aa7f243f authored by Damien Le Moal's avatar Damien Le Moal

zonefs: Separate zone information from inode information

In preparation for adding dynamic inode allocation, separate an inode
zone information from the zonefs inode structure. The new data structure
zonefs_zone is introduced to store in memory information about a zone
that must be kept throughout the lifetime of the device mount.

Linking between a zone file inode and its zone information is done by
setting the inode i_private field to point to a struct zonefs_zone.
Using the i_private pointer avoids the need for adding a pointer in
struct zonefs_inode_info. Beside the vfs inode, this structure is
reduced to a mutex and a write open counter.

One struct zonefs_zone is created per file inode on mount. These
structures are organized in an array using the new struct
zonefs_zone_group data structure to represent zone groups. The
zonefs_zone arrays are indexed per file number (the index of a struct
zonefs_zone in its array directly gives the file number/name for that
zone file inode).
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
parent 34422914
This diff is collapsed.
This diff is collapsed.
......@@ -20,8 +20,9 @@
#define show_dev(dev) MAJOR(dev), MINOR(dev)
TRACE_EVENT(zonefs_zone_mgmt,
TP_PROTO(struct inode *inode, enum req_op op),
TP_ARGS(inode, op),
TP_PROTO(struct super_block *sb, struct zonefs_zone *z,
enum req_op op),
TP_ARGS(sb, z, op),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(ino_t, ino)
......@@ -30,12 +31,12 @@ TRACE_EVENT(zonefs_zone_mgmt,
__field(sector_t, nr_sectors)
),
TP_fast_assign(
__entry->dev = inode->i_sb->s_dev;
__entry->ino = inode->i_ino;
__entry->dev = sb->s_dev;
__entry->ino =
z->z_sector >> ZONEFS_SB(sb)->s_zone_sectors_shift;
__entry->op = op;
__entry->sector = ZONEFS_I(inode)->i_zsector;
__entry->nr_sectors =
ZONEFS_I(inode)->i_zone_size >> SECTOR_SHIFT;
__entry->sector = z->z_sector;
__entry->nr_sectors = z->z_size >> SECTOR_SHIFT;
),
TP_printk("bdev=(%d,%d), ino=%lu op=%s, sector=%llu, nr_sectors=%llu",
show_dev(__entry->dev), (unsigned long)__entry->ino,
......@@ -58,9 +59,10 @@ TRACE_EVENT(zonefs_file_dio_append,
TP_fast_assign(
__entry->dev = inode->i_sb->s_dev;
__entry->ino = inode->i_ino;
__entry->sector = ZONEFS_I(inode)->i_zsector;
__entry->sector = zonefs_inode_zone(inode)->z_sector;
__entry->size = size;
__entry->wpoffset = ZONEFS_I(inode)->i_wpoffset;
__entry->wpoffset =
zonefs_inode_zone(inode)->z_wpoffset;
__entry->ret = ret;
),
TP_printk("bdev=(%d, %d), ino=%lu, sector=%llu, size=%zu, wpoffset=%llu, ret=%zu",
......
......@@ -47,22 +47,39 @@ static inline enum zonefs_ztype zonefs_zone_type(struct blk_zone *zone)
#define ZONEFS_ZONE_CNV (1U << 31)
/*
* In-memory inode data.
* In-memory per-file inode zone data.
*/
struct zonefs_inode_info {
struct inode i_vnode;
struct zonefs_zone {
/* Zone state flags */
unsigned int z_flags;
/* File zone start sector (512B unit) */
sector_t i_zsector;
/* Zone start sector (512B unit) */
sector_t z_sector;
/* File zone write pointer position (sequential zones only) */
loff_t i_wpoffset;
/* Zone size (bytes) */
loff_t z_size;
/* File maximum size */
loff_t i_max_size;
/* Zone capacity (file maximum size, bytes) */
loff_t z_capacity;
/* File zone size */
loff_t i_zone_size;
/* Write pointer offset in the zone (sequential zones only, bytes) */
loff_t z_wpoffset;
};
/*
* In memory zone group information: all zones of a group are exposed
* as files, one file per zone.
*/
struct zonefs_zone_group {
unsigned int g_nr_zones;
struct zonefs_zone *g_zones;
};
/*
* In-memory inode data.
*/
struct zonefs_inode_info {
struct inode i_vnode;
/*
* To serialise fully against both syscall and mmap based IO and
......@@ -81,7 +98,6 @@ struct zonefs_inode_info {
/* guarded by i_truncate_mutex */
unsigned int i_wr_refcnt;
unsigned int i_flags;
};
static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode)
......@@ -89,24 +105,29 @@ static inline struct zonefs_inode_info *ZONEFS_I(struct inode *inode)
return container_of(inode, struct zonefs_inode_info, i_vnode);
}
static inline bool zonefs_zone_is_cnv(struct zonefs_inode_info *zi)
static inline bool zonefs_zone_is_cnv(struct zonefs_zone *z)
{
return z->z_flags & ZONEFS_ZONE_CNV;
}
static inline bool zonefs_zone_is_seq(struct zonefs_zone *z)
{
return zi->i_flags & ZONEFS_ZONE_CNV;
return !zonefs_zone_is_cnv(z);
}
static inline bool zonefs_zone_is_seq(struct zonefs_inode_info *zi)
static inline struct zonefs_zone *zonefs_inode_zone(struct inode *inode)
{
return !zonefs_zone_is_cnv(zi);
return inode->i_private;
}
static inline bool zonefs_inode_is_cnv(struct inode *inode)
{
return zonefs_zone_is_cnv(ZONEFS_I(inode));
return zonefs_zone_is_cnv(zonefs_inode_zone(inode));
}
static inline bool zonefs_inode_is_seq(struct inode *inode)
{
return zonefs_zone_is_seq(ZONEFS_I(inode));
return zonefs_zone_is_seq(zonefs_inode_zone(inode));
}
/*
......@@ -200,7 +221,7 @@ struct zonefs_sb_info {
uuid_t s_uuid;
unsigned int s_zone_sectors_shift;
unsigned int s_nr_files[ZONEFS_ZTYPE_MAX];
struct zonefs_zone_group s_zgroup[ZONEFS_ZTYPE_MAX];
loff_t s_blocks;
loff_t s_used_blocks;
......@@ -229,8 +250,8 @@ static inline struct zonefs_sb_info *ZONEFS_SB(struct super_block *sb)
pr_warn("zonefs (%s) WARNING: " format, sb->s_id, ## args)
/* In super.c */
void zonefs_account_active(struct inode *inode);
int zonefs_zone_mgmt(struct inode *inode, enum req_op op);
void zonefs_inode_account_active(struct inode *inode);
int zonefs_inode_zone_mgmt(struct inode *inode, enum req_op op);
void zonefs_i_size_write(struct inode *inode, loff_t isize);
void zonefs_update_stats(struct inode *inode, loff_t new_isize);
void __zonefs_io_error(struct inode *inode, bool write);
......
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