Skip to contentSkip to conversation

Staging: lustre: Declare local functions as static and drop unused functions

PATCH In review Shraddha Barke 2 participants 9 messages Oct 30, 2015 Staging

lore
Share & tools
lore
#0 lore raw

cover Staging: lustre: Declare local functions as static and drop unused functions

These patches declare local functions as static and remove corresponding declarations from header files. Unused function definitions and declarations are also removed.

Shraddha Barke (7):
Staging: lustre: mdc: Declare local functions as static
Staging: lustre: mdc: Remove unused mdc_open function from header
Staging: lustre: fld: Remove unused seq_client_alloc_super
Staging: lustre: fld: Declare local functions as static
Staging: lustre: fld: Remove unused functions
Staging: lustre: fld: Remove unused declaration
Staging: lustre: osc: Declare local functions as static

 drivers/staging/lustre/lustre/fid/fid_internal.h |  2 --
 drivers/staging/lustre/lustre/fid/fid_request.c  | 21 ---------------
 drivers/staging/lustre/lustre/fld/fld_cache.c    | 34 +++---------------------
 drivers/staging/lustre/lustre/fld/fld_internal.h |  9 -------
 drivers/staging/lustre/lustre/mdc/mdc_internal.h | 13 ---------
 drivers/staging/lustre/lustre/mdc/mdc_request.c  | 14 +++++-----
 drivers/staging/lustre/lustre/osc/osc_internal.h |  6 -----
 drivers/staging/lustre/lustre/osc/osc_request.c  | 13 ++++-----
 8 files changed, 19 insertions(+), 93 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/7 Staging: lustre: mdc: Declare local functions as static

Declare mdc_get_lustre_md, mdc_free_lustre_md and mdc_clear_open_replay_data as static since they are used only in this particular file. Also remove corresponding declarations from header files.

---
 drivers/staging/lustre/lustre/mdc/mdc_internal.h |  8 --------
 drivers/staging/lustre/lustre/mdc/mdc_request.c  | 14 ++++++++------
 2 files changed, 8 insertions(+), 14 deletions(-)
drivers/staging/lustre/lustre/mdc/mdc_internal.h +0 -8
index 29b46f7..5e0c8b5 100644
@@ -104,18 +104,10 @@ int mdc_open(struct obd_export *exp, u64 ino, int type, int flags,
 
 struct obd_client_handle;
 
-int mdc_get_lustre_md(struct obd_export *md_exp, struct ptlrpc_request *req,
-		      struct obd_export *dt_exp, struct obd_export *lmv_exp,
-		      struct lustre_md *md);
-
-int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md);
-
 int mdc_set_open_replay_data(struct obd_export *exp,
 			     struct obd_client_handle *och,
 			     struct lookup_intent *it);
 
-int mdc_clear_open_replay_data(struct obd_export *exp,
-			       struct obd_client_handle *och);
 void mdc_commit_open(struct ptlrpc_request *req);
 void mdc_replay_open(struct ptlrpc_request *req);
 
drivers/staging/lustre/lustre/mdc/mdc_request.c +8 -6
index 16a5a10..074bc88 100644
@@ -447,9 +447,11 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
 #define mdc_unpack_acl(req, md) 0
 #endif
 
-int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
-		      struct obd_export *dt_exp, struct obd_export *md_exp,
-		      struct lustre_md *md)
+static int mdc_get_lustre_md(struct obd_export *exp,
+			     struct ptlrpc_request *req,
+			     struct obd_export *dt_exp,
+			     struct obd_export *md_exp,
+			     struct lustre_md *md)
 {
 	struct req_capsule *pill = &req->rq_pill;
 	int rc;
@@ -573,7 +575,7 @@ out:
 	return rc;
 }
 
-int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
+static int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
 {
 	return 0;
 }
@@ -737,8 +739,8 @@ static void mdc_free_open(struct md_open_data *mod)
 		ptlrpc_request_committed(mod->mod_close_req, committed);
 }
 
-int mdc_clear_open_replay_data(struct obd_export *exp,
-			       struct obd_client_handle *och)
+static int mdc_clear_open_replay_data(struct obd_export *exp,
+				      struct obd_client_handle *och)
 {
 	struct md_open_data *mod = och->och_mod;
 
Signature · 1 line
2.1.4
#2 lore raw

PATCH 2/7 Staging: lustre: mdc: Remove unused mdc_open function from header

In reply to Shraddha Barke

Function mdc_open is declared in header file but it is not used anywhere. Hence drop the declaration.

---
 drivers/staging/lustre/lustre/mdc/mdc_internal.h | 5 -----
 1 file changed, 5 deletions(-)
drivers/staging/lustre/lustre/mdc/mdc_internal.h +0 -5
index 5e0c8b5..a41e2b9 100644
@@ -97,11 +97,6 @@ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
 /* mdc/mdc_request.c */
 int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
 		  struct md_op_data *op_data);
-
-int mdc_open(struct obd_export *exp, u64 ino, int type, int flags,
-	     struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh,
-	     struct ptlrpc_request **);
-
 struct obd_client_handle;
 
 int mdc_set_open_replay_data(struct obd_export *exp,
Signature · 1 line
2.1.4
#3 lore raw

PATCH 3/7 Staging: lustre: fld: Remove unused seq_client_alloc_super

In reply to Shraddha Barke

Remove function seq_client_alloc_super since it is defined but not used. Also remove corresponding declaration from header file.

---
 drivers/staging/lustre/lustre/fid/fid_internal.h |  2 --
 drivers/staging/lustre/lustre/fid/fid_request.c  | 21 ---------------------
 2 files changed, 23 deletions(-)
drivers/staging/lustre/lustre/fid/fid_internal.h +0 -2
index 84daee1..b79a813 100644
@@ -44,8 +44,6 @@
 #include "../../include/linux/libcfs/libcfs.h"
 
 /* Functions used internally in module. */
-int seq_client_alloc_super(struct lu_client_seq *seq,
-			   const struct lu_env *env);
 
 extern struct lprocfs_vars seq_client_debugfs_list[];
 
drivers/staging/lustre/lustre/fid/fid_request.c +0 -21
index 7c45e74..e817628 100644
@@ -142,27 +142,6 @@ out_req:
 	return rc;
 }
 
-/* Request sequence-controller node to allocate new super-sequence. */
-int seq_client_alloc_super(struct lu_client_seq *seq,
-			   const struct lu_env *env)
-{
-	int rc;
-
-	mutex_lock(&seq->lcs_mutex);
-
-	/* Check whether the connection to seq controller has been
-	 * setup (lcs_exp != NULL) */
-	if (!seq->lcs_exp) {
-		mutex_unlock(&seq->lcs_mutex);
-		return -EINPROGRESS;
-	}
-
-	rc = seq_client_rpc(seq, &seq->lcs_space,
-			    SEQ_ALLOC_SUPER, "super");
-	mutex_unlock(&seq->lcs_mutex);
-	return rc;
-}
-
 /* Request sequence-controller node to allocate new meta-sequence. */
 static int seq_client_alloc_meta(const struct lu_env *env,
 				 struct lu_client_seq *seq)
Signature · 1 line
2.1.4
#4 lore raw

PATCH 4/7 Staging: lustre: fld: Declare local functions as static

In reply to Shraddha Barke

Declare fld_cache_entry_delete and fld_cache_insert_nolock as static since they are used only in this particular file. Also remove corresponding declarations from header file.

---
 drivers/staging/lustre/lustre/fld/fld_cache.c    | 8 ++++----
 drivers/staging/lustre/lustre/fld/fld_internal.h | 4 ----
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/staging/lustre/lustre/fld/fld_cache.c +4 -4
index 4469174..c4db390 100644
@@ -121,8 +121,8 @@ void fld_cache_fini(struct fld_cache *cache)
 /**
  * delete given node from list.
  */
-void fld_cache_entry_delete(struct fld_cache *cache,
-			    struct fld_cache_entry *node)
+static void fld_cache_entry_delete(struct fld_cache *cache,
+				   struct fld_cache_entry *node)
 {
 	list_del(&node->fce_list);
 	list_del(&node->fce_lru);
@@ -377,8 +377,8 @@ struct fld_cache_entry
  * This function handles all cases of merging and breaking up of
  * ranges.
  */
-int fld_cache_insert_nolock(struct fld_cache *cache,
-			    struct fld_cache_entry *f_new)
+static int fld_cache_insert_nolock(struct fld_cache *cache,
+				   struct fld_cache_entry *f_new)
 {
 	struct fld_cache_entry *f_curr;
 	struct fld_cache_entry *n;
drivers/staging/lustre/lustre/fld/fld_internal.h +0 -4
index fbb232d..ab184a6 100644
@@ -156,8 +156,6 @@ int fld_cache_insert(struct fld_cache *cache,
 struct fld_cache_entry
 *fld_cache_entry_create(const struct lu_seq_range *range);
 
-int fld_cache_insert_nolock(struct fld_cache *cache,
-			    struct fld_cache_entry *f_new);
 void fld_cache_delete(struct fld_cache *cache,
 		      const struct lu_seq_range *range);
 void fld_cache_delete_nolock(struct fld_cache *cache,
@@ -167,8 +165,6 @@ int fld_cache_lookup(struct fld_cache *cache,
 
 struct fld_cache_entry*
 fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range);
-void fld_cache_entry_delete(struct fld_cache *cache,
-			    struct fld_cache_entry *node);
 void fld_dump_cache_entries(struct fld_cache *cache);
 
 struct fld_cache_entry
Signature · 1 line
2.1.4
#5 lore raw

PATCH 5/7 Staging: lustre: fld: Remove unused functions

In reply to Shraddha Barke

Remove functions fld_cache_delete and fld_cache_delete_nolock since they are defined but not used.

---
 drivers/staging/lustre/lustre/fld/fld_cache.c    | 26 ------------------------
 drivers/staging/lustre/lustre/fld/fld_internal.h |  4 ----
 2 files changed, 30 deletions(-)
drivers/staging/lustre/lustre/fld/fld_cache.c +0 -26
index c4db390..baa0407 100644
@@ -444,36 +444,10 @@ int fld_cache_insert(struct fld_cache *cache,
 	return rc;
 }
 
-void fld_cache_delete_nolock(struct fld_cache *cache,
-		      const struct lu_seq_range *range)
-{
-	struct fld_cache_entry *flde;
-	struct fld_cache_entry *tmp;
-	struct list_head *head;
-
-	head = &cache->fci_entries_head;
-	list_for_each_entry_safe(flde, tmp, head, fce_list) {
-		/* add list if next is end of list */
-		if (range->lsr_start == flde->fce_range.lsr_start ||
-		   (range->lsr_end == flde->fce_range.lsr_end &&
-		    range->lsr_flags == flde->fce_range.lsr_flags)) {
-			fld_cache_entry_delete(cache, flde);
-			break;
-		}
-	}
-}
-
 /**
  * Delete FLD entry in FLD cache.
  *
  */
-void fld_cache_delete(struct fld_cache *cache,
-		      const struct lu_seq_range *range)
-{
-	write_lock(&cache->fci_lock);
-	fld_cache_delete_nolock(cache, range);
-	write_unlock(&cache->fci_lock);
-}
 
 struct fld_cache_entry
 *fld_cache_entry_lookup_nolock(struct fld_cache *cache,
drivers/staging/lustre/lustre/fld/fld_internal.h +0 -4
index ab184a6..88ec7b1 100644
@@ -156,10 +156,6 @@ int fld_cache_insert(struct fld_cache *cache,
 struct fld_cache_entry
 *fld_cache_entry_create(const struct lu_seq_range *range);
 
-void fld_cache_delete(struct fld_cache *cache,
-		      const struct lu_seq_range *range);
-void fld_cache_delete_nolock(struct fld_cache *cache,
-			     const struct lu_seq_range *range);
 int fld_cache_lookup(struct fld_cache *cache,
 		     const u64 seq, struct lu_seq_range *range);
 
Signature · 1 line
2.1.4
#6 lore raw

PATCH 6/7 Staging: lustre: fld: Remove unused declaration

In reply to Shraddha Barke

Function fld_dump_cache_entries is declared in header file but not used. Hence remove the declaration.

---
 drivers/staging/lustre/lustre/fld/fld_internal.h | 1 -
 1 file changed, 1 deletion(-)
drivers/staging/lustre/lustre/fld/fld_internal.h +0 -1
index 88ec7b1..959b8e6 100644
@@ -161,7 +161,6 @@ int fld_cache_lookup(struct fld_cache *cache,
 
 struct fld_cache_entry*
 fld_cache_entry_lookup(struct fld_cache *cache, struct lu_seq_range *range);
-void fld_dump_cache_entries(struct fld_cache *cache);
 
 struct fld_cache_entry
 *fld_cache_entry_lookup_nolock(struct fld_cache *cache,
Signature · 1 line
2.1.4
#7 lore raw

PATCH 7/7 Staging: lustre: osc: Declare local functions as static

In reply to Shraddha Barke

Declare osc_real_create, osc_create and osc_cleanup as static since they are used only in this particular file. Also remove the corresponding declarations from header file.

---
 drivers/staging/lustre/lustre/osc/osc_internal.h |  6 ------
 drivers/staging/lustre/lustre/osc/osc_request.c  | 13 +++++++------
 2 files changed, 7 insertions(+), 12 deletions(-)
drivers/staging/lustre/lustre/osc/osc_internal.h +0 -6
index 5ed30ec..db2ee9c 100644
@@ -89,11 +89,6 @@ struct osc_cache_waiter {
 	int		     ocw_rc;
 };
 
-int osc_create(const struct lu_env *env, struct obd_export *exp,
-	       struct obdo *oa, struct lov_stripe_md **ea,
-	       struct obd_trans_info *oti);
-int osc_real_create(struct obd_export *exp, struct obdo *oa,
-		    struct lov_stripe_md **ea, struct obd_trans_info *oti);
 void osc_wake_cache_waiters(struct client_obd *cli);
 int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes);
 void osc_update_next_shrink(struct client_obd *cli);
@@ -137,7 +132,6 @@ int osc_lru_shrink(struct client_obd *cli, int target);
 
 extern spinlock_t osc_ast_guard;
 
-int osc_cleanup(struct obd_device *obd);
 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
 
 int lproc_osc_attach_seqstat(struct obd_device *dev);
drivers/staging/lustre/lustre/osc/osc_request.c +7 -6
index 367f83a..3e2d431 100644
@@ -104,7 +104,7 @@ struct osc_enqueue_args {
 static void osc_release_ppga(struct brw_page **ppga, u32 count);
 static int brw_interpret(const struct lu_env *env,
 			 struct ptlrpc_request *req, void *data, int rc);
-int osc_cleanup(struct obd_device *obd);
+static int osc_cleanup(struct obd_device *obd);
 
 /* Pack OSC object metadata for disk storage (LE byte order). */
 static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
@@ -431,8 +431,9 @@ static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo,
 				      oinfo->oi_cb_up, oinfo, rqset);
 }
 
-int osc_real_create(struct obd_export *exp, struct obdo *oa,
-		    struct lov_stripe_md **ea, struct obd_trans_info *oti)
+static int osc_real_create(struct obd_export *exp, struct obdo *oa,
+			   struct lov_stripe_md **ea,
+			   struct obd_trans_info *oti)
 {
 	struct ptlrpc_request *req;
 	struct ost_body *body;
@@ -689,9 +690,9 @@ static int osc_can_send_destroy(struct client_obd *cli)
 	return 0;
 }
 
-int osc_create(const struct lu_env *env, struct obd_export *exp,
-	       struct obdo *oa, struct lov_stripe_md **ea,
-	       struct obd_trans_info *oti)
+static int osc_create(const struct lu_env *env, struct obd_export *exp,
+		      struct obdo *oa, struct lov_stripe_md **ea,
+		      struct obd_trans_info *oti)
 {
 	int rc = 0;
 
Signature · 1 line
2.1.4
Reviewed-by on the v1 series
#8 lore raw
In reply to Shraddha Barke
Quoted 4 lines · On Friday 30 October 2015 20:59:02 Shraddha Barke wrote:

These patches declare local functions as static and remove corresponding declarations from header files. Unused function definitions and declarations are also removed.

Quoted 10 lines

Shraddha Barke (7):
Staging: lustre: mdc: Declare local functions as static
Staging: lustre: mdc: Remove unused mdc_open function from header
Staging: lustre: fld: Remove unused seq_client_alloc_super
Staging: lustre: fld: Declare local functions as static
Staging: lustre: fld: Remove unused functions
Staging: lustre: fld: Remove unused declaration
Staging: lustre: osc: Declare local functions as static

Nice work, whole series