mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-21 15:45:02 +00:00
- Avoid holding mutex around M_WAITOK allocations.
- Add locking for mnt_opt field. MFC after: 1 week
This commit is contained in:
parent
44a37a783b
commit
2ff6f0f89a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=196943
@ -45,20 +45,33 @@ vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg,
|
||||
{
|
||||
struct vfsopt *opt;
|
||||
size_t namesize;
|
||||
int locked;
|
||||
|
||||
if (!(locked = mtx_owned(MNT_MTX(vfsp))))
|
||||
MNT_ILOCK(vfsp);
|
||||
|
||||
if (vfsp->mnt_opt == NULL) {
|
||||
vfsp->mnt_opt = malloc(sizeof(*vfsp->mnt_opt), M_MOUNT, M_WAITOK);
|
||||
TAILQ_INIT(vfsp->mnt_opt);
|
||||
void *opts;
|
||||
|
||||
MNT_IUNLOCK(vfsp);
|
||||
opts = malloc(sizeof(*vfsp->mnt_opt), M_MOUNT, M_WAITOK);
|
||||
MNT_ILOCK(vfsp);
|
||||
if (vfsp->mnt_opt == NULL) {
|
||||
vfsp->mnt_opt = opts;
|
||||
TAILQ_INIT(vfsp->mnt_opt);
|
||||
} else {
|
||||
free(opts, M_MOUNT);
|
||||
}
|
||||
}
|
||||
|
||||
opt = malloc(sizeof(*opt), M_MOUNT, M_WAITOK);
|
||||
MNT_IUNLOCK(vfsp);
|
||||
|
||||
opt = malloc(sizeof(*opt), M_MOUNT, M_WAITOK);
|
||||
namesize = strlen(name) + 1;
|
||||
opt->name = malloc(namesize, M_MOUNT, M_WAITOK);
|
||||
strlcpy(opt->name, name, namesize);
|
||||
opt->pos = -1;
|
||||
opt->seen = 1;
|
||||
|
||||
if (arg == NULL) {
|
||||
opt->value = NULL;
|
||||
opt->len = 0;
|
||||
@ -67,16 +80,23 @@ vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg,
|
||||
opt->value = malloc(opt->len, M_MOUNT, M_WAITOK);
|
||||
bcopy(arg, opt->value, opt->len);
|
||||
}
|
||||
/* TODO: Locking. */
|
||||
|
||||
MNT_ILOCK(vfsp);
|
||||
TAILQ_INSERT_TAIL(vfsp->mnt_opt, opt, link);
|
||||
if (!locked)
|
||||
MNT_IUNLOCK(vfsp);
|
||||
}
|
||||
|
||||
void
|
||||
vfs_clearmntopt(vfs_t *vfsp, const char *name)
|
||||
{
|
||||
int locked;
|
||||
|
||||
/* TODO: Locking. */
|
||||
if (!(locked = mtx_owned(MNT_MTX(vfsp))))
|
||||
MNT_ILOCK(vfsp);
|
||||
vfs_deleteopt(vfsp->mnt_opt, name);
|
||||
if (!locked)
|
||||
MNT_IUNLOCK(vfsp);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user