From 7b8aa61f49c3d6f871337718c136b1466985ed0b Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 3 Jul 2023 19:57:17 -0400 Subject: [PATCH] EX-7812 llite: use CIT_MISC in check_compression ll_mmap_check_compression uses a CIT_FAULT io type and initializes it with cl_io_rw_init. This doesn't initialize the IO correctly and this sometimes results in the following crash during io_fini, because the ft_page pointer is initialized to something else by cl_io_rw_init: [ 1512.276302] BUG: unable to handle kernel NULL pointer dereference at 000000000000004a [ 1512.280778] RIP: 0010:cl_pagevec_put+0x9f/0x3a0 [obdclass] [ 1512.288693] vvp_io_fault_fini+0x21/0x40 [lustre] [ 1512.289294] cl_io_fini+0x7a/0x230 [obdclass] [ 1512.289876] ll_mmap_check_compression+0x403/0x540 [lustre] Fixes: 95df962a92 ("EX-6265 llite: disable mmap on compressed files" Signed-off-by: Patrick Farrell Change-Id: Ib1f270f071370d6c045bb9d799ab5b7b41a6c6be Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51553 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger --- lustre/llite/llite_mmap.c | 31 +++++-------------------------- lustre/obdclass/cl_io.c | 4 ++-- 2 files changed, 7 insertions(+), 28 deletions(-) diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index 096c589..22fcf44 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -607,8 +607,6 @@ int ll_mmap_check_compression(struct file *file, loff_t off) { struct inode *inode = file_inode(file); struct ll_inode_info *lli = ll_i2info(inode); - struct vvp_io_args *args; - struct kiocb kiocb; struct lu_env *env; struct cl_io *io; __u16 refcheck; @@ -630,38 +628,19 @@ int ll_mmap_check_compression(struct file *file, loff_t off) /* XXX: ignore PCC for a while */ if (lli->lli_pcc_inode || lli->lli_pcc_generation) RETURN(0); - init_sync_kiocb(&kiocb, file); - kiocb.ki_pos = off; -#ifdef HAVE_KIOCB_KI_LEFT - kiocb.ki_left = 4096; -#elif defined(HAVE_KI_NBYTES) - kiocb.ki_nbytes = 4096; -#endif - - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - RETURN(PTR_ERR(env)); - io = vvp_env_thread_io(env); - - args = ll_env_args(env); - args->u.normal.via_iter = NULL; - args->u.normal.via_iocb = &kiocb; - ll_io_init(io, file, CIT_FAULT, args); - - io->ci_dio_aio = NULL; - io->ci_dio_lock = 0; - io->ci_ndelay_tried = 0; - io->ci_parallel_dio = false; + rc = cl_io_get(inode, &env, &io, &refcheck); + if (rc <= 0) + RETURN(rc); - rc = cl_io_rw_init(env, io, CIT_FAULT, off, 4096); + rc = cl_io_init(env, io, CIT_MISC, lli->lli_clob); if (rc == 0) { if (io->ci_compressed_io) rc = -EOPNOTSUPP; } else if (rc == 1 || rc == -ENODATA) { rc = 0; } else { - CERROR("%s: "DFID" cl_io_rw_init() failed: rc = %d\n", + CERROR("%s: "DFID" cl_io_init() failed: rc = %d\n", ll_i2sbi(inode)->ll_fsname, PFID(&lli->lli_fid), rc); } diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index 6e16645..aae858e 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -208,8 +208,8 @@ EXPORT_SYMBOL(cl_io_init); int cl_io_rw_init(const struct lu_env *env, struct cl_io *io, enum cl_io_type iot, loff_t pos, size_t count) { - LINVRNT(iot == CIT_READ || iot == CIT_WRITE); - LINVRNT(io->ci_obj != NULL); + LASSERT(iot == CIT_READ || iot == CIT_WRITE); + LASSERT(io->ci_obj != NULL); ENTRY; LU_OBJECT_HEADER(D_VFSTRACE, env, &io->ci_obj->co_lu, -- 1.8.3.1