summaryrefslogtreecommitdiff
path: root/fs/iomap/direct-io.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-01-23 10:06:10 -0800
committerDarrick J. Wong <djwong@kernel.org>2021-01-23 10:22:12 -0800
commit213f627104daf8589aad8ee73fcaeb603ab0af15 (patch)
tree78077f4f6fd6915e09d9c3aba35c7214ae9583f8 /fs/iomap/direct-io.c
parent2f63296578cad1ae681152d5b2122a4595195f16 (diff)
downloadlwn-213f627104daf8589aad8ee73fcaeb603ab0af15.tar.gz
lwn-213f627104daf8589aad8ee73fcaeb603ab0af15.zip
iomap: add a IOMAP_DIO_OVERWRITE_ONLY flag
Add a flag to signal that only pure overwrites are allowed. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/iomap/direct-io.c')
-rw-r--r--fs/iomap/direct-io.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 947343730e2c..65d32364345d 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -485,6 +485,13 @@ __iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
iomap_flags |= IOMAP_NOWAIT;
}
+ if (dio_flags & IOMAP_DIO_OVERWRITE_ONLY) {
+ ret = -EAGAIN;
+ if (pos >= dio->i_size || pos + count > dio->i_size)
+ goto out_free_dio;
+ iomap_flags |= IOMAP_OVERWRITE_ONLY;
+ }
+
ret = filemap_write_and_wait_range(mapping, pos, end);
if (ret)
goto out_free_dio;