static ssize_t pcc_copy_data(struct file *src, struct file *dst)
{
+ size_t buf_len = PCC_COPY_BUFFER_BYTES;
+ struct inode *inode = file_inode(src);
+ loff_t offset = 0;
ssize_t rc = 0;
ssize_t rc2;
- loff_t pos, offset = 0;
- size_t buf_len = 1048576;
- struct inode *inode = file_inode(src);
+ loff_t pos;
void *buf;
ENTRY;
RETURN(rc);
}
-static int pcc_attach_data_archive(struct file *file, struct inode *inode,
+static int pcc_attach_data_archive(struct file *lu_file,
+ struct inode *lu_inode,
struct pcc_dataset *dataset,
- struct dentry **dentry)
+ struct dentry **pcc_dentry)
{
const struct cred *old_cred;
- struct file *pcc_filp;
+ struct file *pcc_file;
bool direct = false;
struct path path;
ktime_t kstart = ktime_get();
ENTRY;
- old_cred = override_creds(pcc_super_cred(inode->i_sb));
- rc = __pcc_inode_create(dataset, &ll_i2info(inode)->lli_fid, dentry);
+ old_cred = override_creds(pcc_super_cred(lu_inode->i_sb));
+ rc = __pcc_inode_create(dataset, &ll_i2info(lu_inode)->lli_fid,
+ pcc_dentry);
if (rc)
GOTO(out_cred, rc);
path.mnt = dataset->pccd_path.mnt;
- path.dentry = *dentry;
+ path.dentry = *pcc_dentry;
/* If the inode is encrypted, we want the PCC file to be synced to the
* storage. This is necessary as we are going to decrypt the page cache
* pages of the PCC inode later in pcc_file_read_iter(), but still we
* need to keep the ciphertext version on disk.
*/
- if (IS_ENCRYPTED(inode))
+ if (IS_ENCRYPTED(lu_inode))
flags |= O_SYNC;
- pcc_filp = dentry_open(&path, flags, current_cred());
- if (IS_ERR_OR_NULL(pcc_filp)) {
- rc = pcc_filp == NULL ? -EINVAL : PTR_ERR(pcc_filp);
+ pcc_file = dentry_open(&path, flags, current_cred());
+ if (IS_ERR_OR_NULL(pcc_file)) {
+ rc = pcc_file == NULL ? -EINVAL : PTR_ERR(pcc_file);
GOTO(out_dentry, rc);
}
- rc = pcc_inode_reset_iattr(inode, *dentry, ATTR_UID | ATTR_GID,
+ rc = pcc_inode_reset_iattr(lu_inode, *pcc_dentry, ATTR_UID | ATTR_GID,
old_cred->uid, old_cred->gid, 0);
if (rc)
GOTO(out_fput, rc);
- rc = pcc_file_reset_projid(dataset, pcc_filp,
- ll_i2info(inode)->lli_projid);
+ rc = pcc_file_reset_projid(dataset, pcc_file,
+ ll_i2info(lu_inode)->lli_projid);
if (rc)
GOTO(out_fput, rc);
* data copy. After finished data copying, restore the flag in the
* file handle.
*/
- if (file->f_flags & O_DIRECT) {
- file->f_flags &= ~O_DIRECT;
+ if (lu_file->f_flags & O_DIRECT) {
+ lu_file->f_flags &= ~O_DIRECT;
direct = true;
}
- ret = pcc_copy_data(file, pcc_filp);
+ ret = pcc_copy_data(lu_file, pcc_file);
if (direct)
- file->f_flags |= O_DIRECT;
+ lu_file->f_flags |= O_DIRECT;
if (ret < 0)
GOTO(out_fput, rc = ret);
- CDEBUG(D_CACHE, "Copy data from OSTs to PCC for %pd\n", *dentry);
+ CDEBUG(D_CACHE, "Copy data from OSTs to PCC for %pd\n", *pcc_dentry);
/*
* It must to truncate the PCC copy to the same size of the Lustre
* copy after copy data. Otherwise, it may get wrong file size after
* re-attach a file. See LU-13023 for details.
*/
- rc = pcc_inode_reset_iattr(inode, *dentry,
+ rc = pcc_inode_reset_iattr(lu_inode, *pcc_dentry,
ATTR_SIZE | ATTR_MTIME | ATTR_MTIME_SET,
KUIDT_INIT(0), KGIDT_INIT(0), ret);
out_fput:
- fput(pcc_filp);
+ fput(pcc_file);
out_dentry:
if (rc) {
- pcc_inode_remove(inode, *dentry);
- dput(*dentry);
+ pcc_inode_remove(lu_inode, *pcc_dentry);
+ dput(*pcc_dentry);
} else {
- ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_ATTACH,
+ ll_stats_ops_tally(ll_i2sbi(lu_inode), LPROC_LL_PCC_ATTACH,
ktime_us_delta(ktime_get(), kstart));
- ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_PCC_ATTACH_BYTES,
- inode->i_size);
+ ll_stats_ops_tally(ll_i2sbi(lu_inode),
+ LPROC_LL_PCC_ATTACH_BYTES,
+ lu_inode->i_size);
}
out_cred:
revert_creds(old_cred);