// success?
if (result >= 0) {
- if (fhp)
+ if (fhp) {
*fhp = _create_fh(in, flags, cmode, perms);
+ // ceph_flags_sys2wire/ceph_flags_to_mode() calls above transforms O_DIRECTORY flag
+ // into CEPH_FILE_MODE_PIN mode. Although this mode is used at server size
+ // we [ab]use it here to determine whether we should pin inode to prevent from
+ // undesired cache eviction.
+ if (cmode == CEPH_FILE_MODE_PIN) {
+ ldout(cct, 20) << " pinning ll_get() call for " << *in << dendl;
+ _ll_get(in);
+ }
+ }
} else {
in->put_open_ref(cmode);
}
Fh *fh = get_filehandle(fd);
if (!fh)
return -CEPHFS_EBADF;
+ if (fh->mode == CEPH_FILE_MODE_PIN) {
+ ldout(cct, 20) << " unpinning ll_put() call for " << *(fh->inode.get()) << dendl;
+ _ll_put(fh->inode.get(), 1);
+ }
int err = _release_fh(fh);
fd_map.erase(fd);
put_fd(fd);