summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-01-08 12:49:55 +0000
committerkib <kib@FreeBSD.org>2009-01-08 12:49:55 +0000
commitca2e9cb3a95ecaff97ffcaba97157c04af4855c4 (patch)
treeb9b3c78a46810a4edfee8f02414f3e047ee8b350
parent1f52da301fa5379c80d0cff685919ebf84bbfcb2 (diff)
downloadFreeBSD-src-ca2e9cb3a95ecaff97ffcaba97157c04af4855c4.zip
FreeBSD-src-ca2e9cb3a95ecaff97ffcaba97157c04af4855c4.tar.gz
Lock the uepm_lock around the autostart of extattrs.
Reported and tested by: pho Reviewed by: rwatson MFC after: 3 weeks
-rw-r--r--sys/ufs/ufs/ufs_extattr.c45
1 files changed, 30 insertions, 15 deletions
diff --git a/sys/ufs/ufs/ufs_extattr.c b/sys/ufs/ufs/ufs_extattr.c
index b991920..d034bee 100644
--- a/sys/ufs/ufs/ufs_extattr.c
+++ b/sys/ufs/ufs/ufs_extattr.c
@@ -93,6 +93,10 @@ static int ufs_extattr_set(struct vnode *vp, int attrnamespace,
struct thread *td);
static int ufs_extattr_rm(struct vnode *vp, int attrnamespace,
const char *name, struct ucred *cred, struct thread *td);
+static int ufs_extattr_autostart_locked(struct mount *mp,
+ struct thread *td);
+static int ufs_extattr_start_locked(struct ufsmount *ump,
+ struct thread *td);
/*
* Per-FS attribute lock protecting attribute operations.
@@ -208,24 +212,22 @@ ufs_extattr_start(struct mount *mp, struct thread *td)
ump = VFSTOUFS(mp);
ufs_extattr_uepm_lock(ump, td);
+ error = ufs_extattr_start_locked(ump, td);
+ ufs_extattr_uepm_unlock(ump, td);
+ return (error);
+}
- if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED)) {
- error = EOPNOTSUPP;
- goto unlock;
- }
- if (ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED) {
- error = EBUSY;
- goto unlock;
- }
+static int
+ufs_extattr_start_locked(struct ufsmount *ump, struct thread *td)
+{
+ if (!(ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_INITIALIZED))
+ return (EOPNOTSUPP);
+ if (ump->um_extattr.uepm_flags & UFS_EXTATTR_UEPM_STARTED)
+ return (EBUSY);
ump->um_extattr.uepm_flags |= UFS_EXTATTR_UEPM_STARTED;
-
ump->um_extattr.uepm_ucred = crhold(td->td_ucred);
-
-unlock:
- ufs_extattr_uepm_unlock(ump, td);
-
- return (error);
+ return (0);
}
#ifdef UFS_EXTATTR_AUTOSTART
@@ -448,6 +450,19 @@ ufs_extattr_iterate_directory(struct ufsmount *ump, struct vnode *dvp,
int
ufs_extattr_autostart(struct mount *mp, struct thread *td)
{
+ struct ufsmount *ump;
+ int error;
+
+ ump = VFSTOUFS(mp);
+ ufs_extattr_uepm_lock(ump, td);
+ error = ufs_extattr_autostart_locked(mp, td);
+ ufs_extattr_uepm_unlock(ump, td);
+ return (error);
+}
+
+static int
+ufs_extattr_autostart_locked(struct mount *mp, struct thread *td)
+{
struct vnode *rvp, *attr_dvp, *attr_system_dvp, *attr_user_dvp;
struct ufsmount *ump = VFSTOUFS(mp);
int error;
@@ -491,7 +506,7 @@ ufs_extattr_autostart(struct mount *mp, struct thread *td)
goto return_vput_attr_dvp;
}
- error = ufs_extattr_start(mp, td);
+ error = ufs_extattr_start_locked(ump, td);
if (error) {
printf("ufs_extattr_autostart: ufs_extattr_start failed (%d)\n",
error);
OpenPOWER on IntegriCloud