All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] xfs: reflink/scrub/quota fixes
@ 2018-01-26  2:04 Darrick J. Wong
  2018-01-26  2:04 ` [PATCH 1/6] xfs: refactor accounting updates out of xfs_bmap_btalloc Darrick J. Wong
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Darrick J. Wong @ 2018-01-26  2:04 UTC (permalink / raw)
  To: darrick.wong; +Cc: linux-xfs

Hi all,

This is a rollup of all the remaining patches I've sent in the past 9
days or so.  If all goes well I hope to land this during the 4.16 merge.

Running generic/232 with quotas and reflink demonstrated that there was
something wrong with the way we did quota accounting -- on an otherwise
idle system, fs-wide du block count numbers didn't match the quota
reports.  I started digging into why the quota accounting was wrong, and
the following are the results of my bug hunt.

Patches 1-2 reorganize the copy on write quota updating code to reflect
how the CoW fork works now.  In short, the CoW fork is entirely in
memory, so we can only use the in-memory quota reservation counters for
all CoW blocks; the accounting only becomes permanent if we remap an
extent into the data fork.

Patch 3 creates a separate i_cow_blocks counter to track all the CoW
blocks assigned to a file, which makes changing a file's uid/gid/prjid
easier, makes reporting cow blocks via stat easy, and enables various
cleanups.

Patch 4 fixes a serious corruption problem with the cow extent
allocation -- when we allocate into the CoW fork with the cow extent
size hint set, the allocator enlarges the allocation request to try to
hit alignment goals.  However, if the allocated extent does not actually
fulfill any of the requested range, we send a garbage zero-length extent
back to the iomap code (which also doesn't notice), and the write lands
at the startblock of the garbage extent.  The fix is to detect that we
didn't fill the entire requested range and fix up the returned mapping
so that we always fill the first block of the requested allocation and
for CoW to check the validity returned mappings before blowing things
up.  This also fixes a problem where a direct io overwrite can return
ENOSPC to userspace because of the same fragmentation problem.

The 5th patch fixes a hard to reproduce race between truncate and
buffered CoW writeback.  Writeback doesn't seem to take i_rwsem (aka the
iolock) when it's gathering io requests, so it races with a
truncate-down, which starts by reducing i_size before moving on to
removing the pages from the page cache.  If the writeback was to a
shared block and we "win" the race, we'll return the CoW mapping but
it'll be deemed invalid because it's beyond EOF.  We then blow an assert
when we try to go to the data fork for a valid mapping (because we
should never do that!) though even any data fork mapping will also be
invalidated and we ultimately don't write anything.

The 6th patch fixes a NULL pointer deref because we incorrectly
freed the inode btree cursor if there's an error while counting the
blocks in the inode btree for rmapbt cross-referencing.

Anyway, with this set applied I think we're ready to remove the reflink
EXPERIMENTAL tag during the 4.16 cycle.

--D

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-01-26 19:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-26  2:04 [PATCH v2 0/6] xfs: reflink/scrub/quota fixes Darrick J. Wong
2018-01-26  2:04 ` [PATCH 1/6] xfs: refactor accounting updates out of xfs_bmap_btalloc Darrick J. Wong
2018-01-26 12:19   ` Christoph Hellwig
2018-01-26 19:06   ` Brian Foster
2018-01-26  2:05 ` [PATCH 2/6] xfs: CoW fork operations should only update quota reservations Darrick J. Wong
2018-01-26 19:06   ` Brian Foster
2018-01-26 19:20     ` Darrick J. Wong
2018-01-26  2:05 ` [PATCH 3/6] xfs: track CoW blocks separately in the inode Darrick J. Wong
2018-01-26  2:05 ` [PATCH 4/6] xfs: don't screw up direct writes when freesp is fragmented Darrick J. Wong
2018-01-26 19:24   ` Brian Foster
2018-01-26 19:49     ` Darrick J. Wong
2018-01-26  2:05 ` [PATCH 5/6] xfs: skip CoW writes past EOF when writeback races with truncate Darrick J. Wong
2018-01-26 12:21   ` Christoph Hellwig
2018-01-26  2:05 ` [PATCH 6/6] xfs: don't clobber inobt/finobt cursors when xref with rmap Darrick J. Wong
2018-01-26 12:18 ` [PATCH v2 0/6] xfs: reflink/scrub/quota fixes Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.