Skip to content

Commit 094ea9a

Browse files
committed
dm ioctl: make __dev_status void
__dev_status() cannot fail so make it void and simplify callers. Signed-off-by: Alasdair G Kergon <agk@redhat.com>
1 parent 6be5449 commit 094ea9a

1 file changed

Lines changed: 31 additions & 36 deletions

File tree

‎drivers/md/dm-ioctl.c‎

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static struct dm_table *dm_get_live_or_inactive_table(struct mapped_device *md,
573573
* Fills in a dm_ioctl structure, ready for sending back to
574574
* userland.
575575
*/
576-
static int __dev_status(struct mapped_device *md, struct dm_ioctl *param)
576+
static void __dev_status(struct mapped_device *md, struct dm_ioctl *param)
577577
{
578578
struct gendisk *disk = dm_disk(md);
579579
struct dm_table *table;
@@ -617,8 +617,6 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param)
617617
dm_table_put(table);
618618
}
619619
}
620-
621-
return 0;
622620
}
623621

624622
static int dev_create(struct dm_ioctl *param, size_t param_size)
@@ -638,14 +636,14 @@ static int dev_create(struct dm_ioctl *param, size_t param_size)
638636
return r;
639637

640638
r = dm_hash_insert(param->name, *param->uuid ? param->uuid : NULL, md);
641-
if (r) {
642-
dm_put(md);
643-
return r;
644-
}
639+
if (r)
640+
goto out;
645641

646642
param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
647643

648-
r = __dev_status(md, param);
644+
__dev_status(md, param);
645+
646+
out:
649647
dm_put(md);
650648

651649
return r;
@@ -841,13 +839,17 @@ static int do_suspend(struct dm_ioctl *param)
841839
if (param->flags & DM_NOFLUSH_FLAG)
842840
suspend_flags |= DM_SUSPEND_NOFLUSH_FLAG;
843841

844-
if (!dm_suspended_md(md))
842+
if (!dm_suspended_md(md)) {
845843
r = dm_suspend(md, suspend_flags);
844+
if (r)
845+
goto out;
846+
}
846847

847-
if (!r)
848-
r = __dev_status(md, param);
848+
__dev_status(md, param);
849849

850+
out:
850851
dm_put(md);
852+
851853
return r;
852854
}
853855

@@ -909,7 +911,7 @@ static int do_resume(struct dm_ioctl *param)
909911
dm_table_destroy(old_map);
910912

911913
if (!r)
912-
r = __dev_status(md, param);
914+
__dev_status(md, param);
913915

914916
dm_put(md);
915917
return r;
@@ -933,16 +935,16 @@ static int dev_suspend(struct dm_ioctl *param, size_t param_size)
933935
*/
934936
static int dev_status(struct dm_ioctl *param, size_t param_size)
935937
{
936-
int r;
937938
struct mapped_device *md;
938939

939940
md = find_device(param);
940941
if (!md)
941942
return -ENXIO;
942943

943-
r = __dev_status(md, param);
944+
__dev_status(md, param);
944945
dm_put(md);
945-
return r;
946+
947+
return 0;
946948
}
947949

948950
/*
@@ -1017,7 +1019,7 @@ static void retrieve_status(struct dm_table *table,
10171019
*/
10181020
static int dev_wait(struct dm_ioctl *param, size_t param_size)
10191021
{
1020-
int r;
1022+
int r = 0;
10211023
struct mapped_device *md;
10221024
struct dm_table *table;
10231025

@@ -1038,18 +1040,17 @@ static int dev_wait(struct dm_ioctl *param, size_t param_size)
10381040
* changed to trigger the event, so we may as well tell
10391041
* him and save an ioctl.
10401042
*/
1041-
r = __dev_status(md, param);
1042-
if (r)
1043-
goto out;
1043+
__dev_status(md, param);
10441044

10451045
table = dm_get_live_or_inactive_table(md, param);
10461046
if (table) {
10471047
retrieve_status(table, param, param_size);
10481048
dm_table_put(table);
10491049
}
10501050

1051-
out:
1051+
out:
10521052
dm_put(md);
1053+
10531054
return r;
10541055
}
10551056

@@ -1184,7 +1185,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
11841185
up_write(&_hash_lock);
11851186

11861187
param->flags |= DM_INACTIVE_PRESENT_FLAG;
1187-
r = __dev_status(md, param);
1188+
__dev_status(md, param);
11881189

11891190
out:
11901191
dm_put(md);
@@ -1194,7 +1195,6 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
11941195

11951196
static int table_clear(struct dm_ioctl *param, size_t param_size)
11961197
{
1197-
int r;
11981198
struct hash_cell *hc;
11991199
struct mapped_device *md;
12001200

@@ -1214,11 +1214,12 @@ static int table_clear(struct dm_ioctl *param, size_t param_size)
12141214

12151215
param->flags &= ~DM_INACTIVE_PRESENT_FLAG;
12161216

1217-
r = __dev_status(hc->md, param);
1217+
__dev_status(hc->md, param);
12181218
md = hc->md;
12191219
up_write(&_hash_lock);
12201220
dm_put(md);
1221-
return r;
1221+
1222+
return 0;
12221223
}
12231224

12241225
/*
@@ -1263,27 +1264,24 @@ static void retrieve_deps(struct dm_table *table,
12631264

12641265
static int table_deps(struct dm_ioctl *param, size_t param_size)
12651266
{
1266-
int r = 0;
12671267
struct mapped_device *md;
12681268
struct dm_table *table;
12691269

12701270
md = find_device(param);
12711271
if (!md)
12721272
return -ENXIO;
12731273

1274-
r = __dev_status(md, param);
1275-
if (r)
1276-
goto out;
1274+
__dev_status(md, param);
12771275

12781276
table = dm_get_live_or_inactive_table(md, param);
12791277
if (table) {
12801278
retrieve_deps(table, param, param_size);
12811279
dm_table_put(table);
12821280
}
12831281

1284-
out:
12851282
dm_put(md);
1286-
return r;
1283+
1284+
return 0;
12871285
}
12881286

12891287
/*
@@ -1292,27 +1290,24 @@ static int table_deps(struct dm_ioctl *param, size_t param_size)
12921290
*/
12931291
static int table_status(struct dm_ioctl *param, size_t param_size)
12941292
{
1295-
int r;
12961293
struct mapped_device *md;
12971294
struct dm_table *table;
12981295

12991296
md = find_device(param);
13001297
if (!md)
13011298
return -ENXIO;
13021299

1303-
r = __dev_status(md, param);
1304-
if (r)
1305-
goto out;
1300+
__dev_status(md, param);
13061301

13071302
table = dm_get_live_or_inactive_table(md, param);
13081303
if (table) {
13091304
retrieve_status(table, param, param_size);
13101305
dm_table_put(table);
13111306
}
13121307

1313-
out:
13141308
dm_put(md);
1315-
return r;
1309+
1310+
return 0;
13161311
}
13171312

13181313
/*

0 commit comments

Comments
 (0)