svn commit: r186898 - head/sys/ufs/ufs
Konstantin Belousov
kib at FreeBSD.org
Thu Jan 8 04:49:56 PST 2009
Author: kib
Date: Thu Jan 8 12:49:55 2009
New Revision: 186898
URL: http://svn.freebsd.org/changeset/base/186898
Log:
Lock the uepm_lock around the autostart of extattrs.
Reported and tested by: pho
Reviewed by: rwatson
MFC after: 3 weeks
Modified:
head/sys/ufs/ufs/ufs_extattr.c
Modified: head/sys/ufs/ufs/ufs_extattr.c
==============================================================================
--- head/sys/ufs/ufs/ufs_extattr.c Thu Jan 8 12:48:27 2009 (r186897)
+++ head/sys/ufs/ufs/ufs_extattr.c Thu Jan 8 12:49:55 2009 (r186898)
@@ -93,6 +93,10 @@ static int ufs_extattr_set(struct vnode
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, stru
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 ufs
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,
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);
More information about the svn-src-head
mailing list