Re: [PATCH 1/2] fs: jffs2: remove NAND write support entirely

2024-04-17 Thread Sascha Hauer


On Tue, 16 Apr 2024 08:17:29 +0200, Sascha Hauer wrote:
> Our JFFS2 implementation refuses to work on NAND flashes because we lack
> support for CONFIG_JFFS2_FS_WRITEBUFFER currently. JFFS2 is barely used
> anymore and it seems unlikely that write support for it will ever be
> added, so remove write support altogether. With this we can now safely
> operate on NAND flashes.
> 
> 
> [...]

Applied, thanks!

[1/2] fs: jffs2: remove NAND write support entirely
  https://git.pengutronix.de/cgit/barebox/commit/?id=5817dd7e4826 (link may 
not be stable)
[2/2] fs: jffs2: ignore cleanup hints
  https://git.pengutronix.de/cgit/barebox/commit/?id=524cb0a98fbd (link may 
not be stable)

Best regards,
-- 
Sascha Hauer 




[PATCH 1/2] fs: jffs2: remove NAND write support entirely

2024-04-16 Thread Sascha Hauer
From: Juergen Borleis 

Our JFFS2 implementation refuses to work on NAND flashes because we lack
support for CONFIG_JFFS2_FS_WRITEBUFFER currently. JFFS2 is barely used
anymore and it seems unlikely that write support for it will ever be
added, so remove write support altogether. With this we can now safely
operate on NAND flashes.

Signed-off-by: Juergen Borleis 
Signed-off-by: Sascha Hauer 
---
 fs/jffs2/Kconfig   |  4 ++-
 fs/jffs2/fs.c  | 11 --
 fs/jffs2/jffs2_fs_sb.h | 16 -
 fs/jffs2/nodelist.h|  8 -
 fs/jffs2/os-linux.h| 79 ++
 fs/jffs2/scan.c| 59 +--
 fs/jffs2/super.c   |  4 +--
 7 files changed, 23 insertions(+), 158 deletions(-)

diff --git a/fs/jffs2/Kconfig b/fs/jffs2/Kconfig
index 329e7b806a..76f2a9f70a 100644
--- a/fs/jffs2/Kconfig
+++ b/fs/jffs2/Kconfig
@@ -20,7 +20,7 @@ config FS_JFFS2_COMPRESSION_OPTIONS
  compression modules, if any, are enabled in JFFS2. Removing
  compressors can mean you cannot read existing file systems,
  and enabling experimental compressors can mean that you
- write a file system which cannot be read by a standard kernel.
+ write a file system which cannot be read by the bootloader.
 
  If unsure, you should _definitely_ say 'N'.
 
@@ -30,6 +30,8 @@ config FS_JFFS2_COMPRESSION_ZLIB
bool
select ZLIB
prompt "ZLIB compression support"
+   help
+ Enable zlib, if compression type 0x06 is missed at run-time.
 
 config FS_JFFS2_COMPRESSION_LZO
bool
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 6f2cbff6c9..a9831582bd 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -269,17 +269,6 @@ int jffs2_do_fill_super(struct super_block *sb, int silent)
 
c = JFFS2_SB_INFO(sb);
 
-#ifndef CONFIG_JFFS2_FS_WRITEBUFFER
-   if (c->mtd->type == MTD_NANDFLASH) {
-   pr_err("Cannot operate on NAND flash unless jffs2 NAND support 
is compiled in");
-   return -EINVAL;
-   }
-   if (c->mtd->type == MTD_DATAFLASH) {
-   pr_err("Cannot operate on DataFlash unless jffs2 DataFlash 
support is compiled in");
-   return -EINVAL;
-   }
-#endif
-
c->flash_size = c->mtd->size;
c->sector_size = c->mtd->erasesize;
blocks = c->flash_size / c->sector_size;
diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h
index 20fa9a26a4..9e35a142e4 100644
--- a/fs/jffs2/jffs2_fs_sb.h
+++ b/fs/jffs2/jffs2_fs_sb.h
@@ -120,22 +120,6 @@ struct jffs2_sb_info {
 
uint32_t wbuf_pagesize; /* 0 for NOR and other flashes with no wbuf */
 
-#ifdef CONFIG_JFFS2_FS_WBUF_VERIFY
-   unsigned char *wbuf_verify; /* read-back buffer for verification */
-#endif
-#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
-   unsigned char *wbuf; /* Write-behind buffer for NAND flash */
-   uint32_t wbuf_ofs;
-   uint32_t wbuf_len;
-   struct jffs2_inodirty *wbuf_inodes;
-   struct rw_semaphore wbuf_sem;   /* Protects the write buffer */
-
-   struct delayed_work wbuf_dwork; /* write-buffer write-out work */
-
-   unsigned char *oobbuf;
-   int oobavail; /* How many bytes are available for JFFS2 in OOB */
-#endif
-
struct jffs2_summary *summary;  /* Summary information */
struct jffs2_mount_opts mount_opts;
 
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index b5f7716ce2..d8687319c7 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -489,14 +489,6 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c);
 int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count);
 void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock 
*jeb);
 
-#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
-/* wbuf.c */
-int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino);
-int jffs2_flush_wbuf_pad(struct jffs2_sb_info *c);
-int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, struct 
jffs2_eraseblock *jeb);
-int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, struct 
jffs2_eraseblock *jeb);
-#endif
-
 #include "debug.h"
 
 #endif /* __JFFS2_NODELIST_H__ */
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 29915715bb..424acbdc4d 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -11,6 +11,8 @@
 #ifndef __JFFS2_OS_LINUX_H__
 #define __JFFS2_OS_LINUX_H__
 
+#include 
+
 /* JFFS2 uses Linux mode bits natively -- no need for conversion */
 #define os_to_jffs2_mode(x) (x)
 #define jffs2_to_os_mode(x) (x)
@@ -67,11 +69,21 @@ struct jffs2_file {
unsigned int offset;
 };
 
-#define jffs2_is_readonly(c) (OFNI_BS_2SFFJ(c)->s_flags & SB_RDONLY)
+/* Read-only support */
+#define jffs2_is_readonly(c) (1)
 
 #define SECTOR_ADDR(x) ( (((unsigned long)(x) / c->sector_size) * 
c->sector_size) )
-#ifndef CONFIG_JFFS2_FS_WRITEBUFFER
 
+static inline int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t 
len, size_t *retlen, u_char *buf)
+{