Blame 0041-loopdev-set-block_size-when-using-LOOP_CONFIGURE.patch

Karel Zak 0f3035
From bb387c7bb2d9112362077d6ac275f1ebc7c24023 Mon Sep 17 00:00:00 2001
Karel Zak 0f3035
From: Hideki EIRAKU <hdk@igel.co.jp>
Karel Zak 0f3035
Date: Wed, 25 May 2022 12:23:16 +0900
Karel Zak 0f3035
Subject: loopdev: set block_size when using LOOP_CONFIGURE
Karel Zak 0f3035
Karel Zak 0f3035
LOOP_CONFIGURE ioctl was introduced by commit
Karel Zak 0f3035
d5fd456c88aba4fcf77d35fe38024a8d5c814686. Since the previous
Karel Zak 0f3035
implementation set partscan flag but did not set block_size with the
Karel Zak 0f3035
LOOP_CONFIGURE ioctl, an issue fixed by commit
Karel Zak 0f3035
422f0e9f206a145c59a71333dad20d38cbbfc0c4 was reappeared. Setting
Karel Zak 0f3035
block_size in the LOOP_CONFIGURE ioctl parameter fixes the issue.
Karel Zak 0f3035
Karel Zak 0f3035
Addresses: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=2117203
Karel Zak 0f3035
Signed-off-by: Hideki EIRAKU <hdk@igel.co.jp>
Karel Zak 0f3035
---
Karel Zak 0f3035
 lib/loopdev.c | 7 ++-----
Karel Zak 0f3035
 1 file changed, 2 insertions(+), 5 deletions(-)
Karel Zak 0f3035
Karel Zak 0f3035
diff --git a/lib/loopdev.c b/lib/loopdev.c
Karel Zak 0f3035
index cceab2db1..d7184aba6 100644
Karel Zak 0f3035
--- a/lib/loopdev.c
Karel Zak 0f3035
+++ b/lib/loopdev.c
Karel Zak 0f3035
@@ -1382,6 +1382,8 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
Karel Zak 0f3035
 	 * -- since Linux v5.8-rc1, commit 3448914e8cc550ba792d4ccc74471d1ca4293aae
Karel Zak 0f3035
 	 */
Karel Zak 0f3035
 	lc->config.fd = file_fd;
Karel Zak 0f3035
+	if (lc->blocksize > 0)
Karel Zak 0f3035
+		lc->config.block_size = lc->blocksize;
Karel Zak 0f3035
 
Karel Zak 0f3035
 	rc = repeat_on_eagain( ioctl(dev_fd, LOOP_CONFIGURE, &lc->config) );
Karel Zak 0f3035
 	if (rc != 0) {
Karel Zak 0f3035
@@ -1392,11 +1394,6 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
Karel Zak 0f3035
 		}
Karel Zak 0f3035
 		fallback = 1;
Karel Zak 0f3035
 	} else {
Karel Zak 0f3035
-		if (lc->blocksize > 0
Karel Zak 0f3035
-			&& (rc = loopcxt_ioctl_blocksize(lc, lc->blocksize)) < 0) {
Karel Zak 0f3035
-			errsv = -rc;
Karel Zak 0f3035
-			goto err;
Karel Zak 0f3035
-		}
Karel Zak 0f3035
 		DBG(SETUP, ul_debugobj(lc, "LOOP_CONFIGURE: OK"));
Karel Zak 0f3035
 	}
Karel Zak 0f3035
 
Karel Zak 0f3035
-- 
Karel Zak 0f3035
2.37.1
Karel Zak 0f3035