From owner-freebsd-fs@FreeBSD.ORG Fri Jun 18 07:18:08 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB6C3106564A; Fri, 18 Jun 2010 07:18:07 +0000 (UTC) (envelope-from lynx.ripe@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 666708FC1E; Fri, 18 Jun 2010 07:18:07 +0000 (UTC) Received: by iwn7 with SMTP id 7so985285iwn.13 for ; Fri, 18 Jun 2010 00:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=LVDv93pnNJT9lcqpw99Fb3tOWLyxtEfBpB/0XSTQjMQ=; b=Z/1BowuV7AKZHNT/ZJa/N9T7itQL+oFKqS08ybprtVDaZEIaHZRetH0o13Z+sdaKt9 OZcw362vClCwJxOmNK+69Ks00gozcYZxUC6NDy+Oh10s7v4lFJNKnw2qKm+RPPYMBPz7 EJVM5PeXc/SykeRxmBsFoqODjCgTWhqhUwXcI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=idelFqNtv38yc1Q+ZDlnrPC6j79nlQPNI5buMWPjqkjzfoPy8AK5Kk/EfIlXnxliik lJMyRgrnkim2hiO7oel28lxYTriJnbS+dE7sYA5XWM4itqhX4Fcy2HH/yHajl+9uBWnT i2M+9Lh55aJzBEPblSLSCBoogHfEWb7lpGN5I= MIME-Version: 1.0 Received: by 10.231.85.147 with SMTP id o19mr760350ibl.82.1276845486894; Fri, 18 Jun 2010 00:18:06 -0700 (PDT) Received: by 10.231.146.199 with HTTP; Fri, 18 Jun 2010 00:18:06 -0700 (PDT) In-Reply-To: <20100617083239.GZ13238@deviant.kiev.zoral.com.ua> References: <201006162220.o5GMK3uM002900@freefall.freebsd.org> <20100617072841.GY13238@deviant.kiev.zoral.com.ua> <20100617083239.GZ13238@deviant.kiev.zoral.com.ua> Date: Fri, 18 Jun 2010 10:18:06 +0300 Message-ID: From: Dmitry Pryanishnikov To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-fs@freebsd.org, trasz@freebsd.org Subject: Re: kern/147890: [ufs] [regression] ufs-related lock problem in RELENG_8 (18.04.2010 -> 20.04.2010) X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jun 2010 07:18:08 -0000 Hello! 2010/6/17 Kostik Belousov : > > What _could_ happen in your case is the relock in ufs_accessx for QUOTA. > ufs_delete_denied() calls VOP_ACCESSX for both parent directory > and target vnode while parent directory is locked. If source directory > is not exclusively locked, LOR can happen, since ufs_accessx has to > unlock and lock directory vnode. I am not sure how many similar cases > of VOP_ACCESS[X] is places in the problematic locations. > > Try the (untested) patch below. Thank you! The kernel with this patch applied (RELENG_8 date =3D 14.06.2010) has been running for 9 hours, the problem does not manifest itself (with unpatched kernel the problem typically appear within 1st hour of uptime). > > diff --git a/sys/ufs/ufs/ufs_lookup.c b/sys/ufs/ufs/ufs_lookup.c > index 0030c52..c779491 100644 > --- a/sys/ufs/ufs/ufs_lookup.c > +++ b/sys/ufs/ufs/ufs_lookup.c > @@ -77,6 +77,32 @@ SYSCTL_INT(_debug, OID_AUTO, dircheck, CTLFLAG_RW, &di= rchk, 0, ""); > =A0/* true if old FS format...*/ > =A0#define OFSFMT(vp) =A0 =A0 ((vp)->v_mount->mnt_maxsymlinklen <=3D 0) > > +#ifdef QUOTA > +static int > +ufs_lookup_upgrade_lock(struct vnode *vp) > +{ > + =A0 =A0 =A0 int error; > + > + =A0 =A0 =A0 ASSERT_VOP_LOCKED(vp, __FUNCTION__); > + =A0 =A0 =A0 if (VOP_ISLOCKED(vp) =3D=3D LK_EXCLUSIVE) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (0); > + > + =A0 =A0 =A0 error =3D 0; > + > + =A0 =A0 =A0 /* > + =A0 =A0 =A0 =A0* Upgrade vnode lock, since getinoquota() > + =A0 =A0 =A0 =A0* requires exclusive lock to modify inode. > + =A0 =A0 =A0 =A0*/ > + =A0 =A0 =A0 vhold(vp); > + =A0 =A0 =A0 vn_lock(vp, LK_UPGRADE | LK_RETRY); > + =A0 =A0 =A0 VI_LOCK(vp); > + =A0 =A0 =A0 if (vp->v_iflag & VI_DOOMED) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D ENOENT; > + =A0 =A0 =A0 vdropl(vp); > + =A0 =A0 =A0 return (error); > +} > +#endif > + > =A0static int > =A0ufs_delete_denied(struct vnode *vdp, struct vnode *tdp, struct ucred *= cred, > =A0 =A0 struct thread *td) > @@ -232,6 +258,13 @@ ufs_lookup_ino(struct vnode *vdp, struct vnode **vpp= , struct componentname *cnp, > =A0 =A0 =A0 =A0vnode_create_vobject(vdp, DIP(dp, i_size), cnp->cn_thread)= ; > > =A0 =A0 =A0 =A0bmask =3D VFSTOUFS(vdp->v_mount)->um_mountp->mnt_stat.f_io= size - 1; > +#ifdef QUOTA > + =A0 =A0 =A0 if ((nameiop =3D=3D DELETE || nameiop =3D=3D RENAME) && (fl= ags & ISLASTCN)) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 error =3D ufs_lookup_upgrade_lock(vdp); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (error !=3D 0) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (error); > + =A0 =A0 =A0 } > +#endif > > =A0restart: > =A0 =A0 =A0 =A0bp =3D NULL; > --=20 Sincerely, Dmitry nic-hdl: LYNX-RIPE