if (IS_ERR_OR_NULL(file))
GOTO(out, rc = file == NULL ? -EINVAL : PTR_ERR(file));
+ file->f_ra.ra_pages = 0;
rc = pcc_readonly_attach(file, pccx->pccx_inode,
pccx->pccx_attach_id, false);
pcc_readonly_attach_fini(pccx->pccx_inode);
truncate_pagecache_range(inode, 0, LUSTRE_EOF);
mapping->a_ops = &ll_aops;
+ /*
+ * Please note the mapping host (@mapping->host) for the Lustre file is
+ * replaced with the PCC copy in case of mmap() on the PCC cached file.
+ * This may result in the setting of @ra_pages of the Lustre file
+ * handle with the one of the PCC copy wrongly in the kernel:
+ * ->do_dentry_open()->file_ra_state_init()
+ * And this is the last step of the open() call and is not under the
+ * control inside the Lustre file system.
+ * Thus to avoid the setting of @ra_pages wrongly we set @ra_pages with
+ * zero explictly in all read I/O path.
+ */
mapping->host = inode;
pcc_inode->i_mapping = &pcc_inode->i_data;
ENTRY;
+ file->f_ra.ra_pages = 0;
if (pccf->pccf_file == NULL) {
*cached = false;
RETURN(0);
ENTRY;
+ in_file->f_ra.ra_pages = 0;
if (!pcc_file)
RETURN(default_file_splice_read(in_file, ppos, pipe,
count, flags));
ENTRY;
+ /* With PCC, the files are cached in an unusual way, then we do some
+ * special magic with mmap to allow Lustre and PCC to share the page
+ * mapping, and the @ra_pages may set with the backing device of PCC
+ * wrongly in this case. So we must manually set the @ra_pages with
+ * zero, otherwise it may result in kernel readahead occurring (which
+ * Lustre does not support).
+ */
+ file->f_ra.ra_pages = 0;
+
*cached = false;
if (!pcc_file || !file_inode(pcc_file)->i_fop->mmap)
RETURN(0);
- /* with PCC, the files are created in an unusual way, then we do some
- * special magic with mmap to allow Lustre and PCC to share the mmap,
- * so we must manually set the ra_pages or we can get kernel readahead
- * occurring (which Lustre does not support)
- */
- pcc_file->f_ra.ra_pages = 0;
- file->f_ra.ra_pages = 0;
-
pcc_inode_lock(inode);
pcci = ll_i2pcci(inode);
if (pcci && pcc_inode_has_layout(pcci)) {
}
/*
+ * This is not a Lustre file handle, and should be a file handle of the
+ * PCC copy. It is from PCC mmap readahead I/O path and the PCC copy
+ * was invalidated.
+ * Here return error code directly as it is from readahead I/O path for
+ * the PCC copy.
+ */
+ if (inode->i_op != &ll_file_inode_operations) {
+ CERROR("%s: readpage() on invalidated PCC inode %lu: rc=%d\n",
+ sb->s_id, inode->i_ino, -EIO);
+ unlock_page(vmpage);
+ RETURN(-EIO);
+ }
+
+ /*
* The @vmpage got truncated.
* This is a kernel bug introduced in commit v5.11-10234-gcbd59c48ae
* ("mm/filemap: use head pages in generic_file_buffered_read")
ra_assert = true;
}
#endif
- /* See EX-8421
+ /* See EX-8421 */
if (ra_assert)
- LBUG();*/
+ LASSERT(!ra_assert);
+
/**
* Direct read can fall back to buffered read, but DIO is done
* with lockless i/o, and buffered requires LDLM locking, so in