Skip to content

squid: librbd: avoid losing sparseness in read_parent() - #68462

Merged
batrick merged 2 commits into
ceph:squidfrom
idryomov:wip-73831-squid
Jun 3, 2026
Merged

batrick merged 2 commits into
ceph:squidfrom
idryomov:wip-73831-squid

Conversation

@idryomov

Copy link
Copy Markdown
Contributor

When read_parent() constructs a read for image_ctx->parent, it employs
a thick bufferlist (either re-using the bufferlist on the object extent
or creating a temporary one inside of C_ObjectReadMergedExtents).  This
forgoes any sparseness: even if the result obtained by ObjectRequest is
sparse, it's thickened by ReadResult's handler for Bufferlist type.

This behavior is very old and hasn't been a problem for regular clones
because the public API returns a thick bufferlist in the case of C++ or
equivalent char* buf/struct iovec iov[] buffers in the case of C anyway.
ObjectCacher isn't sparse-aware but it's also not used for caching reads
by default and reading from parent for the purposes of a copyup is done
in CopyupRequest in a way that preserves sparseness.  However, when it
comes to migration, source image reads go through read_parent() and the
destination image gets thickened as an inadvertent side effect.

Fix this by introducing a new ChildObject type for ReadResult whose
handler would plant the result obtained by parent's ObjectRequest into
child's ObjectRequest, as if read_parent() wasn't even called.

Fixes: https://tracker.ceph.com/issues/73831
Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit bd2204f)

Conflicts:
	src/librbd/io/ReadResult.h [ commit 786ea20 ("librbd,
	  tools: migrate from boost::variant to std::variant") not in
	  squid ]
It's similar in concept to the handler for the new ChildObject type.
To highlight that, make comments and log messages consistent between
the two.

Signed-off-by: Ilya Dryomov <[email protected]>
(cherry picked from commit aad0285)
@idryomov idryomov added this to the squid milestone Apr 19, 2026
@idryomov
idryomov requested a review from a team as a code owner April 19, 2026 20:25
@batrick batrick added the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026
@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Backport Parity Review - Backport Deviation Alert

A conflict or unapproved deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff below to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.

Affected File(s)

Range Diff

Click to expand
--- Original (bd2204f7)
+++ Backport (4c453822)
@@ -21,3 +21,9 @@
 
 Fixes: https://tracker.ceph.com/issues/73831
 Signed-off-by: Ilya Dryomov <[email protected]>
+(cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
+
+Conflicts:
+	src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
+	  tools: migrate from boost::variant to std::variant") not in
+	  squid ]

================================================================================
RANGE DIFF
================================================================================

1:  bd2204f7283 ! 1:  4c453822a86 librbd: avoid losing sparseness in read_parent()
    @@ Commit message
     
         Fixes: https://tracker.ceph.com/issues/73831
         Signed-off-by: Ilya Dryomov <[email protected]>
    +    (cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
    +
    +    Conflicts:
    +            src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
    +              tools: migrate from boost::variant to std::variant") not in
    +              squid ]
     
      ## src/librbd/io/ReadResult.cc ##
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor : public boost::static_visitor<void> {
          sbl.image_extents = image_extents;
        }
      
    @@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
        template <typename T>
        void operator()(T &t) const {
        }
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor : public boost::static_visitor<void> {
                         << " bytes to bl "
                         << reinterpret_cast<void*>(sparse_bufferlist.bl) << dendl;
        }
    @@ src/librbd/io/ReadResult.cc: ReadResult::ReadResult(Extents* extent_map, ceph::b
     +}
     +
      void ReadResult::set_image_extents(const Extents& image_extents) {
    -   std::visit(SetImageExtentsVisitor(image_extents), m_buffer);
    +   boost::apply_visitor(SetImageExtentsVisitor(image_extents), m_buffer);
      }
     
      ## src/librbd/io/ReadResult.h ##
    @@ src/librbd/io/ReadResult.h: private:
     +    }
     +  };
     +
    -   typedef std::variant<std::monostate,
    - 		       Linear,
    - 		       Vector,
    - 		       Bufferlist,
    --		       SparseBufferlist> Buffer;
    -+		       SparseBufferlist,
    -+		       ChildObject> Buffer;
    +   typedef boost::variant<Empty,
    +                          Linear,
    +                          Vector,
    +                          Bufferlist,
    +-                         SparseBufferlist> Buffer;
    ++                         SparseBufferlist,
    ++                         ChildObject> Buffer;
        struct SetImageExtentsVisitor;
        struct AssembleResultVisitor;
      

Commit Parity Visualizer

BACKPORT PR #68462 SOURCE PR SOURCE STATUS
4c45382 librbd: avoid losing sparseness in read_parent() PR #68202 bd2204f librbd: avoid losing sparseness in read_parent()
4ebe382 librbd: tweak ReadResult's handler for SparseBufferlist type aad0285 librbd: tweak ReadResult's handler for SparseBufferlist type

🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

CI Run Log: View Workflow Details

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026
@idryomov idryomov added releng-audit-override and removed releng-audit-fail Release engineering: failed backport verification audit. labels May 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Backport Parity Review - Backport Deviation Alert

A conflict or unapproved deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff below to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.

Affected File(s)

Range Diff

Click to expand
--- Original (bd2204f7)
+++ Backport (4c453822)
@@ -21,3 +21,9 @@
 
 Fixes: https://tracker.ceph.com/issues/73831
 Signed-off-by: Ilya Dryomov <[email protected]>
+(cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
+
+Conflicts:
+	src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
+	  tools: migrate from boost::variant to std::variant") not in
+	  squid ]

================================================================================
RANGE DIFF
================================================================================

1:  bd2204f7283 ! 1:  4c453822a86 librbd: avoid losing sparseness in read_parent()
    @@ Commit message
     
         Fixes: https://tracker.ceph.com/issues/73831
         Signed-off-by: Ilya Dryomov <[email protected]>
    +    (cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
    +
    +    Conflicts:
    +            src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
    +              tools: migrate from boost::variant to std::variant") not in
    +              squid ]
     
      ## src/librbd/io/ReadResult.cc ##
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor : public boost::static_visitor<void> {
          sbl.image_extents = image_extents;
        }
      
    @@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
        template <typename T>
        void operator()(T &t) const {
        }
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor : public boost::static_visitor<void> {
                         << " bytes to bl "
                         << reinterpret_cast<void*>(sparse_bufferlist.bl) << dendl;
        }
    @@ src/librbd/io/ReadResult.cc: ReadResult::ReadResult(Extents* extent_map, ceph::b
     +}
     +
      void ReadResult::set_image_extents(const Extents& image_extents) {
    -   std::visit(SetImageExtentsVisitor(image_extents), m_buffer);
    +   boost::apply_visitor(SetImageExtentsVisitor(image_extents), m_buffer);
      }
     
      ## src/librbd/io/ReadResult.h ##
    @@ src/librbd/io/ReadResult.h: private:
     +    }
     +  };
     +
    -   typedef std::variant<std::monostate,
    - 		       Linear,
    - 		       Vector,
    - 		       Bufferlist,
    --		       SparseBufferlist> Buffer;
    -+		       SparseBufferlist,
    -+		       ChildObject> Buffer;
    +   typedef boost::variant<Empty,
    +                          Linear,
    +                          Vector,
    +                          Bufferlist,
    +-                         SparseBufferlist> Buffer;
    ++                         SparseBufferlist,
    ++                         ChildObject> Buffer;
        struct SetImageExtentsVisitor;
        struct AssembleResultVisitor;
      

Commit Parity Visualizer

BACKPORT PR #68462 SOURCE PR SOURCE STATUS
4c45382 librbd: avoid losing sparseness in read_parent() PR #68202 bd2204f librbd: avoid losing sparseness in read_parent()
4ebe382 librbd: tweak ReadResult's handler for SparseBufferlist type aad0285 librbd: tweak ReadResult's handler for SparseBufferlist type

🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

CI Run Log: View Workflow Details

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026
@batrick

batrick commented May 14, 2026

Copy link
Copy Markdown
Member

@idryomov I see it's behaving oddly. I'm looking into it.

@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Backport Parity Review - Backport Deviation Alert

A conflict or unapproved deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff below to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.

Affected File(s)

Range Diff

Click to expand
--- Original (bd2204f7)
+++ Backport (4c453822)
@@ -21,3 +21,9 @@
 
 Fixes: https://tracker.ceph.com/issues/73831
 Signed-off-by: Ilya Dryomov <[email protected]>
+(cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
+
+Conflicts:
+	src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
+	  tools: migrate from boost::variant to std::variant") not in
+	  squid ]

================================================================================
RANGE DIFF
================================================================================

1:  bd2204f7283 ! 1:  4c453822a86 librbd: avoid losing sparseness in read_parent()
    @@ Commit message
     
         Fixes: https://tracker.ceph.com/issues/73831
         Signed-off-by: Ilya Dryomov <[email protected]>
    +    (cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
    +
    +    Conflicts:
    +            src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
    +              tools: migrate from boost::variant to std::variant") not in
    +              squid ]
     
      ## src/librbd/io/ReadResult.cc ##
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor : public boost::static_visitor<void> {
          sbl.image_extents = image_extents;
        }
      
    @@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
        template <typename T>
        void operator()(T &t) const {
        }
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor : public boost::static_visitor<void> {
                         << " bytes to bl "
                         << reinterpret_cast<void*>(sparse_bufferlist.bl) << dendl;
        }
    @@ src/librbd/io/ReadResult.cc: ReadResult::ReadResult(Extents* extent_map, ceph::b
     +}
     +
      void ReadResult::set_image_extents(const Extents& image_extents) {
    -   std::visit(SetImageExtentsVisitor(image_extents), m_buffer);
    +   boost::apply_visitor(SetImageExtentsVisitor(image_extents), m_buffer);
      }
     
      ## src/librbd/io/ReadResult.h ##
    @@ src/librbd/io/ReadResult.h: private:
     +    }
     +  };
     +
    -   typedef std::variant<std::monostate,
    - 		       Linear,
    - 		       Vector,
    - 		       Bufferlist,
    --		       SparseBufferlist> Buffer;
    -+		       SparseBufferlist,
    -+		       ChildObject> Buffer;
    +   typedef boost::variant<Empty,
    +                          Linear,
    +                          Vector,
    +                          Bufferlist,
    +-                         SparseBufferlist> Buffer;
    ++                         SparseBufferlist,
    ++                         ChildObject> Buffer;
        struct SetImageExtentsVisitor;
        struct AssembleResultVisitor;
      

Commit Parity Visualizer

BACKPORT PR #68462 SOURCE PR SOURCE STATUS
4c45382 librbd: avoid losing sparseness in read_parent() PR #68202 bd2204f librbd: avoid losing sparseness in read_parent()
4ebe382 librbd: tweak ReadResult's handler for SparseBufferlist type aad0285 librbd: tweak ReadResult's handler for SparseBufferlist type

🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

CI Run Log: View Workflow Details

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026
@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated Backport Parity Review - Backport Deviation Alert

A conflict or unapproved deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.

How to proceed:

  • Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git Conflicts: block intact) and include an explanation for changes.
  • Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
  • Component Leads (Review): Please review the Range Diff below to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting /audit override.

Be familiar with the rules and guidelines for writing backports.

Affected File(s)

Range Diff

Click to expand
--- Original (bd2204f7)
+++ Backport (4c453822)
@@ -21,3 +21,9 @@
 
 Fixes: https://tracker.ceph.com/issues/73831
 Signed-off-by: Ilya Dryomov <[email protected]>
+(cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
+
+Conflicts:
+	src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
+	  tools: migrate from boost::variant to std::variant") not in
+	  squid ]

================================================================================
RANGE DIFF
================================================================================

1:  bd2204f7283 ! 1:  4c453822a86 librbd: avoid losing sparseness in read_parent()
    @@ Commit message
     
         Fixes: https://tracker.ceph.com/issues/73831
         Signed-off-by: Ilya Dryomov <[email protected]>
    +    (cherry picked from commit bd2204f7283a30d699778834280eed908440fd62)
    +
    +    Conflicts:
    +            src/librbd/io/ReadResult.h [ commit 786ea203a283 ("librbd,
    +              tools: migrate from boost::variant to std::variant") not in
    +              squid ]
     
      ## src/librbd/io/ReadResult.cc ##
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor : public boost::static_visitor<void> {
          sbl.image_extents = image_extents;
        }
      
    @@ src/librbd/io/ReadResult.cc: struct ReadResult::SetImageExtentsVisitor {
        template <typename T>
        void operator()(T &t) const {
        }
    -@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor {
    +@@ src/librbd/io/ReadResult.cc: struct ReadResult::AssembleResultVisitor : public boost::static_visitor<void> {
                         << " bytes to bl "
                         << reinterpret_cast<void*>(sparse_bufferlist.bl) << dendl;
        }
    @@ src/librbd/io/ReadResult.cc: ReadResult::ReadResult(Extents* extent_map, ceph::b
     +}
     +
      void ReadResult::set_image_extents(const Extents& image_extents) {
    -   std::visit(SetImageExtentsVisitor(image_extents), m_buffer);
    +   boost::apply_visitor(SetImageExtentsVisitor(image_extents), m_buffer);
      }
     
      ## src/librbd/io/ReadResult.h ##
    @@ src/librbd/io/ReadResult.h: private:
     +    }
     +  };
     +
    -   typedef std::variant<std::monostate,
    - 		       Linear,
    - 		       Vector,
    - 		       Bufferlist,
    --		       SparseBufferlist> Buffer;
    -+		       SparseBufferlist,
    -+		       ChildObject> Buffer;
    +   typedef boost::variant<Empty,
    +                          Linear,
    +                          Vector,
    +                          Bufferlist,
    +-                         SparseBufferlist> Buffer;
    ++                         SparseBufferlist,
    ++                         ChildObject> Buffer;
        struct SetImageExtentsVisitor;
        struct AssembleResultVisitor;
      

Commit Parity Visualizer

BACKPORT PR #68462 SOURCE PR SOURCE STATUS
4c45382 librbd: avoid losing sparseness in read_parent() PR #68202 bd2204f librbd: avoid losing sparseness in read_parent()
4ebe382 librbd: tweak ReadResult's handler for SparseBufferlist type aad0285 librbd: tweak ReadResult's handler for SparseBufferlist type

🛟 Need Help?

If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.

📋 Component Lead / Release Manager

To override the audit failure, apply releng-audit-override label or comment /audit override.


⚠️ Note: Automated audit checks will be suspended on future pushes to prevent comment spam while you work.

When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.

CI Run Log: View Workflow Details

@github-actions github-actions Bot added the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026
@github-actions github-actions Bot removed the releng-audit-fail Release engineering: failed backport verification audit. label May 14, 2026
@batrick

batrick commented May 14, 2026

Copy link
Copy Markdown
Member

@idryomov I see it's behaving oddly. I'm looking into it.

#68913

@yuriw

yuriw commented May 21, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-yuri7-testing-20260521.154841-squid.

@batrick
batrick merged commit 8db7498 into ceph:squid Jun 3, 2026
23 of 27 checks passed
@idryomov
idryomov deleted the wip-73831-squid branch June 3, 2026 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants