OSDN Git Service

xfs: using generic_file_direct_write() is unnecessary
authorDave Chinner <dchinner@redhat.com>
Thu, 16 Apr 2015 12:03:27 +0000 (22:03 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 16 Apr 2015 12:03:27 +0000 (22:03 +1000)
commit0cefb29e6a63727bc7606c47fc538467594ef112
treee2171e13faac717139a565a6e7268a15aabe4f58
parent40c63fbc55a968383b8bb5cacad81585e80cd323
xfs: using generic_file_direct_write() is unnecessary

generic_file_direct_write() does all sorts of things to make DIO
work "sorta ok" with mixed buffered IO workloads. We already do
most of this work in xfs_file_aio_dio_write() because of the locking
requirements, so there's only a couple of things it does for us.

The first thing is that it does a page cache invalidation after the
->direct_IO callout. This can easily be added to the XFS code.

The second thing it does is that if data was written, it updates the
iov_iter structure to reflect the data written, and then does EOF
size updates if necessary. For XFS, these EOF size updates are now
not necessary, as we do them safely and race-free in IO completion
context. That leaves just the iov_iter update, and that's also moved
to the XFS code.

Therefore we don't need to call generic_file_direct_write() and in
doing so remove redundant buffered writeback and page cache
invalidation calls from the DIO submission path. We also remove a
racy EOF size update, and make the DIO submission code in XFS much
easier to follow. Wins all round, really.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_file.c