goto out;
pcci = ll_i2pcci(inode);
- LASSERT(pcci);
- path = &pcci->pcci_path;
- CDEBUG(D_CACHE, "releasing pcc file \"%pd\"\n", path->dentry);
- pcc_inode_put(pcci);
+ if (pcci) {
+ path = &pcci->pcci_path;
+ CDEBUG(D_CACHE, "releasing pcc file \"%pd\"\n", path->dentry);
+ pcc_inode_put(pcci);
+ } else {
+ CDEBUG(D_CACHE, "PCC copy "DFID" was unlinked?\n",
+ PFID(ll_inode2fid(inode)));
+ }
LASSERT(file_count(pccf->pccf_file) > 0);
fput(pccf->pccf_file);
int rc;
rc = vfs_unlink(&nop_mnt_idmap, d_inode(parent), pcc_dentry);
- if (rc)
- CWARN("%s: failed to unlink PCC file %pd, rc = %d\n",
+ if (rc && rc != -ENOENT)
+ CWARN("%s: failed to unlink PCC file %pd: rc = %d\n",
ll_i2sbi(inode)->ll_fsname, pcc_dentry, rc);
dput(parent);
if (IS_ERR(path))
GOTO(out_unlock, rc = PTR_ERR(path));
+ if (!pcci->pcci_path.dentry->d_inode ||
+ pcci->pcci_path.dentry->d_inode->i_nlink == 0) {
+ state->pccs_flags |= PCC_STATE_FL_UNLINKED;
+ pcc_inode_detach_put(inode);
+ }
+
if (strscpy(state->pccs_path, path, buf_len) < 0)
GOTO(out_unlock, rc = -ENAMETOOLONG);
sleep 3
do_facet $SINGLEAGT rm $lpcc_path || error "rm $lpcc_path failed"
rmultiop_stop $agt_host || error "multiop $file read failed"
+
+ # file will be detached in @pcc_ioctl_state()
check_lpcc_state $file "readonly"
local content=$(do_facet $SINGLEAGT cat $file)
[[ $content == "roattach_removed" ]] || error "data mismatch: $content"
- check_lpcc_state $file "readonly"
+ check_lpcc_state $file "none"
do_facet $SINGLEAGT $LFS pcc detach -k $file ||
error "RO-PCC detach $file failed"
check_lpcc_state $file "none"
do_facet $SINGLEAGT $LFS pcc attach -r -i $HSM_ARCHIVE_NUMBER $file ||
error "RO-PCC attach $file failed"
do_facet $SINGLEAGT rm $lpcc_path || error "rm $lpcc_path failed"
+ # file will be detached in @pcc_ioctl_state()
check_lpcc_state $file "readonly"
content=$(do_facet $SINGLEAGT cat $file)
[[ $content == "roattach_removed" ]] || error "data mismatch: $content"
- check_lpcc_state $file "readonly"
+ check_lpcc_state $file "none"
do_facet $SINGLEAGT $LFS pcc detach -k $file ||
error "RO-PCC detach $file failed"
check_lpcc_state $file "none"
}
run_test 47 "mtime should be kept once file attached into PCC"
+test_48() {
+ local loopfile="$TMP/$tfile"
+ local mntpt="/mnt/pcc.$tdir"
+ local hsm_root="$mntpt/$tdir"
+ local file=$DIR/$tfile
+ local -a lpcc_path
+
+ setup_loopdev client $loopfile $mntpt 60
+ mkdir $hsm_root || error "mkdir $hsm_root failed"
+ setup_pcc_mapping client \
+ "projid={0}\ roid=$HSM_ARCHIVE_NUMBER\ ropcc=1"
+
+ echo "QQQQQ" > $file || error "echo $file failed"
+ lpcc_path=$(lpcc_fid2path $hsm_root $file)
+ cat $file || error "cat $file failed"
+ check_lpcc_state $file "readonly" client
+
+ rm $lpcc_path || error "rm $lpcc_path failed"
+ $LFS pcc state $file | grep "(unlinked)" || error "$file not unlinked"
+ [[ "$(cat $file)" =~ "QQQQQ" ]] || error "read $file content failed"
+ check_lpcc_state $file "readonly" client
+ $LFS pcc detach $file || error "detach '$file' failed"
+}
+run_test 48 "PCC state should check whether the file in local PCC cache"
+
test_96() {
local loopfile="$TMP/$tfile"
local mntpt="/mnt/pcc.$tdir"
}
rc2 = llapi_pcc_detach_file(fullpath, detach_flags);
- if (rc2 < 0) {
+ if (rc2 < 0 && rc2 != -ENOENT) {
rc2 = -errno;
- fprintf(stderr,
- "%s: cannot detach '%s' from PCC: %s\n",
+ fprintf(stderr, "%s: cannot detach '%s' from PCC: %s\n",
argv[0], path, strerror(errno));
if (rc == 0)
rc = rc2;
}
printf(", PCC_file: %s", state.pccs_path);
+ if (state.pccs_flags & PCC_STATE_FL_UNLINKED)
+ printf(" (unlinked)");
printf(", open_count: %u", state.pccs_open_count);
printf(", flags: %x", state.pccs_flags);
printf("\n");