public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] xfs: prevent corruption due to overlapping AIO DIO V2
@ 2011-01-04  4:48 Dave Chinner
  2011-01-04  4:48 ` [PATCH 1/8] xfs: ensure sync write errors are returned Dave Chinner
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Dave Chinner @ 2011-01-04  4:48 UTC (permalink / raw)
  To: xfs

This series aims to serialise unaligned direct IOs to an inode to
avoid corruption caused by sub-block zeroing races. The previous
approaches at the direct IO layer fail because for !DIO_LOCKING
filesystems like XFS, there is no way we can track and serialise all
the direct IOs to a given inode in a race free manner. While we can
track them, we cannot close the races between mapping blocks and
tracked IO completion occuring before subsequent tracking lookups
without adding some kind of locking to the DIO layer. Hence for
!DIO_LOCKING users, unaligned direct IO needs to be serialised at a
higher layer.

Because the xfs_file_aio_write() path is so twisted and difficult to
follow, adding new locking cases to the code is difficult to verify
that it is correct in all cases. Hence the series starts by cleaning
up the code and splitting apart the direct IO and buffered IO paths
before adding the unaligned direct IO detection and serialisation.

The first patch fixes a sync write error handling bug - we should
consider pushing that to .38. The next patches factor code that is
common to write and splice into helpers. The direct and buffered IO
paths are then separated out and the common write checks and bounds
limiting is factored out into a helper.

Finally, the serialisation of unaligned direct IOs is added by a
big-hammer approach. That is, we take the i_mutex and
XFS_IOLOCK_EXCL and hold them across the unaligned IO submission.
This means that unaligned direct IO submission is serialised, and
non-AIO DIO is serialised completely.

For unaligned AIO DIO, this would only serialise the submission of
the DIO, leaving the sub-block zeroing races open for unaligned
writes into unwritten extents. To avoid this problem, we use
xfs_ioend_wait() to ensure all AIO writes have completed before we
submit the unaligned write. We do this wait holding the i_mutex so
we serialise against other unaligned AIO as there is no need to
serialise against aligned DIO.

Version 2:
- fix initial sync write error return fixup
- add new patch to abstract locking from read/write path and remove
  the need for the need_i_mutex variable.

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

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

end of thread, other threads:[~2011-01-07  9:19 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-04  4:48 [PATCH 0/8] xfs: prevent corruption due to overlapping AIO DIO V2 Dave Chinner
2011-01-04  4:48 ` [PATCH 1/8] xfs: ensure sync write errors are returned Dave Chinner
2011-01-05  1:53   ` Alex Elder
2011-01-07  8:45   ` Christoph Hellwig
2011-01-07  9:07     ` Dave Chinner
2011-01-04  4:48 ` [PATCH 2/8] xfs: factor common post-write isize handling code Dave Chinner
2011-01-05  1:54   ` Alex Elder
2011-01-04  4:48 ` [PATCH 4/8] xfs: introduce xfs_rw_lock() helpers for locking the inode Dave Chinner
2011-01-05  1:54   ` Alex Elder
2011-01-05  7:55     ` Dave Chinner
2011-01-04  4:48 ` [PATCH 5/8] xfs: split direct IO write path from xfs_file_aio_write Dave Chinner
2011-01-05  1:54   ` Alex Elder
2011-01-05  7:36     ` Dave Chinner
2011-01-07  8:58   ` Christoph Hellwig
2011-01-07  9:21     ` Dave Chinner
2011-01-04  4:48 ` [PATCH 6/8] xfs: split buffered " Dave Chinner
2011-01-05  1:55   ` Alex Elder
2011-01-04  4:48 ` [PATCH 7/8] xfs: factor common write setup code Dave Chinner
2011-01-05  1:55   ` Alex Elder
2011-01-07  8:53   ` Christoph Hellwig
2011-01-07  9:20     ` Dave Chinner
2011-01-04  4:48 ` [PATCH 8/8] xfs: serialise unaligned direct IOs Dave Chinner
2011-01-05  1:55   ` Alex Elder
2011-01-05  1:53 ` [PATCH 0/8] xfs: prevent corruption due to overlapping AIO DIO V2 Alex Elder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox