We weren't handling the case where the projected node has NULL for the
layout properly. Fixes the client's view when we remove the dir layout.
Signed-off-by: Sage Weil <sage@inktank.com>
i = pfile ? pi:oi;
if (is_file()) {
e.layout = i->layout;
- } else {
- if (ppolicy && get_projected_dir_layout())
- e.layout = *get_projected_dir_layout();
- else if (default_layout)
- e.layout = default_layout->layout;
+ } else if (is_dir()) {
+ ceph_file_layout *l = ppolicy ? get_projected_dir_layout() : ( default_layout ? &default_layout->layout : NULL );
+ if (l)
+ e.layout = *l;
else
memset(&e.layout, 0, sizeof(e.layout));
+ } else {
+ memset(&e.layout, 0, sizeof(e.layout));
}
e.size = i->size;
e.truncate_seq = i->truncate_seq;
}
ceph_file_layout *get_projected_dir_layout() {
- if (!inode.is_dir()) return NULL;
+ if (!inode.is_dir())
+ return NULL;
if (projected_nodes.empty()) {
if (default_layout)
return &default_layout->layout;
}
else if (projected_nodes.back()->dir_layout)
return &projected_nodes.back()->dir_layout->layout;
- else return NULL;
+ else
+ return NULL;
}
version_t get_projected_version() {