Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2016 05:40:07 +1000 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        Konstantin Belousov <kostikbel@gmail.com>, fs@freebsd.org
Subject:   Re: quick fix for slow directory shrinking in ffs
Message-ID:  <20160518052656.R5764@besplex.bde.org>
In-Reply-To: <20160518035413.L4357@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>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160518052656.R5764>