Acquire kernel_lock directly in LFS syscalls.
This commit is contained in:
parent
26190df844
commit
d9bace2a92
@ -1,4 +1,4 @@
|
|||||||
$NetBSD: syscalls.master,v 1.197 2008/04/21 00:13:46 ad Exp $
|
$NetBSD: syscalls.master,v 1.198 2008/04/21 11:45:34 ad Exp $
|
||||||
|
|
||||||
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
|
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
|
||||||
|
|
||||||
@ -375,12 +375,12 @@
|
|||||||
182 STD MPSAFE { int sys_setegid(gid_t egid); }
|
182 STD MPSAFE { int sys_setegid(gid_t egid); }
|
||||||
183 STD MPSAFE { int sys_seteuid(uid_t euid); }
|
183 STD MPSAFE { int sys_seteuid(uid_t euid); }
|
||||||
#if defined(LFS) || !defined(_KERNEL)
|
#if defined(LFS) || !defined(_KERNEL)
|
||||||
184 STD { int sys_lfs_bmapv(fsid_t *fsidp, \
|
184 STD MPSAFE { int sys_lfs_bmapv(fsid_t *fsidp, \
|
||||||
struct block_info *blkiov, int blkcnt); }
|
struct block_info *blkiov, int blkcnt); }
|
||||||
185 STD { int sys_lfs_markv(fsid_t *fsidp, \
|
185 STD MPSAFE { int sys_lfs_markv(fsid_t *fsidp, \
|
||||||
struct block_info *blkiov, int blkcnt); }
|
struct block_info *blkiov, int blkcnt); }
|
||||||
186 STD { int sys_lfs_segclean(fsid_t *fsidp, u_long segment); }
|
186 STD MPSAFE { int sys_lfs_segclean(fsid_t *fsidp, u_long segment); }
|
||||||
187 STD { int sys_lfs_segwait(fsid_t *fsidp, \
|
187 STD MPSAFE { int sys_lfs_segwait(fsid_t *fsidp, \
|
||||||
struct timeval *tv); }
|
struct timeval *tv); }
|
||||||
#else
|
#else
|
||||||
184 EXCL lfs_bmapv
|
184 EXCL lfs_bmapv
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* $NetBSD: lfs_syscalls.c,v 1.128 2008/01/30 11:47:04 ad Exp $ */
|
/* $NetBSD: lfs_syscalls.c,v 1.129 2008/04/21 11:45:34 ad Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007
|
* Copyright (c) 1999, 2000, 2001, 2002, 2003, 2007, 2007, 2008
|
||||||
* The NetBSD Foundation, Inc.
|
* The NetBSD Foundation, Inc.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -68,7 +68,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.128 2008/01/30 11:47:04 ad Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: lfs_syscalls.c,v 1.129 2008/04/21 11:45:34 ad Exp $");
|
||||||
|
|
||||||
#ifndef LFS
|
#ifndef LFS
|
||||||
# define LFS /* for prototypes in syscallargs.h */
|
# define LFS /* for prototypes in syscallargs.h */
|
||||||
@ -139,6 +139,7 @@ sys_lfs_markv(struct lwp *l, const struct sys_lfs_markv_args *uap, register_t *r
|
|||||||
if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
|
if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
|
KERNEL_LOCK(1, NULL);
|
||||||
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
||||||
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
||||||
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
||||||
@ -149,6 +150,7 @@ sys_lfs_markv(struct lwp *l, const struct sys_lfs_markv_args *uap, register_t *r
|
|||||||
blkcnt * sizeof(BLOCK_INFO));
|
blkcnt * sizeof(BLOCK_INFO));
|
||||||
out:
|
out:
|
||||||
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
||||||
|
KERNEL_UNLOCK_ONE(NULL);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -182,6 +184,7 @@ sys_lfs_markv(struct lwp *l, const struct sys_lfs_markv_args *uap, register_t *r
|
|||||||
if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
|
if ((u_int) blkcnt > LFS_MARKV_MAXBLKCNT)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
|
||||||
|
KERNEL_LOCK(1, NULL);
|
||||||
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
||||||
blkiov15 = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO_15), LFS_NB_BLKIOV);
|
blkiov15 = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO_15), LFS_NB_BLKIOV);
|
||||||
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
||||||
@ -214,6 +217,7 @@ sys_lfs_markv(struct lwp *l, const struct sys_lfs_markv_args *uap, register_t *r
|
|||||||
out:
|
out:
|
||||||
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
||||||
lfs_free(fs, blkiov15, LFS_NB_BLKIOV);
|
lfs_free(fs, blkiov15, LFS_NB_BLKIOV);
|
||||||
|
KERNEL_UNLOCK_ONE(NULL);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -524,6 +528,7 @@ err2:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
err3:
|
err3:
|
||||||
|
KERNEL_UNLOCK_ONE(NULL);
|
||||||
/*
|
/*
|
||||||
* XXX should do segwrite here anyway?
|
* XXX should do segwrite here anyway?
|
||||||
*/
|
*/
|
||||||
@ -580,6 +585,7 @@ sys_lfs_bmapv(struct lwp *l, const struct sys_lfs_bmapv_args *uap, register_t *r
|
|||||||
blkcnt = SCARG(uap, blkcnt);
|
blkcnt = SCARG(uap, blkcnt);
|
||||||
if ((u_int) blkcnt > SIZE_T_MAX / sizeof(BLOCK_INFO))
|
if ((u_int) blkcnt > SIZE_T_MAX / sizeof(BLOCK_INFO))
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
KERNEL_LOCK(1, NULL);
|
||||||
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
||||||
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
if ((error = copyin(SCARG(uap, blkiov), blkiov,
|
||||||
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
blkcnt * sizeof(BLOCK_INFO))) != 0)
|
||||||
@ -590,6 +596,7 @@ sys_lfs_bmapv(struct lwp *l, const struct sys_lfs_bmapv_args *uap, register_t *r
|
|||||||
blkcnt * sizeof(BLOCK_INFO));
|
blkcnt * sizeof(BLOCK_INFO));
|
||||||
out:
|
out:
|
||||||
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
||||||
|
KERNEL_UNLOCK_ONE(NULL);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -622,6 +629,7 @@ sys_lfs_bmapv(struct lwp *l, const struct sys_lfs_bmapv_args *uap, register_t *r
|
|||||||
blkcnt = SCARG(uap, blkcnt);
|
blkcnt = SCARG(uap, blkcnt);
|
||||||
if ((size_t) blkcnt > SIZE_T_MAX / sizeof(BLOCK_INFO))
|
if ((size_t) blkcnt > SIZE_T_MAX / sizeof(BLOCK_INFO))
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
KERNEL_LOCK(1, NULL);
|
||||||
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
blkiov = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO), LFS_NB_BLKIOV);
|
||||||
blkiov15 = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO_15), LFS_NB_BLKIOV);
|
blkiov15 = lfs_malloc(fs, blkcnt * sizeof(BLOCK_INFO_15), LFS_NB_BLKIOV);
|
||||||
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
if ((error = copyin(SCARG(uap, blkiov), blkiov15,
|
||||||
@ -654,6 +662,7 @@ sys_lfs_bmapv(struct lwp *l, const struct sys_lfs_bmapv_args *uap, register_t *r
|
|||||||
out:
|
out:
|
||||||
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
lfs_free(fs, blkiov, LFS_NB_BLKIOV);
|
||||||
lfs_free(fs, blkiov15, LFS_NB_BLKIOV);
|
lfs_free(fs, blkiov15, LFS_NB_BLKIOV);
|
||||||
|
KERNEL_UNLOCK_ONE(NULL);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -861,9 +870,11 @@ sys_lfs_segclean(struct lwp *l, const struct sys_lfs_segclean_args *uap, registe
|
|||||||
if ((error = vfs_trybusy(mntp, RW_READER, NULL)) != 0)
|
if ((error = vfs_trybusy(mntp, RW_READER, NULL)) != 0)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
|
KERNEL_LOCK(1, NULL);
|
||||||
lfs_seglock(fs, SEGM_PROT);
|
lfs_seglock(fs, SEGM_PROT);
|
||||||
error = lfs_do_segclean(fs, segnum);
|
error = lfs_do_segclean(fs, segnum);
|
||||||
lfs_segunlock(fs);
|
lfs_segunlock(fs);
|
||||||
|
KERNEL_UNLOCK_ONE(NULL);
|
||||||
vfs_unbusy(mntp, false);
|
vfs_unbusy(mntp, false);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -951,6 +962,7 @@ lfs_segwait(fsid_t *fsidp, struct timeval *tv)
|
|||||||
u_long timeout;
|
u_long timeout;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
KERNEL_LOCK(1, NULL);
|
||||||
if (fsidp == NULL || (mntp = vfs_getvfs(fsidp)) == NULL)
|
if (fsidp == NULL || (mntp = vfs_getvfs(fsidp)) == NULL)
|
||||||
addr = &lfs_allclean_wakeup;
|
addr = &lfs_allclean_wakeup;
|
||||||
else
|
else
|
||||||
@ -961,6 +973,7 @@ lfs_segwait(fsid_t *fsidp, struct timeval *tv)
|
|||||||
*/
|
*/
|
||||||
timeout = tvtohz(tv);
|
timeout = tvtohz(tv);
|
||||||
error = tsleep(addr, PCATCH | PVFS, "segment", timeout);
|
error = tsleep(addr, PCATCH | PVFS, "segment", timeout);
|
||||||
|
KERNEL_UNLOCK_ONE(NULL);
|
||||||
return (error == ERESTART ? EINTR : 0);
|
return (error == ERESTART ? EINTR : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user