mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add mutex_enter_interruptible() for interruptible sleeping IOCTLs
Many long-running ZFS ioctls lock the spa_namespace_lock, forcing concurrent ioctls to sleep for the mutex. Previously, the only option is to call mutex_enter() which sleeps uninterruptibly. This is a usability issue for sysadmins, for example, if the admin runs `zpool status` while a slow `zpool import` is ongoing, the admin's shell will be locked in uninterruptible sleep for a long time. This patch resolves this admin usability issue by introducing mutex_enter_interruptible() which sleeps interruptibly while waiting to acquire a lock. It is implemented for both Linux and FreeBSD. The ZFS_IOC_POOL_CONFIGS ioctl, used by `zpool status`, is changed to use this new macro so that the command can be interrupted if it is issued during a concurrent `zpool import` (or other long-running operation). Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Thomas Bertschinger <bertschinger@lanl.gov> Closes #15360
This commit is contained in:
committed by
Tony Hutter
parent
8ba748d414
commit
f9a9aea126
@@ -64,6 +64,7 @@ typedef enum {
|
||||
} while (0)
|
||||
#define mutex_destroy(lock) sx_destroy(lock)
|
||||
#define mutex_enter(lock) sx_xlock(lock)
|
||||
#define mutex_enter_interruptible(lock) sx_xlock_sig(lock)
|
||||
#define mutex_enter_nested(lock, type) sx_xlock(lock)
|
||||
#define mutex_tryenter(lock) sx_try_xlock(lock)
|
||||
#define mutex_exit(lock) sx_xunlock(lock)
|
||||
|
||||
@@ -128,7 +128,6 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
|
||||
|
||||
#define NESTED_SINGLE 1
|
||||
|
||||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
||||
#define mutex_enter_nested(mp, subclass) \
|
||||
{ \
|
||||
ASSERT3P(mutex_owner(mp), !=, current); \
|
||||
@@ -137,16 +136,22 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
|
||||
spl_mutex_lockdep_on_maybe(mp); \
|
||||
spl_mutex_set_owner(mp); \
|
||||
}
|
||||
#else /* CONFIG_DEBUG_LOCK_ALLOC */
|
||||
#define mutex_enter_nested(mp, subclass) \
|
||||
{ \
|
||||
|
||||
#define mutex_enter_interruptible(mp) \
|
||||
/* CSTYLED */ \
|
||||
({ \
|
||||
int _rc_; \
|
||||
\
|
||||
ASSERT3P(mutex_owner(mp), !=, current); \
|
||||
spl_mutex_lockdep_off_maybe(mp); \
|
||||
mutex_lock(MUTEX(mp)); \
|
||||
_rc_ = mutex_lock_interruptible(MUTEX(mp)); \
|
||||
spl_mutex_lockdep_on_maybe(mp); \
|
||||
spl_mutex_set_owner(mp); \
|
||||
}
|
||||
#endif /* CONFIG_DEBUG_LOCK_ALLOC */
|
||||
if (!_rc_) { \
|
||||
spl_mutex_set_owner(mp); \
|
||||
} \
|
||||
\
|
||||
_rc_; \
|
||||
})
|
||||
|
||||
#define mutex_enter(mp) mutex_enter_nested((mp), 0)
|
||||
|
||||
|
||||
+1
-1
@@ -837,7 +837,7 @@ extern kmutex_t spa_namespace_lock;
|
||||
|
||||
extern void spa_write_cachefile(spa_t *, boolean_t, boolean_t, boolean_t);
|
||||
extern void spa_config_load(void);
|
||||
extern nvlist_t *spa_all_configs(uint64_t *);
|
||||
extern int spa_all_configs(uint64_t *generation, nvlist_t **pools);
|
||||
extern void spa_config_set(spa_t *spa, nvlist_t *config);
|
||||
extern nvlist_t *spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg,
|
||||
int getstats);
|
||||
|
||||
@@ -274,11 +274,13 @@ typedef struct kmutex {
|
||||
extern void mutex_init(kmutex_t *mp, char *name, int type, void *cookie);
|
||||
extern void mutex_destroy(kmutex_t *mp);
|
||||
extern void mutex_enter(kmutex_t *mp);
|
||||
extern int mutex_enter_check_return(kmutex_t *mp);
|
||||
extern void mutex_exit(kmutex_t *mp);
|
||||
extern int mutex_tryenter(kmutex_t *mp);
|
||||
|
||||
#define NESTED_SINGLE 1
|
||||
#define mutex_enter_nested(mp, class) mutex_enter(mp)
|
||||
#define mutex_enter_interruptible(mp) mutex_enter_check_return(mp)
|
||||
/*
|
||||
* RW locks
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user