In most cases, target dentry is pinned by request, so no one will
free the target inode. But for LOOKUP and LOOKUPPARENT requests,
target dentry is not pinned. So we should pin the target inode
Signed-off-by: Yan, Zheng <zyan@redhat.com>
}
}
- if (in && (reply->head.op == CEPH_MDS_OP_READDIR ||
- reply->head.op == CEPH_MDS_OP_LSSNAP)) {
- insert_readdir_results(request, session, in);
+ if (in) {
+ if (reply->head.op == CEPH_MDS_OP_READDIR ||
+ reply->head.op == CEPH_MDS_OP_LSSNAP)
+ insert_readdir_results(request, session, in);
+
+ if (request->dentry() == NULL && in != request->inode()) {
+ // pin the target inode if its parent dentry is not pinned
+ request->set_other_inode(in);
+ }
}
request->target = in;