Commit 232dd599 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'zonefs-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs

Pull zonefs updates from Damien Le Moal:

 - Reorganize zonefs code to split file related operations to a new
   fs/zonefs/file.c file (me)

 - Modify zonefs to use dynamically allocated inodes and dentries (using
   the inode and dentry caches) instead of statically allocating
   everything on mount. This saves a significant amount of memory for
   very large zoned block devices with 10s of thousands of zones (me)

 - Make zonefs_sb_ktype a const struct kobj_type (Thomas)

* tag 'zonefs-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
  zonefs: make kobj_type structure constant
  zonefs: Cache zone group directory inodes
  zonefs: Dynamically create file inodes when needed
  zonefs: Separate zone information from inode information
  zonefs: Reduce struct zonefs_inode_info size
  zonefs: Simplify IO error handling
  zonefs: Reorganize code
parents b7ee8812 2b188a2c
......@@ -3,4 +3,4 @@ ccflags-y += -I$(src)
obj-$(CONFIG_ZONEFS_FS) += zonefs.o
zonefs-y := super.o sysfs.o
zonefs-y := super.o file.o sysfs.o
This diff is collapsed.
This diff is collapsed.
......@@ -79,7 +79,7 @@ static const struct sysfs_ops zonefs_sysfs_attr_ops = {
.show = zonefs_sysfs_attr_show,
};
static struct kobj_type zonefs_sb_ktype = {
static const struct kobj_type zonefs_sb_ktype = {
.default_groups = zonefs_sysfs_groups,
.sysfs_ops = &zonefs_sysfs_attr_ops,
.release = zonefs_sysfs_sb_release,
......
......@@ -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",
......
......@@ -39,31 +39,53 @@ static inline enum zonefs_ztype zonefs_zone_type(struct blk_zone *zone)
return ZONEFS_ZTYPE_SEQ;
}
#define ZONEFS_ZONE_OPEN (1U << 0)
#define ZONEFS_ZONE_ACTIVE (1U << 1)
#define ZONEFS_ZONE_OFFLINE (1U << 2)
#define ZONEFS_ZONE_READONLY (1U << 3)
#define ZONEFS_ZONE_INIT_MODE (1U << 0)
#define ZONEFS_ZONE_OPEN (1U << 1)
#define ZONEFS_ZONE_ACTIVE (1U << 2)
#define ZONEFS_ZONE_OFFLINE (1U << 3)
#define ZONEFS_ZONE_READONLY (1U << 4)
#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 type */
enum zonefs_ztype i_ztype;
/* Zone start sector (512B unit) */
sector_t z_sector;
/* File zone start sector (512B unit) */
sector_t i_zsector;
/* Zone size (bytes) */
loff_t z_size;
/* File zone write pointer position (sequential zones only) */
loff_t i_wpoffset;
/* Zone capacity (file maximum size, bytes) */
loff_t z_capacity;
/* File maximum size */
loff_t i_max_size;
/* Write pointer offset in the zone (sequential zones only, bytes) */
loff_t z_wpoffset;
/* Saved inode uid, gid and access rights */
umode_t z_mode;
kuid_t z_uid;
kgid_t z_gid;
};
/*
* In memory zone group information: all zones of a group are exposed
* as files, one file per zone.
*/
struct zonefs_zone_group {
struct inode *g_inode;
unsigned int g_nr_zones;
struct zonefs_zone *g_zones;
};
/* File zone size */
loff_t i_zone_size;
/*
* In-memory inode data.
*/
struct zonefs_inode_info {
struct inode i_vnode;
/*
* To serialise fully against both syscall and mmap based IO and
......@@ -82,7 +104,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)
......@@ -90,6 +111,31 @@ 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_zone *z)
{
return z->z_flags & ZONEFS_ZONE_CNV;
}
static inline bool zonefs_zone_is_seq(struct zonefs_zone *z)
{
return !zonefs_zone_is_cnv(z);
}
static inline struct zonefs_zone *zonefs_inode_zone(struct inode *inode)
{
return inode->i_private;
}
static inline bool zonefs_inode_is_cnv(struct inode *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_inode_zone(inode));
}
/*
* On-disk super block (block 0).
*/
......@@ -181,7 +227,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;
......@@ -209,6 +255,32 @@ static inline struct zonefs_sb_info *ZONEFS_SB(struct super_block *sb)
#define zonefs_warn(sb, format, args...) \
pr_warn("zonefs (%s) WARNING: " format, sb->s_id, ## args)
/* In super.c */
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);
static inline void zonefs_io_error(struct inode *inode, bool write)
{
struct zonefs_inode_info *zi = ZONEFS_I(inode);
mutex_lock(&zi->i_truncate_mutex);
__zonefs_io_error(inode, write);
mutex_unlock(&zi->i_truncate_mutex);
}
/* In super.c */
extern const struct inode_operations zonefs_dir_inode_operations;
extern const struct file_operations zonefs_dir_operations;
/* In file.c */
extern const struct address_space_operations zonefs_file_aops;
extern const struct file_operations zonefs_file_operations;
int zonefs_file_truncate(struct inode *inode, loff_t isize);
/* In sysfs.c */
int zonefs_sysfs_register(struct super_block *sb);
void zonefs_sysfs_unregister(struct super_block *sb);
int zonefs_sysfs_init(void);
......
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