Re: [Yaffs] [PATCH] yaffs:fix the mount id when several part…

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: chenjie
Date:  
To: yaffs, cdhmanning
Subject: Re: [Yaffs] [PATCH] yaffs:fix the mount id when several partition (chenjie)
How about this patch ?
I do not get any reply ...




On 2014/5/7 19:00, wrote:
> Send yaffs mailing list submissions to
>     

>
> To subscribe or unsubscribe via the World Wide Web, visit
>     http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs
> or, via email, send a message with subject or body 'help' to
>     

>
> You can reach the person managing the list at
>     

>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of yaffs digest..."
>
>
> Today's Topics:
>
>    1. Re: question... (Ed Sutter)
>    2. Re: question... (Charles Manning)
>    3. Re: question... (Charles Manning)
>    4. [PATCH] yaffs:fix the mount id when several partition (chenjie)

>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 06 May 2014 09:19:06 -0400
> From: Ed Sutter <>
> To: Charles Manning <>
> Cc: YAFFS ML <>
> Subject: Re: [Yaffs] question...
> Message-ID: <>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Charles,
> Thanks for the quick reply.
> I pulled all the Q&A to the top...
>
>> Are you using Yaffs1 mode of operation? When a file is deleted the
>> chunks are marked deleted and when all the chunks in a file are
>> deleted, the erasure will occur. This can take some time.
> Apparently I am... is_yaffs2 is not set.
> Should this be set?
>> There is some tuning, but perhaps a better option is to get a
>> background thread going for doing the gc. This will clean the decks
>> for writes to occur unimpeded.
> I didn't see anything in the docs on implementing background garbage
> collection when using CONFIG_YAFFS_DIRECT
>> How full is the file system?
> I've got 32Mbyte for storage, and about 6M used.
>> Are you using the "soft delete" feature? This defers the actual
>> deletion, but unless you have background gc running, this will just
>> move the delays into the gc.
> No, disable_soft_del is set to 1.
>
> Anyway, it sounds like what I want to do here is enable soft-delete and
> background garbage collection (separate task).
> Is there any documentation on that?
>
> Thanks much,
> Ed
>
>> Hello Ed
>>
>> NOR is very slow to erase and this is what is causing the issues.
>>
>>
>> On Tue, May 6, 2014 at 6:15 AM, Ed Sutter
>> < <mailto:ed.sutter@alcatel-lucent.com>>
>> wrote:
>>
>>     Hi,
>>     I have YAFFS running in standalone mode for about a year now.
>>     My underlying memory is NOR, and generally speaking I see a
>>     write rate of about 1Mbyte every 3 seconds.  I have not tuned
>>     the underlying flash accesses so I'm sure there's room for
>>     improvement there.

>>
>>     The problem I am having is that as I add files (and remove them)
>>     I notice more and more that the 3 seconds turns into 10-15
>>     seconds occasionally.  I assume yaffs is doing some garbage
>>     collection; however it seems to occure a lot more often than
>>     necessary.  Is garbage collection likely the culprit?  If yes,
>>     is there any tuning that can be done to adjust how often that
>>     is done?

>>
>>
>> There is some tuning, but perhaps a better option is to get a
>> background thread going for doing the gc. This will clean the decks
>> for writes to occur unimpeded.
>>
>> How full is the file system?
>>
>>
>>     Also, is it correct to observe that the removal of a file takes
>>     essentially the same amount of time as adding a file?

>>
>>
>> Are you using Yaffs1 mode of operation? When a file is deleted the
>> chunks are marked deleted and when all the chunks in a file are
>> deleted, the erasure will occur. This can take some time.
>>
>>
>> Are you using the "soft delete" feature? This defers the actual
>> deletion, but unless you have background gc running, this will just
>> move the delays into the gc.
>>
>> Let's see what we can work out here.
>>
>> Regards
>>
>> Charles
>>
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 7 May 2014 07:39:41 +1200
> From: Charles Manning <>
> To:
> Subject: Re: [Yaffs] question...
> Message-ID: <>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On Wednesday 07 May 2014 01:19:06 Ed Sutter wrote:
>> Charles,
>> Thanks for the quick reply.
>> I pulled all the Q&A to the top...
>>
>>> Are you using Yaffs1 mode of operation? When a file is deleted the
>>> chunks are marked deleted and when all the chunks in a file are
>>> deleted, the erasure will occur. This can take some time.
>>
>> Apparently I am... is_yaffs2 is not set.
>> Should this be set?
>
> No. If you're using yaffs1 format, then changing this flag to yaffs2 will
> break things.
>
>>
>>> There is some tuning, but perhaps a better option is to get a
>>> background thread going for doing the gc. This will clean the decks
>>> for writes to occur unimpeded.
>>
>> I didn't see anything in the docs on implementing background garbage
>> collection when using CONFIG_YAFFS_DIRECT
>>
>>> How full is the file system?
>>
>> I've got 32Mbyte for storage, and about 6M used.
>>
>>> Are you using the "soft delete" feature? This defers the actual
>>> deletion, but unless you have background gc running, this will just
>>> move the delays into the gc.
>>
>> No, disable_soft_del is set to 1.
>>
>> Anyway, it sounds like what I want to do here is enable soft-delete and
>> background garbage collection (separate task).
>> Is there any documentation on that?
>
> It sounds like this is exactly what you need to do.
>
> The Yaffs Direct stuff does not expose background gc. I will work up the code
> & some explanation to do that today. You will basically have a function that
> you put in a thread and call occasionally.
>
> Regards
>
> -- Charles
>
>
>>
>> Thanks much,
>> Ed
>>
>>> Hello Ed
>>>
>>> NOR is very slow to erase and this is what is causing the issues.
>>>
>>>
>>> On Tue, May 6, 2014 at 6:15 AM, Ed Sutter
>>> < <mailto:ed.sutter@alcatel-lucent.com>>
>>> wrote:
>>>
>>>     Hi,
>>>     I have YAFFS running in standalone mode for about a year now.
>>>     My underlying memory is NOR, and generally speaking I see a
>>>     write rate of about 1Mbyte every 3 seconds.  I have not tuned
>>>     the underlying flash accesses so I'm sure there's room for
>>>     improvement there.

>>>
>>>     The problem I am having is that as I add files (and remove them)
>>>     I notice more and more that the 3 seconds turns into 10-15
>>>     seconds occasionally.  I assume yaffs is doing some garbage
>>>     collection; however it seems to occure a lot more often than
>>>     necessary.  Is garbage collection likely the culprit?  If yes,
>>>     is there any tuning that can be done to adjust how often that
>>>     is done?

>>>
>>>
>>> There is some tuning, but perhaps a better option is to get a
>>> background thread going for doing the gc. This will clean the decks
>>> for writes to occur unimpeded.
>>>
>>> How full is the file system?
>>>
>>>
>>>     Also, is it correct to observe that the removal of a file takes
>>>     essentially the same amount of time as adding a file?

>>>
>>>
>>> Are you using Yaffs1 mode of operation? When a file is deleted the
>>> chunks are marked deleted and when all the chunks in a file are
>>> deleted, the erasure will occur. This can take some time.
>>>
>>>
>>> Are you using the "soft delete" feature? This defers the actual
>>> deletion, but unless you have background gc running, this will just
>>> move the delays into the gc.
>>>
>>> Let's see what we can work out here.
>>>
>>> Regards
>>>
>>> Charles
>>
>> _______________________________________________
>> yaffs mailing list
>>
>> http://lists.aleph1.co.uk/cgi-bin/mailman/listinfo/yaffs
>
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 7 May 2014 13:18:05 +1200
> From: Charles Manning <>
> To:
> Subject: Re: [Yaffs] question...
> Message-ID: <>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hello Ed
>
>> The Yaffs Direct stuff does not expose background gc. I will work up the
>> code & some explanation to do that today. You will basically have a
>> function that you put in a thread and call occasionally.
>
> Further to the last reply,...
>
> I have exposed the yaffs background gc in yaffsfs.c and have set up an example
> in the test harness using pthreads.
>
> See:
> http://yaffs.net/gitweb?p=yaffs2.git;a=commit;h=de117c122a4328102305eb6dbe57ad22c1b1eba8
>
> This has had minimal testing, but is rock solid in Linux so it should be Ok
> here too.
>
> There are two variants of the function:
> yaffs_do_ background_gc(path, urgent);
> yaffs_do_ background_gc_reldev(dev, urgent);
>
> Call the version that is easier.
>
> Be careful. The functions use locking, so your locking must be set up before
> you kick this off.
>
> Let me know how you get on.
>
> Charles
>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 7 May 2014 23:34:22 +0800
> From: chenjie <>
> To: <>
> Cc: chenjie <>,
> Subject: [Yaffs] [PATCH] yaffs:fix the mount id when several partition
> Message-ID: <>
> Content-Type: text/plain
>
> The mount id is always same when mount several partition
>         ps -ef:
>         root       927     2  0 Jan01 ?        00:00:00 [yaffs-bg-1]
>         root      1310     2  0 19:17 ?        00:00:00 [yaffs-bg-1]

>
> This patch find mount id which not used
>         ps -ef:
>         root 1234 2 0 23:45 ? 00:00:00 [yaffs-bg-0]
>         root 1236 2 0 23:45 ? 00:00:00 [yaffs-bg-1]

>
> Signed-off-by: chenjie <>
> ---
> yaffs_vfs_multi.c | 37 ++++++++++++++++++++++++++-----------
> yaffs_vfs_single.c | 39 +++++++++++++++++++++++++++++----------
> 2 files changed, 55 insertions(+), 21 deletions(-)
>
> diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c
> index f767315..fb7394a 100644
> --- a/yaffs_vfs_multi.c
> +++ b/yaffs_vfs_multi.c
> @@ -2591,8 +2591,33 @@ static struct dentry *yaffs_make_root(struct inode *inode)
> #endif
> }
>
> +static unsigned yaffs_find_mount_id(void) {
> +    unsigned mount_id = 0;
> +    int found = 0;
> +    struct yaffs_linux_context *context_iterator;
> +    struct list_head *l;

>
> +    if (list_empty(&yaffs_context_list)) {
> +        return mount_id;
> +    }

>
> +    for (mount_id=0; mount_id < 0xffffffff; mount_id++) {
> +        found = 0;
> +        list_for_each(l, &yaffs_context_list) {
> +            context_iterator =
> +                list_entry(l, struct yaffs_linux_context,
> +                context_list);
> +            if (context_iterator->mount_id == mount_id) {
> +                found = 1;
> +                break;
> +            }
> +        }
> +        if (!found)
> +            return mount_id;
> +    }
> +    
> +    return mount_id;
> +}

>
>  static struct super_block *yaffs_internal_read_super(int yaffs_version,
>                               struct super_block *sb,
> @@ -2812,17 +2837,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,

>
>      mutex_lock(&yaffs_context_lock);
>      /* Get a mount id */
> -    found = 0;
> -    for (mount_id = 0; !found; mount_id++) {
> -        found = 1;
> -        list_for_each(l, &yaffs_context_list) {
> -            context_iterator =
> -                list_entry(l, struct yaffs_linux_context,
> -                       context_list);
> -            if (context_iterator->mount_id == mount_id)
> -                found = 0;
> -        }
> -    }
> +    mount_id = yaffs_find_mount_id();
>      context->mount_id = mount_id;

>
>      list_add_tail(&(yaffs_dev_to_lc(dev)->context_list),
> diff --git a/yaffs_vfs_single.c b/yaffs_vfs_single.c
> index 232dc26..3f439fd 100644
> --- a/yaffs_vfs_single.c
> +++ b/yaffs_vfs_single.c
> @@ -1960,6 +1960,34 @@ static const struct super_operations yaffs_super_ops = {
>      .write_super = yaffs_write_super,
>  };

>
> +static unsigned yaffs_find_mount_id(void) {
> +        unsigned mount_id = 0;
> +        int found = 0;
> +        struct yaffs_linux_context *context_iterator;
> +        struct list_head *l;
> +
> +        if (list_empty(&yaffs_context_list)) {
> +                return mount_id;
> +        }
> +
> +        for (mount_id=0; mount_id < 0xffffffff; mount_id++) {
> +                found = 0;
> +                list_for_each(l, &yaffs_context_list) {
> +                        context_iterator =
> +                                list_entry(l, struct yaffs_linux_context,
> +                                context_list);
> +                        if (context_iterator->mount_id == mount_id) {
> +                                found = 1;
> +                                break;
> +                        }
> +                }
> +                if (!found)
> +                        return mount_id;
> +        }
> +
> +        return mount_id;
> +}
> +
>  static struct super_block *yaffs_internal_read_super(int yaffs_version,
>                               struct super_block *sb,
>                               void *data, int silent)
> @@ -2221,16 +2249,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,

>
>      mutex_lock(&yaffs_context_lock);
>      /* Get a mount id */
> -    for (mount_id = 0, found = 0; !found; mount_id++) {
> -        found = 1;
> -        list_for_each(l, &yaffs_context_list) {
> -            context_iterator =
> -                list_entry(l, struct yaffs_linux_context,
> -                    context_list);
> -            if (context_iterator->mount_id == mount_id)
> -                found = 0;
> -        }
> -    }
> +    mount_id = yaffs_find_mount_id();
>      context->mount_id = mount_id;

>
>      list_add_tail(&(yaffs_dev_to_lc(dev)->context_list),

>