[OpenWrt-Devel] [PATCH 1/1] kernel: refined one of 514-yaffs-3.6-use-delayed-work-instead-of-write_super.patch

John Crispin blogic at openwrt.org
Thu Mar 12 05:34:59 EDT 2015


the bit which i am missing here is how do you enable YAFFS_HAS_WRITE_SUPER ?

On 02/03/2015 06:11, ngc wrote:
> Modified 514-yaffs-3.6-use-delayed-work-instead-of-write_super.patch
> which was included old trunk, to fit the current trunk kernel.
> This needs to support the behavior when yaffs_auto_checkpoint is set '2',
> in 3.6.x and later.
> 
> I got worked with linux-3.14.x on ARM.
> 
> signed-off-by: ngc at ff.iij4u.or.jp
> ――
> --- a/target/linux/generic/patches-3.14/514-yaffs-3.6-use-delayed-work-instead-of-write_super.patch	1970-01-01 09:00:00.000000000 +0900
> +++ b/target/linux/generic/patches-3.14/514-yaffs-3.6-use-delayed-work-instead-of-write_super.patch	2015-03-02 13:40:46.000000000 +0900
> @@ -0,0 +1,147 @@
> +diff -Nurp a/fs/yaffs2/yaffs_linux.h b/fs/yaffs2/yaffs_linux.h
> +--- a/fs/yaffs2/yaffs_linux.h	2015-01-07 11:47:43.000000000 +0900
> ++++ b/fs/yaffs2/yaffs_linux.h	2015-03-02 13:38:08.000000000 +0900
> +@@ -18,6 +18,10 @@
> + 
> + #include "yportenv.h"
> + 
> ++#ifndef YAFFS_HAS_WRITE_SUPER
> ++#include <linux/workqueue.h>
> ++#endif
> ++
> + struct yaffs_linux_context {
> + 	struct list_head context_list;	/* List of these we have mounted */
> + 	struct yaffs_dev *dev;
> +@@ -32,6 +36,9 @@ struct yaffs_linux_context {
> + 	struct task_struct *readdir_process;
> + 	unsigned mount_id;
> + 	int dirty;
> ++#ifndef YAFFS_HAS_WRITE_SUPER
> ++	struct delayed_work sb_sync_dwork;	/* superblock write-out work */
> ++#endif
> + };
> + 
> + #define yaffs_dev_to_lc(dev) ((struct yaffs_linux_context *)((dev)->os_context))
> +diff -Nurp a/fs/yaffs2/yaffs_vfs.c b/fs/yaffs2/yaffs_vfs.c
> +--- a/fs/yaffs2/yaffs_vfs.c	2015-02-26 09:41:02.000000000 +0900
> ++++ b/fs/yaffs2/yaffs_vfs.c	2015-03-02 13:35:59.000000000 +0900
> +@@ -357,9 +357,72 @@ static inline void i_gid_write(struct in
> + }
> + #endif
> + 
> ++
> ++#ifdef YAFFS_HAS_WRITE_SUPER
> ++
> ++static inline void yaffs_init_sb_sync_dwork(struct yaffs_LinuxContext *ylc) {}
> ++static inline void yaffs_cancel_sb_sync_dwork(struct super_block *sb) {}
> ++
> ++#else	/* YAFFS_HAS_WRITE_SUPER */
> ++
> ++#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
> ++static void yaffs_write_super(struct super_block *sb);
> ++#else
> ++static int yaffs_write_super(struct super_block *sb);
> ++#endif
> ++
> ++/* this is defined in mm/page-writeback.c */
> ++extern unsigned int	dirty_writeback_interval;
> ++
> ++static inline struct yaffs_linux_context *
> ++yaffs_sb_to_ylc(struct super_block *sb)
> ++{
> ++	struct yaffs_dev *ydev;
> ++	struct yaffs_linux_context *ylc;
> ++
> ++	ydev = yaffs_super_to_dev(sb);
> ++	ylc = yaffs_dev_to_lc(ydev);
> ++	return ylc;
> ++}
> ++
> ++static inline struct super_block *yaffs_work_to_sb(struct work_struct *work)
> ++{
> ++	struct delayed_work *dwork;
> ++	struct yaffs_linux_context *ylc;
> ++
> ++	dwork = container_of(work, struct delayed_work, work);
> ++	ylc = container_of(dwork, struct yaffs_linux_context, sb_sync_dwork);
> ++	return ylc->super;
> ++}
> ++
> ++static void yaffs_sb_sync_dwork_func(struct work_struct *work)
> ++{
> ++	struct super_block *sb = yaffs_work_to_sb(work);
> ++
> ++	yaffs_write_super(sb);
> ++}
> ++
> ++static void yaffs_init_sb_sync_dwork(struct yaffs_linux_context *ylc)
> ++{
> ++	INIT_DELAYED_WORK(&ylc->sb_sync_dwork, yaffs_sb_sync_dwork_func);
> ++}
> ++
> ++static void yaffs_cancel_sb_sync_dwork(struct super_block *sb)
> ++{
> ++	struct yaffs_linux_context *ylc = yaffs_sb_to_ylc(sb);
> ++
> ++	cancel_delayed_work_sync(&ylc->sb_sync_dwork);
> ++}
> ++
> ++#endif	/* YAFFS_HAS_WRITE_SUPER */
> ++
> ++
> + static void yaffs_set_super_dirty_val(struct yaffs_dev *dev, int val)
> + {
> + 	struct yaffs_linux_context *lc = yaffs_dev_to_lc(dev);
> ++#ifndef YAFFS_HAS_WRITE_SUPER
> ++	int	prev_dirty = lc->dirty;
> ++#endif
> + 
> + 	if (lc)
> + 		lc->dirty = val;
> +@@ -372,6 +435,11 @@ static void yaffs_set_super_dirty_val(st
> + 			sb->s_dirt = val;
> + 	}
> + #endif
> ++#ifndef YAFFS_HAS_WRITE_SUPER
> ++	if ( val && (val != prev_dirty) )
> ++		queue_delayed_work(system_long_wq, &lc->sb_sync_dwork,
> ++			   msecs_to_jiffies( dirty_writeback_interval * 10 ));
> ++#endif
> + 
> + }
> + 
> +@@ -2255,6 +2323,8 @@ static void yaffs_put_super(struct super
> + 
> + 	yaffs_flush_super(sb, 1);
> + 
> ++	yaffs_cancel_sb_sync_dwork(sb);
> ++
> + 	yaffs_deinitialise(dev);
> + 
> + 	yaffs_gross_unlock(dev);
> +@@ -2570,8 +2640,6 @@ static int yaffs_do_sync_fs(struct super
> + 	return 0;
> + }
> + 
> +-
> +-#ifdef YAFFS_HAS_WRITE_SUPER
> + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
> + static void yaffs_write_super(struct super_block *sb)
> + #else
> +@@ -2590,7 +2658,6 @@ static int yaffs_write_super(struct supe
> + 	return 0;
> + #endif
> + }
> +-#endif
> + 
> + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
> + static int yaffs_sync_fs(struct super_block *sb, int wait)
> +@@ -2883,6 +2950,8 @@ static struct super_block *yaffs_interna
> + 	context->dev = dev;
> + 	context->super = sb;
> + 
> ++	yaffs_init_sb_sync_dwork(context);
> ++
> + 	dev->read_only = read_only;
> + 
> + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list