From owner-freebsd-fs@freebsd.org Wed Feb 3 16:07:51 2016 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6EBD0A9ACE9 for ; Wed, 3 Feb 2016 16:07:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 15AB71627 for ; Wed, 3 Feb 2016 16:07:50 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u13G7f2J036905 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 3 Feb 2016 18:07:42 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u13G7f2J036905 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u13G7fqE036904; Wed, 3 Feb 2016 18:07:41 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 3 Feb 2016 18:07:41 +0200 From: Konstantin Belousov To: Rick Macklem Cc: FreeBSD Filesystems , Kirk McKusick Subject: Re: panic ffs_truncate3 (maybe fuse being evil) Message-ID: <20160203160741.GJ91220@kib.kiev.ua> References: <1696608910.154845456.1452438117036.JavaMail.zimbra@uoguelph.ca> <20160116191116.GI3942@kib.kiev.ua> <853868666.163292727.1452986431921.JavaMail.zimbra@uoguelph.ca> <20160117035858.GO3942@kib.kiev.ua> <855760730.165482737.1453177516248.JavaMail.zimbra@uoguelph.ca> <20160201221710.GR91220@kib.kiev.ua> <1375939202.186412561.1454375239581.JavaMail.zimbra@uoguelph.ca> <20160202144812.GZ91220@kib.kiev.ua> <1548616575.1027329.1454455168829.JavaMail.zimbra@uoguelph.ca> <20160203153850.GI91220@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160203153850.GI91220@kib.kiev.ua> User-Agent: Mutt/1.5.24 (2015-08-30) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2016 16:07:51 -0000 On Wed, Feb 03, 2016 at 05:38:50PM +0200, Konstantin Belousov wrote: > On Tue, Feb 02, 2016 at 06:19:28PM -0500, Rick Macklem wrote: > > Kostik wrote: > > > I do think that the IO_UNIT patch fixes some situations where the buffer > > > can be left on the vnode queue. I did not found any other places so far. > > Could you, please, try the following explicit buffer relse patch in > addition to the IO_UNIT patch ? This is as similar to r174973 for IO_EXT > ffs2_balloc() as I can do. Please use this version, for several places in the old patch, rollback is not needed. diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index 8551085..9f15df5 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -654,8 +654,16 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size, ffs_blkpref_ufs2(ip, lbn, (int)lbn, &dp->di_extb[0]), osize, nsize, flags, cred, &bp); - if (error) + if (error != 0) { + /* getblk does truncation, if needed */ + bp = getblk(vp, -1 - lbn, osize, 0, 0, + GB_NOCREAT); + if (bp != NULL) { + bp->b_xflags |= BX_ALTDATA; + brelse(bp); + } return (error); + } bp->b_xflags |= BX_ALTDATA; if (DOINGSOFTDEP(vp)) softdep_setup_allocext(ip, lbn, @@ -671,8 +679,17 @@ ffs_balloc_ufs2(struct vnode *vp, off_t startoffset, int size, error = ffs_alloc(ip, lbn, ffs_blkpref_ufs2(ip, lbn, (int)lbn, &dp->di_extb[0]), nsize, flags, cred, &newb); - if (error) + if (error != 0) { + bp = getblk(vp, -1 - lbn, nsize, 0, 0, + GB_NOCREAT); + if (bp != NULL) { + bp->b_xflags |= BX_ALTDATA; + bp->b_flags |= B_RELBUF | B_INVAL; + bp->b_flags &= ~B_ASYNC; + brelse(bp); + } return (error); + } bp = getblk(vp, -1 - lbn, nsize, 0, 0, gbflags); bp->b_blkno = fsbtodb(fs, newb); bp->b_xflags |= BX_ALTDATA; diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 5a70e5c..ecc3f9b 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1311,7 +1313,8 @@ ffs_close_ea(struct vnode *vp, int commit, struct ucred *cred, struct thread *td /* XXX: I'm not happy about truncating to zero size */ if (ip->i_ea_len < dp->di_extsize) error = ffs_truncate(vp, 0, IO_EXT, cred); - error = ffs_extwrite(vp, &luio, IO_EXT | IO_SYNC, cred); + error = ffs_extwrite(vp, &luio, IO_EXT | IO_SYNC | IO_UNIT, + cred); } if (--ip->i_ea_refs == 0) { free(ip->i_ea_area, M_TEMP);