From mboxrd@z Thu Jan 1 00:00:00 1970 From: Charles Manning Subject: Re: [PATCH 05/29] Staging: yaffs2: yaffs_allocator: Add files Date: Tue, 2 Nov 2010 08:19:33 +1300 Message-ID: <201011020819.33777.manningc2@actrix.gen.nz> References: <1288636877-7964-1-git-send-email-tdent48227@gmail.com> <1288636877-7964-6-git-send-email-tdent48227@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Tracey Dent , greg@kroah.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Pekka Enberg Return-path: Received: from smtp.scorch.co.nz ([27.110.127.199]:60749 "HELO scorch.co.nz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with SMTP id S1751283Ab0KATTg convert rfc822-to-8bit (ORCPT ); Mon, 1 Nov 2010 15:19:36 -0400 In-Reply-To: Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tuesday 02 November 2010 07:58:49 Pekka Enberg wrote: > On Mon, Nov 1, 2010 at 8:40 PM, Tracey Dent wr= ote: > > Adding files to yaffs2 directory. > > > > Signed-off-by: Tracey Dent > > --- > > =A0drivers/staging/yaffs2/yaffs_allocator.c | =A0408 > > ++++++++++++++++++++++++++++++ drivers/staging/yaffs2/yaffs_allocat= or.h | > > =A0 30 +++ > > =A02 files changed, 438 insertions(+), 0 deletions(-) > > =A0create mode 100644 drivers/staging/yaffs2/yaffs_allocator.c > > =A0create mode 100644 drivers/staging/yaffs2/yaffs_allocator.h > > > > diff --git a/drivers/staging/yaffs2/yaffs_allocator.c > > b/drivers/staging/yaffs2/yaffs_allocator.c new file mode 100644 > > index 0000000..024ee2a > > --- /dev/null > > +++ b/drivers/staging/yaffs2/yaffs_allocator.c > > @@ -0,0 +1,408 @@ > > +/* > > + * YAFFS: Yet Another Flash File System. A NAND-flash specific fil= e > > system. + * > > + * Copyright (C) 2002-2010 Aleph One Ltd. > > + * =A0 for Toby Churchill Ltd and Brightstar Engineering > > + * > > + * Created by Charles Manning > > + * > > + * This program is free software; you can redistribute it and/or m= odify > > + * it under the terms of the GNU General Public License version 2 = as > > + * published by the Free Software Foundation. > > + */ > > + > > + > > + > > +#include "yaffs_allocator.h" > > +#include "yaffs_guts.h" > > +#include "yaffs_trace.h" > > +#include "yportenv.h" > > + > > +#ifdef CONFIG_YAFFS_YMALLOC_ALLOCATOR > > + > > +void yaffs_deinit_raw_tnodes_and_objs(yaffs_dev_t *dev) > > +{ > > + =A0 =A0 =A0 dev =3D dev; > > +} > > + > > +void yaffs_init_raw_tnodes_and_objs(yaffs_dev_t *dev) > > +{ > > + =A0 =A0 =A0 dev =3D dev; > > +} > > + > > +yaffs_tnode_t *yaffs_alloc_raw_tnode(yaffs_dev_t *dev) > > +{ > > + =A0 =A0 =A0 return (yaffs_tnode_t *)YMALLOC(dev->tnode_size); > > +} > > + > > +void yaffs_free_raw_tnode(yaffs_dev_t *dev, yaffs_tnode_t *tn) > > +{ > > + =A0 =A0 =A0 dev =3D dev; > > + =A0 =A0 =A0 YFREE(tn); > > +} > > So you have your own dynamic memory allocator? What's wrong with kmal= loc()? No. YMALLOC() wraps kmalloc() to keep the code portable. This code does a home-grown slab allocator. The reason for doing this i= s that=20 Linux slab does not allow slab caches to be destroyed while objects exi= st.=20 While that might sound like a dangerous practice, it does mean that whe= n yaffs=20 unmounts it can drop all the data structures without having to walk all= the=20 trees freeing the objects. -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html