udf: allow implicit blocksize specification during mount
[sfrench/cifs-2.6.git] / fs / udf / super.c
index 6b5a1a45a6c1c937f8b04b39f16f1c8b150187b9..14b4bc1f680131c20b774a75716875f50c5d7418 100644 (file)
@@ -1955,7 +1955,7 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,
                if (!nsr_off) {
                        if (!silent)
                                udf_warn(sb, "No VRS found\n");
-                       return 0;
+                       return -EINVAL;
                }
                if (nsr_off == -1)
                        udf_debug("Failed to read sector at offset %d. "
@@ -2159,15 +2159,25 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
                ret = udf_load_vrs(sb, &uopt, silent, &fileset);
        } else {
                uopt.blocksize = bdev_logical_block_size(sb->s_bdev);
-               ret = udf_load_vrs(sb, &uopt, silent, &fileset);
-               if (ret == -EAGAIN && uopt.blocksize != UDF_DEFAULT_BLOCKSIZE) {
-                       if (!silent)
-                               pr_notice("Rescanning with blocksize %d\n",
-                                         UDF_DEFAULT_BLOCKSIZE);
-                       brelse(sbi->s_lvid_bh);
-                       sbi->s_lvid_bh = NULL;
-                       uopt.blocksize = UDF_DEFAULT_BLOCKSIZE;
+               while (uopt.blocksize <= 4096) {
                        ret = udf_load_vrs(sb, &uopt, silent, &fileset);
+                       if (ret < 0) {
+                               if (!silent && ret != -EACCES) {
+                                       pr_notice("Scanning with blocksize %d failed\n",
+                                                 uopt.blocksize);
+                               }
+                               brelse(sbi->s_lvid_bh);
+                               sbi->s_lvid_bh = NULL;
+                               /*
+                                * EACCES is special - we want to propagate to
+                                * upper layers that we cannot handle RW mount.
+                                */
+                               if (ret == -EACCES)
+                                       break;
+                       } else
+                               break;
+
+                       uopt.blocksize <<= 1;
                }
        }
        if (ret < 0) {