1d29fbcdbSNishad Kamdar/* SPDX-License-Identifier: GPL-2.0 */
20a8165d7SJaegeuk Kim/*
339a53e0cSJaegeuk Kim * fs/f2fs/f2fs.h
439a53e0cSJaegeuk Kim *
539a53e0cSJaegeuk Kim * Copyright (c) 2012 Samsung Electronics Co., Ltd.
639a53e0cSJaegeuk Kim *             http://www.samsung.com/
739a53e0cSJaegeuk Kim */
839a53e0cSJaegeuk Kim#ifndef _LINUX_F2FS_H
939a53e0cSJaegeuk Kim#define _LINUX_F2FS_H
1039a53e0cSJaegeuk Kim
11f847c699SChao Yu#include <linux/uio.h>
1239a53e0cSJaegeuk Kim#include <linux/types.h>
1339a53e0cSJaegeuk Kim#include <linux/page-flags.h>
1439a53e0cSJaegeuk Kim#include <linux/buffer_head.h>
1539a53e0cSJaegeuk Kim#include <linux/slab.h>
1639a53e0cSJaegeuk Kim#include <linux/crc32.h>
1739a53e0cSJaegeuk Kim#include <linux/magic.h>
18c2d715d1SJaegeuk Kim#include <linux/kobject.h>
197bd59381SGu Zheng#include <linux/sched.h>
207c2e5963SJaegeuk Kim#include <linux/cred.h>
2139307a8eSJaegeuk Kim#include <linux/vmalloc.h>
22740432f8SJaegeuk Kim#include <linux/bio.h>
23d0239e1bSJaegeuk Kim#include <linux/blkdev.h>
240abd675eSChao Yu#include <linux/quotaops.h>
25c6a564ffSChristoph Hellwig#include <linux/part_stat.h>
2643b6573bSKeith Mok#include <crypto/hash.h>
2739a53e0cSJaegeuk Kim
28734f0d24SDave Chinner#include <linux/fscrypt.h>
2995ae251fSEric Biggers#include <linux/fsverity.h>
30734f0d24SDave Chinner
3151dcbdacSMatthew Wilcox (Oracle)struct pagevec;
3251dcbdacSMatthew Wilcox (Oracle)
335d56b671SJaegeuk Kim#ifdef CONFIG_F2FS_CHECK_FS
349850cf4aSJaegeuk Kim#define f2fs_bug_on(sbi, condition)	BUG_ON(condition)
355d56b671SJaegeuk Kim#else
369850cf4aSJaegeuk Kim#define f2fs_bug_on(sbi, condition)					\
379850cf4aSJaegeuk Kim	do {								\
38db489652SYangtao Li		if (WARN_ON(condition))					\
39caf0047eSChao Yu			set_sbi_flag(sbi, SBI_NEED_FSCK);		\
409850cf4aSJaegeuk Kim	} while (0)
415d56b671SJaegeuk Kim#endif
425d56b671SJaegeuk Kim
432c63feadSJaegeuk Kimenum {
442c63feadSJaegeuk Kim	FAULT_KMALLOC,
45628b3d14SChao Yu	FAULT_KVMALLOC,
46c41f3cc3SJaegeuk Kim	FAULT_PAGE_ALLOC,
4701eccef7SChao Yu	FAULT_PAGE_GET,
48b96d9b3bSChao Yu	FAULT_ALLOC_BIO,	/* it's obsolete due to bio_alloc() will never fail */
49cb78942bSJaegeuk Kim	FAULT_ALLOC_NID,
50cb78942bSJaegeuk Kim	FAULT_ORPHAN,
51cb78942bSJaegeuk Kim	FAULT_BLOCK,
52cb78942bSJaegeuk Kim	FAULT_DIR_DEPTH,
5353aa6bbfSJaegeuk Kim	FAULT_EVICT_INODE,
5414b44d23SJaegeuk Kim	FAULT_TRUNCATE,
556f5c2ed0SChao Yu	FAULT_READ_IO,
560f348028SChao Yu	FAULT_CHECKPOINT,
57b83dcfe6SChao Yu	FAULT_DISCARD,
586f5c2ed0SChao Yu	FAULT_WRITE_IO,
5932410577SChao Yu	FAULT_SLAB_ALLOC,
6010a26878SChao Yu	FAULT_DQUOT_INIT,
613e020389SChao Yu	FAULT_LOCK_OP,
622c63feadSJaegeuk Kim	FAULT_MAX,
632c63feadSJaegeuk Kim};
642c63feadSJaegeuk Kim
657fa750a1SArnd Bergmann#ifdef CONFIG_F2FS_FAULT_INJECTION
66d494500aSChao Yu#define F2FS_ALL_FAULT_TYPE		((1 << FAULT_MAX) - 1)
67d494500aSChao Yu
6808796897SSheng Yongstruct f2fs_fault_info {
6908796897SSheng Yong	atomic_t inject_ops;
7008796897SSheng Yong	unsigned int inject_rate;
7108796897SSheng Yong	unsigned int inject_type;
7208796897SSheng Yong};
7308796897SSheng Yong
7419880e6eSAlexey Dobriyanextern const char *f2fs_fault_name[FAULT_MAX];
7568afcf2dSTomohiro Kusumi#define IS_FAULT_SET(fi, type) ((fi)->inject_type & (1 << (type)))
762c63feadSJaegeuk Kim#endif
772c63feadSJaegeuk Kim
7839a53e0cSJaegeuk Kim/*
7939a53e0cSJaegeuk Kim * For mount options
8039a53e0cSJaegeuk Kim */
8139a53e0cSJaegeuk Kim#define F2FS_MOUNT_DISABLE_ROLL_FORWARD	0x00000002
8239a53e0cSJaegeuk Kim#define F2FS_MOUNT_DISCARD		0x00000004
8339a53e0cSJaegeuk Kim#define F2FS_MOUNT_NOHEAP		0x00000008
8439a53e0cSJaegeuk Kim#define F2FS_MOUNT_XATTR_USER		0x00000010
8539a53e0cSJaegeuk Kim#define F2FS_MOUNT_POSIX_ACL		0x00000020
8639a53e0cSJaegeuk Kim#define F2FS_MOUNT_DISABLE_EXT_IDENTIFY	0x00000040
87444c580fSJaegeuk Kim#define F2FS_MOUNT_INLINE_XATTR		0x00000080
881001b347SHuajun Li#define F2FS_MOUNT_INLINE_DATA		0x00000100
8934d67debSChao Yu#define F2FS_MOUNT_INLINE_DENTRY	0x00000200
9034d67debSChao Yu#define F2FS_MOUNT_FLUSH_MERGE		0x00000400
9134d67debSChao Yu#define F2FS_MOUNT_NOBARRIER		0x00000800
92d5053a34SJaegeuk Kim#define F2FS_MOUNT_FASTBOOT		0x00001000
9389672159SChao Yu#define F2FS_MOUNT_EXTENT_CACHE		0x00002000
94343f40f0SChao Yu#define F2FS_MOUNT_DATA_FLUSH		0x00008000
9573faec4dSJaegeuk Kim#define F2FS_MOUNT_FAULT_INJECTION	0x00010000
960abd675eSChao Yu#define F2FS_MOUNT_USRQUOTA		0x00080000
970abd675eSChao Yu#define F2FS_MOUNT_GRPQUOTA		0x00100000
985c57132eSChao Yu#define F2FS_MOUNT_PRJQUOTA		0x00200000
994b2414d0SChao Yu#define F2FS_MOUNT_QUOTA		0x00400000
1006afc662eSChao Yu#define F2FS_MOUNT_INLINE_XATTR_SIZE	0x00800000
1017e65be49SJaegeuk Kim#define F2FS_MOUNT_RESERVE_ROOT		0x01000000
1024354994fSDaniel Rosenberg#define F2FS_MOUNT_DISABLE_CHECKPOINT	0x02000000
103a9117ecaSChao Yu#define F2FS_MOUNT_NORECOVERY		0x04000000
104093749e2SChao Yu#define F2FS_MOUNT_ATGC			0x08000000
105261eeb9cSDaeho Jeong#define F2FS_MOUNT_MERGE_CHECKPOINT	0x10000000
1065911d2d1SChao Yu#define	F2FS_MOUNT_GC_MERGE		0x20000000
1076ce19affSChao Yu#define F2FS_MOUNT_COMPRESS_CACHE	0x40000000
10839a53e0cSJaegeuk Kim
10963189b78SChao Yu#define F2FS_OPTION(sbi)	((sbi)->mount_opt)
11063189b78SChao Yu#define clear_opt(sbi, option)	(F2FS_OPTION(sbi).opt &= ~F2FS_MOUNT_##option)
11163189b78SChao Yu#define set_opt(sbi, option)	(F2FS_OPTION(sbi).opt |= F2FS_MOUNT_##option)
11263189b78SChao Yu#define test_opt(sbi, option)	(F2FS_OPTION(sbi).opt & F2FS_MOUNT_##option)
11339a53e0cSJaegeuk Kim
11439a53e0cSJaegeuk Kim#define ver_after(a, b)	(typecheck(unsigned long long, a) &&		\
11539a53e0cSJaegeuk Kim		typecheck(unsigned long long, b) &&			\
11639a53e0cSJaegeuk Kim		((long long)((a) - (b)) > 0))
11739a53e0cSJaegeuk Kim
118a9841c4dSJaegeuk Kimtypedef u32 block_t;	/*
119a9841c4dSJaegeuk Kim			 * should not change u32, since it is the on-disk block
120a9841c4dSJaegeuk Kim			 * address format, __le32.
121a9841c4dSJaegeuk Kim			 */
12239a53e0cSJaegeuk Kimtypedef u32 nid_t;
12339a53e0cSJaegeuk Kim
1244c8ff709SChao Yu#define COMPRESS_EXT_NUM		16
1254c8ff709SChao Yu
12639a53e0cSJaegeuk Kimstruct f2fs_mount_info {
12763189b78SChao Yu	unsigned int opt;
12863189b78SChao Yu	int write_io_size_bits;		/* Write IO size bits */
12963189b78SChao Yu	block_t root_reserved_blocks;	/* root reserved blocks */
13063189b78SChao Yu	kuid_t s_resuid;		/* reserved blocks for uid */
13163189b78SChao Yu	kgid_t s_resgid;		/* reserved blocks for gid */
13263189b78SChao Yu	int active_logs;		/* # of active logs */
13363189b78SChao Yu	int inline_xattr_size;		/* inline xattr size */
13463189b78SChao Yu#ifdef CONFIG_F2FS_FAULT_INJECTION
13563189b78SChao Yu	struct f2fs_fault_info fault_info;	/* For fault injection */
13663189b78SChao Yu#endif
13763189b78SChao Yu#ifdef CONFIG_QUOTA
13863189b78SChao Yu	/* Names of quota files with journalled quota */
13963189b78SChao Yu	char *s_qf_names[MAXQUOTAS];
14063189b78SChao Yu	int s_jquota_fmt;			/* Format of quota to use */
14163189b78SChao Yu#endif
14263189b78SChao Yu	/* For which write hints are passed down to block layer */
14363189b78SChao Yu	int whint_mode;
14463189b78SChao Yu	int alloc_mode;			/* segment allocation policy */
14563189b78SChao Yu	int fsync_mode;			/* fsync policy */
146b0332a0fSChao Yu	int fs_mode;			/* fs mode: LFS or ADAPTIVE */
147bbbc34fdSChao Yu	int bggc_mode;			/* bggc mode: off, on or sync */
1484f993264SChao Yu	int discard_unit;		/*
1494f993264SChao Yu					 * discard command's offset/size should
1504f993264SChao Yu					 * be aligned to this unit: block,
1514f993264SChao Yu					 * segment or section
1524f993264SChao Yu					 */
153ac4acb1fSEric Biggers	struct fscrypt_dummy_policy dummy_enc_policy; /* test dummy encryption */
1541ae18f71SJaegeuk Kim	block_t unusable_cap_perc;	/* percentage for cap */
1554d3aed70SDaniel Rosenberg	block_t unusable_cap;		/* Amount of space allowed to be
1564d3aed70SDaniel Rosenberg					 * unusable when disabling checkpoint
1574d3aed70SDaniel Rosenberg					 */
1584c8ff709SChao Yu
1594c8ff709SChao Yu	/* For compression */
1604c8ff709SChao Yu	unsigned char compress_algorithm;	/* algorithm type */
161b28f047bSChao Yu	unsigned char compress_log_size;	/* cluster log size */
1623fde13f8SChao Yu	unsigned char compress_level;		/* compress level */
163b28f047bSChao Yu	bool compress_chksum;			/* compressed data chksum */
1644c8ff709SChao Yu	unsigned char compress_ext_cnt;		/* extension count */
165151b1982SFengnan Chang	unsigned char nocompress_ext_cnt;		/* nocompress extension count */
166602a16d5SDaeho Jeong	int compress_mode;			/* compression mode */
1674c8ff709SChao Yu	unsigned char extensions[COMPRESS_EXT_NUM][F2FS_EXTENSION_LEN];	/* extensions */
168151b1982SFengnan Chang	unsigned char noextensions[COMPRESS_EXT_NUM][F2FS_EXTENSION_LEN]; /* extensions */
16939a53e0cSJaegeuk Kim};
17039a53e0cSJaegeuk Kim
1717a2af766SChao Yu#define F2FS_FEATURE_ENCRYPT		0x0001
1727a2af766SChao Yu#define F2FS_FEATURE_BLKZONED		0x0002
1737a2af766SChao Yu#define F2FS_FEATURE_ATOMIC_WRITE	0x0004
1747a2af766SChao Yu#define F2FS_FEATURE_EXTRA_ATTR		0x0008
1755c57132eSChao Yu#define F2FS_FEATURE_PRJQUOTA		0x0010
176704956ecSChao Yu#define F2FS_FEATURE_INODE_CHKSUM	0x0020
1776afc662eSChao Yu#define F2FS_FEATURE_FLEXIBLE_INLINE_XATTR	0x0040
178234a9689SJaegeuk Kim#define F2FS_FEATURE_QUOTA_INO		0x0080
1791c1d35dfSChao Yu#define F2FS_FEATURE_INODE_CRTIME	0x0100
180b7c409deSSheng Yong#define F2FS_FEATURE_LOST_FOUND		0x0200
18195ae251fSEric Biggers#define F2FS_FEATURE_VERITY		0x0400
182d440c52dSJunling Zheng#define F2FS_FEATURE_SB_CHKSUM		0x0800
1835aba5430SDaniel Rosenberg#define F2FS_FEATURE_CASEFOLD		0x1000
1844c8ff709SChao Yu#define F2FS_FEATURE_COMPRESSION	0x2000
185a7d9fe3cSJaegeuk Kim#define F2FS_FEATURE_RO			0x4000
186cde4de12SJaegeuk Kim
1877beb01f7SChao Yu#define __F2FS_HAS_FEATURE(raw_super, mask)				\
1887beb01f7SChao Yu	((raw_super->feature & cpu_to_le32(mask)) != 0)
1897beb01f7SChao Yu#define F2FS_HAS_FEATURE(sbi, mask)	__F2FS_HAS_FEATURE(sbi->raw_super, mask)
1907beb01f7SChao Yu#define F2FS_SET_FEATURE(sbi, mask)					\
1917beb01f7SChao Yu	(sbi->raw_super->feature |= cpu_to_le32(mask))
1927beb01f7SChao Yu#define F2FS_CLEAR_FEATURE(sbi, mask)					\
1937beb01f7SChao Yu	(sbi->raw_super->feature &= ~cpu_to_le32(mask))
19476f105a2SJaegeuk Kim
1957c2e5963SJaegeuk Kim/*
1967c2e5963SJaegeuk Kim * Default values for user and/or group using reserved blocks
1977c2e5963SJaegeuk Kim */
1987c2e5963SJaegeuk Kim#define	F2FS_DEF_RESUID		0
1997c2e5963SJaegeuk Kim#define	F2FS_DEF_RESGID		0
2007c2e5963SJaegeuk Kim
20139a53e0cSJaegeuk Kim/*
20239a53e0cSJaegeuk Kim * For checkpoint manager
20339a53e0cSJaegeuk Kim */
20439a53e0cSJaegeuk Kimenum {
20539a53e0cSJaegeuk Kim	NAT_BITMAP,
20639a53e0cSJaegeuk Kim	SIT_BITMAP
20739a53e0cSJaegeuk Kim};
20839a53e0cSJaegeuk Kim
209c473f1a9SChao Yu#define	CP_UMOUNT	0x00000001
210c473f1a9SChao Yu#define	CP_FASTBOOT	0x00000002
211c473f1a9SChao Yu#define	CP_SYNC		0x00000004
212c473f1a9SChao Yu#define	CP_RECOVERY	0x00000008
213c473f1a9SChao Yu#define	CP_DISCARD	0x00000010
2141f43e2adSChao Yu#define CP_TRIMMED	0x00000020
2154354994fSDaniel Rosenberg#define CP_PAUSE	0x00000040
216b4b10061SJaegeuk Kim#define CP_RESIZE 	0x00000080
21775ab4cb8SJaegeuk Kim
2184ddb1a4dSJaegeuk Kim#define MAX_DISCARD_BLOCKS(sbi)		BLKS_PER_SEC(sbi)
219ecc9aa00SChao Yu#define DEF_MAX_DISCARD_REQUEST		8	/* issue 8 discards per round */
220969d1b18SChao Yu#define DEF_MIN_DISCARD_ISSUE_TIME	50	/* 50 ms, if exists */
221f9d1dcedSYunlei He#define DEF_MID_DISCARD_ISSUE_TIME	500	/* 500 ms, if device busy */
222969d1b18SChao Yu#define DEF_MAX_DISCARD_ISSUE_TIME	60000	/* 60 s, if no candidates */
2238bb4f253SJaegeuk Kim#define DEF_DISCARD_URGENT_UTIL		80	/* do more discard over 80% */
22460b99b48SJaegeuk Kim#define DEF_CP_INTERVAL			60	/* 60 secs */
225dcf25fe8SChao Yu#define DEF_IDLE_INTERVAL		5	/* 5 secs */
2264354994fSDaniel Rosenberg#define DEF_DISABLE_INTERVAL		5	/* 5 secs */
227db610a64SJaegeuk Kim#define DEF_DISABLE_QUICK_INTERVAL	1	/* 1 secs */
22803f2c02dSJaegeuk Kim#define DEF_UMOUNT_DISCARD_TIMEOUT	5	/* 5 secs */
229bba681cbSJaegeuk Kim
23075ab4cb8SJaegeuk Kimstruct cp_control {
23175ab4cb8SJaegeuk Kim	int reason;
2324b2fecc8SJaegeuk Kim	__u64 trim_start;
2334b2fecc8SJaegeuk Kim	__u64 trim_end;
2344b2fecc8SJaegeuk Kim	__u64 trim_minlen;
23575ab4cb8SJaegeuk Kim};
23675ab4cb8SJaegeuk Kim
237662befdaSChao Yu/*
238e1da7872SChao Yu * indicate meta/data type
239662befdaSChao Yu */
240662befdaSChao Yuenum {
241662befdaSChao Yu	META_CP,
242662befdaSChao Yu	META_NAT,
24381c1a0f1SChao Yu	META_SIT,
2444c521f49SJaegeuk Kim	META_SSA,
245b63e7be5SChao Yu	META_MAX,
2464c521f49SJaegeuk Kim	META_POR,
24793770ab7SChao Yu	DATA_GENERIC,		/* check range only */
24893770ab7SChao Yu	DATA_GENERIC_ENHANCE,	/* strong check on range and segment bitmap */
25093770ab7SChao Yu					 * strong check on range and segment
25193770ab7SChao Yu					 * bitmap but no warning due to race
25293770ab7SChao Yu					 * condition of read on truncated area
25393770ab7SChao Yu					 * by extent_cache
25493770ab7SChao Yu					 */
255e1da7872SChao Yu	META_GENERIC,
256662befdaSChao Yu};
257662befdaSChao Yu
2586451e041SJaegeuk Kim/* for the list of ino */
2596451e041SJaegeuk Kimenum {
2606451e041SJaegeuk Kim	ORPHAN_INO,		/* for orphan ino list */
261fff04f90SJaegeuk Kim	APPEND_INO,		/* for append ino list */
262fff04f90SJaegeuk Kim	UPDATE_INO,		/* for update ino list */
2630a007b97SJaegeuk Kim	TRANS_DIR_INO,		/* for trasactions dir ino list */
26439d787beSChao Yu	FLUSH_INO,		/* for multiple device flushing */
2656451e041SJaegeuk Kim	MAX_INO_ENTRY,		/* max. list */
2666451e041SJaegeuk Kim};
2676451e041SJaegeuk Kim
2686451e041SJaegeuk Kimstruct ino_entry {
26939d787beSChao Yu	struct list_head list;		/* list head */
27039d787beSChao Yu	nid_t ino;			/* inode number */
27139d787beSChao Yu	unsigned int dirty_device;	/* dirty device bitmap */
27239a53e0cSJaegeuk Kim};
27339a53e0cSJaegeuk Kim
2742710fd7eSChao Yu/* for the list of inodes to be GCed */
27506292073SChao Yustruct inode_entry {
27639a53e0cSJaegeuk Kim	struct list_head list;	/* list head */
27739a53e0cSJaegeuk Kim	struct inode *inode;	/* vfs inode pointer */
27839a53e0cSJaegeuk Kim};
27939a53e0cSJaegeuk Kim
28050fa53ecSChao Yustruct fsync_node_entry {
28150fa53ecSChao Yu	struct list_head list;	/* list head */
28250fa53ecSChao Yu	struct page *page;	/* warm node page pointer */
28350fa53ecSChao Yu	unsigned int seq_id;	/* sequence id */
28450fa53ecSChao Yu};
28550fa53ecSChao Yu
286261eeb9cSDaeho Jeongstruct ckpt_req {
287261eeb9cSDaeho Jeong	struct completion wait;		/* completion for checkpoint done */
288261eeb9cSDaeho Jeong	struct llist_node llnode;	/* llist_node to be linked in wait queue */
289261eeb9cSDaeho Jeong	int ret;			/* return code of checkpoint */
290261eeb9cSDaeho Jeong	ktime_t queue_time;		/* request queued time */
291261eeb9cSDaeho Jeong};
292261eeb9cSDaeho Jeong
293261eeb9cSDaeho Jeongstruct ckpt_req_control {
294261eeb9cSDaeho Jeong	struct task_struct *f2fs_issue_ckpt;	/* checkpoint task */
295e6592066SDaeho Jeong	int ckpt_thread_ioprio;			/* checkpoint merge thread ioprio */
296261eeb9cSDaeho Jeong	wait_queue_head_t ckpt_wait_queue;	/* waiting queue for wake-up */
297261eeb9cSDaeho Jeong	atomic_t issued_ckpt;		/* # of actually issued ckpts */
298261eeb9cSDaeho Jeong	atomic_t total_ckpt;		/* # of total ckpts */
299261eeb9cSDaeho Jeong	atomic_t queued_ckpt;		/* # of queued ckpts */
300261eeb9cSDaeho Jeong	struct llist_head issue_list;	/* list for command issue */
301261eeb9cSDaeho Jeong	spinlock_t stat_lock;		/* lock for below checkpoint time stats */
302261eeb9cSDaeho Jeong	unsigned int cur_time;		/* cur wait time in msec for currently issued checkpoint */
303261eeb9cSDaeho Jeong	unsigned int peak_time;		/* peak wait time in msec until now */
304261eeb9cSDaeho Jeong};
305261eeb9cSDaeho Jeong
306a7eeb823SChao Yu/* for the bitmap indicate blocks to be discarded */
3077fd9e544SJaegeuk Kimstruct discard_entry {
3087fd9e544SJaegeuk Kim	struct list_head list;	/* list head */
309a7eeb823SChao Yu	block_t start_blkaddr;	/* start blockaddr of current segment */
310a7eeb823SChao Yu	unsigned char discard_map[SIT_VBLOCK_MAP_SIZE];	/* segment discard bitmap */
3117fd9e544SJaegeuk Kim};
3127fd9e544SJaegeuk Kim
313969d1b18SChao Yu/* default discard granularity of inner discard thread, unit: block count */
314969d1b18SChao Yu#define DEFAULT_DISCARD_GRANULARITY		16
315969d1b18SChao Yu
316ba48a33eSChao Yu/* max discard pend list number */
317ba48a33eSChao Yu#define MAX_PLIST_NUM		512
318ba48a33eSChao Yu#define plist_idx(blk_num)	((blk_num) >= MAX_PLIST_NUM ?		\
3192f84babfSSheng Yong					(MAX_PLIST_NUM - 1) : ((blk_num) - 1))
320ba48a33eSChao Yu
32115469963SJaegeuk Kimenum {
32235ec7d57SChao Yu	D_PREP,			/* initial */
32335ec7d57SChao Yu	D_PARTIAL,		/* partially submitted */
32435ec7d57SChao Yu	D_SUBMIT,		/* all submitted */
32535ec7d57SChao Yu	D_DONE,			/* finished */
32615469963SJaegeuk Kim};
32715469963SJaegeuk Kim
328004b6862SChao Yustruct discard_info {
329004b6862SChao Yu	block_t lstart;			/* logical start address */
330004b6862SChao Yu	block_t len;			/* length */
331004b6862SChao Yu	block_t start;			/* actual start address in dev */
332004b6862SChao Yu};
333004b6862SChao Yu
334b01a9201SJaegeuk Kimstruct discard_cmd {
335004b6862SChao Yu	struct rb_node rb_node;		/* rb node located in rb-tree */
336004b6862SChao Yu	union {
337004b6862SChao Yu		struct {
338004b6862SChao Yu			block_t lstart;	/* logical start address */
339004b6862SChao Yu			block_t len;	/* length */
340004b6862SChao Yu			block_t start;	/* actual start address in dev */
341004b6862SChao Yu		};
342004b6862SChao Yu		struct discard_info di;	/* discard info */
343004b6862SChao Yu
344004b6862SChao Yu	};
345b01a9201SJaegeuk Kim	struct list_head list;		/* command list */
346b01a9201SJaegeuk Kim	struct completion wait;		/* compleation */
347c81abe34SJaegeuk Kim	struct block_device *bdev;	/* bdev */
348ec9895adSChao Yu	unsigned short ref;		/* reference count */
3499a744b92SChao Yu	unsigned char state;		/* state */
35072691af6SJaegeuk Kim	unsigned char queued;		/* queued discard */
351c81abe34SJaegeuk Kim	int error;			/* bio error */
35235ec7d57SChao Yu	spinlock_t lock;		/* for state/bio_ref updating */
35335ec7d57SChao Yu	unsigned short bio_ref;		/* bio reference count */
354275b66b0SChao Yu};
355275b66b0SChao Yu