| 1088 | } |
| 1089 | |
| 1090 | Inode * Client::add_update_inode(InodeStat *st, utime_t from, |
| 1091 | MetaSession *session, |
| 1092 | const UserPerm& request_perms) |
| 1093 | { |
| 1094 | Inode *in; |
| 1095 | bool was_new = false; |
| 1096 | auto [it, b] = inode_map.try_emplace(st->vino); |
| 1097 | ldout(cct, 25) << __func__ << ": " << *st << dendl; |
| 1098 | if (!b) { |
| 1099 | in = it->second; |
| 1100 | ldout(cct, 12) << __func__ << " had " << *in << " caps " << ccap_string(st->cap.caps) << dendl; |
| 1101 | } else { |
| 1102 | in = new Inode(this, st->vino, &st->layout); |
| 1103 | it->second = in; |
| 1104 | |
| 1105 | if (use_faked_inos()) |
| 1106 | _assign_faked_ino(in); |
| 1107 | |
| 1108 | if (!root) { |
| 1109 | root = in; |
| 1110 | if (use_faked_inos()) |
| 1111 | _assign_faked_root(root.get()); |
| 1112 | root_ancestor = in; |
| 1113 | cwd = root; |
| 1114 | } else if (is_mounting()) { |
| 1115 | root_parents[root_ancestor] = in; |
| 1116 | root_ancestor = in; |
| 1117 | } |
| 1118 | |
| 1119 | // immutable bits |
| 1120 | in->ino = st->vino.ino; |
| 1121 | in->snapid = st->vino.snapid; |
| 1122 | in->mode = st->mode & S_IFMT; |
| 1123 | was_new = true; |
| 1124 | } |
| 1125 | |
| 1126 | in->rdev = st->rdev; |
| 1127 | if (in->is_symlink()) |
| 1128 | in->symlink = st->symlink; |
| 1129 | |
| 1130 | in->optmetadata = st->optmetadata; // TODO maybe prune unknown_md_t |
| 1131 | |
| 1132 | // only update inode if mds info is strictly newer, or it is the same and projected (odd). |
| 1133 | bool new_version = false; |
| 1134 | if (in->version == 0 || |
| 1135 | ((st->cap.flags & CEPH_CAP_FLAG_AUTH) && |
| 1136 | (in->version & ~1) < st->version)) |
| 1137 | new_version = true; |
| 1138 | |
| 1139 | int issued; |
| 1140 | in->caps_issued(&issued); |
| 1141 | issued |= in->caps_dirty(); |
| 1142 | int new_issued = ~issued & (int)st->cap.caps; |
| 1143 | |
| 1144 | bool need_snapdir_attr_refresh = false; |
| 1145 | if ((new_version || (new_issued & CEPH_CAP_AUTH_SHARED)) && |
| 1146 | !(issued & CEPH_CAP_AUTH_EXCL)) { |
| 1147 | in->mode = st->mode; |
nothing calls this directly
no test coverage detected