From a5546155a87a245f40062b68d26e53bed7dca44f Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Thu, 24 Oct 2024 13:58:41 +0700 Subject: [PATCH] LU-17525 llite: soft fail unaligned dio Skip unaligned DIO and pass io as buffered I/O rather than hard fail unaligned DIO. Test-Parameters: testlist=sanity serverversion=2.14 env=SANITY_EXCEPT="65n 211 413" Fixes: ff018bb77a ("LU-18284 llite: disallow udio exceptions") Signed-off-by: Shaun Tancheff Change-Id: I638f62ec96abc3032da5fbcf895cd835022fd759 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56775 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin --- lustre/llite/rw26.c | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index c3986e9..110af3c 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -529,23 +529,6 @@ ll_direct_IO_impl(struct kiocb *iocb, struct iov_iter *iter, int rw) if (rw == READ && file_offset >= i_size_read(inode)) RETURN(0); - /* unaligned DIO support can be turned off, so is it on? */ - if (unaligned && !ll_sbi_has_unaligned_dio(ll_i2sbi(inode))) - RETURN(-EINVAL); - - /* the requirement to not return EIOCBQUEUED for pipes (see bottom of - * this function) plays havoc with the unaligned I/O lifecycle, so - * don't allow unaligned I/O on pipes - */ - if (unaligned && iov_iter_is_pipe(iter)) - RETURN(0); - - /* Unpatched older servers which cannot safely support unaligned DIO - * should abort here - */ - if (unaligned && !cl_io_top(io)->ci_allow_unaligned_dio) - RETURN(-EINVAL); - /* if one part of an I/O is unaligned, just handle all of it that way - * otherwise we create significant complexities with managing the iovec * in different ways, etc, all for very marginal benefits @@ -559,10 +542,31 @@ ll_direct_IO_impl(struct kiocb *iocb, struct iov_iter *iter, int rw) LASSERT(ll_dio_aio); LASSERT(ll_dio_aio->cda_iocb == iocb); + /* unaligned DIO support can be turned off, so is it on? */ + if (unaligned && !ll_sbi_has_unaligned_dio(ll_i2sbi(inode))) + RETURN(-EINVAL); + /* unaligned AIO is not supported - see LU-18032 */ if (unaligned && ll_dio_aio->cda_is_aio) RETURN(-EINVAL); + /* the requirement to not return EIOCBQUEUED for pipes (see bottom of + * this function) plays havoc with the unaligned I/O lifecycle, so + * don't allow unaligned I/O on pipes + */ + if (unaligned && iov_iter_is_pipe(iter)) + RETURN(0); + + /* returning 0 here forces the remaining I/O through buffered I/O + * while returning -EINVAL stops the I/O from continuing + */ + + /* Unpatched older servers which cannot safely support unaligned DIO + * should abort here + */ + if (unaligned && !cl_io_top(io)->ci_allow_unaligned_dio) + RETURN(0); + /* We cannot do parallel submission of sub-I/Os - for AIO or regular * DIO - unless lockless because it causes us to release the lock * early. -- 1.8.3.1