.close = ll_vm_close,
};
+int ll_mmap_check_compression(struct file *file, unsigned long 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;
+ int rc = 0;
+ __u32 gen;
+
+ rc = ll_layout_refresh(inode, &gen);
+ if (rc) {
+ CERROR("can't refresh layout: rc=%d\n", rc);
+ RETURN(rc);
+ }
+ if (ll_layout_version_get(lli) == CL_LAYOUT_GEN_EMPTY)
+ RETURN(0);
+ /* 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_rw_init(env, io, CIT_FAULT, off, 4096);
+ if (rc == 0) {
+ if (io->ci_compressed_io)
+ rc = -EOPNOTSUPP;
+ } else if (rc == 1 || rc == -ENODATA) {
+ rc = 0;
+ } else
+ CDEBUG(D_ERROR, "rc=%d\n", rc);
+
+ cl_io_fini(env, io);
+
+ cl_env_put(env, &refcheck);
+
+ RETURN(rc);
+}
+
int ll_file_mmap(struct file *file, struct vm_area_struct * vma)
{
struct inode *inode = file_inode(file);
if (ll_file_nolock(file))
RETURN(-EOPNOTSUPP);
+ rc = ll_mmap_check_compression(file, vma->vm_pgoff << PAGE_SHIFT);
+ if (rc)
+ RETURN(rc);
+
rc = pcc_file_mmap(file, vma, &cached);
if (cached && rc != 0)
RETURN(rc);
}
run_test 460d "Check encrypt pools output"
+test_460e() {
+ (( MDS1_VERSION >= $(version_code 2.14.0.85) )) ||
+ skip "Need MDS version at least 2.14.0.85"
+
+ local tf=$DIR/$tfile
+
+ stack_trap "rm -Rf $DIR/$tfile; disable_compression"
+ enable_compression
+
+ $LFS setstripe -E -1 -Z lz4:5 --compress-chunk=64 $tf ||
+ error "set a compress component in $tf failed"
+
+ dd if=/dev/zero of=$tf bs=32k count=5 ||
+ error "dd to $stored failed"
+
+ sync; echo 3 > /proc/sys/vm/drop_caches
+
+ $LFS getstripe $tf
+ $LFS getstripe $tf | grep lcme_flags.*compress ||
+ error "no compressed component"
+
+ $MULTIOP $tf OSMc && error "mmap must be disabled"
+
+ rm -f $tf
+ dd if=/dev/zero of=$tf bs=32k count=5 ||
+ error "dd to $stored failed"
+ $MULTIOP $tf OSMc || error "mmap must be disabled"
+
+ return 0
+}
+run_test 460e "verify mmap is disabled with compressed files"
+
test_460f() {
(( MDS1_VERSION >= $(version_code 2.14.0.90) )) ||
skip "Need MDS version at least 2.14.0.90"