18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/* -*- mode: c; c-basic-offset: 8; -*-
38c2ecf20Sopenharmony_ci * vim: noexpandtab sw=8 ts=8 sts=0:
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * filecheck.h
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Online file check.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Copyright (C) 2016 SuSE.  All rights reserved.
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#ifndef FILECHECK_H
148c2ecf20Sopenharmony_ci#define FILECHECK_H
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <linux/types.h>
178c2ecf20Sopenharmony_ci#include <linux/list.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* File check errno */
218c2ecf20Sopenharmony_cienum {
228c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_SUCCESS = 0,	/* Success */
238c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_FAILED = 1000,	/* Other failure */
248c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_INPROGRESS,		/* In progress */
258c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_READONLY,		/* Read only */
268c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_INJBD,		/* Buffer in jbd */
278c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_INVALIDINO,		/* Invalid ino */
288c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_BLOCKECC,		/* Block ecc */
298c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_BLOCKNO,		/* Block number */
308c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_VALIDFLAG,		/* Inode valid flag */
318c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_GENERATION,		/* Inode generation */
328c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_ERR_UNSUPPORTED		/* Unsupported */
338c2ecf20Sopenharmony_ci};
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define OCFS2_FILECHECK_ERR_START	OCFS2_FILECHECK_ERR_FAILED
368c2ecf20Sopenharmony_ci#define OCFS2_FILECHECK_ERR_END		OCFS2_FILECHECK_ERR_UNSUPPORTED
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct ocfs2_filecheck {
398c2ecf20Sopenharmony_ci	struct list_head fc_head;	/* File check entry list head */
408c2ecf20Sopenharmony_ci	spinlock_t fc_lock;
418c2ecf20Sopenharmony_ci	unsigned int fc_max;	/* Maximum number of entry in list */
428c2ecf20Sopenharmony_ci	unsigned int fc_size;	/* Current entry count in list */
438c2ecf20Sopenharmony_ci	unsigned int fc_done;	/* Finished entry count in list */
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define OCFS2_FILECHECK_MAXSIZE		100
478c2ecf20Sopenharmony_ci#define OCFS2_FILECHECK_MINSIZE		10
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* File check operation type */
508c2ecf20Sopenharmony_cienum {
518c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_TYPE_CHK = 0,	/* Check a file(inode) */
528c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_TYPE_FIX,	/* Fix a file(inode) */
538c2ecf20Sopenharmony_ci	OCFS2_FILECHECK_TYPE_SET = 100	/* Set entry list maximum size */
548c2ecf20Sopenharmony_ci};
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_cistruct ocfs2_filecheck_sysfs_entry {	/* sysfs entry per partition */
578c2ecf20Sopenharmony_ci	struct kobject fs_kobj;
588c2ecf20Sopenharmony_ci	struct completion fs_kobj_unregister;
598c2ecf20Sopenharmony_ci	struct ocfs2_filecheck *fs_fcheck;
608c2ecf20Sopenharmony_ci};
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ciint ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb);
648c2ecf20Sopenharmony_civoid ocfs2_filecheck_remove_sysfs(struct ocfs2_super *osb);
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#endif  /* FILECHECK_H */
67