503-yaffs-add-tags-9bytes-mount-option.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. Subject: yaffs: add support for tags-9bytes mount option
  2. Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
  3. ---
  4. --- a/fs/yaffs2/yaffs_vfs.c
  5. +++ b/fs/yaffs2/yaffs_vfs.c
  6. @@ -2644,6 +2644,7 @@ static const struct super_operations yaf
  7. struct yaffs_options {
  8. int inband_tags;
  9. + int tags_9bytes;
  10. int skip_checkpoint_read;
  11. int skip_checkpoint_write;
  12. int no_cache;
  13. @@ -2683,6 +2684,8 @@ static int yaffs_parse_options(struct ya
  14. if (!strcmp(cur_opt, "inband-tags")) {
  15. options->inband_tags = 1;
  16. + } else if (!strcmp(cur_opt, "tags-9bytes")) {
  17. + options->tags_9bytes = 1;
  18. } else if (!strcmp(cur_opt, "tags-ecc-off")) {
  19. options->tags_ecc_on = 0;
  20. options->tags_ecc_overridden = 1;
  21. @@ -2756,7 +2759,6 @@ static struct super_block *yaffs_interna
  22. struct yaffs_param *param;
  23. int read_only = 0;
  24. - int inband_tags = 0;
  25. struct yaffs_options options;
  26. @@ -2796,6 +2798,9 @@ static struct super_block *yaffs_interna
  27. memset(&options, 0, sizeof(options));
  28. + if (IS_ENABLED(CONFIG_YAFFS_9BYTE_TAGS))
  29. + options.tags_9bytes = 1;
  30. +
  31. if (yaffs_parse_options(&options, data_str)) {
  32. /* Option parsing failed */
  33. return NULL;
  34. @@ -2829,17 +2834,22 @@ static struct super_block *yaffs_interna
  35. }
  36. /* Added NCB 26/5/2006 for completeness */
  37. - if (yaffs_version == 2 && !options.inband_tags
  38. - && WRITE_SIZE(mtd) == 512) {
  39. + if (yaffs_version == 2 &&
  40. + (!options.inband_tags || options.tags_9bytes) &&
  41. + WRITE_SIZE(mtd) == 512) {
  42. yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting yaffs1");
  43. yaffs_version = 1;
  44. }
  45. - if (mtd->oobavail < sizeof(struct yaffs_packed_tags2) ||
  46. - options.inband_tags)
  47. - inband_tags = 1;
  48. + if (yaffs_version == 2 &&
  49. + mtd->oobavail < sizeof(struct yaffs_packed_tags2)) {
  50. + yaffs_trace(YAFFS_TRACE_ALWAYS, "auto selecting inband tags");
  51. + options.inband_tags = 1;
  52. + }
  53. - if(yaffs_verify_mtd(mtd, yaffs_version, inband_tags) < 0)
  54. + err = yaffs_verify_mtd(mtd, yaffs_version, options.inband_tags,
  55. + options.tags_9bytes);
  56. + if (err < 0)
  57. return NULL;
  58. /* OK, so if we got here, we have an MTD that's NAND and looks
  59. @@ -2896,7 +2906,8 @@ static struct super_block *yaffs_interna
  60. param->n_reserved_blocks = 5;
  61. param->n_caches = (options.no_cache) ? 0 : 10;
  62. - param->inband_tags = inband_tags;
  63. + param->inband_tags = options.inband_tags;
  64. + param->tags_9bytes = options.tags_9bytes;
  65. param->enable_xattr = 1;
  66. if (options.lazy_loading_overridden)
  67. --- a/fs/yaffs2/yaffs_mtdif.c
  68. +++ b/fs/yaffs2/yaffs_mtdif.c
  69. @@ -278,7 +278,8 @@ struct mtd_info * yaffs_get_mtd_device(d
  70. return mtd;
  71. }
  72. -int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags)
  73. +int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
  74. + int tags_9bytes)
  75. {
  76. if (yaffs_version == 2) {
  77. if ((WRITE_SIZE(mtd) < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
  78. @@ -297,6 +298,12 @@ int yaffs_verify_mtd(struct mtd_info *mt
  79. );
  80. return -1;
  81. }
  82. +
  83. + if (tags_9bytes && mtd->oobavail < 9) {
  84. + yaffs_trace(YAFFS_TRACE_ALWAYS,
  85. + "MTD device does not support 9-byte tags");
  86. + return -1;
  87. + }
  88. }
  89. return 0;
  90. --- a/fs/yaffs2/yaffs_mtdif.h
  91. +++ b/fs/yaffs2/yaffs_mtdif.h
  92. @@ -21,5 +21,6 @@
  93. void yaffs_mtd_drv_install(struct yaffs_dev *dev);
  94. struct mtd_info * yaffs_get_mtd_device(dev_t sdev);
  95. void yaffs_put_mtd_device(struct mtd_info *mtd);
  96. -int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags);
  97. +int yaffs_verify_mtd(struct mtd_info *mtd, int yaffs_version, int inband_tags,
  98. + int tags_9bytes);
  99. #endif