- /* shift entries array first */
- comp_v1->lcm_entry_count = cpu_to_le16(entries);
- memmove(dom_ent, dom_ent + 1,
- entries * sizeof(struct lov_comp_md_entry_v1));
+ /* all entries offsets are shifted by entry size at least */
+ shift = sizeof(*dom_ent);
+ for_each_comp_entry_v1(comp_v1, ent) {
+ off = le32_to_cpu(ent->lcme_offset);
+ if (off == dom_off) {
+ /* Entry deletion creates two holes in layout data:
+ * - hole in entries array
+ * - hole in layout data at dom_off with dom_size
+ *
+ * First memmove is one entry shift from next entry
+ * start with size up to dom_off in blob
+ */
+ dst = (void *)ent;
+ src = (void *)(ent + 1);
+ size = (unsigned long)((void *)comp_v1 + dom_off - src);
+ memmove(dst, src, size);
+ /* take 'off' from just moved entry */
+ off = le32_to_cpu(ent->lcme_offset);
+ /* second memmove is blob tail after 'off' up to
+ * component end
+ */
+ dst = (void *)comp_v1 + dom_off - sizeof(*ent);
+ src = (void *)comp_v1 + off;
+ size = (unsigned long)(comp_size - off);
+ memmove(dst, src, size);
+ /* all entries offsets after DoM entry are shifted by
+ * dom_size additionally
+ */
+ shift += dom_size;
+ }
+ ent->lcme_offset = cpu_to_le32(off - shift);
+ }
+ comp_v1->lcm_size = cpu_to_le32(comp_size - shift);