From owner-freebsd-fs@freebsd.org Tue May 17 19:40:19 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 EC41CB3D061 for ; Tue, 17 May 2016 19:40:19 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id D91BE1D0B for ; Tue, 17 May 2016 19:40:19 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: by mailman.ysv.freebsd.org (Postfix) id D4FC3B3D05F; Tue, 17 May 2016 19:40:19 +0000 (UTC) Delivered-To: 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 D2582B3D05E for ; Tue, 17 May 2016 19:40:19 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail105.syd.optusnet.com.au (mail105.syd.optusnet.com.au [211.29.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id 8F5851D0A for ; Tue, 17 May 2016 19:40:19 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-149-109.carlnfd1.nsw.optusnet.com.au (c122-106-149-109.carlnfd1.nsw.optusnet.com.au [122.106.149.109]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 4E38C1046239; Wed, 18 May 2016 05:40:10 +1000 (AEST) Date: Wed, 18 May 2016 05:40:07 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans cc: Konstantin Belousov , fs@freebsd.org Subject: Re: quick fix for slow directory shrinking in ffs In-Reply-To: <20160518035413.L4357@besplex.bde.org> Message-ID: <20160518052656.R5764@besplex.bde.org> References: <20160517072705.F2157@besplex.bde.org> <20160517082050.GX89104@kib.kiev.ua> <20160517192933.U4573@besplex.bde.org> <20160517111715.GC89104@kib.kiev.ua> <20160518035413.L4357@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=c+ZWOkJl c=1 sm=1 tr=0 a=R/f3m204ZbWUO/0rwPSMPw==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=7sixqL4dHYFS359oKKQA:9 a=91Z7TcaMQPEi1bVU:21 a=sc9wKKxEHgg0U6Hn:21 a=CjuIK1q_8ugA:10 X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2016 19:40:20 -0000 On Wed, 18 May 2016, Bruce Evans wrote: > On Tue, 17 May 2016, Konstantin Belousov wrote: >> diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c >> index 0202820..50b456b 100644 >> --- a/sys/ufs/ffs/ffs_inode.c >> +++ b/sys/ufs/ffs/ffs_inode.c >> @@ -610,7 +610,7 @@ extclean: >> softdep_journal_freeblocks(ip, cred, length, IO_EXT); >> else >> softdep_setup_freeblocks(ip, length, IO_EXT); >> - return (ffs_update(vp, !DOINGASYNC(vp))); >> + return (ffs_update(vp, (flags & IO_SYNC) != 0 || !DOINGASYNC(vp))); >> } >> >> /* > > Oops, this needs fixing in my version, but in -current the fix has > little effect since in -current ffs_update() still dishonors the waitfor > flag for its bwrite()/bdwrite() decision if DOINGASYNC(). This is > essentially the same as dishonoring the IO_SYNC flag here. > > ffs_update() needs the same fix in 4 more places. Also, ftruncate() seems to be broken. POSIX doesn't seem to require it to honor O_SYNC, but POLA requires this. But there is no VOP_TRUNCATE(); truncation is done using VOP_SETATTR() and there is no way to pass down the O_SYNC flag to it; in practice, ffs just does UFS_TRUNCATE() without IO_SYNC. This makes a difference mainly for async mounts with my fixes to honor IO_SYNC in ffs_update(). With async mounts, consistency of the file system is not guaranteed but O_SYNC for a file should at least cause all of the file data and most of its metdata to be written. Not syncing for ftruncate() unnecessarily loses metadata writes. With !async mounts, consistency of the file system is partly guaranteed and lost metadata writes for ftruncate() shouldn't affect this -- they should just lose the ftruncate() atomically. vfs could do an fsync() after VOP_SETATTR() for the O_SYNC case. This reduces the race window. Bruce