svn commit: r187886 - in stable/7/sys: . contrib/pf dev/cxgb ufs/ufs

Konstantin Belousov kib at FreeBSD.org
Thu Jan 29 02:49:23 PST 2009


Author: kib
Date: Thu Jan 29 10:49:21 2009
New Revision: 187886
URL: http://svn.freebsd.org/changeset/base/187886

Log:
  MFC r186898:
  Lock the uepm_lock around the autostart of extattrs.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/ufs/ufs/ufs_extattr.c

Modified: stable/7/sys/ufs/ufs/ufs_extattr.c
==============================================================================
--- stable/7/sys/ufs/ufs/ufs_extattr.c	Thu Jan 29 10:47:01 2009	(r187885)
+++ stable/7/sys/ufs/ufs/ufs_extattr.c	Thu Jan 29 10:49:21 2009	(r187886)
@@ -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-stable mailing list