return rc;
}
-struct pcc_create_attach {
- struct pcc_dataset *pca_dataset;
- struct dentry *pca_dentry;
-};
-
static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
struct lookup_intent *it,
void **secctx, __u32 *secctxlen,
void *secctx = NULL;
__u32 secctxlen = 0;
struct ll_sb_info *sbi;
- struct pcc_create_attach pca = {NULL, NULL};
- struct pcc_dataset *dataset = NULL;
+ struct pcc_create_attach pca = { NULL, NULL };
int rc = 0;
ENTRY;
if (!filename_is_volatile(dentry->d_name.name,
dentry->d_name.len, NULL)) {
struct pcc_matcher item;
+ struct pcc_dataset *dataset;
item.pm_uid = from_kuid(&init_user_ns, current_uid());
item.pm_gid = from_kgid(&init_user_ns, current_gid());
dput(de);
goto out_release;
}
- if (dataset != NULL && dentry->d_inode) {
- rc = pcc_inode_create_fini(dataset,
- dentry->d_inode,
- pca.pca_dentry);
- if (rc) {
- if (de != NULL)
- dput(de);
- GOTO(out_release, rc);
- }
+
+ rc = pcc_inode_create_fini(dentry->d_inode, &pca);
+ if (rc) {
+ if (de != NULL)
+ dput(de);
+ GOTO(out_release, rc);
}
+
ll_set_created(opened, file);
+ } else {
+ /* Open the file with O_CREAT, but the file already
+ * existed on MDT. This may happend in the case that
+ * the LOOKUP ibits lock is revoked and the
+ * corresponding dentry cache is deleted.
+ * i.e. In the current Lustre, the truncate operation
+ * will revoke the LOOKUP ibits lock, and the file
+ * dentry cache will be invalidated. The following open
+ * with O_CREAT flag will call into ->atomic_open, the
+ * file was wrongly though as newly created file and
+ * try to auto cache the file. So after client knows it
+ * is not a DISP_OPEN_CREATE, it should cleanup the
+ * already created PCC copy.
+ */
+ pcc_create_attach_cleanup(dir->i_sb, &pca);
}
if (dentry->d_inode && it_disposition(it, DISP_OPEN_OPEN)) {
} else {
rc = finish_no_open(file, de);
}
+ } else {
+ pcc_create_attach_cleanup(dir->i_sb, &pca);
}
out_release:
- if (dataset != NULL)
- pcc_dataset_put(dataset);
ll_intent_release(it);
OBD_FREE(it, sizeof(*it));