// SPDX-License-Identifier: GPL-2.0/* * Simple file system for zoned block devices exposing zones as files. * * Copyright (C) 2019 Western Digital Corporation or its affiliates. */#include<linux/module.h>#include<linux/pagemap.h>#include<linux/magic.h>#include<linux/iomap.h>#include<linux/init.h>#include<linux/slab.h>#include<linux/blkdev.h>#include<linux/statfs.h>#include<linux/writeback.h>#include<linux/quotaops.h>#include<linux/seq_file.h>#include<linux/uio.h>#include<linux/mman.h>#include<linux/sched/mm.h>#include<linux/crc32.h>#include<linux/task_io_accounting_ops.h>#include<linux/fs_parser.h>#include<linux/fs_context.h>#include"zonefs.h"#define CREATE_TRACE_POINTS#include"trace.h"/* * Get the name of a zone group directory. */staticconstchar*zonefs_zgroup_name(enumzonefs_ztypeztype){switch(ztype){caseZONEFS_ZTYPE_CNV:return"cnv";caseZONEFS_ZTYPE_SEQ:return"seq";default:WARN_ON_ONCE(1);return"???";}}/* * Manage the active zone count. */staticvoidzonefs_account_active(structsuper_block*sb,structzonefs_zone*z){structzonefs_sb_info*sbi=ZONEFS_SB(sb);if(zonefs_zone_is_cnv(z))return;/* * For zones that transitioned to the offline or readonly condition, * we only need to clear the active state. */if(z->z_flags&(ZONEFS_ZONE_OFFLINE|ZONEFS_ZONE_READONLY))gotoout