[PATCH] squashfs: identify device in mount errors

Christian Loehle posted 1 patch 1 week, 5 days ago
fs/squashfs/super.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
[PATCH] squashfs: identify device in mount errors
Posted by Christian Loehle 1 week, 5 days ago
Squashfs mount failures reported through fs_context do not identify the
backing device, fix this y printing the block device.

Repeated automount failures used to be ambiguous, for example:
  Filesystem uses "xz" compression. This is not supported

All of the affected errors occur after get_tree_bdev() has opened the
block device and setup_bdev_super() has assigned sb->s_bdev.
Use it to identify the failing Squashfs image even when the mount is
retried. For example, the error above now reads:
  Filesystem on loop0 uses "xz" compression. This is not supported

Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
 fs/squashfs/super.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index 5dabc5770f1b..90b9d5b18153 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -150,26 +150,26 @@ static int squashfs_parse_param(struct fs_context *fc, struct fs_parameter *para
 }
 
 static const struct squashfs_decompressor *supported_squashfs_filesystem(
-	struct fs_context *fc,
+	struct super_block *sb, struct fs_context *fc,
 	short major, short minor, short id)
 {
 	const struct squashfs_decompressor *decompressor;
 
 	if (major < SQUASHFS_MAJOR) {
-		errorf(fc, "Major/Minor mismatch, older Squashfs %d.%d "
-		       "filesystems are unsupported", major, minor);
+		errorf(fc, "Unsupported older Squashfs %d.%d filesystem on %pg",
+		       major, minor, sb->s_bdev);
 		return NULL;
 	} else if (major > SQUASHFS_MAJOR || minor > SQUASHFS_MINOR) {
-		errorf(fc, "Major/Minor mismatch, trying to mount newer "
-		       "%d.%d filesystem", major, minor);
+		errorf(fc, "Major/Minor mismatch, trying to mount newer %d.%d filesystem on %pg",
+		       major, minor, sb->s_bdev);
 		errorf(fc, "Please update your kernel");
 		return NULL;
 	}
 
 	decompressor = squashfs_lookup_decompressor(id);
 	if (!decompressor->supported) {
-		errorf(fc, "Filesystem uses \"%s\" compression. This is not supported",
-		       decompressor->name);
+		errorf(fc, "Filesystem on %pg uses \"%s\" compression. This is not supported",
+		       sb->s_bdev, decompressor->name);
 		return NULL;
 	}
 
@@ -192,7 +192,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	TRACE("Entered squashfs_fill_superblock\n");
 
 	if (!devblksize) {
-		errorf(fc, "squashfs: unable to set blocksize\n");
+		errorf(fc, "squashfs: unable to set blocksize on %pg\n", sb->s_bdev);
 		return -EINVAL;
 	}
 
@@ -221,7 +221,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	sblk = squashfs_read_table(sb, SQUASHFS_START, sizeof(*sblk));
 
 	if (IS_ERR(sblk)) {
-		errorf(fc, "unable to read squashfs_super_block");
+		errorf(fc, "unable to read squashfs_super_block on %pg", sb->s_bdev);
 		err = PTR_ERR(sblk);
 		sblk = NULL;
 		goto failed_mount;
@@ -246,7 +246,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 
 	/* Check the MAJOR & MINOR versions and lookup compression type */
 	msblk->decompressor = supported_squashfs_filesystem(
-			fc,
+			sb, fc,
 			le16_to_cpu(sblk->s_major),
 			le16_to_cpu(sblk->s_minor),
 			le16_to_cpu(sblk->compression));
@@ -270,8 +270,8 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	 * block size (by default 128K).  This is currently not supported.
 	 */
 	if (PAGE_SIZE > msblk->block_size) {
-		errorf(fc, "Page size > filesystem block size (%d).  This is "
-		       "currently not supported!", msblk->block_size);
+		errorf(fc, "Page size > filesystem block size (%d) on %pg is not supported",
+		       msblk->block_size, sb->s_bdev);
 		goto failed_mount;
 	}
 
@@ -330,7 +330,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	msblk->read_page = squashfs_cache_init("data",
 		SQUASHFS_READ_PAGES, msblk->block_size);
 	if (IS_ERR(msblk->read_page)) {
-		errorf(fc, "Failed to allocate read_page block");
+		errorf(fc, "Failed to allocate read_page block for %pg", sb->s_bdev);
 		err = PTR_ERR(msblk->read_page);
 		goto failed_mount;
 	}
@@ -369,7 +369,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	msblk->xattr_id_table = squashfs_read_xattr_id_table(sb,
 		xattr_id_table_start, &msblk->xattr_table, &msblk->xattr_ids);
 	if (IS_ERR(msblk->xattr_id_table)) {
-		errorf(fc, "unable to read xattr id index table");
+		errorf(fc, "unable to read xattr id index table on %pg", sb->s_bdev);
 		err = PTR_ERR(msblk->xattr_id_table);
 		msblk->xattr_id_table = NULL;
 		if (err != -ENOTSUPP)
@@ -382,7 +382,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	msblk->id_table = squashfs_read_id_index_table(sb,
 		le64_to_cpu(sblk->id_table_start), next_table, msblk->ids);
 	if (IS_ERR(msblk->id_table)) {
-		errorf(fc, "unable to read id index table");
+		errorf(fc, "unable to read id index table on %pg", sb->s_bdev);
 		err = PTR_ERR(msblk->id_table);
 		msblk->id_table = NULL;
 		goto failed_mount;
@@ -398,7 +398,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	msblk->inode_lookup_table = squashfs_read_inode_lookup_table(sb,
 		lookup_table_start, next_table, msblk->inodes);
 	if (IS_ERR(msblk->inode_lookup_table)) {
-		errorf(fc, "unable to read inode lookup table");
+		errorf(fc, "unable to read inode lookup table on %pg", sb->s_bdev);
 		err = PTR_ERR(msblk->inode_lookup_table);
 		msblk->inode_lookup_table = NULL;
 		goto failed_mount;
@@ -423,7 +423,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	msblk->fragment_index = squashfs_read_fragment_index_table(sb,
 		le64_to_cpu(sblk->fragment_table_start), next_table, fragments);
 	if (IS_ERR(msblk->fragment_index)) {
-		errorf(fc, "unable to read fragment index table");
+		errorf(fc, "unable to read fragment index table on %pg", sb->s_bdev);
 		err = PTR_ERR(msblk->fragment_index);
 		msblk->fragment_index = NULL;
 		goto failed_mount;
@@ -470,7 +470,7 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc)
 	return 0;
 
 insanity:
-	errorf(fc, "squashfs image failed sanity check");
+	errorf(fc, "squashfs image on %pg failed sanity check", sb->s_bdev);
 failed_mount:
 	squashfs_cache_delete(msblk->block_cache);
 	squashfs_cache_delete(msblk->fragment_cache);
-- 
2.34.1