Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (C) 2019 Oracle.  All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Author: Darrick J. Wong <darrick.wong@oracle.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #ifndef __XFS_PWORK_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #define __XFS_PWORK_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) struct xfs_pwork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) struct xfs_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) typedef int (*xfs_pwork_work_fn)(struct xfs_mount *mp, struct xfs_pwork *pwork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * Parallel work coordination structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct xfs_pwork_ctl {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	struct workqueue_struct	*wq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	struct xfs_mount	*mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	xfs_pwork_work_fn	work_fn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	struct wait_queue_head	poll_wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	atomic_t		nr_work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	int			error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)  * Embed this parallel work control item inside your own work structure,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)  * then queue work with it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct xfs_pwork {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	struct work_struct	work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	struct xfs_pwork_ctl	*pctl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define XFS_PWORK_SINGLE_THREADED	{ .pctl = NULL }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* Have we been told to abort? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) xfs_pwork_ctl_want_abort(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	struct xfs_pwork_ctl	*pctl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	return pctl && pctl->error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /* Have we been told to abort? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) static inline bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) xfs_pwork_want_abort(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	struct xfs_pwork	*pwork)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	return xfs_pwork_ctl_want_abort(pwork->pctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) int xfs_pwork_init(struct xfs_mount *mp, struct xfs_pwork_ctl *pctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		xfs_pwork_work_fn work_fn, const char *tag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		unsigned int nr_threads);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) void xfs_pwork_queue(struct xfs_pwork_ctl *pctl, struct xfs_pwork *pwork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int xfs_pwork_destroy(struct xfs_pwork_ctl *pctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void xfs_pwork_poll(struct xfs_pwork_ctl *pctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) unsigned int xfs_pwork_guess_datadev_parallelism(struct xfs_mount *mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #endif /* __XFS_PWORK_H__ */