Message ID | 20210827164926.1726765-15-agruenba@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | gfs2: Fix mmap + page fault deadlocks | expand |
On Fri, Aug 27, 2021 at 06:49:21PM +0200, Andreas Gruenbacher wrote: > When a user copy fails in one of the helpers of iomap_dio_rw, fail with > -EFAULT instead of returning 0. This matches what iomap_dio_bio_actor > returns when it gets an -EFAULT from bio_iov_iter_get_pages. With these > changes, iomap_dio_actor now consistently fails with -EFAULT when a user > page cannot be faulted in. > > Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> --D > --- > fs/iomap/direct-io.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index 9398b8c31323..8054f5d6c273 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -370,7 +370,7 @@ iomap_dio_hole_actor(loff_t length, struct iomap_dio *dio) > { > length = iov_iter_zero(length, dio->submit.iter); > dio->size += length; > - return length; > + return length ? length : -EFAULT; > } > > static loff_t > @@ -397,7 +397,7 @@ iomap_dio_inline_actor(struct inode *inode, loff_t pos, loff_t length, > copied = copy_to_iter(iomap->inline_data + pos, length, iter); > } > dio->size += copied; > - return copied; > + return copied ? copied : -EFAULT; > } > > static loff_t > -- > 2.26.3 >
On Fri, Aug 27, 2021 at 06:49:21PM +0200, Andreas Gruenbacher wrote: > When a user copy fails in one of the helpers of iomap_dio_rw, fail with > -EFAULT instead of returning 0. This matches what iomap_dio_bio_actor > returns when it gets an -EFAULT from bio_iov_iter_get_pages. With these > changes, iomap_dio_actor now consistently fails with -EFAULT when a user > page cannot be faulted in. > > Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> > --- > fs/iomap/direct-io.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c > index 9398b8c31323..8054f5d6c273 100644 > --- a/fs/iomap/direct-io.c > +++ b/fs/iomap/direct-io.c > @@ -370,7 +370,7 @@ iomap_dio_hole_actor(loff_t length, struct iomap_dio *dio) > { > length = iov_iter_zero(length, dio->submit.iter); > dio->size += length; > - return length; > + return length ? length : -EFAULT; What's wrong with a good old: if (!length) return -EFAULT; return length? Besides this nit and the fact that the patch needs a reabse it looks good to me: Reviewed-by: Christoph Hellwig <hch@lst.de>
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 9398b8c31323..8054f5d6c273 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -370,7 +370,7 @@ iomap_dio_hole_actor(loff_t length, struct iomap_dio *dio) { length = iov_iter_zero(length, dio->submit.iter); dio->size += length; - return length; + return length ? length : -EFAULT; } static loff_t @@ -397,7 +397,7 @@ iomap_dio_inline_actor(struct inode *inode, loff_t pos, loff_t length, copied = copy_to_iter(iomap->inline_data + pos, length, iter); } dio->size += copied; - return copied; + return copied ? copied : -EFAULT; } static loff_t
When a user copy fails in one of the helpers of iomap_dio_rw, fail with -EFAULT instead of returning 0. This matches what iomap_dio_bio_actor returns when it gets an -EFAULT from bio_iov_iter_get_pages. With these changes, iomap_dio_actor now consistently fails with -EFAULT when a user page cannot be faulted in. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> --- fs/iomap/direct-io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)