linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mtd: add mtd repartition ioctl
@ 2010-06-18 10:08 Roman Tereshonkov
  2010-06-18 10:08 ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Roman Tereshonkov
  2010-07-08  5:50 ` [PATCH 0/4] mtd: add mtd repartition ioctl Artem Bityutskiy
  0 siblings, 2 replies; 14+ messages in thread
From: Roman Tereshonkov @ 2010-06-18 10:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: Roman Tereshonkov

Adding mtd master device after all partitions should provide
minimum effect on the created partition enumeration.

The master mtd device can be repartitioned in runtime through
the mtd ioctl MTDREPARTITION. The ioctl passed argument is
the set of the new partitions defined by the structures:
struct mtd_partitions and struct mtd_partition_user.

All at once partition configuration is used and caused by
the all at once partition removing. Only unused partitions are deleted.
If any of the partitions for given mtd device is used then user gets error.
The care should be taken to close all applications which access
the partitions.

Roman Tereshonkov (4):
  mtd: add new ioctl structures to be used for repartitioning
  mtd: add the possibility to modify partitions in runtime
  mtd: add MTDREPARTITION ioctl
  mtd: create the mtd master device for given set of partitions

 drivers/mtd/mtdchar.c          |  110 +++++++++++++++++++++++++++++++++++++++-
 drivers/mtd/mtdpart.c          |   45 ++++++++++++++--
 drivers/mtd/onenand/omap2.c    |    8 ++-
 include/linux/mtd/partitions.h |    2 +
 include/mtd/mtd-abi.h          |   15 ++++++
 5 files changed, 170 insertions(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning
  2010-06-18 10:08 [PATCH 0/4] mtd: add mtd repartition ioctl Roman Tereshonkov
@ 2010-06-18 10:08 ` Roman Tereshonkov
  2010-06-18 10:08   ` [PATCH 2/4] mtd: add the possibility to modify partitions in runtime Roman Tereshonkov
  2010-07-18 17:00   ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Artem Bityutskiy
  2010-07-08  5:50 ` [PATCH 0/4] mtd: add mtd repartition ioctl Artem Bityutskiy
  1 sibling, 2 replies; 14+ messages in thread
From: Roman Tereshonkov @ 2010-06-18 10:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: Roman Tereshonkov

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
---
 include/mtd/mtd-abi.h |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index be51ae2..c2c6b41 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -88,6 +88,20 @@ struct otp_info {
 	__u32 locked;
 };
 
+#define MTD_MAX_PARTITION_NAME_LEN	64
+struct mtd_partition_user {
+	__u64 size;
+	__u64 offset;
+	__u32 mask_flags;
+	char name[MTD_MAX_PARTITION_NAME_LEN];
+	__u8 padding[128];	/* reserved for future, must be zero! */
+};
+
+struct mtd_partitions {
+	__u32 nparts;
+	struct mtd_partition_user __user *parts;
+};
+
 #define MEMGETINFO		_IOR('M', 1, struct mtd_info_user)
 #define MEMERASE		_IOW('M', 2, struct erase_info_user)
 #define MEMWRITEOOB		_IOWR('M', 3, struct mtd_oob_buf)
@@ -110,6 +124,7 @@ struct otp_info {
 #define MEMERASE64		_IOW('M', 20, struct erase_info_user64)
 #define MEMWRITEOOB64		_IOWR('M', 21, struct mtd_oob_buf64)
 #define MEMREADOOB64		_IOWR('M', 22, struct mtd_oob_buf64)
+#define MTDREPARTITION		_IOW('M', 23, struct mtd_partitions)
 
 /*
  * Obsolete legacy interface. Keep it in order not to break userspace
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/4] mtd: add the possibility to modify partitions in runtime
  2010-06-18 10:08 ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Roman Tereshonkov
@ 2010-06-18 10:08   ` Roman Tereshonkov
  2010-06-18 10:08     ` [PATCH 3/4] mtd: add MTDREPARTITION ioctl Roman Tereshonkov
  2010-07-18 17:00   ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Artem Bityutskiy
  1 sibling, 1 reply; 14+ messages in thread
From: Roman Tereshonkov @ 2010-06-18 10:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: Roman Tereshonkov

This includes adding locks, appropriate memory handling and function
to get the master device for given partition.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
---
 drivers/mtd/mtdpart.c          |   45 ++++++++++++++++++++++++++++++++++-----
 include/linux/mtd/partitions.h |    2 +
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index b8043a9..595d270 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -21,6 +21,7 @@
 
 /* Our partition linked list */
 static LIST_HEAD(mtd_partitions);
+static DEFINE_MUTEX(mtd_partitions_mutex);
 
 /* Our partition node structure */
 struct mtd_part {
@@ -309,21 +310,30 @@ static int part_block_markbad(struct mtd_info *mtd, loff_t ofs)
 
 /*
  * This function unregisters and destroy all slave MTD objects which are
- * attached to the given master MTD object.
+ * attached to the given master MTD object and which are possible to be
+ * deleted (usercount==0).
  */
 
 int del_mtd_partitions(struct mtd_info *master)
 {
 	struct mtd_part *slave, *next;
+	int ret, err = 0;
 
+	mutex_lock(&mtd_partitions_mutex);
 	list_for_each_entry_safe(slave, next, &mtd_partitions, list)
 		if (slave->master == master) {
+			ret = del_mtd_device(&slave->mtd);
+			if (ret < 0) {
+				err = ret;
+				continue;
+			}
 			list_del(&slave->list);
-			del_mtd_device(&slave->mtd);
+			kfree(slave->mtd.name);
 			kfree(slave);
 		}
+	mutex_unlock(&mtd_partitions_mutex);
 
-	return 0;
+	return err;
 }
 EXPORT_SYMBOL(del_mtd_partitions);
 
@@ -332,16 +342,19 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
 		uint64_t cur_offset)
 {
 	struct mtd_part *slave;
+	char *name;
 
 	/* allocate the partition structure */
 	slave = kzalloc(sizeof(*slave), GFP_KERNEL);
-	if (!slave) {
+	name = kstrdup(part->name, GFP_KERNEL);
+	if (!name || !slave) {
 		printk(KERN_ERR"memory allocation error while creating partitions for \"%s\"\n",
 			master->name);
 		del_mtd_partitions(master);
+		kfree(name);
+		kfree(slave);
 		return NULL;
 	}
-	list_add(&slave->list, &mtd_partitions);
 
 	/* set up the MTD object for this partition */
 	slave->mtd.type = master->type;
@@ -352,7 +365,7 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
 	slave->mtd.oobavail = master->oobavail;
 	slave->mtd.subpage_sft = master->subpage_sft;
 
-	slave->mtd.name = part->name;
+	slave->mtd.name = name;
 	slave->mtd.owner = master->owner;
 	slave->mtd.backing_dev_info = master->backing_dev_info;
 
@@ -497,6 +510,9 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
 	}
 
 out_register:
+	mutex_lock(&mtd_partitions_mutex);
+	list_add(&slave->list, &mtd_partitions);
+	mutex_unlock(&mtd_partitions_mutex);
 	/* register our partition */
 	add_mtd_device(&slave->mtd);
 
@@ -597,3 +613,20 @@ int parse_mtd_partitions(struct mtd_info *master, const char **types,
 	return ret;
 }
 EXPORT_SYMBOL_GPL(parse_mtd_partitions);
+
+struct mtd_info *part_get_mtd_master(struct mtd_info *mtd)
+{
+	struct mtd_part *part;
+	struct mtd_info *master = NULL;
+
+	mutex_lock(&mtd_partitions_mutex);
+	list_for_each_entry(part, &mtd_partitions, list)
+		if (&part->mtd == mtd) {
+			master = part->master;
+			break;
+		}
+	mutex_unlock(&mtd_partitions_mutex);
+
+	return master;
+}
+EXPORT_SYMBOL(part_get_mtd_master);
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index 274b619..942c425 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -89,4 +89,6 @@ static inline int mtd_has_cmdlinepart(void) { return 1; }
 static inline int mtd_has_cmdlinepart(void) { return 0; }
 #endif
 
+struct mtd_info *part_get_mtd_master(struct mtd_info *mtd);
+
 #endif
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/4] mtd: add MTDREPARTITION ioctl
  2010-06-18 10:08   ` [PATCH 2/4] mtd: add the possibility to modify partitions in runtime Roman Tereshonkov
@ 2010-06-18 10:08     ` Roman Tereshonkov
  2010-06-18 10:08       ` [PATCH 4/4] mtd: create the mtd master device for given set of partitions Roman Tereshonkov
  0 siblings, 1 reply; 14+ messages in thread
From: Roman Tereshonkov @ 2010-06-18 10:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: Roman Tereshonkov

Add MTDREPARTITION ioctl to modify all partitions for given mtd
master device. The partitions having the same master are modified
all at once: all previous are deleted and the new set is created.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
---
 drivers/mtd/mtdchar.c |  110 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 109 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 91c8013..ccdccad 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -19,7 +19,7 @@
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/compatmac.h>
-
+#include <linux/mtd/partitions.h>
 #include <asm/uaccess.h>
 
 #define MTD_INODE_FS_MAGIC 0x11307854
@@ -463,6 +463,65 @@ static int mtd_do_readoob(struct mtd_info *mtd, uint64_t start,
 	return ret;
 }
 
+#ifdef CONFIG_MTD_PARTITIONS
+static int mtd_do_repartition(struct file *file, struct mtd_info *mtd,
+				uint32_t nparts, void __user *ptr)
+{
+	struct mtd_partition *parts;
+	struct mtd_partition_user *up;
+	int size, i, ret = -ENOMEM;
+
+	if (!(file->f_mode & FMODE_WRITE))
+		return -EPERM;
+
+	size = nparts * sizeof(struct mtd_partition_user);
+	if (!size)
+		return -EINVAL;
+
+	if (!access_ok(VERIFY_READ, ptr, size))
+		return -EFAULT;
+
+	up = kmalloc(size, GFP_KERNEL);
+	if (!up)
+		return -ENOMEM;
+
+	if (copy_from_user(up, ptr, size)) {
+		ret = -EFAULT;
+		goto err_free_up;
+	}
+
+	size = nparts * sizeof(struct mtd_partition);
+	parts = kzalloc(size, GFP_KERNEL);
+	if (!parts)
+		goto err_free_up;
+
+	for (i = 0; i < nparts; i++) {
+		parts[i].offset = up[i].offset;
+		parts[i].size = up[i].size;
+		parts[i].mask_flags = up[i].mask_flags;
+
+		parts[i].name = kstrndup(up[i].name, MTD_MAX_PARTITION_NAME_LEN,
+					 GFP_KERNEL);
+		if (!parts[i].name)
+			goto err_free;
+	}
+
+	ret = del_mtd_partitions(mtd);
+	if (!ret)
+		ret = add_mtd_partitions(mtd, parts, nparts);
+
+ err_free:
+	for (i = 0; i < nparts; i++)
+		kfree(parts[i].name);
+	kfree(parts);
+ err_free_up:
+	kfree(up);
+
+	return ret;
+}
+#endif
+
+
 static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
 {
 	struct mtd_file_info *mfi = file->private_data;
@@ -826,7 +885,25 @@ static int mtd_ioctl(struct file *file, u_int cmd, u_long arg)
 		file->f_pos = 0;
 		break;
 	}
+#ifdef CONFIG_MTD_PARTITIONS
+	case MTDREPARTITION:
+	{
+		struct mtd_partitions p;
+		struct mtd_info *master;
+
+		/* only root (no assigned master) device can be accessed */
+		master = part_get_mtd_master(mtd);
+		if (master)
+			return -EACCES;
+
+		if (copy_from_user(&p, argp, sizeof(p)))
+			return -EFAULT;
+
+		ret = mtd_do_repartition(file, mtd, p.nparts, p.parts);
 
+		break;
+	}
+#endif
 	default:
 		ret = -ENOTTY;
 	}
@@ -856,6 +933,15 @@ struct mtd_oob_buf32 {
 #define MEMWRITEOOB32		_IOWR('M', 3, struct mtd_oob_buf32)
 #define MEMREADOOB32		_IOWR('M', 4, struct mtd_oob_buf32)
 
+#ifdef CONFIG_MTD_PARTITIONS
+struct mtd_partitions32 {
+	uint32_t nparts;
+	compat_caddr_t ptr;
+};
+
+#define MTDREPARTITION32	_IOW('M', 23, struct mtd_partitions32)
+#endif
+
 static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
 	unsigned long arg)
 {
@@ -895,6 +981,28 @@ static long mtd_compat_ioctl(struct file *file, unsigned int cmd,
 				&buf_user->start);
 		break;
 	}
+
+#ifdef CONFIG_MTD_PARTITIONS
+	case MTDREPARTITION32:
+	{
+		struct mtd_partitions32 p;
+		struct mtd_info *master;
+
+		/* only root (no assigned master) device can be accessed */
+		master = part_get_mtd_master(mtd);
+		if (!master) {
+			if (copy_from_user(&p, argp, sizeof(p)))
+				ret = -EFAULT;
+			else
+				ret = mtd_do_repartition(file, mtd, p.nparts,
+							 compat_ptr(p.ptr));
+		} else {
+			ret = -EACCES;
+		}
+
+		break;
+	}
+#endif
 	default:
 		ret = mtd_ioctl(file, cmd, (unsigned long)argp);
 	}
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 4/4] mtd: create the mtd master device for given set of partitions
  2010-06-18 10:08     ` [PATCH 3/4] mtd: add MTDREPARTITION ioctl Roman Tereshonkov
@ 2010-06-18 10:08       ` Roman Tereshonkov
  0 siblings, 0 replies; 14+ messages in thread
From: Roman Tereshonkov @ 2010-06-18 10:08 UTC (permalink / raw)
  To: linux-mtd; +Cc: Roman Tereshonkov

The master device is needed for repartioning to be done.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
---
 drivers/mtd/onenand/omap2.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index 9f322f1..f9bdad8 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -724,12 +724,14 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
 	}
 
 #ifdef CONFIG_MTD_PARTITIONS
-	if (pdata->parts != NULL)
+	if (pdata->parts != NULL) {
 		r = add_mtd_partitions(&c->mtd, pdata->parts,
 				       pdata->nr_parts);
-	else
+		if (r < 0)
+			goto err_release_onenand;
+	}
 #endif
-		r = add_mtd_device(&c->mtd);
+	r = add_mtd_device(&c->mtd);
 	if (r < 0)
 		goto err_release_onenand;
 
-- 
1.6.2.4

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/4] mtd: add mtd repartition ioctl
  2010-06-18 10:08 [PATCH 0/4] mtd: add mtd repartition ioctl Roman Tereshonkov
  2010-06-18 10:08 ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Roman Tereshonkov
@ 2010-07-08  5:50 ` Artem Bityutskiy
  2010-07-21  9:58   ` Artem Bityutskiy
  1 sibling, 1 reply; 14+ messages in thread
From: Artem Bityutskiy @ 2010-07-08  5:50 UTC (permalink / raw)
  To: Roman Tereshonkov; +Cc: linux-mtd

On Fri, 2010-06-18 at 13:08 +0300, Roman Tereshonkov wrote:
> Adding mtd master device after all partitions should provide
> minimum effect on the created partition enumeration.
> 
> The master mtd device can be repartitioned in runtime through
> the mtd ioctl MTDREPARTITION. The ioctl passed argument is
> the set of the new partitions defined by the structures:
> struct mtd_partitions and struct mtd_partition_user.
> 
> All at once partition configuration is used and caused by
> the all at once partition removing. Only unused partitions are deleted.
> If any of the partitions for given mtd device is used then user gets error.
> The care should be taken to close all applications which access
> the partitions.
> 
> Roman Tereshonkov (4):
>   mtd: add new ioctl structures to be used for repartitioning
>   mtd: add the possibility to modify partitions in runtime
>   mtd: add MTDREPARTITION ioctl
>   mtd: create the mtd master device for given set of partitions
> 
>  drivers/mtd/mtdchar.c          |  110 +++++++++++++++++++++++++++++++++++++++-
>  drivers/mtd/mtdpart.c          |   45 ++++++++++++++--
>  drivers/mtd/onenand/omap2.c    |    8 ++-
>  include/linux/mtd/partitions.h |    2 +
>  include/mtd/mtd-abi.h          |   15 ++++++
>  5 files changed, 170 insertions(+), 10 deletions(-)

I've pushed this to my l2-mtd-2.6.git / master, looks good to me.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning
  2010-06-18 10:08 ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Roman Tereshonkov
  2010-06-18 10:08   ` [PATCH 2/4] mtd: add the possibility to modify partitions in runtime Roman Tereshonkov
@ 2010-07-18 17:00   ` Artem Bityutskiy
  2010-07-18 20:22     ` Arnd Bergmann
  1 sibling, 1 reply; 14+ messages in thread
From: Artem Bityutskiy @ 2010-07-18 17:00 UTC (permalink / raw)
  To: Roman Tereshonkov; +Cc: linux-mtd, Arnd Bergmann

CCing Arnd to review the ioctl interface.

One thing just struck me, see below.

On Fri, 2010-06-18 at 13:08 +0300, Roman Tereshonkov wrote:
> Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
> ---
>  include/mtd/mtd-abi.h |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
> index be51ae2..c2c6b41 100644
> --- a/include/mtd/mtd-abi.h
> +++ b/include/mtd/mtd-abi.h
> @@ -88,6 +88,20 @@ struct otp_info {
>  	__u32 locked;
>  };
>  
> +#define MTD_MAX_PARTITION_NAME_LEN	64
> +struct mtd_partition_user {
> +	__u64 size;
> +	__u64 offset;
> +	__u32 mask_flags;
> +	char name[MTD_MAX_PARTITION_NAME_LEN];
> +	__u8 padding[128];	/* reserved for future, must be zero! */
> +};
> +
> +struct mtd_partitions {
> +	__u32 nparts;
> +	struct mtd_partition_user __user *parts;
> +};

Hmm, I think nowadays pointers should be passed as __u64 and
compat_ioctl() should be avoided.

Also please, document the ioctl a little - add some comments.

> +
>  #define MEMGETINFO		_IOR('M', 1, struct mtd_info_user)
>  #define MEMERASE		_IOW('M', 2, struct erase_info_user)
>  #define MEMWRITEOOB		_IOWR('M', 3, struct mtd_oob_buf)
> @@ -110,6 +124,7 @@ struct otp_info {
>  #define MEMERASE64		_IOW('M', 20, struct erase_info_user64)
>  #define MEMWRITEOOB64		_IOWR('M', 21, struct mtd_oob_buf64)
>  #define MEMREADOOB64		_IOWR('M', 22, struct mtd_oob_buf64)
> +#define MTDREPARTITION		_IOW('M', 23, struct mtd_partitions)
>  
>  /*
>   * Obsolete legacy interface. Keep it in order not to break userspace
-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning
  2010-07-18 17:00   ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Artem Bityutskiy
@ 2010-07-18 20:22     ` Arnd Bergmann
  2010-07-19  4:06       ` Artem Bityutskiy
  0 siblings, 1 reply; 14+ messages in thread
From: Arnd Bergmann @ 2010-07-18 20:22 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd, Roman Tereshonkov

On Sunday 18 July 2010, Artem Bityutskiy wrote:
> CCing Arnd to review the ioctl interface.
> 
> One thing just struck me, see below.
> 
> On Fri, 2010-06-18 at 13:08 +0300, Roman Tereshonkov wrote:
> > Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
> > ---
> >  include/mtd/mtd-abi.h |   15 +++++++++++++++
> >  1 files changed, 15 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
> > index be51ae2..c2c6b41 100644
> > --- a/include/mtd/mtd-abi.h
> > +++ b/include/mtd/mtd-abi.h
> > @@ -88,6 +88,20 @@ struct otp_info {
> >  	__u32 locked;
> >  };
> >  
> > +#define MTD_MAX_PARTITION_NAME_LEN	64
> > +struct mtd_partition_user {
> > +	__u64 size;
> > +	__u64 offset;
> > +	__u32 mask_flags;
> > +	char name[MTD_MAX_PARTITION_NAME_LEN];
> > +	__u8 padding[128];	/* reserved for future, must be zero! */
> > +};
> > +
> > +struct mtd_partitions {
> > +	__u32 nparts;
> > +	struct mtd_partition_user __user *parts;
> > +};
> 
> Hmm, I think nowadays pointers should be passed as __u64 and
> compat_ioctl() should be avoided.

Yes, that's generally true. It would be nice if the BLKPG ioctl
definition could be reused for this. It is more complicated
than it should be, but not more than this suggestion, and
it's an existing ioctl.

	Arnd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning
  2010-07-18 20:22     ` Arnd Bergmann
@ 2010-07-19  4:06       ` Artem Bityutskiy
  2010-07-20  9:19         ` Arnd Bergmann
  0 siblings, 1 reply; 14+ messages in thread
From: Artem Bityutskiy @ 2010-07-19  4:06 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-mtd, Roman Tereshonkov

On Sun, 2010-07-18 at 20:22 +0000, Arnd Bergmann wrote:
> > > +#define MTD_MAX_PARTITION_NAME_LEN	64
> > > +struct mtd_partition_user {
> > > +	__u64 size;
> > > +	__u64 offset;
> > > +	__u32 mask_flags;
> > > +	char name[MTD_MAX_PARTITION_NAME_LEN];
> > > +	__u8 padding[128];	/* reserved for future, must be zero! */
> > > +};
> > > +
> > > +struct mtd_partitions {
> > > +	__u32 nparts;
> > > +	struct mtd_partition_user __user *parts;
> > > +};
> > 
> > Hmm, I think nowadays pointers should be passed as __u64 and
> > compat_ioctl() should be avoided.
> 
> Yes, that's generally true. It would be nice if the BLKPG ioctl
> definition could be reused for this. It is more complicated
> than it should be, but not more than this suggestion, and
> it's an existing ioctl.

Thanks for reply.

MTD devices do not support BLKPG, do you mean we should you the same
data-structures and names as block devices?

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning
  2010-07-19  4:06       ` Artem Bityutskiy
@ 2010-07-20  9:19         ` Arnd Bergmann
  2010-07-20  9:25           ` Artem Bityutskiy
  0 siblings, 1 reply; 14+ messages in thread
From: Arnd Bergmann @ 2010-07-20  9:19 UTC (permalink / raw)
  To: dedekind1; +Cc: linux-mtd, Roman Tereshonkov

On Monday 19 July 2010, Artem Bityutskiy wrote:
> On Sun, 2010-07-18 at 20:22 +0000, Arnd Bergmann wrote:
> > Yes, that's generally true. It would be nice if the BLKPG ioctl
> > definition could be reused for this. It is more complicated
> > than it should be, but not more than this suggestion, and
> > it's an existing ioctl.
> 
> Thanks for reply.
> 
> MTD devices do not support BLKPG, do you mean we should you the same
> data-structures and names as block devices?

Yes. I'm not sure if it should also be possible to actually repartition
the flash using the mtdblock driver, but what I meant was to implement
the BLKPG API in the mtdchar driver, with slightly adapted semantics.

	Arnd

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning
  2010-07-20  9:19         ` Arnd Bergmann
@ 2010-07-20  9:25           ` Artem Bityutskiy
  0 siblings, 0 replies; 14+ messages in thread
From: Artem Bityutskiy @ 2010-07-20  9:25 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-mtd, Roman Tereshonkov

On Tue, 2010-07-20 at 11:19 +0200, Arnd Bergmann wrote:
> On Monday 19 July 2010, Artem Bityutskiy wrote:
> > On Sun, 2010-07-18 at 20:22 +0000, Arnd Bergmann wrote:
> > > Yes, that's generally true. It would be nice if the BLKPG ioctl
> > > definition could be reused for this. It is more complicated
> > > than it should be, but not more than this suggestion, and
> > > it's an existing ioctl.
> > 
> > Thanks for reply.
> > 
> > MTD devices do not support BLKPG, do you mean we should you the same
> > data-structures and names as block devices?
> 
> Yes. I'm not sure if it should also be possible to actually repartition
> the flash using the mtdblock driver, but what I meant was to implement
> the BLKPG API in the mtdchar driver, with slightly adapted semantics.

No, using mtdblock is not feasible, because of several reasons like that
it is a debugging driver which does not handle bad blocks, and it works
on top of mtd, has no idea about mtd internals, and all the partitions
logic is inside mtd, and not available for mtdblock.

But yes, using the BLKPG API sounds like a reasonable idea, thanks.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/4] mtd: add mtd repartition ioctl
  2010-07-08  5:50 ` [PATCH 0/4] mtd: add mtd repartition ioctl Artem Bityutskiy
@ 2010-07-21  9:58   ` Artem Bityutskiy
  2010-07-21 11:44     ` Vivek
  0 siblings, 1 reply; 14+ messages in thread
From: Artem Bityutskiy @ 2010-07-21  9:58 UTC (permalink / raw)
  To: Roman Tereshonkov; +Cc: linux-mtd

On Thu, 2010-07-08 at 08:50 +0300, Artem Bityutskiy wrote:
> On Fri, 2010-06-18 at 13:08 +0300, Roman Tereshonkov wrote:
> > Adding mtd master device after all partitions should provide
> > minimum effect on the created partition enumeration.
> > 
> > The master mtd device can be repartitioned in runtime through
> > the mtd ioctl MTDREPARTITION. The ioctl passed argument is
> > the set of the new partitions defined by the structures:
> > struct mtd_partitions and struct mtd_partition_user.
> > 
> > All at once partition configuration is used and caused by
> > the all at once partition removing. Only unused partitions are deleted.
> > If any of the partitions for given mtd device is used then user gets error.
> > The care should be taken to close all applications which access
> > the partitions.
> > 
> > Roman Tereshonkov (4):
> >   mtd: add new ioctl structures to be used for repartitioning
> >   mtd: add the possibility to modify partitions in runtime
> >   mtd: add MTDREPARTITION ioctl
> >   mtd: create the mtd master device for given set of partitions
> > 
> >  drivers/mtd/mtdchar.c          |  110 +++++++++++++++++++++++++++++++++++++++-
> >  drivers/mtd/mtdpart.c          |   45 ++++++++++++++--
> >  drivers/mtd/onenand/omap2.c    |    8 ++-
> >  include/linux/mtd/partitions.h |    2 +
> >  include/mtd/mtd-abi.h          |   15 ++++++
> >  5 files changed, 170 insertions(+), 10 deletions(-)
> 
> I've pushed this to my l2-mtd-2.6.git / master, looks good to me.

Removed from l2-mtd-2.6 - please, address the comments from me and Arnd.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 0/4] mtd: add mtd repartition ioctl
  2010-07-21  9:58   ` Artem Bityutskiy
@ 2010-07-21 11:44     ` Vivek
  2010-07-21 11:46       ` Artem Bityutskiy
  0 siblings, 1 reply; 14+ messages in thread
From: Vivek @ 2010-07-21 11:44 UTC (permalink / raw)
  To: dedekind1, 'Roman Tereshonkov'; +Cc: linux-mtd

Hi Artem

> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org [mailto:linux-mtd-
> bounces@lists.infradead.org] On Behalf Of Artem Bityutskiy
> Sent: Wednesday, July 21, 2010 3:29 PM
> To: Roman Tereshonkov
> Cc: linux-mtd@lists.infradead.org
> Subject: Re: [PATCH 0/4] mtd: add mtd repartition ioctl
> 
> On Thu, 2010-07-08 at 08:50 +0300, Artem Bityutskiy wrote:
> > On Fri, 2010-06-18 at 13:08 +0300, Roman Tereshonkov wrote:
> > > Adding mtd master device after all partitions should provide
> > > minimum effect on the created partition enumeration.
> > >
> > > The master mtd device can be repartitioned in runtime through
> > > the mtd ioctl MTDREPARTITION. The ioctl passed argument is
> > > the set of the new partitions defined by the structures:
> > > struct mtd_partitions and struct mtd_partition_user.
> > >
> > > All at once partition configuration is used and caused by
> > > the all at once partition removing. Only unused partitions are
> deleted.
> > > If any of the partitions for given mtd device is used then user
> gets error.
> > > The care should be taken to close all applications which access
> > > the partitions.
> > >
> > > Roman Tereshonkov (4):
> > >   mtd: add new ioctl structures to be used for repartitioning
> > >   mtd: add the possibility to modify partitions in runtime
> > >   mtd: add MTDREPARTITION ioctl
> > >   mtd: create the mtd master device for given set of partitions
> > >
> > >  drivers/mtd/mtdchar.c          |  110
> +++++++++++++++++++++++++++++++++++++++-
> > >  drivers/mtd/mtdpart.c          |   45 ++++++++++++++--
> > >  drivers/mtd/onenand/omap2.c    |    8 ++-
> > >  include/linux/mtd/partitions.h |    2 +
> > >  include/mtd/mtd-abi.h          |   15 ++++++
> > >  5 files changed, 170 insertions(+), 10 deletions(-)
> >
> > I've pushed this to my l2-mtd-2.6.git / master, looks good to me.
> 
> Removed from l2-mtd-2.6 - please, address the comments from me and Arnd.

We have also developed the similar solution for run-time partitioning support; it includes 3 ioctl's(for creating,deleting,changing permissions of partitions) and the mtd utility for partitioning(which supports resizing and deleting partitions, changing permissions). 
Very shortly we are going to release that.

Regards
Vivek Dalal and Rohit H.S
> 
> --
> Best Regards,
> Artem Bityutskiy (Артём Битюцкий)
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 14+ messages in thread

* RE: [PATCH 0/4] mtd: add mtd repartition ioctl
  2010-07-21 11:44     ` Vivek
@ 2010-07-21 11:46       ` Artem Bityutskiy
  0 siblings, 0 replies; 14+ messages in thread
From: Artem Bityutskiy @ 2010-07-21 11:46 UTC (permalink / raw)
  To: Vivek; +Cc: linux-mtd, 'Roman Tereshonkov'

On Wed, 2010-07-21 at 17:14 +0530, Vivek wrote:
> > Removed from l2-mtd-2.6 - please, address the comments from me and Arnd.
> 
> We have also developed the similar solution for run-time partitioning support; it includes 3 ioctl's(for creating,deleting,changing permissions of partitions) and the mtd utility for partitioning(which supports resizing and deleting partitions, changing permissions). 
> Very shortly we are going to release that.

Sure, please, do.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-07-21 11:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-18 10:08 [PATCH 0/4] mtd: add mtd repartition ioctl Roman Tereshonkov
2010-06-18 10:08 ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Roman Tereshonkov
2010-06-18 10:08   ` [PATCH 2/4] mtd: add the possibility to modify partitions in runtime Roman Tereshonkov
2010-06-18 10:08     ` [PATCH 3/4] mtd: add MTDREPARTITION ioctl Roman Tereshonkov
2010-06-18 10:08       ` [PATCH 4/4] mtd: create the mtd master device for given set of partitions Roman Tereshonkov
2010-07-18 17:00   ` [PATCH 1/4] mtd: add new ioctl structures to be used for repartitioning Artem Bityutskiy
2010-07-18 20:22     ` Arnd Bergmann
2010-07-19  4:06       ` Artem Bityutskiy
2010-07-20  9:19         ` Arnd Bergmann
2010-07-20  9:25           ` Artem Bityutskiy
2010-07-08  5:50 ` [PATCH 0/4] mtd: add mtd repartition ioctl Artem Bityutskiy
2010-07-21  9:58   ` Artem Bityutskiy
2010-07-21 11:44     ` Vivek
2010-07-21 11:46       ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).