500-v4.20-ubifs-Fix-default-compression-selection-in-ubifs.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From d62e98ed1efcaa94caa004f622944afdce5f1c3c Mon Sep 17 00:00:00 2001
  2. From: Gabor Juhos <[email protected]>
  3. Date: Sun, 9 Dec 2018 18:12:13 +0100
  4. Subject: [PATCH] ubifs: Fix default compression selection in ubifs
  5. When ubifs is build without the LZO compressor and no compressor is
  6. given the creation of the default file system will fail. before
  7. selection the LZO compressor check if it is present and if not fall back
  8. to the zlib or none.
  9. Signed-off-by: Gabor Juhos <[email protected]>
  10. Signed-off-by: Hauke Mehrtens <[email protected]>
  11. Signed-off-by: Richard Weinberger <[email protected]>
  12. ---
  13. fs/ubifs/sb.c | 13 ++++++++++++-
  14. 1 file changed, 12 insertions(+), 1 deletion(-)
  15. --- a/fs/ubifs/sb.c
  16. +++ b/fs/ubifs/sb.c
  17. @@ -63,6 +63,17 @@
  18. /* Default time granularity in nanoseconds */
  19. #define DEFAULT_TIME_GRAN 1000000000
  20. +static int get_default_compressor(struct ubifs_info *c)
  21. +{
  22. + if (ubifs_compr_present(c, UBIFS_COMPR_LZO))
  23. + return UBIFS_COMPR_LZO;
  24. +
  25. + if (ubifs_compr_present(c, UBIFS_COMPR_ZLIB))
  26. + return UBIFS_COMPR_ZLIB;
  27. +
  28. + return UBIFS_COMPR_NONE;
  29. +}
  30. +
  31. /**
  32. * create_default_filesystem - format empty UBI volume.
  33. * @c: UBIFS file-system description object
  34. @@ -186,7 +197,7 @@ static int create_default_filesystem(str
  35. if (c->mount_opts.override_compr)
  36. sup->default_compr = cpu_to_le16(c->mount_opts.compr_type);
  37. else
  38. - sup->default_compr = cpu_to_le16(UBIFS_COMPR_LZO);
  39. + sup->default_compr = cpu_to_le16(get_default_compressor(c));
  40. generate_random_uuid(sup->uuid);