 dm: Always split write BIOs to zoned device limits · gregkh/linux@4e9fef1 · GitHub Skip to content Navigation Menu Toggle navigation Sign in Appearance settings Platform AI CODE CREATION GitHub Copilot Write better code with AI GitHub Spark Build and deploy intelligent apps GitHub Models Manage and compare prompts MCP Registry New Integrate external tools DEVELOPER WORKFLOWS Actions Automate any workflow Codespaces Instant dev environments Issues Plan and track work Code Review Manage code changes APPLICATION SECURITY GitHub Advanced Security Find and fix vulnerabilities Code security Secure your code as you build Secret protection  EXPLORE Why GitHub Documentation Blog Changelog Marketplace View all features Solutions BY COMPANY SIZE Enterprises Small and medium teams Startups Nonprofits BY USE CASE App Modernization DevSecOps DevOps CI/CD View all use cases BY INDUSTRY Healthcare Financial services Manufacturing Government View all industries View all solutions Resources EXPLORE BY TOPIC AI Software Development DevOps Security View all topics EXPLORE BY TYPE Customer stories Events &amp; webinars Ebooks &amp; reports Business insights GitHub Skills SUPPORT &amp; SERVICES Documentation Customer support Community forum Trust center Partners View all resources Open Source COMMUNITY GitHub Sponsors Fund open source developers PROGRAMS Security Lab Maintainer Community Accelerator GitHub Stars Archive Program REPOSITORIES Topics Trending Collections Enterprise ENTERPRISE SOLUTIONS Enterprise platform AI-powered developer platform AVAILABLE ADD-ONS GitHub Advanced Security Enterprise-grade security features Copilot for Business Enterprise-grade AI features Premium Support Enterprise-grade 24/7 support Pricing Search or jump to... Search code, repositories, users, issues, pull requests... --> Search Clear Search syntax tips Provide feedback --> We read every piece of feedback, and take your input very seriously.  Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly --> Name Query To see all available qualifiers, see our documentation . Cancel Create saved search Sign in Sign up Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} gregkh / linux Public Notifications You must be signed in to change notification settings Fork 686 Star 644 Code Actions Security and quality 0 Insights Additional navigation options Code Actions Security and quality Insights Commit 4e9fef1 Browse files Browse files damien-lemoal authored and gregkh committed dm: Always split write BIOs to zoned device limits commit 2df7168 upstream. Any zoned DM target that requires zone append emulation will use the block layer zone write plugging. In such case, DM target drivers must not split BIOs using dm_accept_partial_bio() as doing so can potentially lead to deadlocks with queue freeze operations. Regular write operations used to emulate zone append operations also cannot be split by the target driver as that would result in an invalid writen sector value return using the BIO sector. In order for zoned DM target drivers to avoid such incorrect BIO splitting, we must ensure that large BIOs are split before being passed to the map() function of the target, thus guaranteeing that the limits for the mapped device are not exceeded. dm-crypt and dm-flakey are the only target drivers supporting zoned devices and using dm_accept_partial_bio(). In the case of dm-crypt, this function is used to split BIOs to the internal max_write_size limit (which will be suppressed in a different patch). However, since crypt_alloc_buffer() uses a bioset allowing only up to BIO_MAX_VECS (256) vectors in a BIO. The dm-crypt device max_segments limit, which is not set and so default to BLK_MAX_SEGMENTS (128), must thus be respected and write BIOs split accordingly. In the case of dm-flakey, since zone append emulation is not required, the block layer zone write plugging is not used and no splitting of BIOs required. Modify the function dm_zone_bio_needs_split() to use the block layer helper function bio_needs_zone_write_plugging() to force a call to bio_split_to_limits() in dm_split_and_process_bio(). This allows DM target drivers to avoid using dm_accept_partial_bio() for write operations on zoned DM devices. Fixes: f211268 ("dm: Use the block layer zone append emulation") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal &lt;dlemoal@kernel.org&gt; Reviewed-by: Mikulas Patocka &lt;mpatocka@redhat.com&gt; Reviewed-by: Johannes Thumshirn &lt;johannes.thumshirn@wdc.com&gt; Link: https://lore.kernel.org/r/20250625093327.548866-4-dlemoal@kernel.org Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt; Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt; 1 parent 5486888 commit 4e9fef1 Copy full SHA for 4e9fef1 1 file changed + 22 - 7 Lines changed: 22 additions &amp; 7 deletions File tree Expand file tree Collapse file tree Open diff view settings Filter options drivers/md dm.c Expand file tree Collapse file tree Open diff view settings Collapse file ‎ drivers/md/dm.c ‎ Copy file name to clipboard Expand all lines: drivers/md/dm.c + 22 - 7 Lines changed: 22 additions &amp; 7 deletions Original file line number Diff line number Diff line change @@ -1780,12 +1780,29 @@ static inline bool dm_zone_bio_needs_split(struct mapped_device *md, 1780 1780 struct bio * bio ) 1781 1781 { 1782 1782 /* 1783 - * For mapped device that need zone append emulation, we must 1784 - * split any large BIO that straddles zone boundaries. 1783 + * Special case the zone operations that cannot or should not be split. 1785 1784 */ 1786 - return dm_emulate_zone_append ( md ) &amp;&amp; bio_straddles_zones ( bio ) &amp;&amp; 1787 - ! bio_flagged ( bio , BIO_ZONE_WRITE_PLUGGING ); 1785 + switch ( bio_op ( bio )) { 1786 + case REQ_OP_ZONE_APPEND : 1787 + case REQ_OP_ZONE_FINISH : 1788 + case REQ_OP_ZONE_RESET : 1789 + case REQ_OP_ZONE_RESET_ALL : 1790 + return false; 1791 + default : 1792 + break ; 1793 + } 1794 + 1795 + /* 1796 + * Mapped devices that require zone append emulation will use the block 1797 + * layer zone write plugging. In such case, we must split any large BIO 1798 + * to the mapped device limits to avoid potential deadlocks with queue 1799 + * freeze operations. 1800 + */ 1801 + if (! dm_emulate_zone_append ( md )) 1802 + return false; 1803 + return bio_needs_zone_write_plugging ( bio ) || bio_straddles_zones ( bio ); 1788 1804 } 1805 + 1789 1806 static inline bool dm_zone_plug_bio ( struct mapped_device * md , struct bio * bio ) 1790 1807 { 1791 1808 if (! bio_needs_zone_write_plugging ( bio )) @@ -1934,9 +1951,7 @@ static void dm_split_and_process_bio(struct mapped_device *md, 1934 1951 1935 1952 is_abnormal = is_abnormal_io ( bio ); 1936 1953 if ( static_branch_unlikely ( &amp; zoned_enabled )) { 1937 - /* Special case REQ_OP_ZONE_RESET_ALL as it cannot be split. */ 1938 - need_split = ( bio_op ( bio ) != REQ_OP_ZONE_RESET_ALL ) &amp;&amp; 1939 - ( is_abnormal || dm_zone_bio_needs_split ( md , bio )); 1954 + need_split = is_abnormal || dm_zone_bio_needs_split ( md , bio ); 1940 1955 } else { 1941 1956 need_split = is_abnormal ; 1942 1957 } 0 commit comments Comments 0 ( 0 ) Footer &copy; 2026 GitHub,&nbsp;Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. 