* 2.6.0-test5-mm2 Device Mapper Patches
@ 2003-09-22 15:44 Kevin Corry
2003-09-22 15:51 ` [PATCH] DM 1/6: Use new format_dev_t macro Kevin Corry
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Kevin Corry @ 2003-09-22 15:44 UTC (permalink / raw)
To: torvalds, akpm, thornber; +Cc: LKML
A handful of minor fixes for Device-Mapper. Joe Thornber asked me to forward
these on while he is changing internet connections.
--
Kevin Corry
kevcorry@us.ibm.com
http://evms.sourceforge.net/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] DM 1/6: Use new format_dev_t macro
2003-09-22 15:44 2.6.0-test5-mm2 Device Mapper Patches Kevin Corry
@ 2003-09-22 15:51 ` Kevin Corry
2003-09-22 19:29 ` viro
2003-09-22 15:51 ` [PATCH] DM 2/6: Drop extra table ref-count Kevin Corry
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Kevin Corry @ 2003-09-22 15:51 UTC (permalink / raw)
To: torvalds, akpm, thornber; +Cc: LKML
Use the format_dev_t function for target status functions.
--- diff/drivers/md/dm-linear.c 2003-06-30 10:07:21.000000000 +0100
+++ source/drivers/md/dm-linear.c 2003-09-17 13:08:44.000000000 +0100
@@ -79,7 +79,7 @@
char *result, unsigned int maxlen)
{
struct linear_c *lc = (struct linear_c *) ti->private;
- char b[BDEVNAME_SIZE];
+ char buffer[32];
switch (type) {
case STATUSTYPE_INFO:
@@ -87,8 +87,8 @@
break;
case STATUSTYPE_TABLE:
- snprintf(result, maxlen, "%s " SECTOR_FORMAT,
- bdevname(lc->dev->bdev, b), lc->start);
+ format_dev_t(buffer, lc->dev->bdev->bd_dev);
+ snprintf(result, maxlen, "%s " SECTOR_FORMAT, buffer, lc->start);
break;
}
return 0;
--- diff/drivers/md/dm-stripe.c 2003-08-20 14:16:28.000000000 +0100
+++ source/drivers/md/dm-stripe.c 2003-09-17 13:08:44.000000000 +0100
@@ -187,7 +187,7 @@
struct stripe_c *sc = (struct stripe_c *) ti->private;
int offset;
unsigned int i;
- char b[BDEVNAME_SIZE];
+ char buffer[32];
switch (type) {
case STATUSTYPE_INFO:
@@ -198,10 +198,10 @@
offset = snprintf(result, maxlen, "%d " SECTOR_FORMAT,
sc->stripes, sc->chunk_mask + 1);
for (i = 0; i < sc->stripes; i++) {
+ format_dev_t(buffer, sc->stripe[i].dev->bdev->bd_dev);
offset +=
snprintf(result + offset, maxlen - offset,
- " %s " SECTOR_FORMAT,
- bdevname(sc->stripe[i].dev->bdev, b),
+ " %s " SECTOR_FORMAT, buffer,
sc->stripe[i].physical_start);
}
break;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] DM 2/6: Drop extra table ref-count
2003-09-22 15:44 2.6.0-test5-mm2 Device Mapper Patches Kevin Corry
2003-09-22 15:51 ` [PATCH] DM 1/6: Use new format_dev_t macro Kevin Corry
@ 2003-09-22 15:51 ` Kevin Corry
2003-09-22 15:52 ` [PATCH] DM 3/6: Move retrieve_status function Kevin Corry
` (3 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Kevin Corry @ 2003-09-22 15:51 UTC (permalink / raw)
To: torvalds, akpm, thornber; +Cc: LKML
When multiple load ioctls are issued the reference count on older
'new_tables' wasn't being dropped. [Christophe Saout]
--- diff/drivers/md/dm-ioctl-v4.c 2003-09-17 12:28:06.000000000 +0100
+++ source/drivers/md/dm-ioctl-v4.c 2003-09-17 13:08:53.000000000 +0100
@@ -817,6 +817,8 @@
return -ENXIO;
}
+ if (hc->new_map)
+ dm_table_put(hc->new_map);
hc->new_map = t;
param->flags |= DM_INACTIVE_PRESENT_FLAG;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] DM 3/6: Move retrieve_status function
2003-09-22 15:44 2.6.0-test5-mm2 Device Mapper Patches Kevin Corry
2003-09-22 15:51 ` [PATCH] DM 1/6: Use new format_dev_t macro Kevin Corry
2003-09-22 15:51 ` [PATCH] DM 2/6: Drop extra table ref-count Kevin Corry
@ 2003-09-22 15:52 ` Kevin Corry
2003-09-22 15:52 ` [PATCH] DM 4/6: Return table status for dev_wait Kevin Corry
` (2 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Kevin Corry @ 2003-09-22 15:52 UTC (permalink / raw)
To: torvalds, akpm, thornber; +Cc: LKML
Move retrieve_status up so dev_wait() can use it.
--- diff/drivers/md/dm-ioctl-v4.c 2003-09-17 13:08:53.000000000 +0100
+++ source/drivers/md/dm-ioctl-v4.c 2003-09-17 13:09:04.000000000 +0100
@@ -700,6 +700,69 @@
}
/*
+ * Build up the status struct for each target
+ */
+static void retrieve_status(struct dm_table *table,
+ struct dm_ioctl *param, size_t param_size)
+{
+ unsigned int i, num_targets;
+ struct dm_target_spec *spec;
+ char *outbuf, *outptr;
+ status_type_t type;
+ size_t remaining, len, used = 0;
+
+ outptr = outbuf = get_result_buffer(param, param_size, &len);
+
+ if (param->flags & DM_STATUS_TABLE_FLAG)
+ type = STATUSTYPE_TABLE;
+ else
+ type = STATUSTYPE_INFO;
+
+ /* Get all the target info */
+ num_targets = dm_table_get_num_targets(table);
+ for (i = 0; i < num_targets; i++) {
+ struct dm_target *ti = dm_table_get_target(table, i);
+
+ remaining = len - (outptr - outbuf);
+ if (remaining < sizeof(struct dm_target_spec)) {
+ param->flags |= DM_BUFFER_FULL_FLAG;
+ break;
+ }
+
+ spec = (struct dm_target_spec *) outptr;
+
+ spec->status = 0;
+ spec->sector_start = ti->begin;
+ spec->length = ti->len;
+ strncpy(spec->target_type, ti->type->name,
+ sizeof(spec->target_type));
+
+ outptr += sizeof(struct dm_target_spec);
+ remaining = len - (outptr - outbuf);
+
+ /* Get the status/table string from the target driver */
+ if (ti->type->status) {
+ if (ti->type->status(ti, type, outptr, remaining)) {
+ param->flags |= DM_BUFFER_FULL_FLAG;
+ break;
+ }
+ } else
+ outptr[0] = '\0';
+
+ outptr += strlen(outptr) + 1;
+ used = param->data_start + (outptr - outbuf);
+
+ align_ptr(outptr);
+ spec->next = outptr - outbuf;
+ }
+
+ if (used)
+ param->data_size = used;
+
+ param->target_count = num_targets;
+}
+
+/*
* Wait for a device to report an event
*/
static int dev_wait(struct dm_ioctl *param, size_t param_size)
@@ -920,69 +983,6 @@
}
/*
- * Build up the status struct for each target
- */
-static void retrieve_status(struct dm_table *table,
- struct dm_ioctl *param, size_t param_size)
-{
- unsigned int i, num_targets;
- struct dm_target_spec *spec;
- char *outbuf, *outptr;
- status_type_t type;
- size_t remaining, len, used = 0;
-
- outptr = outbuf = get_result_buffer(param, param_size, &len);
-
- if (param->flags & DM_STATUS_TABLE_FLAG)
- type = STATUSTYPE_TABLE;
- else
- type = STATUSTYPE_INFO;
-
- /* Get all the target info */
- num_targets = dm_table_get_num_targets(table);
- for (i = 0; i < num_targets; i++) {
- struct dm_target *ti = dm_table_get_target(table, i);
-
- remaining = len - (outptr - outbuf);
- if (remaining < sizeof(struct dm_target_spec)) {
- param->flags |= DM_BUFFER_FULL_FLAG;
- break;
- }
-
- spec = (struct dm_target_spec *) outptr;
-
- spec->status = 0;
- spec->sector_start = ti->begin;
- spec->length = ti->len;
- strncpy(spec->target_type, ti->type->name,
- sizeof(spec->target_type));
-
- outptr += sizeof(struct dm_target_spec);
- remaining = len - (outptr - outbuf);
-
- /* Get the status/table string from the target driver */
- if (ti->type->status) {
- if (ti->type->status(ti, type, outptr, remaining)) {
- param->flags |= DM_BUFFER_FULL_FLAG;
- break;
- }
- } else
- outptr[0] = '\0';
-
- outptr += strlen(outptr) + 1;
- used = param->data_start + (outptr - outbuf);
-
- align_ptr(outptr);
- spec->next = outptr - outbuf;
- }
-
- if (used)
- param->data_size = used;
-
- param->target_count = num_targets;
-}
-
-/*
* Return the status of a device as a text string for each
* target.
*/
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] DM 4/6: Return table status for dev_wait
2003-09-22 15:44 2.6.0-test5-mm2 Device Mapper Patches Kevin Corry
` (2 preceding siblings ...)
2003-09-22 15:52 ` [PATCH] DM 3/6: Move retrieve_status function Kevin Corry
@ 2003-09-22 15:52 ` Kevin Corry
2003-09-22 15:52 ` [PATCH] DM 5/6: Message fix in dm-linear Kevin Corry
2003-09-22 15:53 ` [PATCH] DM 6/6: Support arbitrary number of target params Kevin Corry
5 siblings, 0 replies; 11+ messages in thread
From: Kevin Corry @ 2003-09-22 15:52 UTC (permalink / raw)
To: torvalds, akpm, thornber; +Cc: LKML
dev_wait was meant to return table status not dev status. [Alasdair Kergon]
--- diff/drivers/md/dm-ioctl-v4.c 2003-09-17 13:09:04.000000000 +0100
+++ source/drivers/md/dm-ioctl-v4.c 2003-09-17 13:09:26.000000000 +0100
@@ -769,6 +769,7 @@
{
int r;
struct mapped_device *md;
+ struct dm_table *table;
DECLARE_WAITQUEUE(wq, current);
md = find_device(param);
@@ -791,7 +792,16 @@
* him and save an ioctl.
*/
r = __dev_status(md, param);
+ if (r)
+ goto out;
+
+ table = dm_get_table(md);
+ if (table) {
+ retrieve_status(table, param, param_size);
+ dm_table_put(table);
+ }
+ out:
dm_put(md);
return r;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] DM 5/6: Message fix in dm-linear
2003-09-22 15:44 2.6.0-test5-mm2 Device Mapper Patches Kevin Corry
` (3 preceding siblings ...)
2003-09-22 15:52 ` [PATCH] DM 4/6: Return table status for dev_wait Kevin Corry
@ 2003-09-22 15:52 ` Kevin Corry
2003-09-22 15:53 ` [PATCH] DM 6/6: Support arbitrary number of target params Kevin Corry
5 siblings, 0 replies; 11+ messages in thread
From: Kevin Corry @ 2003-09-22 15:52 UTC (permalink / raw)
To: torvalds, akpm, thornber; +Cc: LKML
Fix error message when linear targets gets handed more than 2 arguments.
[Alasdair Kergon]
--- diff/drivers/md/dm-linear.c 2003-09-17 13:08:44.000000000 +0100
+++ source/drivers/md/dm-linear.c 2003-09-17 13:09:34.000000000 +0100
@@ -28,7 +28,7 @@
struct linear_c *lc;
if (argc != 2) {
- ti->error = "dm-linear: Not enough arguments";
+ ti->error = "dm-linear: Invalid argument count";
return -EINVAL;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] DM 6/6: Support arbitrary number of target params
2003-09-22 15:44 2.6.0-test5-mm2 Device Mapper Patches Kevin Corry
` (4 preceding siblings ...)
2003-09-22 15:52 ` [PATCH] DM 5/6: Message fix in dm-linear Kevin Corry
@ 2003-09-22 15:53 ` Kevin Corry
5 siblings, 0 replies; 11+ messages in thread
From: Kevin Corry @ 2003-09-22 15:53 UTC (permalink / raw)
To: torvalds, akpm, thornber; +Cc: LKML
Support an arbitrary number of target parameters. [Alasdair Kergon]
--- diff/drivers/md/dm-table.c 2003-09-17 12:28:06.000000000 +0100
+++ source/drivers/md/dm-table.c 2003-09-17 13:09:41.000000000 +0100
@@ -534,12 +534,36 @@
}
/*
+ * Used to dynamically allocate the arg array.
+ */
+static char **realloc_argv(unsigned *array_size, char **old_argv)
+{
+ char **argv;
+ unsigned new_size;
+
+ new_size = *array_size ? *array_size * 2 : 64;
+ argv = kmalloc(new_size * sizeof(*argv), GFP_KERNEL);
+ if (argv) {
+ memcpy(argv, old_argv, *array_size * sizeof(*argv));
+ *array_size = new_size;
+ }
+
+ kfree(old_argv);
+ return argv;
+}
+
+/*
* Destructively splits up the argument list to pass to ctr.
*/
-static int split_args(int max, int *argc, char **argv, char *input)
+static int split_args(int *argc, char ***argvp, char *input)
{
- char *start, *end = input, *out;
+ char *start, *end = input, *out, **argv = NULL;
+ unsigned array_size = 0;
+
*argc = 0;
+ argv = realloc_argv(&array_size, argv);
+ if (!argv)
+ return -ENOMEM;
while (1) {
start = end;
@@ -568,8 +592,11 @@
}
/* have we already filled the array ? */
- if ((*argc + 1) > max)
- return -EINVAL;
+ if ((*argc + 1) > array_size) {
+ argv = realloc_argv(&array_size, argv);
+ if (!argv)
+ return -ENOMEM;
+ }
/* we know this is whitespace */
if (*end)
@@ -581,6 +608,7 @@
(*argc)++;
}
+ *argvp = argv;
return 0;
}
@@ -588,7 +616,7 @@
sector_t start, sector_t len, char *params)
{
int r = -EINVAL, argc;
- char *argv[32];
+ char **argv;
struct dm_target *tgt;
if ((r = check_space(t)))
@@ -617,13 +645,14 @@
goto bad;
}
- r = split_args(ARRAY_SIZE(argv), &argc, argv, params);
+ r = split_args(&argc, &argv, params);
if (r) {
- tgt->error = "couldn't split parameters";
+ tgt->error = "couldn't split parameters (insufficient memory)";
goto bad;
}
r = tgt->type->ctr(tgt, argc, argv);
+ kfree(argv);
if (r)
goto bad;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] DM 1/6: Use new format_dev_t macro
2003-09-22 15:51 ` [PATCH] DM 1/6: Use new format_dev_t macro Kevin Corry
@ 2003-09-22 19:29 ` viro
2003-09-23 7:57 ` Joe Thornber
0 siblings, 1 reply; 11+ messages in thread
From: viro @ 2003-09-22 19:29 UTC (permalink / raw)
To: Kevin Corry; +Cc: torvalds, akpm, thornber, LKML
On Mon, Sep 22, 2003 at 10:51:27AM -0500, Kevin Corry wrote:
> Use the format_dev_t function for target status functions.
[instead of bdevname, that is]
It's wrong. Simply because "sdb3" is immediately parsed by admin and
08:13 is nowhere near that convenient. These are error messages, let's
keep them readable.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] DM 1/6: Use new format_dev_t macro
2003-09-22 19:29 ` viro
@ 2003-09-23 7:57 ` Joe Thornber
2003-09-23 7:57 ` viro
0 siblings, 1 reply; 11+ messages in thread
From: Joe Thornber @ 2003-09-23 7:57 UTC (permalink / raw)
To: viro; +Cc: Kevin Corry, torvalds, akpm, thornber, LKML
On Monday, September 22, 2003, at 08:29 PM,
viro@parcelfarce.linux.theplanet.co.uk wrote:
> On Mon, Sep 22, 2003 at 10:51:27AM -0500, Kevin Corry wrote:
>> Use the format_dev_t function for target status functions.
>
> [instead of bdevname, that is]
>
> It's wrong. Simply because "sdb3" is immediately parsed by admin and
> 08:13 is nowhere near that convenient. These are error messages, let's
> keep them readable.
>
>
No they are not just error messages, userland tools use them.
- Joe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] DM 1/6: Use new format_dev_t macro
2003-09-23 7:57 ` Joe Thornber
@ 2003-09-23 7:57 ` viro
2003-09-23 14:07 ` Kevin Corry
0 siblings, 1 reply; 11+ messages in thread
From: viro @ 2003-09-23 7:57 UTC (permalink / raw)
To: Joe Thornber; +Cc: Kevin Corry, torvalds, akpm, thornber, LKML
On Tue, Sep 23, 2003 at 08:57:07AM +0100, Joe Thornber wrote:
>
> On Monday, September 22, 2003, at 08:29 PM,
> viro@parcelfarce.linux.theplanet.co.uk wrote:
>
> >On Mon, Sep 22, 2003 at 10:51:27AM -0500, Kevin Corry wrote:
> >>Use the format_dev_t function for target status functions.
> >
> >[instead of bdevname, that is]
> >
> >It's wrong. Simply because "sdb3" is immediately parsed by admin and
> >08:13 is nowhere near that convenient. These are error messages, let's
> >keep them readable.
> >
> >
>
> No they are not just error messages, userland tools use them.
In which case the change in question would break said userland tools, wouldn't
it?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] DM 1/6: Use new format_dev_t macro
2003-09-23 7:57 ` viro
@ 2003-09-23 14:07 ` Kevin Corry
0 siblings, 0 replies; 11+ messages in thread
From: Kevin Corry @ 2003-09-23 14:07 UTC (permalink / raw)
To: viro, Joe Thornber; +Cc: torvalds, akpm, LKML
On Tuesday 23 September 2003 02:57, viro@parcelfarce.linux.theplanet.co.uk
wrote:
> On Tue, Sep 23, 2003 at 08:57:07AM +0100, Joe Thornber wrote:
> > On Monday, September 22, 2003, at 08:29 PM,
> >
> > viro@parcelfarce.linux.theplanet.co.uk wrote:
> > >On Mon, Sep 22, 2003 at 10:51:27AM -0500, Kevin Corry wrote:
> > >>Use the format_dev_t function for target status functions.
> > >
> > >[instead of bdevname, that is]
> > >
> > >It's wrong. Simply because "sdb3" is immediately parsed by admin and
> > >08:13 is nowhere near that convenient. These are error messages, let's
> > >keep them readable.
> >
> > No they are not just error messages, userland tools use them.
>
> In which case the change in question would break said userland tools,
> wouldn't it?
No, actually this change brings the status info back in-line with how the 2.4
version of DM behaves. A while back the bdevname() function changed to return
a text name (it used to return a major:minor, similar to kdevname in 2.4). In
many cases the only way to make any sense of this text name is to search
around in sysfs for a matching entry (provided, of course, that sysfs is
mounted, which many people still don't realize they should be doing. :) And
if you find that entry in sysfs, the info you're really looking for is in the
"dev" file, whose contents are displayed using format_dev_t().
--
Kevin Corry
kevcorry@us.ibm.com
http://evms.sourceforge.net/
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2003-09-23 14:07 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-22 15:44 2.6.0-test5-mm2 Device Mapper Patches Kevin Corry
2003-09-22 15:51 ` [PATCH] DM 1/6: Use new format_dev_t macro Kevin Corry
2003-09-22 19:29 ` viro
2003-09-23 7:57 ` Joe Thornber
2003-09-23 7:57 ` viro
2003-09-23 14:07 ` Kevin Corry
2003-09-22 15:51 ` [PATCH] DM 2/6: Drop extra table ref-count Kevin Corry
2003-09-22 15:52 ` [PATCH] DM 3/6: Move retrieve_status function Kevin Corry
2003-09-22 15:52 ` [PATCH] DM 4/6: Return table status for dev_wait Kevin Corry
2003-09-22 15:52 ` [PATCH] DM 5/6: Message fix in dm-linear Kevin Corry
2003-09-22 15:53 ` [PATCH] DM 6/6: Support arbitrary number of target params Kevin Corry
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).