Skip to contentSkip to conversation

dm: remove unused functions (fwd)

PATCH In review Adrian Bunk 3 participants 4 messages Nov 29, 2004 – Dec 1, 2004 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: remove unused functions (fwd)

The patch forwarded below still applies and compiles against 2.6.10-rc2-mm3.

Please apply or comment on it.

----- Forwarded message from Adrian Bunk <[email protected]> -----

Date: Fri, 29 Oct 2004 02:15:49 +0200
From: Adrian Bunk <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [2.6 patch] dm: remove unused functions

[ this time without the problems due to a digital signature... ]

The patch below removes two unsed functions from dm code.

diffstat output:

 drivers/md/dm-io.c   |   16 ----------------
 drivers/md/dm-snap.c |    5 -----
 2 files changed, 21 deletions(-)
drivers/md/dm-io.c renamed from drivers/md/dm-io.c.old +0 -16
@@ -149,22 +149,6 @@
 	return 0;
 }
 
-static inline void bs_bio_init(struct bio *bio)
-{
-	bio->bi_next = NULL;
-	bio->bi_flags = 1 << BIO_UPTODATE;
-	bio->bi_rw = 0;
-	bio->bi_vcnt = 0;
-	bio->bi_idx = 0;
-	bio->bi_phys_segments = 0;
-	bio->bi_hw_segments = 0;
-	bio->bi_size = 0;
-	bio->bi_max_vecs = 0;
-	bio->bi_end_io = NULL;
-	atomic_set(&bio->bi_cnt, 1);
-	bio->bi_private = NULL;
-}
-
 static unsigned _bio_count = 0;
 struct bio *bio_set_alloc(struct bio_set *bs, int gfp_mask, int nr_iovecs)
 {
drivers/md/dm-snap.c renamed from drivers/md/dm-snap.c.old +0 -5
@@ -271,11 +271,6 @@
 	return e;
 }
 
-static inline void free_exception(struct exception *e)
-{
-	kmem_cache_free(exception_cache, e);
-}
-
 static inline struct pending_exception *alloc_pending_exception(void)
 {
 	return mempool_alloc(pending_pool, GFP_NOIO);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

----- End forwarded message -----

#1 lore raw
Quoted 1 line · Adrian Bunk

Please apply or comment on it.

Please check *why* the functions aren't used first.

e.g. An alloc function with a corresponding free that never gets called suggests a leak to me...

Alasdair

Signature · 1 line
[email protected]
#2 lore raw
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Adrian Bunk

Please apply or comment on it.

Please check *why* the functions aren't used first.

e.g. An alloc function with a corresponding free that never gets called suggests a leak to me...

I have to admit that I don't thoroughly check the code where I find unused code. That's why I asked for comments on this patch. Ususally the maintainers of the code in question know best whether such a patch is correct or not.

Simply consider my patches as some kind of "list of unused functions".

Quoted 1 line

Alasdair

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#3 lore raw
In reply to Alasdair G Kergon
Quoted 7 lines · Alasdair G Kergon
Quoted 1 line · Adrian Bunk

Please apply or comment on it.

Please check *why* the functions aren't used first.

e.g. An alloc function with a corresponding free that never gets called suggests a leak to me...

That one isn't a leak (referring to "kmem_cache_t *exception_cache" in dm-snap.c). Items are allocated from this cache using alloc_exception(). This can happen either when an existing snapshot is activated and it's exception table is read from disk into an in-memory hash-table, or when a copy-on-write completes and a new exception is added to this hash-table. As long as the snapshot is active, this hash-table remains in memory and items cannot be removed from it. When the snapshot is deactivated, we call exit_exception_table() and pass it a pointer to this hash-table and exception_cache. This routine calls kmem_cache_free() directly instead of using the free_exception() routine. The reason it doesn't use free_exception() is that exit_exception_table() is used to tear down two different but somewhat similar hash-tables, each of which uses a different kmem_cache_t.

So, it may be nice to keep the symmetric routines defined (alloc_exception() and free_exception()), but Adrian is correct in that the later is not being used, and it really can't be used without some more significant code changes.

As for bs_bio_init(), it can be safely removed. It was just a duplicate of bio_init() from fs/bio.c. The use of that call in dm-io.c was changed to use bio_init(), but apparently the routine itself was never removed.

Signature · 3 lines
Kevin Corry
[email protected]
http://evms.sourceforge.net/