From b429293b9e81a24053429d46a07e6649f65ad040 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 30 Jun 2023 17:15:30 -0400 Subject: [PATCH] EX-7601 llite: allow aligned DIO with compression If a DIO is fully aligned to compression chunk boundaries, it is safe to do on a compressed file, so allow it. Signed-off-by: Patrick Farrell Change-Id: If8fa3397c9424254538738f4d77f9f50d1c21129 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51529 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson --- lustre/llite/rw26.c | 10 +++++++--- lustre/tests/sanity.sh | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 29e5ee6..cd2d9b5 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -512,10 +512,14 @@ ll_direct_IO_impl(struct kiocb *iocb, struct iov_iter *iter, int rw) io = lcc->lcc_io; LASSERT(io != NULL); - /* compression is not supported with direct I/O yet, so we fall back to - * buffered I/O by returning 0 to the kernel + /* we can only do DIO to compressed files if the IO is aligned to + * compression chunk size - we determine this by checking to see if the + * leading and trailing chunk boundaries are set. if they are not, + * the IO is entirely aligned and we can use DIO */ - if (io->ci_compressed_file) + if (io->ci_compressed_file && + (io->ci_cmpc_leading.e_start != -1 || + io->ci_cmpc_trailing.e_start != -1)) RETURN(0); ll_dio_aio = io->ci_dio_aio; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 90e2bac..6685b56 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -27802,8 +27802,8 @@ compress_type() { cmp --verbose $decomp3 $decomp4 || error "decompression failed" - # Copy file with direct I/O (falls back to buffered I/O) - dd if=$orig of=$stored3 bs=$PAGE_SIZE oflag=direct || + # Copy file with direct I/O + dd if=$orig of=$stored3 bs=$c1 oflag=direct || error "dd to $stored3 failed" cmp --verbose $orig $stored3 || error "decompression failed" -- 1.8.3.1