All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] lustre: continues dead code removal
@ 2014-08-30 21:12 Oleg Drokin
  2014-08-30 21:12 ` [PATCH 01/12] staging/lustre: Remove unused header libcfs_heap.h Oleg Drokin
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Oleg Drokin

This series of patches continues removal of unused code in
lustre client tree.

John L. Hammond (9):
  staging/lustre/obdecho: remove #if 0-ed out regions
  staging/lustre/obdclass: remove idmap.c
  staging/lustre/obdclass: remove lu_ucred.c
  staging/lustre/obdclass: remove mea.c
  staging/lustre: remove md_object.h
  staging/lustre/mgc: remove server specific handlers
  staging/lustre/obdclass: remove llog_test.ko
  staging/lustre/obdclass: remove llog_osd.c
  staging/lustre/mdc: remove obsolete llog ioctl handlers

Oleg Drokin (2):
  staging/lustre: Remove unused header libcfs_heap.h
  staging/lustre: remove unused som_attrs and hsm_attrs structures

Peng Tao (1):
  staging/lustre/obdecho: remove metadata echo client

 .../staging/lustre/include/linux/libcfs/libcfs.h   |    1 -
 .../lustre/include/linux/libcfs/libcfs_heap.h      |  200 ---
 drivers/staging/lustre/lustre/fid/lproc_fid.c      |    1 -
 drivers/staging/lustre/lustre/fld/fld_cache.c      |    1 -
 drivers/staging/lustre/lustre/fld/fld_request.c    |    1 -
 drivers/staging/lustre/lustre/fld/lproc_fld.c      |    1 -
 .../lustre/lustre/include/lustre/lustre_idl.h      |   37 -
 .../staging/lustre/lustre/include/lustre_idmap.h   |  104 --
 drivers/staging/lustre/lustre/include/lustre_log.h |    9 -
 drivers/staging/lustre/lustre/include/lustre_net.h |    1 -
 drivers/staging/lustre/lustre/include/md_object.h  |  899 --------------
 drivers/staging/lustre/lustre/include/obd_class.h  |    4 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c    |   15 -
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |  177 ---
 drivers/staging/lustre/lustre/obdclass/Makefile    |    9 +-
 drivers/staging/lustre/lustre/obdclass/idmap.c     |  477 --------
 drivers/staging/lustre/lustre/obdclass/llog_osd.c  | 1290 --------------------
 drivers/staging/lustre/lustre/obdclass/llog_test.c | 1072 ----------------
 drivers/staging/lustre/lustre/obdclass/lu_ucred.c  |  107 --
 drivers/staging/lustre/lustre/obdclass/mea.c       |  112 --
 .../staging/lustre/lustre/obdecho/echo_client.c    | 1103 +----------------
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c    |   48 -
 22 files changed, 50 insertions(+), 5619 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_heap.h
 delete mode 100644 drivers/staging/lustre/lustre/include/lustre_idmap.h
 delete mode 100644 drivers/staging/lustre/lustre/include/md_object.h
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/idmap.c
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/llog_osd.c
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/llog_test.c
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ucred.c
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/mea.c

-- 
1.9.3


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

* [PATCH 01/12] staging/lustre: Remove unused header libcfs_heap.h
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 02/12] staging/lustre/obdecho: remove metadata echo client Oleg Drokin
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Oleg Drokin

With removal of libcfs/heap.c, it's header can also go away now.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 .../staging/lustre/include/linux/libcfs/libcfs.h   |   1 -
 .../lustre/include/linux/libcfs/libcfs_heap.h      | 200 ---------------------
 drivers/staging/lustre/lustre/include/lustre_net.h |   1 -
 3 files changed, 202 deletions(-)
 delete mode 100644 drivers/staging/lustre/include/linux/libcfs/libcfs_heap.h

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 7d37bec..1122ae9 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -165,7 +165,6 @@ void cfs_get_random_bytes(void *buf, int size);
 #include "libcfs_kernelcomm.h"
 #include "libcfs_workitem.h"
 #include "libcfs_hash.h"
-#include "libcfs_heap.h"
 #include "libcfs_fail.h"
 #include "libcfs_crypto.h"
 
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_heap.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_heap.h
deleted file mode 100644
index bfa6d7b..0000000
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_heap.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License version 2 for more details.  A copy is
- * included in the COPYING file that accompanied this code.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2011 Intel Corporation
- */
-/*
- * libcfs/include/libcfs/heap.h
- *
- * Author: Eric Barton	<eeb@whamcloud.com>
- *	   Liang Zhen	<liang@whamcloud.com>
- */
-
-#ifndef __LIBCFS_HEAP_H__
-#define __LIBCFS_HEAP_H__
-
-/** \defgroup heap Binary heap
- *
- * The binary heap is a scalable data structure created using a binary tree. It
- * is capable of maintaining large sets of elements sorted usually by one or
- * more element properties, but really based on anything that can be used as a
- * binary predicate in order to determine the relevant ordering of any two nodes
- * that belong to the set. There is no search operation, rather the intention is
- * for the element of the lowest priority which will always be at the root of
- * the tree (as this is an implementation of a min-heap) to be removed by users
- * for consumption.
- *
- * Users of the heap should embed a \e cfs_binheap_node_t object instance on
- * every object of the set that they wish the binary heap instance to handle,
- * and (at a minimum) provide a cfs_binheap_ops_t::hop_compare() implementation
- * which is used by the heap as the binary predicate during its internal sorting
- * operations.
- *
- * The current implementation enforces no locking scheme, and so assumes the
- * user caters for locking between calls to insert, delete and lookup
- * operations. Since the only consumer for the data structure at this point
- * are NRS policies, and these operate on a per-CPT basis, binary heap instances
- * are tied to a specific CPT.
- * @{
- */
-
-/**
- * Binary heap node.
- *
- * Objects of this type are embedded into objects of the ordered set that is to
- * be maintained by a \e cfs_binheap_t instance.
- */
-typedef struct {
-	/** Index into the binary tree */
-	unsigned int	chn_index;
-} cfs_binheap_node_t;
-
-#define CBH_SHIFT	9
-#define CBH_SIZE       (1 << CBH_SHIFT)		    /* # ptrs per level */
-#define CBH_MASK       (CBH_SIZE - 1)
-#define CBH_NOB	(CBH_SIZE * sizeof(cfs_binheap_node_t *))
-
-#define CBH_POISON	0xdeadbeef
-
-/**
- * Binary heap flags.
- */
-enum {
-	CBH_FLAG_ATOMIC_GROW	= 1,
-};
-
-struct cfs_binheap;
-
-/**
- * Binary heap operations.
- */
-typedef struct {
-	/**
-	 * Called right before inserting a node into the binary heap.
-	 *
-	 * Implementing this operation is optional.
-	 *
-	 * \param[in] h The heap
-	 * \param[in] e The node
-	 *
-	 * \retval 0 success
-	 * \retval != 0 error
-	 */
-	int		(*hop_enter)(struct cfs_binheap *h,
-				     cfs_binheap_node_t *e);
-	/**
-	 * Called right after removing a node from the binary heap.
-	 *
-	 * Implementing this operation is optional.
-	 *
-	 * \param[in] h The heap
-	 * \param[in] e The node
-	 */
-	void		(*hop_exit)(struct cfs_binheap *h,
-				    cfs_binheap_node_t *e);
-	/**
-	 * A binary predicate which is called during internal heap sorting
-	 * operations, and used in order to determine the relevant ordering of
-	 * two heap nodes.
-	 *
-	 * Implementing this operation is mandatory.
-	 *
-	 * \param[in] a The first heap node
-	 * \param[in] b The second heap node
-	 *
-	 * \retval 0 Node a > node b
-	 * \retval 1 Node a < node b
-	 *
-	 * \see cfs_binheap_bubble()
-	 * \see cfs_biheap_sink()
-	 */
-	int		(*hop_compare)(cfs_binheap_node_t *a,
-				       cfs_binheap_node_t *b);
-} cfs_binheap_ops_t;
-
-/**
- * Binary heap object.
- *
- * Sorts elements of type \e cfs_binheap_node_t
- */
-typedef struct cfs_binheap {
-	/** Triple indirect */
-	cfs_binheap_node_t  ****cbh_elements3;
-	/** double indirect */
-	cfs_binheap_node_t   ***cbh_elements2;
-	/** single indirect */
-	cfs_binheap_node_t    **cbh_elements1;
-	/** # elements referenced */
-	unsigned int		cbh_nelements;
-	/** high water mark */
-	unsigned int		cbh_hwm;
-	/** user flags */
-	unsigned int		cbh_flags;
-	/** operations table */
-	cfs_binheap_ops_t      *cbh_ops;
-	/** private data */
-	void		       *cbh_private;
-	/** associated CPT table */
-	struct cfs_cpt_table   *cbh_cptab;
-	/** associated CPT id of this cfs_binheap_t::cbh_cptab */
-	int			cbh_cptid;
-} cfs_binheap_t;
-
-void cfs_binheap_destroy(cfs_binheap_t *h);
-cfs_binheap_t *cfs_binheap_create(cfs_binheap_ops_t *ops, unsigned int flags,
-				  unsigned count, void *arg,
-				  struct cfs_cpt_table *cptab, int cptid);
-cfs_binheap_node_t *cfs_binheap_find(cfs_binheap_t *h, unsigned int idx);
-int cfs_binheap_insert(cfs_binheap_t *h, cfs_binheap_node_t *e);
-void cfs_binheap_remove(cfs_binheap_t *h, cfs_binheap_node_t *e);
-
-static inline int
-cfs_binheap_size(cfs_binheap_t *h)
-{
-	return h->cbh_nelements;
-}
-
-static inline int
-cfs_binheap_is_empty(cfs_binheap_t *h)
-{
-	return h->cbh_nelements == 0;
-}
-
-static inline cfs_binheap_node_t *
-cfs_binheap_root(cfs_binheap_t *h)
-{
-	return cfs_binheap_find(h, 0);
-}
-
-static inline cfs_binheap_node_t *
-cfs_binheap_remove_root(cfs_binheap_t *h)
-{
-	cfs_binheap_node_t *e = cfs_binheap_find(h, 0);
-
-	if (e != NULL)
-		cfs_binheap_remove(h, e);
-	return e;
-}
-
-/** @} heap */
-
-#endif /* __LIBCFS_HEAP_H__ */
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index 8d58349..0a024d3 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1204,7 +1204,6 @@ struct ptlrpc_nrs_request {
 	unsigned			nr_enqueued:1;
 	unsigned			nr_started:1;
 	unsigned			nr_finalized:1;
-	cfs_binheap_node_t		nr_node;
 
 	/**
 	 * Policy-specific fields, used for determining a request's scheduling
-- 
1.9.3


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

* [PATCH 02/12] staging/lustre/obdecho: remove metadata echo client
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
  2014-08-30 21:12 ` [PATCH 01/12] staging/lustre: Remove unused header libcfs_heap.h Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 03/12] staging/lustre/obdecho: remove #if 0-ed out regions Oleg Drokin
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Peng Tao, Liu Xuezhao, Oleg Drokin

From: Peng Tao <tao.peng@emc.com>

The metadata echo client requires server support and should not have
been included.

Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Signed-off-by: Peng Tao <tao.peng@emc.com>
Signed-off-by: John L. Hammond <john.hammond@intel.com>
Reviewed-on: http://review.whamcloud.com/2674
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-1330
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
---
 .../staging/lustre/lustre/obdecho/echo_client.c    | 1053 +-------------------
 1 file changed, 46 insertions(+), 1007 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index ad5acf6..68a5ed1 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -43,7 +43,6 @@
 #include "../include/lustre_debug.h"
 #include "../include/lprocfs_status.h"
 #include "../include/cl_object.h"
-#include "../include/md_object.h"
 #include "../include/lustre_fid.h"
 #include "../include/lustre_acl.h"
 #include "../include/lustre_net.h"
@@ -62,8 +61,6 @@ struct echo_device {
 	struct cl_site	 *ed_site;
 	struct lu_device       *ed_next;
 	int		     ed_next_islov;
-	int		     ed_next_ismd;
-	struct lu_client_seq   *ed_cl_seq;
 };
 
 struct echo_object {
@@ -192,17 +189,6 @@ struct echo_thread_info {
 	struct cl_lock_descr    eti_descr;
 	struct lu_fid	   eti_fid;
 	struct lu_fid		eti_fid2;
-	struct md_op_spec       eti_spec;
-	struct lov_mds_md_v3    eti_lmm;
-	struct lov_user_md_v3   eti_lum;
-	struct md_attr	  eti_ma;
-	struct lu_name	  eti_lname;
-	/* per-thread values, can be re-used */
-	void			*eti_big_lmm;
-	int			eti_big_lmmsize;
-	char		    eti_name[20];
-	struct lu_buf	   eti_buf;
-	char		    eti_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
 };
 
 /* No session used right now */
@@ -463,6 +449,8 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj,
 	struct echo_device *ed	 = cl2echo_dev(lu2cl_dev(obj->lo_dev));
 	struct echo_client_obd *ec     = ed->ed_ec;
 	struct echo_object *eco	= cl2echo_obj(lu2cl(obj));
+	const struct cl_object_conf *cconf;
+	struct echo_object_conf *econf;
 
 	if (ed->ed_next) {
 		struct lu_object  *below;
@@ -476,17 +464,13 @@ static int echo_object_init(const struct lu_env *env, struct lu_object *obj,
 		lu_object_add(obj, below);
 	}
 
-	if (!ed->ed_next_ismd) {
-		const struct cl_object_conf *cconf = lu2cl_conf(conf);
-		struct echo_object_conf *econf = cl2echo_conf(cconf);
+	cconf = lu2cl_conf(conf);
+	econf = cl2echo_conf(cconf);
 
-		LASSERT(econf->eoc_md);
-		eco->eo_lsm = *econf->eoc_md;
-		/* clear the lsm pointer so that it won't get freed. */
-		*econf->eoc_md = NULL;
-	} else {
-		eco->eo_lsm = NULL;
-	}
+	LASSERT(econf->eoc_md);
+	eco->eo_lsm = *econf->eoc_md;
+	/* clear the lsm pointer so that it won't get freed. */
+	*econf->eoc_md = NULL;
 
 	eco->eo_dev = ed;
 	atomic_set(&eco->eo_npages, 0);
@@ -651,8 +635,7 @@ static int echo_site_init(const struct lu_env *env, struct echo_device *ed)
 static void echo_site_fini(const struct lu_env *env, struct echo_device *ed)
 {
 	if (ed->ed_site) {
-		if (!ed->ed_next_ismd)
-			cl_site_fini(ed->ed_site);
+		cl_site_fini(ed->ed_site);
 		ed->ed_site = NULL;
 	}
 }
@@ -719,53 +702,6 @@ static struct lu_context_key echo_session_key = {
 
 LU_TYPE_INIT_FINI(echo, &echo_thread_key, &echo_session_key);
 
-#define ECHO_SEQ_WIDTH 0xffffffff
-static int echo_fid_init(struct echo_device *ed, char *obd_name,
-			 struct seq_server_site *ss)
-{
-	char *prefix;
-	int rc;
-
-	OBD_ALLOC_PTR(ed->ed_cl_seq);
-	if (ed->ed_cl_seq == NULL)
-		return -ENOMEM;
-
-	OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
-	if (prefix == NULL)
-		GOTO(out_free_seq, rc = -ENOMEM);
-
-	snprintf(prefix, MAX_OBD_NAME + 5, "srv-%s", obd_name);
-
-	/* Init client side sequence-manager */
-	rc = seq_client_init(ed->ed_cl_seq, NULL,
-			     LUSTRE_SEQ_METADATA,
-			     prefix, ss->ss_server_seq);
-	ed->ed_cl_seq->lcs_width = ECHO_SEQ_WIDTH;
-	OBD_FREE(prefix, MAX_OBD_NAME + 5);
-	if (rc)
-		GOTO(out_free_seq, rc);
-
-	return 0;
-
-out_free_seq:
-	OBD_FREE_PTR(ed->ed_cl_seq);
-	ed->ed_cl_seq = NULL;
-	return rc;
-}
-
-static int echo_fid_fini(struct obd_device *obddev)
-{
-	struct echo_device *ed = obd2echo_dev(obddev);
-
-	if (ed->ed_cl_seq != NULL) {
-		seq_client_fini(ed->ed_cl_seq);
-		OBD_FREE_PTR(ed->ed_cl_seq);
-		ed->ed_cl_seq = NULL;
-	}
-
-	return 0;
-}
-
 static struct lu_device *echo_device_alloc(const struct lu_env *env,
 					   struct lu_device_type *t,
 					   struct lustre_cfg *cfg)
@@ -806,13 +742,14 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
 
 	next = tgt->obd_lu_dev;
 	if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) {
-		ed->ed_next_ismd = 1;
-	} else {
-		ed->ed_next_ismd = 0;
-		rc = echo_site_init(env, ed);
-		if (rc)
-			GOTO(out, rc);
+		CERROR("echo MDT client must be run on server\n");
+		GOTO(out, rc = -EOPNOTSUPP);
 	}
+
+	rc = echo_site_init(env, ed);
+	if (rc)
+		GOTO(out, rc);
+
 	cleanup = 3;
 
 	rc = echo_client_setup(env, obd, cfg);
@@ -822,82 +759,34 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
 	ed->ed_ec = &obd->u.echo_client;
 	cleanup = 4;
 
-	if (ed->ed_next_ismd) {
-		/* Suppose to connect to some Metadata layer */
-		struct lu_site *ls;
-		struct lu_device *ld;
-		int    found = 0;
-
-		if (next == NULL) {
-			CERROR("%s is not lu device type!\n",
-			       lustre_cfg_string(cfg, 1));
-			GOTO(out, rc = -EINVAL);
-		}
-
-		tgt_type_name = lustre_cfg_string(cfg, 2);
-		if (!tgt_type_name) {
-			CERROR("%s no type name for echo %s setup\n",
-				lustre_cfg_string(cfg, 1),
-				tgt->obd_type->typ_name);
-			GOTO(out, rc = -EINVAL);
-		}
-
-		ls = next->ld_site;
-
-		spin_lock(&ls->ls_ld_lock);
-		list_for_each_entry(ld, &ls->ls_ld_linkage, ld_linkage) {
-			if (strcmp(ld->ld_type->ldt_name, tgt_type_name) == 0) {
-				found = 1;
-				break;
-			}
-		}
-		spin_unlock(&ls->ls_ld_lock);
-
-		if (found == 0) {
-			CERROR("%s is not lu device type!\n",
-			       lustre_cfg_string(cfg, 1));
-			GOTO(out, rc = -EINVAL);
-		}
-
-		next = ld;
-		/* For MD echo client, it will use the site in MDS stack */
-		ed->ed_site_myself.cs_lu = *ls;
-		ed->ed_site = &ed->ed_site_myself;
-		ed->ed_cl.cd_lu_dev.ld_site = &ed->ed_site_myself.cs_lu;
-		rc = echo_fid_init(ed, obd->obd_name, lu_site2seq(ls));
-		if (rc) {
-			CERROR("echo fid init error %d\n", rc);
+	/* if echo client is to be stacked upon ost device, the next is
+	 * NULL since ost is not a clio device so far */
+	if (next != NULL && !lu_device_is_cl(next))
+		next = NULL;
+
+	tgt_type_name = tgt->obd_type->typ_name;
+	if (next != NULL) {
+		LASSERT(next != NULL);
+		if (next->ld_site != NULL)
+			GOTO(out, rc = -EBUSY);
+
+		next->ld_site = &ed->ed_site->cs_lu;
+		rc = next->ld_type->ldt_ops->ldto_device_init(env, next,
+						next->ld_type->ldt_name,
+							      NULL);
+		if (rc)
 			GOTO(out, rc);
-		}
+
+		/* Tricky case, I have to determine the obd type since
+		 * CLIO uses the different parameters to initialize
+		 * objects for lov & osc. */
+		if (strcmp(tgt_type_name, LUSTRE_LOV_NAME) == 0)
+			ed->ed_next_islov = 1;
+		else
+			LASSERT(strcmp(tgt_type_name,
+				       LUSTRE_OSC_NAME) == 0);
 	} else {
-		 /* if echo client is to be stacked upon ost device, the next is
-		  * NULL since ost is not a clio device so far */
-		if (next != NULL && !lu_device_is_cl(next))
-			next = NULL;
-
-		tgt_type_name = tgt->obd_type->typ_name;
-		if (next != NULL) {
-			LASSERT(next != NULL);
-			if (next->ld_site != NULL)
-				GOTO(out, rc = -EBUSY);
-
-			next->ld_site = &ed->ed_site->cs_lu;
-			rc = next->ld_type->ldt_ops->ldto_device_init(env, next,
-						     next->ld_type->ldt_name,
-						     NULL);
-			if (rc)
-				GOTO(out, rc);
-
-			/* Tricky case, I have to determine the obd type since
-			 * CLIO uses the different parameters to initialize
-			 * objects for lov & osc. */
-			if (strcmp(tgt_type_name, LUSTRE_LOV_NAME) == 0)
-				ed->ed_next_islov = 1;
-			else
-				LASSERT(strcmp(tgt_type_name,
-					       LUSTRE_OSC_NAME) == 0);
-		} else
-			LASSERT(strcmp(tgt_type_name, LUSTRE_OST_NAME) == 0);
+		LASSERT(strcmp(tgt_type_name, LUSTRE_OST_NAME) == 0);
 	}
 
 	ed->ed_next = next;
@@ -938,7 +827,7 @@ static struct lu_device *echo_device_fini(const struct lu_env *env,
 	struct echo_device *ed = cl2echo_dev(lu2cl_dev(d));
 	struct lu_device *next = ed->ed_next;
 
-	while (next && !ed->ed_next_ismd)
+	while (next)
 		next = next->ld_type->ldt_ops->ldto_device_fini(env, next);
 	return NULL;
 }
@@ -1008,8 +897,8 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
 	CDEBUG(D_INFO, "No object exists, exiting...\n");
 
 	echo_client_cleanup(d->ld_obd);
-	echo_fid_fini(d->ld_obd);
-	while (next && !ed->ed_next_ismd)
+
+	while (next)
 		next = next->ld_type->ldt_ops->ldto_device_free(env, next);
 
 	LASSERT(ed->ed_site == lu2cl_site(d->ld_site));
@@ -1037,7 +926,7 @@ static struct lu_device_type echo_device_type = {
 	.ldt_tags     = LU_DEVICE_CL,
 	.ldt_name     = LUSTRE_ECHO_CLIENT_NAME,
 	.ldt_ops      = &echo_device_type_ops,
-	.ldt_ctx_tags = LCT_CL_THREAD | LCT_MD_THREAD | LCT_DT_THREAD,
+	.ldt_ctx_tags = LCT_CL_THREAD,
 };
 /** @} echo_init */
 
@@ -1427,773 +1316,6 @@ echo_copyin_lsm (struct echo_device *ed, struct lov_stripe_md *lsm,
 	return 0;
 }
 
-static inline void echo_md_build_name(struct lu_name *lname, char *name,
-				      __u64 id)
-{
-	sprintf(name, "%llu", id);
-	lname->ln_name = name;
-	lname->ln_namelen = strlen(name);
-}
-
-/* similar to mdt_attr_get_complex */
-static int echo_big_lmm_get(const struct lu_env *env, struct md_object *o,
-			    struct md_attr *ma)
-{
-	struct echo_thread_info	*info = echo_env_info(env);
-	int			 rc;
-
-	LASSERT(ma->ma_lmm_size > 0);
-
-	rc = mo_xattr_get(env, o, &LU_BUF_NULL, XATTR_NAME_LOV);
-	if (rc < 0)
-		return rc;
-
-	/* big_lmm may need to be grown */
-	if (info->eti_big_lmmsize < rc) {
-		int size = size_roundup_power2(rc);
-
-		if (info->eti_big_lmmsize > 0) {
-			/* free old buffer */
-			LASSERT(info->eti_big_lmm);
-			OBD_FREE_LARGE(info->eti_big_lmm,
-				       info->eti_big_lmmsize);
-			info->eti_big_lmm = NULL;
-			info->eti_big_lmmsize = 0;
-		}
-
-		OBD_ALLOC_LARGE(info->eti_big_lmm, size);
-		if (info->eti_big_lmm == NULL)
-			return -ENOMEM;
-		info->eti_big_lmmsize = size;
-	}
-	LASSERT(info->eti_big_lmmsize >= rc);
-
-	info->eti_buf.lb_buf = info->eti_big_lmm;
-	info->eti_buf.lb_len = info->eti_big_lmmsize;
-	rc = mo_xattr_get(env, o, &info->eti_buf, XATTR_NAME_LOV);
-	if (rc < 0)
-		return rc;
-
-	ma->ma_valid |= MA_LOV;
-	ma->ma_lmm = info->eti_big_lmm;
-	ma->ma_lmm_size = rc;
-
-	return 0;
-}
-
-int echo_attr_get_complex(const struct lu_env *env, struct md_object *next,
-			  struct md_attr *ma)
-{
-	struct echo_thread_info	*info = echo_env_info(env);
-	struct lu_buf		*buf = &info->eti_buf;
-	umode_t		 mode = lu_object_attr(&next->mo_lu);
-	int			 need = ma->ma_need;
-	int			 rc = 0, rc2;
-
-	ma->ma_valid = 0;
-
-	if (need & MA_INODE) {
-		ma->ma_need = MA_INODE;
-		rc = mo_attr_get(env, next, ma);
-		if (rc)
-			GOTO(out, rc);
-		ma->ma_valid |= MA_INODE;
-	}
-
-	if (need & MA_LOV) {
-		if (S_ISREG(mode) || S_ISDIR(mode)) {
-			LASSERT(ma->ma_lmm_size > 0);
-			buf->lb_buf = ma->ma_lmm;
-			buf->lb_len = ma->ma_lmm_size;
-			rc2 = mo_xattr_get(env, next, buf, XATTR_NAME_LOV);
-			if (rc2 > 0) {
-				ma->ma_lmm_size = rc2;
-				ma->ma_valid |= MA_LOV;
-			} else if (rc2 == -ENODATA) {
-				/* no LOV EA */
-				ma->ma_lmm_size = 0;
-			} else if (rc2 == -ERANGE) {
-				rc2 = echo_big_lmm_get(env, next, ma);
-				if (rc2 < 0)
-					GOTO(out, rc = rc2);
-			} else {
-				GOTO(out, rc = rc2);
-			}
-		}
-	}
-
-#ifdef CONFIG_FS_POSIX_ACL
-	if (need & MA_ACL_DEF && S_ISDIR(mode)) {
-		buf->lb_buf = ma->ma_acl;
-		buf->lb_len = ma->ma_acl_size;
-		rc2 = mo_xattr_get(env, next, buf, XATTR_NAME_ACL_DEFAULT);
-		if (rc2 > 0) {
-			ma->ma_acl_size = rc2;
-			ma->ma_valid |= MA_ACL_DEF;
-		} else if (rc2 == -ENODATA) {
-			/* no ACLs */
-			ma->ma_acl_size = 0;
-		} else {
-			GOTO(out, rc = rc2);
-		}
-	}
-#endif
-out:
-	ma->ma_need = need;
-	CDEBUG(D_INODE, "after getattr rc = %d, ma_valid = %#llx ma_lmm=%p\n",
-	       rc, ma->ma_valid, ma->ma_lmm);
-	return rc;
-}
-
-static int
-echo_md_create_internal(const struct lu_env *env, struct echo_device *ed,
-			struct md_object *parent, struct lu_fid *fid,
-			struct lu_name *lname, struct md_op_spec *spec,
-			struct md_attr *ma)
-{
-	struct lu_object	*ec_child, *child;
-	struct lu_device	*ld = ed->ed_next;
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_fid		*fid2 = &info->eti_fid2;
-	struct lu_object_conf    conf = { .loc_flags = LOC_F_NEW };
-	int			 rc;
-
-	rc = mdo_lookup(env, parent, lname, fid2, spec);
-	if (rc == 0)
-		return -EEXIST;
-	else if (rc != -ENOENT)
-		return rc;
-
-	ec_child = lu_object_find_at(env, &ed->ed_cl.cd_lu_dev,
-				     fid, &conf);
-	if (IS_ERR(ec_child)) {
-		CERROR("Can not find the child "DFID": rc = %ld\n", PFID(fid),
-			PTR_ERR(ec_child));
-		return PTR_ERR(ec_child);
-	}
-
-	child = lu_object_locate(ec_child->lo_header, ld->ld_type);
-	if (child == NULL) {
-		CERROR("Can not locate the child "DFID"\n", PFID(fid));
-		GOTO(out_put, rc = -EINVAL);
-	}
-
-	CDEBUG(D_RPCTRACE, "Start creating object "DFID" %s %p\n",
-	       PFID(lu_object_fid(&parent->mo_lu)), lname->ln_name, parent);
-
-	/*
-	 * Do not perform lookup sanity check. We know that name does not exist.
-	 */
-	spec->sp_cr_lookup = 0;
-	rc = mdo_create(env, parent, lname, lu2md(child), spec, ma);
-	if (rc) {
-		CERROR("Can not create child "DFID": rc = %d\n", PFID(fid), rc);
-		GOTO(out_put, rc);
-	}
-	CDEBUG(D_RPCTRACE, "End creating object "DFID" %s %p rc  = %d\n",
-	       PFID(lu_object_fid(&parent->mo_lu)), lname->ln_name, parent, rc);
-out_put:
-	lu_object_put(env, ec_child);
-	return rc;
-}
-
-static int echo_set_lmm_size(const struct lu_env *env, struct lu_device *ld,
-			     struct md_attr *ma)
-{
-	struct echo_thread_info *info = echo_env_info(env);
-
-	if (strcmp(ld->ld_type->ldt_name, LUSTRE_MDD_NAME)) {
-		ma->ma_lmm = (void *)&info->eti_lmm;
-		ma->ma_lmm_size = sizeof(info->eti_lmm);
-	} else {
-		LASSERT(info->eti_big_lmmsize);
-		ma->ma_lmm = info->eti_big_lmm;
-		ma->ma_lmm_size = info->eti_big_lmmsize;
-	}
-
-	return 0;
-}
-
-static int echo_create_md_object(const struct lu_env *env,
-				 struct echo_device *ed,
-				 struct lu_object *ec_parent,
-				 struct lu_fid *fid,
-				 char *name, int namelen,
-				 __u64 id, __u32 mode, int count,
-				 int stripe_count, int stripe_offset)
-{
-	struct lu_object	*parent;
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_name	  *lname = &info->eti_lname;
-	struct md_op_spec       *spec = &info->eti_spec;
-	struct md_attr	  *ma = &info->eti_ma;
-	struct lu_device	*ld = ed->ed_next;
-	int		      rc = 0;
-	int		      i;
-
-	if (ec_parent == NULL)
-		return -1;
-	parent = lu_object_locate(ec_parent->lo_header, ld->ld_type);
-	if (parent == NULL)
-		return -ENXIO;
-
-	memset(ma, 0, sizeof(*ma));
-	memset(spec, 0, sizeof(*spec));
-	if (stripe_count != 0) {
-		spec->sp_cr_flags |= FMODE_WRITE;
-		echo_set_lmm_size(env, ld, ma);
-		if (stripe_count != -1) {
-			struct lov_user_md_v3 *lum = &info->eti_lum;
-
-			lum->lmm_magic = LOV_USER_MAGIC_V3;
-			lum->lmm_stripe_count = stripe_count;
-			lum->lmm_stripe_offset = stripe_offset;
-			lum->lmm_pattern = 0;
-			spec->u.sp_ea.eadata = lum;
-			spec->u.sp_ea.eadatalen = sizeof(*lum);
-			spec->sp_cr_flags |= MDS_OPEN_HAS_EA;
-		}
-	}
-
-	ma->ma_attr.la_mode = mode;
-	ma->ma_attr.la_valid = LA_CTIME | LA_MODE;
-	ma->ma_attr.la_ctime = cfs_time_current_64();
-
-	if (name != NULL) {
-		lname->ln_name = name;
-		lname->ln_namelen = namelen;
-		/* If name is specified, only create one object by name */
-		rc = echo_md_create_internal(env, ed, lu2md(parent), fid, lname,
-					     spec, ma);
-		return rc;
-	}
-
-	/* Create multiple object sequenced by id */
-	for (i = 0; i < count; i++) {
-		char *tmp_name = info->eti_name;
-
-		echo_md_build_name(lname, tmp_name, id);
-
-		rc = echo_md_create_internal(env, ed, lu2md(parent), fid, lname,
-					     spec, ma);
-		if (rc) {
-			CERROR("Can not create child %s: rc = %d\n", tmp_name,
-				rc);
-			break;
-		}
-		id++;
-		fid->f_oid++;
-	}
-
-	return rc;
-}
-
-static struct lu_object *echo_md_lookup(const struct lu_env *env,
-					struct echo_device *ed,
-					struct md_object *parent,
-					struct lu_name *lname)
-{
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_fid	   *fid = &info->eti_fid;
-	struct lu_object	*child;
-	int    rc;
-
-	CDEBUG(D_INFO, "lookup %s in parent "DFID" %p\n", lname->ln_name,
-	       PFID(fid), parent);
-	rc = mdo_lookup(env, parent, lname, fid, NULL);
-	if (rc) {
-		CERROR("lookup %s: rc = %d\n", lname->ln_name, rc);
-		return ERR_PTR(rc);
-	}
-
-	/* In the function below, .hs_keycmp resolves to
-	 * lu_obj_hop_keycmp() */
-	/* coverity[overrun-buffer-val] */
-	child = lu_object_find_at(env, &ed->ed_cl.cd_lu_dev, fid, NULL);
-
-	return child;
-}
-
-static int echo_setattr_object(const struct lu_env *env,
-			       struct echo_device *ed,
-			       struct lu_object *ec_parent,
-			       __u64 id, int count)
-{
-	struct lu_object	*parent;
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_name	  *lname = &info->eti_lname;
-	char		    *name = info->eti_name;
-	struct lu_device	*ld = ed->ed_next;
-	struct lu_buf	   *buf = &info->eti_buf;
-	int		      rc = 0;
-	int		      i;
-
-	if (ec_parent == NULL)
-		return -1;
-	parent = lu_object_locate(ec_parent->lo_header, ld->ld_type);
-	if (parent == NULL)
-		return -ENXIO;
-
-	for (i = 0; i < count; i++) {
-		struct lu_object *ec_child, *child;
-
-		echo_md_build_name(lname, name, id);
-
-		ec_child = echo_md_lookup(env, ed, lu2md(parent), lname);
-		if (IS_ERR(ec_child)) {
-			CERROR("Can't find child %s: rc = %ld\n",
-				lname->ln_name, PTR_ERR(ec_child));
-			return PTR_ERR(ec_child);
-		}
-
-		child = lu_object_locate(ec_child->lo_header, ld->ld_type);
-		if (child == NULL) {
-			CERROR("Can not locate the child %s\n", lname->ln_name);
-			lu_object_put(env, ec_child);
-			rc = -EINVAL;
-			break;
-		}
-
-		CDEBUG(D_RPCTRACE, "Start setattr object "DFID"\n",
-		       PFID(lu_object_fid(child)));
-
-		buf->lb_buf = info->eti_xattr_buf;
-		buf->lb_len = sizeof(info->eti_xattr_buf);
-
-		sprintf(name, "%s.test1", XATTR_USER_PREFIX);
-		rc = mo_xattr_set(env, lu2md(child), buf, name,
-				  LU_XATTR_CREATE);
-		if (rc < 0) {
-			CERROR("Can not setattr child "DFID": rc = %d\n",
-				PFID(lu_object_fid(child)), rc);
-			lu_object_put(env, ec_child);
-			break;
-		}
-		CDEBUG(D_RPCTRACE, "End setattr object "DFID"\n",
-		       PFID(lu_object_fid(child)));
-		id++;
-		lu_object_put(env, ec_child);
-	}
-	return rc;
-}
-
-static int echo_getattr_object(const struct lu_env *env,
-			       struct echo_device *ed,
-			       struct lu_object *ec_parent,
-			       __u64 id, int count)
-{
-	struct lu_object	*parent;
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_name	  *lname = &info->eti_lname;
-	char		    *name = info->eti_name;
-	struct md_attr	  *ma = &info->eti_ma;
-	struct lu_device	*ld = ed->ed_next;
-	int		      rc = 0;
-	int		      i;
-
-	if (ec_parent == NULL)
-		return -1;
-	parent = lu_object_locate(ec_parent->lo_header, ld->ld_type);
-	if (parent == NULL)
-		return -ENXIO;
-
-	memset(ma, 0, sizeof(*ma));
-	ma->ma_need |= MA_INODE | MA_LOV | MA_PFID | MA_HSM | MA_ACL_DEF;
-	ma->ma_acl = info->eti_xattr_buf;
-	ma->ma_acl_size = sizeof(info->eti_xattr_buf);
-
-	for (i = 0; i < count; i++) {
-		struct lu_object *ec_child, *child;
-
-		ma->ma_valid = 0;
-		echo_md_build_name(lname, name, id);
-		echo_set_lmm_size(env, ld, ma);
-
-		ec_child = echo_md_lookup(env, ed, lu2md(parent), lname);
-		if (IS_ERR(ec_child)) {
-			CERROR("Can't find child %s: rc = %ld\n",
-			       lname->ln_name, PTR_ERR(ec_child));
-			return PTR_ERR(ec_child);
-		}
-
-		child = lu_object_locate(ec_child->lo_header, ld->ld_type);
-		if (child == NULL) {
-			CERROR("Can not locate the child %s\n", lname->ln_name);
-			lu_object_put(env, ec_child);
-			return -EINVAL;
-		}
-
-		CDEBUG(D_RPCTRACE, "Start getattr object "DFID"\n",
-		       PFID(lu_object_fid(child)));
-		rc = echo_attr_get_complex(env, lu2md(child), ma);
-		if (rc) {
-			CERROR("Can not getattr child "DFID": rc = %d\n",
-				PFID(lu_object_fid(child)), rc);
-			lu_object_put(env, ec_child);
-			break;
-		}
-		CDEBUG(D_RPCTRACE, "End getattr object "DFID"\n",
-		       PFID(lu_object_fid(child)));
-		id++;
-		lu_object_put(env, ec_child);
-	}
-
-	return rc;
-}
-
-static int echo_lookup_object(const struct lu_env *env,
-			      struct echo_device *ed,
-			      struct lu_object *ec_parent,
-			      __u64 id, int count)
-{
-	struct lu_object	*parent;
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_name	  *lname = &info->eti_lname;
-	char		    *name = info->eti_name;
-	struct lu_fid	   *fid = &info->eti_fid;
-	struct lu_device	*ld = ed->ed_next;
-	int		      rc = 0;
-	int		      i;
-
-	if (ec_parent == NULL)
-		return -1;
-	parent = lu_object_locate(ec_parent->lo_header, ld->ld_type);
-	if (parent == NULL)
-		return -ENXIO;
-
-	/*prepare the requests*/
-	for (i = 0; i < count; i++) {
-		echo_md_build_name(lname, name, id);
-
-		CDEBUG(D_RPCTRACE, "Start lookup object "DFID" %s %p\n",
-		       PFID(lu_object_fid(parent)), lname->ln_name, parent);
-
-		rc = mdo_lookup(env, lu2md(parent), lname, fid, NULL);
-		if (rc) {
-			CERROR("Can not lookup child %s: rc = %d\n", name, rc);
-			break;
-		}
-		CDEBUG(D_RPCTRACE, "End lookup object "DFID" %s %p\n",
-		       PFID(lu_object_fid(parent)), lname->ln_name, parent);
-
-		id++;
-	}
-	return rc;
-}
-
-static int echo_md_destroy_internal(const struct lu_env *env,
-				    struct echo_device *ed,
-				    struct md_object *parent,
-				    struct lu_name *lname,
-				    struct md_attr *ma)
-{
-	struct lu_device   *ld = ed->ed_next;
-	struct lu_object   *ec_child;
-	struct lu_object   *child;
-	int		 rc;
-
-	ec_child = echo_md_lookup(env, ed, parent, lname);
-	if (IS_ERR(ec_child)) {
-		CERROR("Can't find child %s: rc = %ld\n", lname->ln_name,
-			PTR_ERR(ec_child));
-		return PTR_ERR(ec_child);
-	}
-
-	child = lu_object_locate(ec_child->lo_header, ld->ld_type);
-	if (child == NULL) {
-		CERROR("Can not locate the child %s\n", lname->ln_name);
-		GOTO(out_put, rc = -EINVAL);
-	}
-
-	CDEBUG(D_RPCTRACE, "Start destroy object "DFID" %s %p\n",
-	       PFID(lu_object_fid(&parent->mo_lu)), lname->ln_name, parent);
-
-	rc = mdo_unlink(env, parent, lu2md(child), lname, ma, 0);
-	if (rc) {
-		CERROR("Can not unlink child %s: rc = %d\n",
-			lname->ln_name, rc);
-		GOTO(out_put, rc);
-	}
-	CDEBUG(D_RPCTRACE, "End destroy object "DFID" %s %p\n",
-	       PFID(lu_object_fid(&parent->mo_lu)), lname->ln_name, parent);
-out_put:
-	lu_object_put(env, ec_child);
-	return rc;
-}
-
-static int echo_destroy_object(const struct lu_env *env,
-			       struct echo_device *ed,
-			       struct lu_object *ec_parent,
-			       char *name, int namelen,
-			       __u64 id, __u32 mode,
-			       int count)
-{
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_name	  *lname = &info->eti_lname;
-	struct md_attr	  *ma = &info->eti_ma;
-	struct lu_device	*ld = ed->ed_next;
-	struct lu_object	*parent;
-	int		      rc = 0;
-	int		      i;
-
-	parent = lu_object_locate(ec_parent->lo_header, ld->ld_type);
-	if (parent == NULL)
-		return -EINVAL;
-
-	memset(ma, 0, sizeof(*ma));
-	ma->ma_attr.la_mode = mode;
-	ma->ma_attr.la_valid = LA_CTIME;
-	ma->ma_attr.la_ctime = cfs_time_current_64();
-	ma->ma_need = MA_INODE;
-	ma->ma_valid = 0;
-
-	if (name != NULL) {
-		lname->ln_name = name;
-		lname->ln_namelen = namelen;
-		rc = echo_md_destroy_internal(env, ed, lu2md(parent), lname,
-					      ma);
-		return rc;
-	}
-
-	/*prepare the requests*/
-	for (i = 0; i < count; i++) {
-		char *tmp_name = info->eti_name;
-
-		ma->ma_valid = 0;
-		echo_md_build_name(lname, tmp_name, id);
-
-		rc = echo_md_destroy_internal(env, ed, lu2md(parent), lname,
-					      ma);
-		if (rc) {
-			CERROR("Can not unlink child %s: rc = %d\n", name, rc);
-			break;
-		}
-		id++;
-	}
-
-	return rc;
-}
-
-static struct lu_object *echo_resolve_path(const struct lu_env *env,
-					   struct echo_device *ed, char *path,
-					   int path_len)
-{
-	struct lu_device	*ld = ed->ed_next;
-	struct md_device	*md = lu2md_dev(ld);
-	struct echo_thread_info *info = echo_env_info(env);
-	struct lu_fid	   *fid = &info->eti_fid;
-	struct lu_name	  *lname = &info->eti_lname;
-	struct lu_object	*parent = NULL;
-	struct lu_object	*child = NULL;
-	int rc = 0;
-
-	/*Only support MDD layer right now*/
-	rc = md->md_ops->mdo_root_get(env, md, fid);
-	if (rc) {
-		CERROR("get root error: rc = %d\n", rc);
-		return ERR_PTR(rc);
-	}
-
-	/* In the function below, .hs_keycmp resolves to
-	 * lu_obj_hop_keycmp() */
-	/* coverity[overrun-buffer-val] */
-	parent = lu_object_find_at(env, &ed->ed_cl.cd_lu_dev, fid, NULL);
-	if (IS_ERR(parent)) {
-		CERROR("Can not find the parent "DFID": rc = %ld\n",
-			PFID(fid), PTR_ERR(parent));
-		return parent;
-	}
-
-	while (1) {
-		struct lu_object *ld_parent;
-		char *e;
-
-		e = strsep(&path, "/");
-		if (e == NULL)
-			break;
-
-		if (e[0] == 0) {
-			if (!path || path[0] == '\0')
-				break;
-			continue;
-		}
-
-		lname->ln_name = e;
-		lname->ln_namelen = strlen(e);
-
-		ld_parent = lu_object_locate(parent->lo_header, ld->ld_type);
-		if (ld_parent == NULL) {
-			lu_object_put(env, parent);
-			rc = -EINVAL;
-			break;
-		}
-
-		child = echo_md_lookup(env, ed, lu2md(ld_parent), lname);
-		lu_object_put(env, parent);
-		if (IS_ERR(child)) {
-			rc = (int)PTR_ERR(child);
-			CERROR("lookup %s under parent "DFID": rc = %d\n",
-				lname->ln_name, PFID(lu_object_fid(ld_parent)),
-				rc);
-			break;
-		}
-		parent = child;
-	}
-	if (rc)
-		return ERR_PTR(rc);
-
-	return parent;
-}
-
-static void echo_ucred_init(struct lu_env *env)
-{
-	struct lu_ucred *ucred = lu_ucred(env);
-
-	ucred->uc_valid = UCRED_INVALID;
-
-	ucred->uc_suppgids[0] = -1;
-	ucred->uc_suppgids[1] = -1;
-
-	ucred->uc_uid   = ucred->uc_o_uid   =
-				from_kuid(&init_user_ns, current_uid());
-	ucred->uc_gid   = ucred->uc_o_gid   =
-				from_kgid(&init_user_ns, current_gid());
-	ucred->uc_fsuid = ucred->uc_o_fsuid =
-				from_kuid(&init_user_ns, current_fsuid());
-	ucred->uc_fsgid = ucred->uc_o_fsgid =
-				from_kgid(&init_user_ns, current_fsgid());
-	ucred->uc_cap   = cfs_curproc_cap_pack();
-
-	/* remove fs privilege for non-root user. */
-	if (ucred->uc_fsuid)
-		ucred->uc_cap &= ~CFS_CAP_FS_MASK;
-	ucred->uc_valid = UCRED_NEW;
-}
-
-static void echo_ucred_fini(struct lu_env *env)
-{
-	struct lu_ucred *ucred = lu_ucred(env);
-	ucred->uc_valid = UCRED_INIT;
-}
-
-#define ECHO_MD_CTX_TAG (LCT_REMEMBER | LCT_MD_THREAD)
-#define ECHO_MD_SES_TAG (LCT_REMEMBER | LCT_SESSION)
-static int echo_md_handler(struct echo_device *ed, int command,
-			   char *path, int path_len, __u64 id, int count,
-			   struct obd_ioctl_data *data)
-{
-	struct echo_thread_info *info;
-	struct lu_device      *ld = ed->ed_next;
-	struct lu_env	 *env;
-	int		    refcheck;
-	struct lu_object      *parent;
-	char		  *name = NULL;
-	int		    namelen = data->ioc_plen2;
-	int		    rc = 0;
-
-	if (ld == NULL) {
-		CERROR("MD echo client is not being initialized properly\n");
-		return -EINVAL;
-	}
-
-	if (strcmp(ld->ld_type->ldt_name, LUSTRE_MDD_NAME)) {
-		CERROR("Only support MDD layer right now!\n");
-		return -EINVAL;
-	}
-
-	env = cl_env_get(&refcheck);
-	if (IS_ERR(env))
-		return PTR_ERR(env);
-
-	rc = lu_env_refill_by_tags(env, ECHO_MD_CTX_TAG, ECHO_MD_SES_TAG);
-	if (rc != 0)
-		GOTO(out_env, rc);
-
-	/* init big_lmm buffer */
-	info = echo_env_info(env);
-	LASSERT(info->eti_big_lmm == NULL);
-	OBD_ALLOC_LARGE(info->eti_big_lmm, MIN_MD_SIZE);
-	if (info->eti_big_lmm == NULL)
-		GOTO(out_env, rc = -ENOMEM);
-	info->eti_big_lmmsize = MIN_MD_SIZE;
-
-	parent = echo_resolve_path(env, ed, path, path_len);
-	if (IS_ERR(parent)) {
-		CERROR("Can not resolve the path %s: rc = %ld\n", path,
-			PTR_ERR(parent));
-		GOTO(out_free, rc = PTR_ERR(parent));
-	}
-
-	if (namelen > 0) {
-		OBD_ALLOC(name, namelen + 1);
-		if (name == NULL)
-			GOTO(out_put, rc = -ENOMEM);
-		if (copy_from_user(name, data->ioc_pbuf2, namelen))
-			GOTO(out_name, rc = -EFAULT);
-	}
-
-	echo_ucred_init(env);
-
-	switch (command) {
-	case ECHO_MD_CREATE:
-	case ECHO_MD_MKDIR: {
-		struct echo_thread_info *info = echo_env_info(env);
-		__u32 mode = data->ioc_obdo2.o_mode;
-		struct lu_fid *fid = &info->eti_fid;
-		int stripe_count = (int)data->ioc_obdo2.o_misc;
-		int stripe_index = (int)data->ioc_obdo2.o_stripe_idx;
-
-		rc = ostid_to_fid(fid, &data->ioc_obdo1.o_oi, 0);
-		if (rc != 0)
-			break;
-
-		/* In the function below, .hs_keycmp resolves to
-		 * lu_obj_hop_keycmp() */
-		/* coverity[overrun-buffer-val] */
-		rc = echo_create_md_object(env, ed, parent, fid, name, namelen,
-					   id, mode, count, stripe_count,
-					   stripe_index);
-		break;
-	}
-	case ECHO_MD_DESTROY:
-	case ECHO_MD_RMDIR: {
-		__u32 mode = data->ioc_obdo2.o_mode;
-
-		rc = echo_destroy_object(env, ed, parent, name, namelen,
-					 id, mode, count);
-		break;
-	}
-	case ECHO_MD_LOOKUP:
-		rc = echo_lookup_object(env, ed, parent, id, count);
-		break;
-	case ECHO_MD_GETATTR:
-		rc = echo_getattr_object(env, ed, parent, id, count);
-		break;
-	case ECHO_MD_SETATTR:
-		rc = echo_setattr_object(env, ed, parent, id, count);
-		break;
-	default:
-		CERROR("unknown command %d\n", command);
-		rc = -EINVAL;
-		break;
-	}
-	echo_ucred_fini(env);
-
-out_name:
-	if (name != NULL)
-		OBD_FREE(name, namelen + 1);
-out_put:
-	lu_object_put(env, parent);
-out_free:
-	LASSERT(info->eti_big_lmm);
-	OBD_FREE_LARGE(info->eti_big_lmm, info->eti_big_lmmsize);
-	info->eti_big_lmm = NULL;
-	info->eti_big_lmmsize = 0;
-out_env:
-	cl_env_put(env, &refcheck);
-	return rc;
-}
-
 static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
 			      int on_target, struct obdo *oa, void *ulsm,
 			      int ulsm_nob, struct obd_trans_info *oti)
@@ -2770,72 +1892,6 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 					data->ioc_plen1, &dummy_oti);
 		GOTO(out, rc);
 
-	case OBD_IOC_ECHO_MD: {
-		int count;
-		int cmd;
-		char *dir = NULL;
-		int dirlen;
-		__u64 id;
-
-		if (!capable(CFS_CAP_SYS_ADMIN))
-			GOTO(out, rc = -EPERM);
-
-		count = data->ioc_count;
-		cmd = data->ioc_command;
-
-		id = ostid_id(&data->ioc_obdo2.o_oi);
-
-		dirlen = data->ioc_plen1;
-		OBD_ALLOC(dir, dirlen + 1);
-		if (dir == NULL)
-			GOTO(out, rc = -ENOMEM);
-
-		if (copy_from_user(dir, data->ioc_pbuf1, dirlen)) {
-			OBD_FREE(dir, data->ioc_plen1 + 1);
-			GOTO(out, rc = -EFAULT);
-		}
-
-		rc = echo_md_handler(ed, cmd, dir, dirlen, id, count, data);
-		OBD_FREE(dir, dirlen + 1);
-		GOTO(out, rc);
-	}
-	case OBD_IOC_ECHO_ALLOC_SEQ: {
-		struct lu_env   *cl_env;
-		int	      refcheck;
-		__u64	    seq;
-		int	      max_count;
-
-		if (!capable(CFS_CAP_SYS_ADMIN))
-			GOTO(out, rc = -EPERM);
-
-		cl_env = cl_env_get(&refcheck);
-		if (IS_ERR(cl_env))
-			GOTO(out, rc = PTR_ERR(cl_env));
-
-		rc = lu_env_refill_by_tags(cl_env, ECHO_MD_CTX_TAG,
-					    ECHO_MD_SES_TAG);
-		if (rc != 0) {
-			cl_env_put(cl_env, &refcheck);
-			GOTO(out, rc);
-		}
-
-		rc = seq_client_get_seq(cl_env, ed->ed_cl_seq, &seq);
-		cl_env_put(cl_env, &refcheck);
-		if (rc < 0) {
-			CERROR("%s: Can not alloc seq: rc = %d\n",
-			       obd->obd_name, rc);
-			GOTO(out, rc);
-		}
-
-		if (copy_to_user(data->ioc_pbuf1, &seq, data->ioc_plen1))
-			return -EFAULT;
-
-		max_count = LUSTRE_METADATA_SEQ_MAX_WIDTH;
-		if (copy_to_user(data->ioc_pbuf2, &max_count,
-				     data->ioc_plen2))
-			return -EFAULT;
-		GOTO(out, rc);
-	}
 	case OBD_IOC_DESTROY:
 		if (!capable(CFS_CAP_SYS_ADMIN))
 			GOTO (out, rc = -EPERM);
@@ -2973,12 +2029,6 @@ static int echo_client_setup(const struct lu_env *env,
 	ec->ec_unique = 0;
 	ec->ec_nstripes = 0;
 
-	if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) {
-		lu_context_tags_update(ECHO_MD_CTX_TAG);
-		lu_session_tags_update(ECHO_MD_SES_TAG);
-		return 0;
-	}
-
 	OBD_ALLOC(ocd, sizeof(*ocd));
 	if (ocd == NULL) {
 		CERROR("Can't alloc ocd connecting to %s\n",
@@ -3016,20 +2066,9 @@ static int echo_client_setup(const struct lu_env *env,
 
 static int echo_client_cleanup(struct obd_device *obddev)
 {
-	struct echo_device *ed = obd2echo_dev(obddev);
 	struct echo_client_obd *ec = &obddev->u.echo_client;
 	int rc;
 
-	/*Do nothing for Metadata echo client*/
-	if (ed == NULL )
-		return 0;
-
-	if (ed->ed_next_ismd) {
-		lu_context_tags_clear(ECHO_MD_CTX_TAG);
-		lu_session_tags_clear(ECHO_MD_SES_TAG);
-		return 0;
-	}
-
 	if (!list_empty(&obddev->obd_exports)) {
 		CERROR("still has clients!\n");
 		return -EBUSY;
-- 
1.9.3


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

* [PATCH 03/12] staging/lustre/obdecho: remove #if 0-ed out regions
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
  2014-08-30 21:12 ` [PATCH 01/12] staging/lustre: Remove unused header libcfs_heap.h Oleg Drokin
  2014-08-30 21:12 ` [PATCH 02/12] staging/lustre/obdecho: remove metadata echo client Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 04/12] staging/lustre/obdclass: remove idmap.c Oleg Drokin
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger; +Cc: John L. Hammond

From: "John L. Hammond" <john.hammond@intel.com>

The landing of clio #if 0-ed out some regions of echo_client.c. Just
remove these regions entirely.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Reviewed-on: http://review.whamcloud.com/5580
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2675
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
 .../staging/lustre/lustre/obdecho/echo_client.c    | 50 ----------------------
 1 file changed, 50 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index 68a5ed1..98e4290 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -93,16 +93,6 @@ struct echo_lock {
 	atomic_t	   el_refcount;
 };
 
-struct echo_io {
-	struct cl_io_slice     ei_cl;
-};
-
-#if 0
-struct echo_req {
-	struct cl_req_slice er_cl;
-};
-#endif
-
 static int echo_client_setup(const struct lu_env *env,
 			     struct obd_device *obddev,
 			     struct lustre_cfg *lcfg);
@@ -200,7 +190,6 @@ static struct kmem_cache *echo_lock_kmem;
 static struct kmem_cache *echo_object_kmem;
 static struct kmem_cache *echo_thread_kmem;
 static struct kmem_cache *echo_session_kmem;
-//static struct kmem_cache *echo_req_kmem;
 
 static struct lu_kmem_descr echo_caches[] = {
 	{
@@ -223,13 +212,6 @@ static struct lu_kmem_descr echo_caches[] = {
 		.ckd_name  = "echo_session_kmem",
 		.ckd_size  = sizeof (struct echo_session_info)
 	},
-#if 0
-	{
-		.ckd_cache = &echo_req_kmem,
-		.ckd_name  = "echo_req_kmem",
-		.ckd_size  = sizeof (struct echo_req)
-	},
-#endif
 	{
 		.ckd_cache = NULL
 	}
@@ -2100,37 +2082,11 @@ static int echo_client_connect(const struct lu_env *env,
 
 static int echo_client_disconnect(struct obd_export *exp)
 {
-#if 0
-	struct obd_device      *obd;
-	struct echo_client_obd *ec;
-	struct ec_lock	 *ecl;
-#endif
 	int		     rc;
 
 	if (exp == NULL)
 		GOTO(out, rc = -EINVAL);
 
-#if 0
-	obd = exp->exp_obd;
-	ec = &obd->u.echo_client;
-
-	/* no more contention on export's lock list */
-	while (!list_empty (&exp->exp_ec_data.eced_locks)) {
-		ecl = list_entry (exp->exp_ec_data.eced_locks.next,
-				      struct ec_lock, ecl_exp_chain);
-		list_del (&ecl->ecl_exp_chain);
-
-		rc = obd_cancel(ec->ec_exp, ecl->ecl_object->eco_lsm,
-				 ecl->ecl_mode, &ecl->ecl_lock_handle);
-
-		CDEBUG (D_INFO, "Cancel lock on object %#llx on disconnect "
-			"(%d)\n", ecl->ecl_object->eco_id, rc);
-
-		echo_put_object (ecl->ecl_object);
-		OBD_FREE (ecl, sizeof (*ecl));
-	}
-#endif
-
 	rc = class_disconnect(exp);
 	GOTO(out, rc);
  out:
@@ -2139,12 +2095,6 @@ static int echo_client_disconnect(struct obd_export *exp)
 
 static struct obd_ops echo_client_obd_ops = {
 	.o_owner       = THIS_MODULE,
-
-#if 0
-	.o_setup       = echo_client_setup,
-	.o_cleanup     = echo_client_cleanup,
-#endif
-
 	.o_iocontrol   = echo_client_iocontrol,
 	.o_connect     = echo_client_connect,
 	.o_disconnect  = echo_client_disconnect
-- 
1.9.3


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

* [PATCH 04/12] staging/lustre/obdclass: remove idmap.c
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (2 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 03/12] staging/lustre/obdecho: remove #if 0-ed out regions Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 05/12] staging/lustre/obdclass: remove lu_ucred.c Oleg Drokin
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Oleg Drokin

From: "John L. Hammond" <john.hammond@intel.com>

The functions defined in lustre/include/lustre_idmap.h are not used so
remove them.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
---
 .../staging/lustre/lustre/include/lustre_idmap.h   | 104 -----
 drivers/staging/lustre/lustre/obdclass/Makefile    |   2 +-
 drivers/staging/lustre/lustre/obdclass/idmap.c     | 477 ---------------------
 3 files changed, 1 insertion(+), 582 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/include/lustre_idmap.h
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/idmap.c

diff --git a/drivers/staging/lustre/lustre/include/lustre_idmap.h b/drivers/staging/lustre/lustre/include/lustre_idmap.h
deleted file mode 100644
index 5624b8b..0000000
--- a/drivers/staging/lustre/lustre/include/lustre_idmap.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/lustre/include/lustre_idmap.h
- *
- * MDS data structures.
- * See also lustre_idl.h for wire formats of requests.
- */
-
-#ifndef _LUSTRE_IDMAP_H
-#define _LUSTRE_IDMAP_H
-
-/** \defgroup idmap idmap
- *
- * @{
- */
-
-#include "../../include/linux/libcfs/libcfs.h"
-
-#define CFS_NGROUPS_PER_BLOCK   ((int)(PAGE_CACHE_SIZE / sizeof(gid_t)))
-
-#define CFS_GROUP_AT(gi, i) \
-	((gi)->blocks[(i) / CFS_NGROUPS_PER_BLOCK][(i) % CFS_NGROUPS_PER_BLOCK])
-
-enum {
-	CFS_IC_NOTHING     = 0,    /* convert nothing */
-	CFS_IC_ALL	 = 1,    /* convert all items */
-	CFS_IC_MAPPED      = 2,    /* convert mapped uid/gid */
-	CFS_IC_UNMAPPED    = 3     /* convert unmapped uid/gid */
-};
-
-#define  CFS_IDMAP_NOTFOUND     (-1)
-
-#define CFS_IDMAP_HASHSIZE      32
-
-enum lustre_idmap_idx {
-	RMT_UIDMAP_IDX,
-	LCL_UIDMAP_IDX,
-	RMT_GIDMAP_IDX,
-	LCL_GIDMAP_IDX,
-	CFS_IDMAP_N_HASHES
-};
-
-struct lustre_idmap_table {
-	spinlock_t	lit_lock;
-	struct list_head	lit_idmaps[CFS_IDMAP_N_HASHES][CFS_IDMAP_HASHSIZE];
-};
-
-struct lu_ucred;
-
-extern void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist);
-extern void lustre_groups_sort(struct group_info *group_info);
-extern int lustre_in_group_p(struct lu_ucred *mu, gid_t grp);
-
-extern int lustre_idmap_add(struct lustre_idmap_table *t,
-			    uid_t ruid, uid_t luid,
-			    gid_t rgid, gid_t lgid);
-extern int lustre_idmap_del(struct lustre_idmap_table *t,
-			    uid_t ruid, uid_t luid,
-			    gid_t rgid, gid_t lgid);
-extern int lustre_idmap_lookup_uid(struct lu_ucred *mu,
-				   struct lustre_idmap_table *t,
-				   int reverse, uid_t uid);
-extern int lustre_idmap_lookup_gid(struct lu_ucred *mu,
-				   struct lustre_idmap_table *t,
-				   int reverse, gid_t gid);
-extern struct lustre_idmap_table *lustre_idmap_init(void);
-extern void lustre_idmap_fini(struct lustre_idmap_table *t);
-
-/** @} idmap */
-
-#endif
diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index ba10043..989fb7c 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -6,5 +6,5 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
 	      lustre_handles.o lustre_peer.o llog_osd.o \
 	      local_storage.o statfs_pack.o obdo.o obd_config.o obd_mount.o\
 	      mea.o lu_object.o dt_object.o capa.o cl_object.o   \
-	      cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o idmap.o	   \
+	      cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o \
 	      lu_ucred.o
diff --git a/drivers/staging/lustre/lustre/obdclass/idmap.c b/drivers/staging/lustre/lustre/obdclass/idmap.c
deleted file mode 100644
index 8c2f0b7..0000000
--- a/drivers/staging/lustre/lustre/obdclass/idmap.c
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/obdclass/idmap.c
- *
- * Lustre user identity mapping.
- *
- * Author: Fan Yong <fanyong@clusterfs.com>
- */
-
-#define DEBUG_SUBSYSTEM S_SEC
-
-#include "../include/lustre_idmap.h"
-#include "../include/md_object.h"
-#include "../include/obd_support.h"
-
-#define lustre_get_group_info(group_info) do {	     \
-	atomic_inc(&(group_info)->usage);	      \
-} while (0)
-
-#define lustre_put_group_info(group_info) do {	     \
-	if (atomic_dec_and_test(&(group_info)->usage)) \
-		groups_free(group_info);	       \
-} while (0)
-
-/*
- * groups_search() is copied from linux kernel!
- * A simple bsearch.
- */
-static int lustre_groups_search(const struct group_info *group_info, gid_t grp)
-{
-	int left, right;
-
-	if (!group_info)
-		return 0;
-
-	left = 0;
-	right = group_info->ngroups;
-	while (left < right) {
-		int mid = (left + right) / 2;
-		int cmp = grp -
-			from_kgid(&init_user_ns, CFS_GROUP_AT(group_info, mid));
-
-		if (cmp > 0)
-			left = mid + 1;
-		else if (cmp < 0)
-			right = mid;
-		else
-			return 1;
-	}
-	return 0;
-}
-
-void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist)
-{
-	int i;
-	int count = ginfo->ngroups;
-
-	/* fill group_info from gid array */
-	for (i = 0; i < ginfo->nblocks && count > 0; i++) {
-		int cp_count = min(CFS_NGROUPS_PER_BLOCK, count);
-		int off = i * CFS_NGROUPS_PER_BLOCK;
-		int len = cp_count * sizeof(*glist);
-
-		memcpy(ginfo->blocks[i], glist + off, len);
-		count -= cp_count;
-	}
-}
-EXPORT_SYMBOL(lustre_groups_from_list);
-
-/* groups_sort() is copied from linux kernel! */
-/* a simple shell-metzner sort */
-void lustre_groups_sort(struct group_info *group_info)
-{
-	int base, max, stride;
-	int gidsetsize = group_info->ngroups;
-
-	for (stride = 1; stride < gidsetsize; stride = 3 * stride + 1)
-		; /* nothing */
-	stride /= 3;
-
-	while (stride) {
-		max = gidsetsize - stride;
-		for (base = 0; base < max; base++) {
-			int left = base;
-			int right = left + stride;
-			gid_t tmp = from_kgid(&init_user_ns,
-					      CFS_GROUP_AT(group_info, right));
-
-			while (left >= 0 &&
-			       tmp < from_kgid(&init_user_ns,
-					       CFS_GROUP_AT(group_info, left))) {
-				CFS_GROUP_AT(group_info, right) =
-				    CFS_GROUP_AT(group_info, left);
-				right = left;
-				left -= stride;
-			}
-			CFS_GROUP_AT(group_info, right) =
-						make_kgid(&init_user_ns, tmp);
-		}
-		stride /= 3;
-	}
-}
-EXPORT_SYMBOL(lustre_groups_sort);
-
-int lustre_in_group_p(struct lu_ucred *mu, gid_t grp)
-{
-	int rc = 1;
-
-	if (grp != mu->uc_fsgid) {
-		struct group_info *group_info = NULL;
-
-		if (mu->uc_ginfo || !mu->uc_identity ||
-		    mu->uc_valid == UCRED_OLD)
-			if (grp == mu->uc_suppgids[0] ||
-			    grp == mu->uc_suppgids[1])
-				return 1;
-
-		if (mu->uc_ginfo)
-			group_info = mu->uc_ginfo;
-		else if (mu->uc_identity)
-			group_info = mu->uc_identity->mi_ginfo;
-
-		if (!group_info)
-			return 0;
-
-		lustre_get_group_info(group_info);
-		rc = lustre_groups_search(group_info, grp);
-		lustre_put_group_info(group_info);
-	}
-	return rc;
-}
-EXPORT_SYMBOL(lustre_in_group_p);
-
-struct lustre_idmap_entry {
-	struct list_head       lie_rmt_uid_hash; /* hashed as lie_rmt_uid; */
-	struct list_head       lie_lcl_uid_hash; /* hashed as lie_lcl_uid; */
-	struct list_head       lie_rmt_gid_hash; /* hashed as lie_rmt_gid; */
-	struct list_head       lie_lcl_gid_hash; /* hashed as lie_lcl_gid; */
-	uid_t	    lie_rmt_uid;      /* remote uid */
-	uid_t	    lie_lcl_uid;      /* local uid */
-	gid_t	    lie_rmt_gid;      /* remote gid */
-	gid_t	    lie_lcl_gid;      /* local gid */
-};
-
-static inline __u32 lustre_idmap_hashfunc(__u32 id)
-{
-	return id & (CFS_IDMAP_HASHSIZE - 1);
-}
-
-static
-struct lustre_idmap_entry *idmap_entry_alloc(uid_t rmt_uid, uid_t lcl_uid,
-					     gid_t rmt_gid, gid_t lcl_gid)
-{
-	struct lustre_idmap_entry *e;
-
-	OBD_ALLOC_PTR(e);
-	if (e == NULL)
-		return NULL;
-
-	INIT_LIST_HEAD(&e->lie_rmt_uid_hash);
-	INIT_LIST_HEAD(&e->lie_lcl_uid_hash);
-	INIT_LIST_HEAD(&e->lie_rmt_gid_hash);
-	INIT_LIST_HEAD(&e->lie_lcl_gid_hash);
-	e->lie_rmt_uid = rmt_uid;
-	e->lie_lcl_uid = lcl_uid;
-	e->lie_rmt_gid = rmt_gid;
-	e->lie_lcl_gid = lcl_gid;
-
-	return e;
-}
-
-static void idmap_entry_free(struct lustre_idmap_entry *e)
-{
-	if (!list_empty(&e->lie_rmt_uid_hash))
-		list_del(&e->lie_rmt_uid_hash);
-	if (!list_empty(&e->lie_lcl_uid_hash))
-		list_del(&e->lie_lcl_uid_hash);
-	if (!list_empty(&e->lie_rmt_gid_hash))
-		list_del(&e->lie_rmt_gid_hash);
-	if (!list_empty(&e->lie_lcl_gid_hash))
-		list_del(&e->lie_lcl_gid_hash);
-	OBD_FREE_PTR(e);
-}
-
-/*
- * return value
- * NULL: not found entry
- * ERR_PTR(-EACCES): found 1(remote):N(local) mapped entry
- * others: found normal entry
- */
-static
-struct lustre_idmap_entry *idmap_search_entry(struct lustre_idmap_table *t,
-					      uid_t rmt_uid, uid_t lcl_uid,
-					      gid_t rmt_gid, gid_t lcl_gid)
-{
-	struct list_head *head;
-	struct lustre_idmap_entry *e;
-
-	head = &t->lit_idmaps[RMT_UIDMAP_IDX][lustre_idmap_hashfunc(rmt_uid)];
-	list_for_each_entry(e, head, lie_rmt_uid_hash)
-		if (e->lie_rmt_uid == rmt_uid) {
-			if (e->lie_lcl_uid == lcl_uid) {
-				if (e->lie_rmt_gid == rmt_gid &&
-				    e->lie_lcl_gid == lcl_gid)
-					/* must be quaternion match */
-					return e;
-			} else {
-				/* 1:N uid mapping */
-				CERROR("rmt uid %u already be mapped to %u"
-				       " (new %u)\n", e->lie_rmt_uid,
-				       e->lie_lcl_uid, lcl_uid);
-				return ERR_PTR(-EACCES);
-			}
-		}
-
-	head = &t->lit_idmaps[RMT_GIDMAP_IDX][lustre_idmap_hashfunc(rmt_gid)];
-	list_for_each_entry(e, head, lie_rmt_gid_hash)
-		if (e->lie_rmt_gid == rmt_gid) {
-			if (e->lie_lcl_gid == lcl_gid) {
-				if (unlikely(e->lie_rmt_uid == rmt_uid &&
-				    e->lie_lcl_uid == lcl_uid))
-					/* after uid mapping search above,
-					 * we should never come here */
-					LBUG();
-			} else {
-				/* 1:N gid mapping */
-				CERROR("rmt gid %u already be mapped to %u"
-				       " (new %u)\n", e->lie_rmt_gid,
-				       e->lie_lcl_gid, lcl_gid);
-				return ERR_PTR(-EACCES);
-			}
-		}
-
-	return NULL;
-}
-
-static __u32 idmap_lookup_uid(struct list_head *hash, int reverse,
-			      __u32 uid)
-{
-	struct list_head *head = &hash[lustre_idmap_hashfunc(uid)];
-	struct lustre_idmap_entry *e;
-
-	if (!reverse) {
-		list_for_each_entry(e, head, lie_rmt_uid_hash)
-			if (e->lie_rmt_uid == uid)
-				return e->lie_lcl_uid;
-	} else {
-		list_for_each_entry(e, head, lie_lcl_uid_hash)
-			if (e->lie_lcl_uid == uid)
-				return e->lie_rmt_uid;
-	}
-
-	return CFS_IDMAP_NOTFOUND;
-}
-
-static __u32 idmap_lookup_gid(struct list_head *hash, int reverse, __u32 gid)
-{
-	struct list_head *head = &hash[lustre_idmap_hashfunc(gid)];
-	struct lustre_idmap_entry *e;
-
-	if (!reverse) {
-		list_for_each_entry(e, head, lie_rmt_gid_hash)
-			if (e->lie_rmt_gid == gid)
-				return e->lie_lcl_gid;
-	} else {
-		list_for_each_entry(e, head, lie_lcl_gid_hash)
-			if (e->lie_lcl_gid == gid)
-				return e->lie_rmt_gid;
-	}
-
-	return CFS_IDMAP_NOTFOUND;
-}
-
-int lustre_idmap_add(struct lustre_idmap_table *t,
-		     uid_t ruid, uid_t luid,
-		     gid_t rgid, gid_t lgid)
-{
-	struct lustre_idmap_entry *e0, *e1;
-
-	LASSERT(t);
-
-	spin_lock(&t->lit_lock);
-	e0 = idmap_search_entry(t, ruid, luid, rgid, lgid);
-	spin_unlock(&t->lit_lock);
-	if (!e0) {
-		e0 = idmap_entry_alloc(ruid, luid, rgid, lgid);
-		if (!e0)
-			return -ENOMEM;
-
-		spin_lock(&t->lit_lock);
-		e1 = idmap_search_entry(t, ruid, luid, rgid, lgid);
-		if (e1 == NULL) {
-			list_add_tail(&e0->lie_rmt_uid_hash,
-					  &t->lit_idmaps[RMT_UIDMAP_IDX]
-					  [lustre_idmap_hashfunc(ruid)]);
-			list_add_tail(&e0->lie_lcl_uid_hash,
-					  &t->lit_idmaps[LCL_UIDMAP_IDX]
-					  [lustre_idmap_hashfunc(luid)]);
-			list_add_tail(&e0->lie_rmt_gid_hash,
-					  &t->lit_idmaps[RMT_GIDMAP_IDX]
-					  [lustre_idmap_hashfunc(rgid)]);
-			list_add_tail(&e0->lie_lcl_gid_hash,
-					  &t->lit_idmaps[LCL_GIDMAP_IDX]
-					  [lustre_idmap_hashfunc(lgid)]);
-		}
-		spin_unlock(&t->lit_lock);
-		if (e1 != NULL) {
-			idmap_entry_free(e0);
-			if (IS_ERR(e1))
-				return PTR_ERR(e1);
-		}
-	} else if (IS_ERR(e0)) {
-		return PTR_ERR(e0);
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL(lustre_idmap_add);
-
-int lustre_idmap_del(struct lustre_idmap_table *t,
-		    uid_t ruid, uid_t luid,
-		    gid_t rgid, gid_t lgid)
-{
-	struct lustre_idmap_entry *e;
-	int rc = 0;
-
-	LASSERT(t);
-
-	spin_lock(&t->lit_lock);
-	e = idmap_search_entry(t, ruid, luid, rgid, lgid);
-	if (IS_ERR(e))
-		rc = PTR_ERR(e);
-	else if (e)
-		idmap_entry_free(e);
-	spin_unlock(&t->lit_lock);
-
-	return rc;
-}
-EXPORT_SYMBOL(lustre_idmap_del);
-
-int lustre_idmap_lookup_uid(struct lu_ucred *mu,
-			    struct lustre_idmap_table *t,
-			    int reverse, uid_t uid)
-{
-	struct list_head *hash;
-
-	if (mu && (mu->uc_valid == UCRED_OLD || mu->uc_valid == UCRED_NEW)) {
-		if (!reverse) {
-			if (uid == mu->uc_o_uid)
-				return mu->uc_uid;
-			else if (uid == mu->uc_o_fsuid)
-				return mu->uc_fsuid;
-		} else {
-			if (uid == mu->uc_uid)
-				return mu->uc_o_uid;
-			else if (uid == mu->uc_fsuid)
-				return mu->uc_o_fsuid;
-		}
-	}
-
-	if (t == NULL)
-		return CFS_IDMAP_NOTFOUND;
-
-	hash = t->lit_idmaps[reverse ? LCL_UIDMAP_IDX : RMT_UIDMAP_IDX];
-
-	spin_lock(&t->lit_lock);
-	uid = idmap_lookup_uid(hash, reverse, uid);
-	spin_unlock(&t->lit_lock);
-
-	return uid;
-}
-EXPORT_SYMBOL(lustre_idmap_lookup_uid);
-
-int lustre_idmap_lookup_gid(struct lu_ucred *mu, struct lustre_idmap_table *t,
-			    int reverse, gid_t gid)
-{
-	struct list_head *hash;
-
-	if (mu && (mu->uc_valid == UCRED_OLD || mu->uc_valid == UCRED_NEW)) {
-		if (!reverse) {
-			if (gid == mu->uc_o_gid)
-				return mu->uc_gid;
-			else if (gid == mu->uc_o_fsgid)
-				return mu->uc_fsgid;
-		} else {
-			if (gid == mu->uc_gid)
-				return mu->uc_o_gid;
-			else if (gid == mu->uc_fsgid)
-				return mu->uc_o_fsgid;
-		}
-	}
-
-	if (t == NULL)
-		return CFS_IDMAP_NOTFOUND;
-
-	hash = t->lit_idmaps[reverse ? LCL_GIDMAP_IDX : RMT_GIDMAP_IDX];
-
-	spin_lock(&t->lit_lock);
-	gid = idmap_lookup_gid(hash, reverse, gid);
-	spin_unlock(&t->lit_lock);
-
-	return gid;
-}
-EXPORT_SYMBOL(lustre_idmap_lookup_gid);
-
-struct lustre_idmap_table *lustre_idmap_init(void)
-{
-	struct lustre_idmap_table *t;
-	int i, j;
-
-	OBD_ALLOC_PTR(t);
-	if (unlikely(t == NULL))
-		return ERR_PTR(-ENOMEM);
-
-	spin_lock_init(&t->lit_lock);
-	for (i = 0; i < ARRAY_SIZE(t->lit_idmaps); i++)
-		for (j = 0; j < ARRAY_SIZE(t->lit_idmaps[i]); j++)
-			INIT_LIST_HEAD(&t->lit_idmaps[i][j]);
-
-	return t;
-}
-EXPORT_SYMBOL(lustre_idmap_init);
-
-void lustre_idmap_fini(struct lustre_idmap_table *t)
-{
-	struct list_head *list;
-	struct lustre_idmap_entry *e;
-	int i;
-	LASSERT(t);
-
-	list = t->lit_idmaps[RMT_UIDMAP_IDX];
-	spin_lock(&t->lit_lock);
-	for (i = 0; i < CFS_IDMAP_HASHSIZE; i++)
-		while (!list_empty(&list[i])) {
-			e = list_entry(list[i].next,
-					   struct lustre_idmap_entry,
-					   lie_rmt_uid_hash);
-			idmap_entry_free(e);
-		}
-	spin_unlock(&t->lit_lock);
-
-	OBD_FREE_PTR(t);
-}
-EXPORT_SYMBOL(lustre_idmap_fini);
-- 
1.9.3


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

* [PATCH 05/12] staging/lustre/obdclass: remove lu_ucred.c
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (3 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 04/12] staging/lustre/obdclass: remove idmap.c Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 06/12] staging/lustre/obdclass: remove mea.c Oleg Drokin
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger; +Cc: John L. Hammond

From: "John L. Hammond" <john.hammond@intel.com>

The functions exported by lustre/obdclass/lu_ucred.c are not used so
remove that file.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
---
 drivers/staging/lustre/lustre/obdclass/Makefile   |   3 +-
 drivers/staging/lustre/lustre/obdclass/lu_ucred.c | 107 ----------------------
 2 files changed, 1 insertion(+), 109 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/lu_ucred.c

diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index 989fb7c..91a5a2b 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -6,5 +6,4 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
 	      lustre_handles.o lustre_peer.o llog_osd.o \
 	      local_storage.o statfs_pack.o obdo.o obd_config.o obd_mount.o\
 	      mea.o lu_object.o dt_object.o capa.o cl_object.o   \
-	      cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o \
-	      lu_ucred.o
+	      cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c b/drivers/staging/lustre/lustre/obdclass/lu_ucred.c
deleted file mode 100644
index 3676563..0000000
--- a/drivers/staging/lustre/lustre/obdclass/lu_ucred.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/obdclass/lu_ucred.c
- *
- * Lustre user credentials context infrastructure.
- *
- *   Author: Nikita Danilov <nikita.danilov@sun.com>
- *   Author: Fan Yong <fan.yong@intel.com>
- *   Author: Vitaly Fertman <vitaly_fertman@xyratex.com>
- */
-
-#define DEBUG_SUBSYSTEM S_CLASS
-
-#include "../../include/linux/libcfs/libcfs.h"
-#include "../include/obd_support.h"
-#include "../include/lu_object.h"
-#include "../include/md_object.h"
-
-/* context key constructor/destructor: lu_ucred_key_init, lu_ucred_key_fini */
-LU_KEY_INIT_FINI(lu_ucred, struct lu_ucred);
-
-static struct lu_context_key lu_ucred_key = {
-	.lct_tags = LCT_SESSION,
-	.lct_init = lu_ucred_key_init,
-	.lct_fini = lu_ucred_key_fini
-};
-
-/**
- * Get ucred key if session exists and ucred key is allocated on it.
- * Return NULL otherwise.
- */
-struct lu_ucred *lu_ucred(const struct lu_env *env)
-{
-	if (!env->le_ses)
-		return NULL;
-	return lu_context_key_get(env->le_ses, &lu_ucred_key);
-}
-EXPORT_SYMBOL(lu_ucred);
-
-/**
- * Get ucred key and check if it is properly initialized.
- * Return NULL otherwise.
- */
-struct lu_ucred *lu_ucred_check(const struct lu_env *env)
-{
-	struct lu_ucred *uc = lu_ucred(env);
-	if (uc && uc->uc_valid != UCRED_OLD && uc->uc_valid != UCRED_NEW)
-		return NULL;
-	return uc;
-}
-EXPORT_SYMBOL(lu_ucred_check);
-
-/**
- * Get ucred key, which must exist and must be properly initialized.
- * Assert otherwise.
- */
-struct lu_ucred *lu_ucred_assert(const struct lu_env *env)
-{
-	struct lu_ucred *uc = lu_ucred_check(env);
-	LASSERT(uc != NULL);
-	return uc;
-}
-EXPORT_SYMBOL(lu_ucred_assert);
-
-int lu_ucred_global_init(void)
-{
-	LU_CONTEXT_KEY_INIT(&lu_ucred_key);
-	return lu_context_key_register(&lu_ucred_key);
-}
-
-void lu_ucred_global_fini(void)
-{
-	lu_context_key_degister(&lu_ucred_key);
-}
-- 
1.9.3


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

* [PATCH 06/12] staging/lustre/obdclass: remove mea.c
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (4 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 05/12] staging/lustre/obdclass: remove lu_ucred.c Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 07/12] staging/lustre: remove md_object.h Oleg Drokin
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger; +Cc: John L. Hammond

From: "John L. Hammond" <john.hammond@intel.com>

The functions exported by lustre/obdclass/mea.c are not used so remove
them.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
---
 drivers/staging/lustre/lustre/include/obd_class.h |   4 -
 drivers/staging/lustre/lustre/obdclass/Makefile   |   2 +-
 drivers/staging/lustre/lustre/obdclass/mea.c      | 112 ----------------------
 3 files changed, 1 insertion(+), 117 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/mea.c

diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 4c64471..65143ab 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -2182,10 +2182,6 @@ int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
 void class_init_uuidlist(void);
 void class_exit_uuidlist(void);
 
-/* mea.c */
-int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen);
-int raw_name2idx(int hashtype, int count, const char *name, int namelen);
-
 /* class_obd.c */
 extern char obd_jobid_node[];
 
diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index 91a5a2b..f1dcf8e 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -5,5 +5,5 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
 	      genops.o uuid.o llog_ioctl.o lprocfs_status.o		   \
 	      lustre_handles.o lustre_peer.o llog_osd.o \
 	      local_storage.o statfs_pack.o obdo.o obd_config.o obd_mount.o\
-	      mea.o lu_object.o dt_object.o capa.o cl_object.o   \
+	      lu_object.o dt_object.o capa.o cl_object.o   \
 	      cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o
diff --git a/drivers/staging/lustre/lustre/obdclass/mea.c b/drivers/staging/lustre/lustre/obdclass/mea.c
deleted file mode 100644
index d6ce084..0000000
--- a/drivers/staging/lustre/lustre/obdclass/mea.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-
-#define DEBUG_SUBSYSTEM S_CLASS
-#include "../include/obd_class.h"
-#include <linux/kmod.h>   /* for request_module() */
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
-#include "../include/lprocfs_status.h"
-#include "../include/lustre/lustre_idl.h"
-
-static int mea_last_char_hash(int count, char *name, int namelen)
-{
-	unsigned int c;
-
-	c = name[namelen - 1];
-	if (c == 0)
-		CWARN("looks like wrong len is passed\n");
-	c = c % count;
-	return c;
-}
-
-static int mea_all_chars_hash(int count, char *name, int namelen)
-{
-	unsigned int c = 0;
-
-	while (--namelen >= 0)
-		c += name[namelen];
-	c = c % count;
-	return c;
-}
-
-int raw_name2idx(int hashtype, int count, const char *name, int namelen)
-{
-	unsigned int	c = 0;
-	int		idx;
-
-	LASSERT(namelen > 0);
-
-	if (filename_is_volatile(name, namelen, &idx)) {
-		if ((idx >= 0) && (idx < count))
-			return idx;
-		goto hashchoice;
-	}
-
-	if (count <= 1)
-		return 0;
-
-hashchoice:
-	switch (hashtype) {
-	case MEA_MAGIC_LAST_CHAR:
-		c = mea_last_char_hash(count, (char *)name, namelen);
-		break;
-	case MEA_MAGIC_ALL_CHARS:
-		c = mea_all_chars_hash(count, (char *)name, namelen);
-		break;
-	case MEA_MAGIC_HASH_SEGMENT:
-		CERROR("Unsupported hash type MEA_MAGIC_HASH_SEGMENT\n");
-		break;
-	default:
-		CERROR("Unknown hash type 0x%x\n", hashtype);
-	}
-
-	LASSERT(c < count);
-	return c;
-}
-EXPORT_SYMBOL(raw_name2idx);
-
-int mea_name2idx(struct lmv_stripe_md *mea, const char *name, int namelen)
-{
-	unsigned int c;
-
-	LASSERT(mea && mea->mea_count);
-
-	c = raw_name2idx(mea->mea_magic, mea->mea_count, name, namelen);
-
-	LASSERT(c < mea->mea_count);
-	return c;
-}
-EXPORT_SYMBOL(mea_name2idx);
-- 
1.9.3


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

* [PATCH 07/12] staging/lustre: remove md_object.h
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (5 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 06/12] staging/lustre/obdclass: remove mea.c Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 08/12] staging/lustre/mgc: remove server specific handlers Oleg Drokin
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Oleg Drokin

From: "John L. Hammond" <john.hammond@intel.com>

The declarations from lustre/include/md_object.h are not used so
remove them.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
---
 drivers/staging/lustre/lustre/fid/lproc_fid.c     |   1 -
 drivers/staging/lustre/lustre/fld/fld_cache.c     |   1 -
 drivers/staging/lustre/lustre/fld/fld_request.c   |   1 -
 drivers/staging/lustre/lustre/fld/lproc_fld.c     |   1 -
 drivers/staging/lustre/lustre/include/md_object.h | 899 ----------------------
 5 files changed, 903 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/include/md_object.h

diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index 92a27fa..c9fa676 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -48,7 +48,6 @@
 #include "../include/obd.h"
 #include "../include/obd_class.h"
 #include "../include/dt_object.h"
-#include "../include/md_object.h"
 #include "../include/obd_support.h"
 #include "../include/lustre_req_layout.h"
 #include "../include/lustre_fid.h"
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
index f5a340a..5d95d0b 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -54,7 +54,6 @@
 #include "../include/lprocfs_status.h"
 
 #include "../include/dt_object.h"
-#include "../include/md_object.h"
 #include "../include/lustre_req_layout.h"
 #include "../include/lustre_fld.h"
 #include "fld_internal.h"
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c
index f63c669..02454db 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -53,7 +53,6 @@
 #include "../include/lprocfs_status.h"
 
 #include "../include/dt_object.h"
-#include "../include/md_object.h"
 #include "../include/lustre_req_layout.h"
 #include "../include/lustre_fld.h"
 #include "../include/lustre_mdc.h"
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index 7f6bcc6..95e7de1 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -49,7 +49,6 @@
 #include "../include/obd.h"
 #include "../include/obd_class.h"
 #include "../include/dt_object.h"
-#include "../include/md_object.h"
 #include "../include/obd_support.h"
 #include "../include/lustre_req_layout.h"
 #include "../include/lustre_fld.h"
diff --git a/drivers/staging/lustre/lustre/include/md_object.h b/drivers/staging/lustre/lustre/include/md_object.h
deleted file mode 100644
index 454a230..0000000
--- a/drivers/staging/lustre/lustre/include/md_object.h
+++ /dev/null
@@ -1,899 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2011, 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/include/md_object.h
- *
- * Extension of lu_object.h for metadata objects
- */
-
-#ifndef _LUSTRE_MD_OBJECT_H
-#define _LUSTRE_MD_OBJECT_H
-
-/** \defgroup md md
- * Sub-class of lu_object with methods common for "meta-data" objects in MDT
- * stack.
- *
- * Meta-data objects implement namespace operations: you can link, unlink
- * them, and treat them as directories.
- *
- * Examples: mdt, cmm, and mdt are implementations of md interface.
- * @{
- */
-
-
-/*
- * super-class definitions.
- */
-#include "dt_object.h"
-
-struct md_device;
-struct md_device_operations;
-struct md_object;
-struct obd_export;
-
-enum {
-	UCRED_INVALID   = -1,
-	UCRED_INIT      = 0,
-	UCRED_OLD       = 1,
-	UCRED_NEW       = 2
-};
-
-enum {
-	MD_CAPAINFO_MAX = 5
-};
-
-/** there are at most 5 fids in one operation, see rename, NOTE the last one
- * is a temporary one used for is_subdir() */
-struct md_capainfo {
-	__u32		   mc_auth;
-	__u32		   mc_padding;
-	struct lu_fid	   mc_fid[MD_CAPAINFO_MAX];
-	struct lustre_capa     *mc_capa[MD_CAPAINFO_MAX];
-};
-
-struct md_quota {
-	struct obd_export       *mq_exp;
-};
-
-/**
- * Implemented in mdd/mdd_handler.c.
- *
- * XXX should be moved into separate .h/.c together with all md security
- * related definitions.
- */
-struct md_capainfo *md_capainfo(const struct lu_env *env);
-struct md_quota *md_quota(const struct lu_env *env);
-
-/** metadata attributes */
-enum ma_valid {
-	MA_INODE     = (1 << 0),
-	MA_LOV       = (1 << 1),
-	MA_COOKIE    = (1 << 2),
-	MA_FLAGS     = (1 << 3),
-	MA_LMV       = (1 << 4),
-	MA_ACL_DEF   = (1 << 5),
-	MA_LOV_DEF   = (1 << 6),
-	MA_LAY_GEN   = (1 << 7),
-	MA_HSM       = (1 << 8),
-	MA_SOM       = (1 << 9),
-	MA_PFID      = (1 << 10)
-};
-
-typedef enum {
-	MDL_MINMODE  = 0,
-	MDL_EX       = 1,
-	MDL_PW       = 2,
-	MDL_PR       = 4,
-	MDL_CW       = 8,
-	MDL_CR       = 16,
-	MDL_NL       = 32,
-	MDL_GROUP    = 64,
-	MDL_MAXMODE
-} mdl_mode_t;
-
-typedef enum {
-	MDT_NUL_LOCK = 0,
-	MDT_REG_LOCK = (1 << 0),
-	MDT_PDO_LOCK = (1 << 1)
-} mdl_type_t;
-
-/* memory structure for hsm attributes
- * for fields description see the on disk structure hsm_attrs
- * which is defined in lustre_idl.h
- */
-struct md_hsm {
-	__u32	mh_compat;
-	__u32	mh_flags;
-	__u64	mh_arch_id;
-	__u64	mh_arch_ver;
-};
-
-#define IOEPOCH_INVAL 0
-
-/* memory structure for som attributes
- * for fields description see the on disk structure som_attrs
- * which is defined in lustre_idl.h
- */
-struct md_som_data {
-	__u32	msd_compat;
-	__u32	msd_incompat;
-	__u64	msd_ioepoch;
-	__u64	msd_size;
-	__u64	msd_blocks;
-	__u64	msd_mountid;
-};
-
-struct md_attr {
-	__u64		   ma_valid;
-	__u64		   ma_need;
-	__u64		   ma_attr_flags;
-	struct lu_attr	  ma_attr;
-	struct lu_fid	   ma_pfid;
-	struct md_hsm	   ma_hsm;
-	struct lov_mds_md      *ma_lmm;
-	struct lmv_stripe_md   *ma_lmv;
-	void		   *ma_acl;
-	struct llog_cookie     *ma_cookie;
-	struct lustre_capa     *ma_capa;
-	struct md_som_data     *ma_som;
-	int		     ma_lmm_size;
-	int		     ma_lmv_size;
-	int		     ma_acl_size;
-	int		     ma_cookie_size;
-	__u16		   ma_layout_gen;
-};
-
-/** Additional parameters for create */
-struct md_op_spec {
-	union {
-		/** symlink target */
-		const char	       *sp_symname;
-		/** parent FID for cross-ref mkdir */
-		const struct lu_fid      *sp_pfid;
-		/** eadata for regular files */
-		struct md_spec_reg {
-			/** lov objs exist already */
-			const struct lu_fid   *fid;
-			const void *eadata;
-			int  eadatalen;
-		} sp_ea;
-	} u;
-
-	/** Create flag from client: such as MDS_OPEN_CREAT, and others. */
-	__u64      sp_cr_flags;
-
-	/** don't create lov objects or llog cookie - this replay */
-	unsigned int no_create:1,
-		     sp_cr_lookup:1, /* do lookup sanity check or not. */
-		     sp_rm_entry:1;  /* only remove name entry */
-
-	/** Current lock mode for parent dir where create is performing. */
-	mdl_mode_t sp_cr_mode;
-
-	/** to create directory */
-	const struct dt_index_features *sp_feat;
-};
-
-/**
- * Operations implemented for each md object (both directory and leaf).
- */
-struct md_object_operations {
-	int (*moo_permission)(const struct lu_env *env,
-			      struct md_object *pobj, struct md_object *cobj,
-			      struct md_attr *attr, int mask);
-
-	int (*moo_attr_get)(const struct lu_env *env, struct md_object *obj,
-			    struct md_attr *attr);
-
-	int (*moo_attr_set)(const struct lu_env *env, struct md_object *obj,
-			    const struct md_attr *attr);
-
-	int (*moo_xattr_get)(const struct lu_env *env, struct md_object *obj,
-			     struct lu_buf *buf, const char *name);
-
-	int (*moo_xattr_list)(const struct lu_env *env, struct md_object *obj,
-			      struct lu_buf *buf);
-
-	int (*moo_xattr_set)(const struct lu_env *env, struct md_object *obj,
-			     const struct lu_buf *buf, const char *name,
-			     int fl);
-
-	int (*moo_xattr_del)(const struct lu_env *env, struct md_object *obj,
-			     const char *name);
-
-	/** This method is used to swap the layouts between 2 objects */
-	int (*moo_swap_layouts)(const struct lu_env *env,
-			       struct md_object *obj1, struct md_object *obj2,
-			       __u64 flags);
-
-	/** \retval number of bytes actually read upon success */
-	int (*moo_readpage)(const struct lu_env *env, struct md_object *obj,
-			    const struct lu_rdpg *rdpg);
-
-	int (*moo_readlink)(const struct lu_env *env, struct md_object *obj,
-			    struct lu_buf *buf);
-	int (*moo_changelog)(const struct lu_env *env,
-			     enum changelog_rec_type type, int flags,
-			     struct md_object *obj);
-	/** part of cross-ref operation */
-	int (*moo_object_create)(const struct lu_env *env,
-				 struct md_object *obj,
-				 const struct md_op_spec *spec,
-				 struct md_attr *ma);
-
-	int (*moo_ref_add)(const struct lu_env *env,
-			   struct md_object *obj,
-			   const struct md_attr *ma);
-
-	int (*moo_ref_del)(const struct lu_env *env,
-			   struct md_object *obj,
-			   struct md_attr *ma);
-
-	int (*moo_open)(const struct lu_env *env,
-			struct md_object *obj, int flag);
-
-	int (*moo_close)(const struct lu_env *env, struct md_object *obj,
-			 struct md_attr *ma, int mode);
-
-	int (*moo_capa_get)(const struct lu_env *, struct md_object *,
-			    struct lustre_capa *, int renewal);
-
-	int (*moo_object_sync)(const struct lu_env *, struct md_object *);
-
-	int (*moo_file_lock)(const struct lu_env *env, struct md_object *obj,
-			     struct lov_mds_md *lmm, struct ldlm_extent *extent,
-			     struct lustre_handle *lockh);
-	int (*moo_file_unlock)(const struct lu_env *env, struct md_object *obj,
-			       struct lov_mds_md *lmm,
-			       struct lustre_handle *lockh);
-	int (*moo_object_lock)(const struct lu_env *env, struct md_object *obj,
-			       struct lustre_handle *lh,
-			       struct ldlm_enqueue_info *einfo,
-			       void *policy);
-};
-
-/**
- * Operations implemented for each directory object.
- */
-struct md_dir_operations {
-	int (*mdo_is_subdir) (const struct lu_env *env, struct md_object *obj,
-			      const struct lu_fid *fid, struct lu_fid *sfid);
-
-	int (*mdo_lookup)(const struct lu_env *env, struct md_object *obj,
-			  const struct lu_name *lname, struct lu_fid *fid,
-			  struct md_op_spec *spec);
-
-	mdl_mode_t (*mdo_lock_mode)(const struct lu_env *env,
-				    struct md_object *obj,
-				    mdl_mode_t mode);
-
-	int (*mdo_create)(const struct lu_env *env, struct md_object *pobj,
-			  const struct lu_name *lname, struct md_object *child,
-			  struct md_op_spec *spec,
-			  struct md_attr *ma);
-
-	/** This method is used for creating data object for this meta object*/
-	int (*mdo_create_data)(const struct lu_env *env, struct md_object *p,
-			       struct md_object *o,
-			       const struct md_op_spec *spec,
-			       struct md_attr *ma);
-
-	int (*mdo_rename)(const struct lu_env *env, struct md_object *spobj,
-			  struct md_object *tpobj, const struct lu_fid *lf,
-			  const struct lu_name *lsname, struct md_object *tobj,
-			  const struct lu_name *ltname, struct md_attr *ma);
-
-	int (*mdo_link)(const struct lu_env *env, struct md_object *tgt_obj,
-			struct md_object *src_obj, const struct lu_name *lname,
-			struct md_attr *ma);
-
-	int (*mdo_unlink)(const struct lu_env *env, struct md_object *pobj,
-			  struct md_object *cobj, const struct lu_name *lname,
-			  struct md_attr *ma, int no_name);
-
-	/** This method is used to compare a requested layout to an existing
-	 * layout (struct lov_mds_md_v1/3 vs struct lov_mds_md_v1/3) */
-	int (*mdo_lum_lmm_cmp)(const struct lu_env *env,
-			       struct md_object *cobj,
-			       const struct md_op_spec *spec,
-			       struct md_attr *ma);
-
-	/** partial ops for cross-ref case */
-	int (*mdo_name_insert)(const struct lu_env *env,
-			       struct md_object *obj,
-			       const struct lu_name *lname,
-			       const struct lu_fid *fid,
-			       const struct md_attr *ma);
-
-	int (*mdo_name_remove)(const struct lu_env *env,
-			       struct md_object *obj,
-			       const struct lu_name *lname,
-			       const struct md_attr *ma);
-
-	int (*mdo_rename_tgt)(const struct lu_env *env, struct md_object *pobj,
-			      struct md_object *tobj, const struct lu_fid *fid,
-			      const struct lu_name *lname, struct md_attr *ma);
-};
-
-struct md_device_operations {
-	/** meta-data device related handlers. */
-	int (*mdo_root_get)(const struct lu_env *env, struct md_device *m,
-			    struct lu_fid *f);
-
-	int (*mdo_maxeasize_get)(const struct lu_env *env, struct md_device *m,
-				int *easize);
-
-	int (*mdo_statfs)(const struct lu_env *env, struct md_device *m,
-			  struct obd_statfs *sfs);
-
-	int (*mdo_init_capa_ctxt)(const struct lu_env *env, struct md_device *m,
-				  int mode, unsigned long timeout, __u32 alg,
-				  struct lustre_capa_key *keys);
-
-	int (*mdo_update_capa_key)(const struct lu_env *env,
-				   struct md_device *m,
-				   struct lustre_capa_key *key);
-
-	int (*mdo_llog_ctxt_get)(const struct lu_env *env,
-				 struct md_device *m, int idx, void **h);
-
-	int (*mdo_iocontrol)(const struct lu_env *env, struct md_device *m,
-			     unsigned int cmd, int len, void *data);
-};
-
-enum md_upcall_event {
-	/** Sync the md layer*/
-	MD_LOV_SYNC = (1 << 0),
-	/** Just for split, no need trans, for replay */
-	MD_NO_TRANS = (1 << 1),
-	MD_LOV_CONFIG = (1 << 2),
-	/** Trigger quota recovery */
-	MD_LOV_QUOTA = (1 << 3)
-};
-
-struct md_upcall {
-	/** this lock protects upcall using against its removal
-	 * read lock is for usage the upcall, write - for init/fini */
-	struct rw_semaphore	mu_upcall_sem;
-	/** device to call, upper layer normally */
-	struct md_device       *mu_upcall_dev;
-	/** upcall function */
-	int (*mu_upcall)(const struct lu_env *env, struct md_device *md,
-			 enum md_upcall_event ev, void *data);
-};
-
-struct md_device {
-	struct lu_device		   md_lu_dev;
-	const struct md_device_operations *md_ops;
-	struct md_upcall		   md_upcall;
-};
-
-static inline void md_upcall_init(struct md_device *m, void *upcl)
-{
-	init_rwsem(&m->md_upcall.mu_upcall_sem);
-	m->md_upcall.mu_upcall_dev = NULL;
-	m->md_upcall.mu_upcall = upcl;
-}
-
-static inline void md_upcall_dev_set(struct md_device *m, struct md_device *up)
-{
-	down_write(&m->md_upcall.mu_upcall_sem);
-	m->md_upcall.mu_upcall_dev = up;
-	up_write(&m->md_upcall.mu_upcall_sem);
-}
-
-static inline void md_upcall_fini(struct md_device *m)
-{
-	down_write(&m->md_upcall.mu_upcall_sem);
-	m->md_upcall.mu_upcall_dev = NULL;
-	m->md_upcall.mu_upcall = NULL;
-	up_write(&m->md_upcall.mu_upcall_sem);
-}
-
-static inline int md_do_upcall(const struct lu_env *env, struct md_device *m,
-				enum md_upcall_event ev, void *data)
-{
-	int rc = 0;
-	down_read(&m->md_upcall.mu_upcall_sem);
-	if (m->md_upcall.mu_upcall_dev != NULL &&
-	    m->md_upcall.mu_upcall_dev->md_upcall.mu_upcall != NULL) {
-		rc = m->md_upcall.mu_upcall_dev->md_upcall.mu_upcall(env,
-					      m->md_upcall.mu_upcall_dev,
-					      ev, data);
-	}
-	up_read(&m->md_upcall.mu_upcall_sem);
-	return rc;
-}
-
-struct md_object {
-	struct lu_object		   mo_lu;
-	const struct md_object_operations *mo_ops;
-	const struct md_dir_operations    *mo_dir_ops;
-};
-
-/**
- * seq-server site.
- */
-struct seq_server_site {
-	struct lu_site	     *ss_lu;
-	/**
-	 * mds number of this site.
-	 */
-	u32		      ss_node_id;
-	/**
-	 * Fid location database
-	 */
-	struct lu_server_fld *ss_server_fld;
-	struct lu_client_fld *ss_client_fld;
-
-	/**
-	 * Server Seq Manager
-	 */
-	struct lu_server_seq *ss_server_seq;
-
-	/**
-	 * Controller Seq Manager
-	 */
-	struct lu_server_seq *ss_control_seq;
-	struct obd_export    *ss_control_exp;
-
-	/**
-	 * Client Seq Manager
-	 */
-	struct lu_client_seq *ss_client_seq;
-};
-
-static inline struct md_device *lu2md_dev(const struct lu_device *d)
-{
-	LASSERT(IS_ERR(d) || lu_device_is_md(d));
-	return container_of0(d, struct md_device, md_lu_dev);
-}
-
-static inline struct lu_device *md2lu_dev(struct md_device *d)
-{
-	return &d->md_lu_dev;
-}
-
-static inline struct md_object *lu2md(const struct lu_object *o)
-{
-	LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->lo_dev));
-	return container_of0(o, struct md_object, mo_lu);
-}
-
-static inline struct md_object *md_object_next(const struct md_object *obj)
-{
-	return (obj ? lu2md(lu_object_next(&obj->mo_lu)) : NULL);
-}
-
-static inline struct md_device *md_obj2dev(const struct md_object *o)
-{
-	LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->mo_lu.lo_dev));
-	return container_of0(o->mo_lu.lo_dev, struct md_device, md_lu_dev);
-}
-
-static inline int md_device_init(struct md_device *md, struct lu_device_type *t)
-{
-	return lu_device_init(&md->md_lu_dev, t);
-}
-
-static inline void md_device_fini(struct md_device *md)
-{
-	lu_device_fini(&md->md_lu_dev);
-}
-
-static inline struct md_object *md_object_find_slice(const struct lu_env *env,
-						     struct md_device *md,
-						     const struct lu_fid *f)
-{
-	return lu2md(lu_object_find_slice(env, md2lu_dev(md), f, NULL));
-}
-
-
-/** md operations */
-static inline int mo_permission(const struct lu_env *env,
-				struct md_object *p,
-				struct md_object *c,
-				struct md_attr *at,
-				int mask)
-{
-	LASSERT(c->mo_ops->moo_permission);
-	return c->mo_ops->moo_permission(env, p, c, at, mask);
-}
-
-static inline int mo_attr_get(const struct lu_env *env,
-			      struct md_object *m,
-			      struct md_attr *at)
-{
-	LASSERT(m->mo_ops->moo_attr_get);
-	return m->mo_ops->moo_attr_get(env, m, at);
-}
-
-static inline int mo_readlink(const struct lu_env *env,
-			      struct md_object *m,
-			      struct lu_buf *buf)
-{
-	LASSERT(m->mo_ops->moo_readlink);
-	return m->mo_ops->moo_readlink(env, m, buf);
-}
-
-static inline int mo_changelog(const struct lu_env *env,
-			       enum changelog_rec_type type,
-			       int flags, struct md_object *m)
-{
-	LASSERT(m->mo_ops->moo_changelog);
-	return m->mo_ops->moo_changelog(env, type, flags, m);
-}
-
-static inline int mo_attr_set(const struct lu_env *env,
-			      struct md_object *m,
-			      const struct md_attr *at)
-{
-	LASSERT(m->mo_ops->moo_attr_set);
-	return m->mo_ops->moo_attr_set(env, m, at);
-}
-
-static inline int mo_xattr_get(const struct lu_env *env,
-			       struct md_object *m,
-			       struct lu_buf *buf,
-			       const char *name)
-{
-	LASSERT(m->mo_ops->moo_xattr_get);
-	return m->mo_ops->moo_xattr_get(env, m, buf, name);
-}
-
-static inline int mo_xattr_del(const struct lu_env *env,
-			       struct md_object *m,
-			       const char *name)
-{
-	LASSERT(m->mo_ops->moo_xattr_del);
-	return m->mo_ops->moo_xattr_del(env, m, name);
-}
-
-static inline int mo_xattr_set(const struct lu_env *env,
-			       struct md_object *m,
-			       const struct lu_buf *buf,
-			       const char *name,
-			       int flags)
-{
-	LASSERT(m->mo_ops->moo_xattr_set);
-	return m->mo_ops->moo_xattr_set(env, m, buf, name, flags);
-}
-
-static inline int mo_xattr_list(const struct lu_env *env,
-				struct md_object *m,
-				struct lu_buf *buf)
-{
-	LASSERT(m->mo_ops->moo_xattr_list);
-	return m->mo_ops->moo_xattr_list(env, m, buf);
-}
-
-static inline int mo_swap_layouts(const struct lu_env *env,
-				  struct md_object *o1,
-				  struct md_object *o2, __u64 flags)
-{
-	LASSERT(o1->mo_ops->moo_swap_layouts);
-	LASSERT(o2->mo_ops->moo_swap_layouts);
-	if (o1->mo_ops->moo_swap_layouts != o2->mo_ops->moo_swap_layouts)
-		return -EPERM;
-	return o1->mo_ops->moo_swap_layouts(env, o1, o2, flags);
-}
-
-static inline int mo_open(const struct lu_env *env,
-			  struct md_object *m,
-			  int flags)
-{
-	LASSERT(m->mo_ops->moo_open);
-	return m->mo_ops->moo_open(env, m, flags);
-}
-
-static inline int mo_close(const struct lu_env *env,
-			   struct md_object *m,
-			   struct md_attr *ma,
-			   int mode)
-{
-	LASSERT(m->mo_ops->moo_close);
-	return m->mo_ops->moo_close(env, m, ma, mode);
-}
-
-static inline int mo_readpage(const struct lu_env *env,
-			      struct md_object *m,
-			      const struct lu_rdpg *rdpg)
-{
-	LASSERT(m->mo_ops->moo_readpage);
-	return m->mo_ops->moo_readpage(env, m, rdpg);
-}
-
-static inline int mo_object_create(const struct lu_env *env,
-				   struct md_object *m,
-				   const struct md_op_spec *spc,
-				   struct md_attr *at)
-{
-	LASSERT(m->mo_ops->moo_object_create);
-	return m->mo_ops->moo_object_create(env, m, spc, at);
-}
-
-static inline int mo_ref_add(const struct lu_env *env,
-			     struct md_object *m,
-			     const struct md_attr *ma)
-{
-	LASSERT(m->mo_ops->moo_ref_add);
-	return m->mo_ops->moo_ref_add(env, m, ma);
-}
-
-static inline int mo_ref_del(const struct lu_env *env,
-			     struct md_object *m,
-			     struct md_attr *ma)
-{
-	LASSERT(m->mo_ops->moo_ref_del);
-	return m->mo_ops->moo_ref_del(env, m, ma);
-}
-
-static inline int mo_capa_get(const struct lu_env *env,
-			      struct md_object *m,
-			      struct lustre_capa *c,
-			      int renewal)
-{
-	LASSERT(m->mo_ops->moo_capa_get);
-	return m->mo_ops->moo_capa_get(env, m, c, renewal);
-}
-
-static inline int mo_object_sync(const struct lu_env *env, struct md_object *m)
-{
-	LASSERT(m->mo_ops->moo_object_sync);
-	return m->mo_ops->moo_object_sync(env, m);
-}
-
-static inline int mo_file_lock(const struct lu_env *env, struct md_object *m,
-			       struct lov_mds_md *lmm,
-			       struct ldlm_extent *extent,
-			       struct lustre_handle *lockh)
-{
-	LASSERT(m->mo_ops->moo_file_lock);
-	return m->mo_ops->moo_file_lock(env, m, lmm, extent, lockh);
-}
-
-static inline int mo_file_unlock(const struct lu_env *env, struct md_object *m,
-				 struct lov_mds_md *lmm,
-				 struct lustre_handle *lockh)
-{
-	LASSERT(m->mo_ops->moo_file_unlock);
-	return m->mo_ops->moo_file_unlock(env, m, lmm, lockh);
-}
-
-static inline int mo_object_lock(const struct lu_env *env,
-				 struct md_object *m,
-				 struct lustre_handle *lh,
-				 struct ldlm_enqueue_info *einfo,
-				 void *policy)
-{
-	LASSERT(m->mo_ops->moo_object_lock);
-	return m->mo_ops->moo_object_lock(env, m, lh, einfo, policy);
-}
-
-static inline int mdo_lookup(const struct lu_env *env,
-			     struct md_object *p,
-			     const struct lu_name *lname,
-			     struct lu_fid *f,
-			     struct md_op_spec *spec)
-{
-	LASSERT(p->mo_dir_ops->mdo_lookup);
-	return p->mo_dir_ops->mdo_lookup(env, p, lname, f, spec);
-}
-
-static inline mdl_mode_t mdo_lock_mode(const struct lu_env *env,
-				       struct md_object *mo,
-				       mdl_mode_t lm)
-{
-	if (mo->mo_dir_ops->mdo_lock_mode == NULL)
-		return MDL_MINMODE;
-	return mo->mo_dir_ops->mdo_lock_mode(env, mo, lm);
-}
-
-static inline int mdo_create(const struct lu_env *env,
-			     struct md_object *p,
-			     const struct lu_name *lchild_name,
-			     struct md_object *c,
-			     struct md_op_spec *spc,
-			     struct md_attr *at)
-{
-	LASSERT(p->mo_dir_ops->mdo_create);
-	return p->mo_dir_ops->mdo_create(env, p, lchild_name, c, spc, at);
-}
-
-static inline int mdo_create_data(const struct lu_env *env,
-				  struct md_object *p,
-				  struct md_object *c,
-				  const struct md_op_spec *spec,
-				  struct md_attr *ma)
-{
-	LASSERT(c->mo_dir_ops->mdo_create_data);
-	return c->mo_dir_ops->mdo_create_data(env, p, c, spec, ma);
-}
-
-static inline int mdo_rename(const struct lu_env *env,
-			     struct md_object *sp,
-			     struct md_object *tp,
-			     const struct lu_fid *lf,
-			     const struct lu_name *lsname,
-			     struct md_object *t,
-			     const struct lu_name *ltname,
-			     struct md_attr *ma)
-{
-	LASSERT(tp->mo_dir_ops->mdo_rename);
-	return tp->mo_dir_ops->mdo_rename(env, sp, tp, lf, lsname, t, ltname,
-					  ma);
-}
-
-static inline int mdo_is_subdir(const struct lu_env *env,
-				struct md_object *mo,
-				const struct lu_fid *fid,
-				struct lu_fid *sfid)
-{
-	LASSERT(mo->mo_dir_ops->mdo_is_subdir);
-	return mo->mo_dir_ops->mdo_is_subdir(env, mo, fid, sfid);
-}
-
-static inline int mdo_link(const struct lu_env *env,
-			   struct md_object *p,
-			   struct md_object *s,
-			   const struct lu_name *lname,
-			   struct md_attr *ma)
-{
-	LASSERT(s->mo_dir_ops->mdo_link);
-	return s->mo_dir_ops->mdo_link(env, p, s, lname, ma);
-}
-
-static inline int mdo_unlink(const struct lu_env *env,
-			     struct md_object *p,
-			     struct md_object *c,
-			     const struct lu_name *lname,
-			     struct md_attr *ma, int no_name)
-{
-	LASSERT(p->mo_dir_ops->mdo_unlink);
-	return p->mo_dir_ops->mdo_unlink(env, p, c, lname, ma, no_name);
-}
-
-static inline int mdo_lum_lmm_cmp(const struct lu_env *env,
-				  struct md_object *c,
-				  const struct md_op_spec *spec,
-				  struct md_attr *ma)
-{
-	LASSERT(c->mo_dir_ops->mdo_lum_lmm_cmp);
-	return c->mo_dir_ops->mdo_lum_lmm_cmp(env, c, spec, ma);
-}
-
-static inline int mdo_name_insert(const struct lu_env *env,
-				  struct md_object *p,
-				  const struct lu_name *lname,
-				  const struct lu_fid *f,
-				  const struct md_attr *ma)
-{
-	LASSERT(p->mo_dir_ops->mdo_name_insert);
-	return p->mo_dir_ops->mdo_name_insert(env, p, lname, f, ma);
-}
-
-static inline int mdo_name_remove(const struct lu_env *env,
-				  struct md_object *p,
-				  const struct lu_name *lname,
-				  const struct md_attr *ma)
-{
-	LASSERT(p->mo_dir_ops->mdo_name_remove);
-	return p->mo_dir_ops->mdo_name_remove(env, p, lname, ma);
-}
-
-static inline int mdo_rename_tgt(const struct lu_env *env,
-				 struct md_object *p,
-				 struct md_object *t,
-				 const struct lu_fid *lf,
-				 const struct lu_name *lname,
-				 struct md_attr *ma)
-{
-	if (t) {
-		LASSERT(t->mo_dir_ops->mdo_rename_tgt);
-		return t->mo_dir_ops->mdo_rename_tgt(env, p, t, lf, lname, ma);
-	} else {
-		LASSERT(p->mo_dir_ops->mdo_rename_tgt);
-		return p->mo_dir_ops->mdo_rename_tgt(env, p, t, lf, lname, ma);
-	}
-}
-
-/**
- * Used in MDD/OUT layer for object lock rule
- **/
-enum mdd_object_role {
-	MOR_SRC_PARENT,
-	MOR_SRC_CHILD,
-	MOR_TGT_PARENT,
-	MOR_TGT_CHILD,
-	MOR_TGT_ORPHAN
-};
-
-struct dt_device;
-/**
- * Structure to hold object information. This is used to create object
- * \pre llod_dir exist
- */
-struct lu_local_obj_desc {
-	const char		      *llod_dir;
-	const char		      *llod_name;
-	__u32			    llod_oid;
-	int			      llod_is_index;
-	const struct dt_index_features  *llod_feat;
-	struct list_head		       llod_linkage;
-};
-
-struct lu_ucred {
-	__u32	       uc_valid;
-	__u32	       uc_o_uid;
-	__u32	       uc_o_gid;
-	__u32	       uc_o_fsuid;
-	__u32	       uc_o_fsgid;
-	__u32	       uc_uid;
-	__u32	       uc_gid;
-	__u32	       uc_fsuid;
-	__u32	       uc_fsgid;
-	__u32	       uc_suppgids[2];
-	cfs_cap_t	   uc_cap;
-	__u32	       uc_umask;
-	struct group_info *uc_ginfo;
-	struct md_identity *uc_identity;
-};
-
-struct lu_ucred *lu_ucred(const struct lu_env *env);
-
-struct lu_ucred *lu_ucred_check(const struct lu_env *env);
-
-struct lu_ucred *lu_ucred_assert(const struct lu_env *env);
-
-int lu_ucred_global_init(void);
-
-void lu_ucred_global_fini(void);
-
-#define md_cap_t(x) (x)
-
-#define MD_CAP_TO_MASK(x) (1 << (x))
-
-#define md_cap_raised(c, flag) (md_cap_t(c) & MD_CAP_TO_MASK(flag))
-
-/* capable() is copied from linux kernel! */
-static inline int md_capable(struct lu_ucred *uc, cfs_cap_t cap)
-{
-	if (md_cap_raised(uc->uc_cap, cap))
-		return 1;
-	return 0;
-}
-
-/** @} md */
-#endif /* _LINUX_MD_OBJECT_H */
-- 
1.9.3


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

* [PATCH 08/12] staging/lustre/mgc: remove server specific handlers
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (6 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 07/12] staging/lustre: remove md_object.h Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 09/12] staging/lustre/obdclass: remove llog_test.ko Oleg Drokin
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Oleg Drokin

From: "John L. Hammond" <john.hammond@intel.com>

Remove the server specific set_info handlers (KEY_REGISTER_TARGET,
KEY_SET_FS, KEY_CLEAR_FS) and supporting functions.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 177 ------------------------
 1 file changed, 177 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index b21a135..970e91c 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -47,7 +47,6 @@
 #include "../include/lprocfs_status.h"
 #include "../include/lustre_log.h"
 #include "../include/lustre_disk.h"
-#include "../include/dt_object.h"
 
 #include "mgc_internal.h"
 
@@ -628,150 +627,6 @@ static void mgc_requeue_add(struct config_llog_data *cld)
 	}
 }
 
-/********************** class fns **********************/
-static int mgc_local_llog_init(const struct lu_env *env,
-			       struct obd_device *obd,
-			       struct obd_device *disk)
-{
-	struct llog_ctxt	*ctxt;
-	int			 rc;
-
-	rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CONFIG_ORIG_CTXT, disk,
-			&llog_osd_ops);
-	if (rc)
-		return rc;
-
-	ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
-	LASSERT(ctxt);
-	ctxt->loc_dir = obd->u.cli.cl_mgc_configs_dir;
-	llog_ctxt_put(ctxt);
-
-	return 0;
-}
-
-static int mgc_local_llog_fini(const struct lu_env *env,
-			       struct obd_device *obd)
-{
-	struct llog_ctxt *ctxt;
-
-	ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
-	llog_cleanup(env, ctxt);
-
-	return 0;
-}
-
-static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb)
-{
-	struct lustre_sb_info	*lsi = s2lsi(sb);
-	struct client_obd	*cli = &obd->u.cli;
-	struct lu_fid		 rfid, fid;
-	struct dt_object	*root, *dto;
-	struct lu_env		*env;
-	int			 rc = 0;
-
-	LASSERT(lsi);
-	LASSERT(lsi->lsi_dt_dev);
-
-	OBD_ALLOC_PTR(env);
-	if (env == NULL)
-		return -ENOMEM;
-
-	/* The mgc fs exclusion mutex. Only one fs can be setup at a time. */
-	mutex_lock(&cli->cl_mgc_mutex);
-
-	cfs_cleanup_group_info();
-
-	/* Setup the configs dir */
-	rc = lu_env_init(env, LCT_MG_THREAD);
-	if (rc)
-		goto out_err;
-
-	fid.f_seq = FID_SEQ_LOCAL_NAME;
-	fid.f_oid = 1;
-	fid.f_ver = 0;
-	rc = local_oid_storage_init(env, lsi->lsi_dt_dev, &fid,
-				    &cli->cl_mgc_los);
-	if (rc)
-		goto out_env;
-
-	rc = dt_root_get(env, lsi->lsi_dt_dev, &rfid);
-	if (rc)
-		goto out_env;
-
-	root = dt_locate_at(env, lsi->lsi_dt_dev, &rfid,
-			    &cli->cl_mgc_los->los_dev->dd_lu_dev);
-	if (unlikely(IS_ERR(root))) {
-		rc = PTR_ERR(root);
-		goto out_los;
-	}
-
-	dto = local_file_find_or_create(env, cli->cl_mgc_los, root,
-					MOUNT_CONFIGS_DIR,
-					S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO);
-	lu_object_put_nocache(env, &root->do_lu);
-	if (IS_ERR(dto)) {
-		rc = PTR_ERR(dto);
-		goto out_los;
-	}
-
-	cli->cl_mgc_configs_dir = dto;
-
-	LASSERT(lsi->lsi_osd_exp->exp_obd->obd_lvfs_ctxt.dt);
-	rc = mgc_local_llog_init(env, obd, lsi->lsi_osd_exp->exp_obd);
-	if (rc)
-		goto out_llog;
-
-	/* We take an obd ref to insure that we can't get to mgc_cleanup
-	 * without calling mgc_fs_cleanup first. */
-	class_incref(obd, "mgc_fs", obd);
-
-	/* We keep the cl_mgc_sem until mgc_fs_cleanup */
-out_llog:
-	if (rc) {
-		lu_object_put(env, &cli->cl_mgc_configs_dir->do_lu);
-		cli->cl_mgc_configs_dir = NULL;
-	}
-out_los:
-	if (rc < 0) {
-		local_oid_storage_fini(env, cli->cl_mgc_los);
-		cli->cl_mgc_los = NULL;
-		mutex_unlock(&cli->cl_mgc_mutex);
-	}
-out_env:
-	lu_env_fini(env);
-out_err:
-	OBD_FREE_PTR(env);
-	return rc;
-}
-
-static int mgc_fs_cleanup(struct obd_device *obd)
-{
-	struct lu_env		 env;
-	struct client_obd	*cli = &obd->u.cli;
-	int			 rc;
-
-	LASSERT(cli->cl_mgc_los != NULL);
-
-	rc = lu_env_init(&env, LCT_MG_THREAD);
-	if (rc)
-		goto unlock;
-
-	mgc_local_llog_fini(&env, obd);
-
-	lu_object_put_nocache(&env, &cli->cl_mgc_configs_dir->do_lu);
-	cli->cl_mgc_configs_dir = NULL;
-
-	local_oid_storage_fini(&env, cli->cl_mgc_los);
-	cli->cl_mgc_los = NULL;
-	lu_env_fini(&env);
-
-unlock:
-	class_decref(obd, "mgc_fs", obd);
-	mutex_unlock(&cli->cl_mgc_mutex);
-
-	return 0;
-}
-
 static int mgc_llog_init(const struct lu_env *env, struct obd_device *obd)
 {
 	struct llog_ctxt	*ctxt;
@@ -1131,38 +986,6 @@ int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
 			ptlrpc_reconnect_import(imp);
 		return 0;
 	}
-	/* FIXME move this to mgc_process_config */
-	if (KEY_IS(KEY_REGISTER_TARGET)) {
-		struct mgs_target_info *mti;
-		if (vallen != sizeof(struct mgs_target_info))
-			return -EINVAL;
-		mti = (struct mgs_target_info *)val;
-		CDEBUG(D_MGC, "register_target %s %#x\n",
-		       mti->mti_svname, mti->mti_flags);
-		rc =  mgc_target_register(exp, mti);
-		return rc;
-	}
-	if (KEY_IS(KEY_SET_FS)) {
-		struct super_block *sb = (struct super_block *)val;
-
-		if (vallen != sizeof(struct super_block))
-			return -EINVAL;
-
-		rc = mgc_fs_setup(exp->exp_obd, sb);
-		if (rc)
-			CERROR("set_fs got %d\n", rc);
-
-		return rc;
-	}
-	if (KEY_IS(KEY_CLEAR_FS)) {
-		if (vallen != 0)
-			return -EINVAL;
-		rc = mgc_fs_cleanup(exp->exp_obd);
-		if (rc)
-			CERROR("clear_fs got %d\n", rc);
-
-		return rc;
-	}
 	if (KEY_IS(KEY_SET_INFO)) {
 		struct mgs_send_param *msp;
 
-- 
1.9.3


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

* [PATCH 09/12] staging/lustre/obdclass: remove llog_test.ko
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (7 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 08/12] staging/lustre/mgc: remove server specific handlers Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 10/12] staging/lustre/obdclass: remove llog_osd.c Oleg Drokin
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger; +Cc: John L. Hammond

From: "John L. Hammond" <john.hammond@intel.com>

The llog_test module requires server support (it needs a local MGS to
function) and should not have been included.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
---
 drivers/staging/lustre/lustre/obdclass/Makefile    |    2 +-
 drivers/staging/lustre/lustre/obdclass/llog_test.c | 1072 --------------------
 2 files changed, 1 insertion(+), 1073 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/llog_test.c

diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index f1dcf8e..9a2b83f 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -1,4 +1,4 @@
-obj-$(CONFIG_LUSTRE_FS) += obdclass.o llog_test.o
+obj-$(CONFIG_LUSTRE_FS) += obdclass.o
 
 obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
 	      llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_test.c b/drivers/staging/lustre/lustre/obdclass/llog_test.c
deleted file mode 100644
index ef008ab..0000000
--- a/drivers/staging/lustre/lustre/obdclass/llog_test.c
+++ /dev/null
@@ -1,1072 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/obdclass/llog_test.c
- *
- * Author: Phil Schwan <phil@clusterfs.com>
- * Author: Mikhail Pershin <mike.pershin@intel.com>
- */
-
-#define DEBUG_SUBSYSTEM S_CLASS
-
-#include <linux/module.h>
-#include <linux/init.h>
-
-#include "../include/obd_class.h"
-#include "../include/lustre_fid.h"
-#include "../include/lustre_log.h"
-
-/* This is slightly more than the number of records that can fit into a
- * single llog file, because the llog_log_header takes up some of the
- * space in the first block that cannot be used for the bitmap. */
-#define LLOG_TEST_RECNUM  (LLOG_CHUNK_SIZE * 8)
-
-static int llog_test_rand;
-static struct obd_uuid uuid = { .uuid = "test_uuid" };
-static struct llog_logid cat_logid;
-
-struct llog_mini_rec {
-	struct llog_rec_hdr     lmr_hdr;
-	struct llog_rec_tail    lmr_tail;
-} __attribute__((packed));
-
-static int verify_handle(char *test, struct llog_handle *llh, int num_recs)
-{
-	int i;
-	int last_idx = 0;
-	int active_recs = 0;
-
-	for (i = 0; i < LLOG_BITMAP_BYTES * 8; i++) {
-		if (ext2_test_bit(i, llh->lgh_hdr->llh_bitmap)) {
-			last_idx = i;
-			active_recs++;
-		}
-	}
-
-	if (active_recs != num_recs) {
-		CERROR("%s: expected %d active recs after write, found %d\n",
-		       test, num_recs, active_recs);
-		return -ERANGE;
-	}
-
-	if (llh->lgh_hdr->llh_count != num_recs) {
-		CERROR("%s: handle->count is %d, expected %d after write\n",
-		       test, llh->lgh_hdr->llh_count, num_recs);
-		return -ERANGE;
-	}
-
-	if (llh->lgh_last_idx < last_idx) {
-		CERROR("%s: handle->last_idx is %d, expected %d after write\n",
-		       test, llh->lgh_last_idx, last_idx);
-		return -ERANGE;
-	}
-
-	return 0;
-}
-
-/* Test named-log create/open, close */
-static int llog_test_1(const struct lu_env *env,
-		       struct obd_device *obd, char *name)
-{
-	struct llog_handle	*llh;
-	struct llog_ctxt	*ctxt;
-	int rc;
-	int rc2;
-
-	CWARN("1a: create a log with name: %s\n", name);
-	ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
-	LASSERT(ctxt);
-
-	rc = llog_open_create(env, ctxt, &llh, NULL, name);
-	if (rc) {
-		CERROR("1a: llog_create with name %s failed: %d\n", name, rc);
-		GOTO(out, rc);
-	}
-	rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, &uuid);
-	if (rc) {
-		CERROR("1a: can't init llog handle: %d\n", rc);
-		GOTO(out_close, rc);
-	}
-
-	rc = verify_handle("1", llh, 1);
-
-	CWARN("1b: close newly-created log\n");
-out_close:
-	rc2 = llog_close(env, llh);
-	if (rc2) {
-		CERROR("1b: close log %s failed: %d\n", name, rc2);
-		if (rc == 0)
-			rc = rc2;
-	}
-out:
-	llog_ctxt_put(ctxt);
-	return rc;
-}
-
-/* Test named-log reopen; returns opened log on success */
-static int llog_test_2(const struct lu_env *env, struct obd_device *obd,
-		       char *name, struct llog_handle **llh)
-{
-	struct llog_ctxt	*ctxt;
-	struct llog_handle	*loghandle;
-	struct llog_logid	 logid;
-	int			 rc;
-
-	CWARN("2a: re-open a log with name: %s\n", name);
-	ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
-	LASSERT(ctxt);
-
-	rc = llog_open(env, ctxt, llh, NULL, name, LLOG_OPEN_EXISTS);
-	if (rc) {
-		CERROR("2a: re-open log with name %s failed: %d\n", name, rc);
-		GOTO(out_put, rc);
-	}
-
-	rc = llog_init_handle(env, *llh, LLOG_F_IS_PLAIN, &uuid);
-	if (rc) {
-		CERROR("2a: can't init llog handle: %d\n", rc);
-		GOTO(out_close_llh, rc);
-	}
-
-	rc = verify_handle("2", *llh, 1);
-	if (rc)
-		GOTO(out_close_llh, rc);
-
-	/* XXX: there is known issue with tests 2b, MGS is not able to create
-	 * anonymous llog, exit now to allow following tests run.
-	 * It is fixed in upcoming llog over OSD code */
-	GOTO(out_put, rc);
-
-	CWARN("2b: create a log without specified NAME & LOGID\n");
-	rc = llog_open_create(env, ctxt, &loghandle, NULL, NULL);
-	if (rc) {
-		CERROR("2b: create log failed\n");
-		GOTO(out_close_llh, rc);
-	}
-	rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, &uuid);
-	if (rc) {
-		CERROR("2b: can't init llog handle: %d\n", rc);
-		GOTO(out_close, rc);
-	}
-
-	logid = loghandle->lgh_id;
-	llog_close(env, loghandle);
-
-	CWARN("2c: re-open the log by LOGID\n");
-	rc = llog_open(env, ctxt, &loghandle, &logid, NULL, LLOG_OPEN_EXISTS);
-	if (rc) {
-		CERROR("2c: re-open log by LOGID failed\n");
-		GOTO(out_close_llh, rc);
-	}
-
-	rc = llog_init_handle(env, loghandle, LLOG_F_IS_PLAIN, &uuid);
-	if (rc) {
-		CERROR("2c: can't init llog handle: %d\n", rc);
-		GOTO(out_close, rc);
-	}
-
-	CWARN("2b: destroy this log\n");
-	rc = llog_destroy(env, loghandle);
-	if (rc)
-		CERROR("2d: destroy log failed\n");
-out_close:
-	llog_close(env, loghandle);
-out_close_llh:
-	if (rc)
-		llog_close(env, *llh);
-out_put:
-	llog_ctxt_put(ctxt);
-
-	return rc;
-}
-
-/* Test record writing, single and in bulk */
-static int llog_test_3(const struct lu_env *env, struct obd_device *obd,
-		       struct llog_handle *llh)
-{
-	struct llog_gen_rec	 lgr;
-	int			 rc, i;
-	int			 num_recs = 1; /* 1 for the header */
-
-	lgr.lgr_hdr.lrh_len = lgr.lgr_tail.lrt_len = sizeof(lgr);
-	lgr.lgr_hdr.lrh_type = LLOG_GEN_REC;
-
-	CWARN("3a: write one create_rec\n");
-	rc = llog_write(env, llh,  &lgr.lgr_hdr, NULL, 0, NULL, -1);
-	num_recs++;
-	if (rc < 0) {
-		CERROR("3a: write one log record failed: %d\n", rc);
-		return rc;
-	}
-
-	rc = verify_handle("3a", llh, num_recs);
-	if (rc)
-		return rc;
-
-	CWARN("3b: write 10 cfg log records with 8 bytes bufs\n");
-	for (i = 0; i < 10; i++) {
-		struct llog_rec_hdr	hdr;
-		char			buf[8];
-
-		hdr.lrh_len = 8;
-		hdr.lrh_type = OBD_CFG_REC;
-		memset(buf, 0, sizeof(buf));
-		rc = llog_write(env, llh, &hdr, NULL, 0, buf, -1);
-		if (rc < 0) {
-			CERROR("3b: write 10 records failed at #%d: %d\n",
-			       i + 1, rc);
-			return rc;
-		}
-		num_recs++;
-	}
-
-	rc = verify_handle("3b", llh, num_recs);
-	if (rc)
-		return rc;
-
-	CWARN("3c: write 1000 more log records\n");
-	for (i = 0; i < 1000; i++) {
-		rc = llog_write(env, llh, &lgr.lgr_hdr, NULL, 0, NULL, -1);
-		if (rc < 0) {
-			CERROR("3c: write 1000 records failed at #%d: %d\n",
-			       i + 1, rc);
-			return rc;
-		}
-		num_recs++;
-	}
-
-	rc = verify_handle("3c", llh, num_recs);
-	if (rc)
-		return rc;
-
-	CWARN("3d: write log more than BITMAP_SIZE, return -ENOSPC\n");
-	for (i = 0; i < LLOG_BITMAP_SIZE(llh->lgh_hdr) + 1; i++) {
-		struct llog_rec_hdr	hdr;
-		char			buf_even[24];
-		char			buf_odd[32];
-
-		memset(buf_odd, 0, sizeof(buf_odd));
-		memset(buf_even, 0, sizeof(buf_even));
-		if ((i % 2) == 0) {
-			hdr.lrh_len = 24;
-			hdr.lrh_type = OBD_CFG_REC;
-			rc = llog_write(env, llh, &hdr, NULL, 0, buf_even, -1);
-		} else {
-			hdr.lrh_len = 32;
-			hdr.lrh_type = OBD_CFG_REC;
-			rc = llog_write(env, llh, &hdr, NULL, 0, buf_odd, -1);
-		}
-		if (rc == -ENOSPC) {
-			break;
-		} else if (rc < 0) {
-			CERROR("3d: write recs failed at #%d: %d\n",
-			       i + 1, rc);
-			return rc;
-		}
-		num_recs++;
-	}
-	if (rc != -ENOSPC) {
-		CWARN("3d: write record more than BITMAP size!\n");
-		return -EINVAL;
-	}
-	CWARN("3d: wrote %d more records before end of llog is reached\n",
-	      num_recs);
-
-	rc = verify_handle("3d", llh, num_recs);
-
-	return rc;
-}
-
-/* Test catalogue additions */
-static int llog_test_4(const struct lu_env *env, struct obd_device *obd)
-{
-	struct llog_handle	*cath;
-	char			 name[10];
-	int			 rc, rc2, i, buflen;
-	struct llog_mini_rec	 lmr;
-	struct llog_cookie	 cookie;
-	struct llog_ctxt	*ctxt;
-	int			 num_recs = 0;
-	char			*buf;
-	struct llog_rec_hdr	 rec;
-
-	ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
-	LASSERT(ctxt);
-
-	lmr.lmr_hdr.lrh_len = lmr.lmr_tail.lrt_len = LLOG_MIN_REC_SIZE;
-	lmr.lmr_hdr.lrh_type = 0xf00f00;
-
-	sprintf(name, "%x", llog_test_rand + 1);
-	CWARN("4a: create a catalog log with name: %s\n", name);
-	rc = llog_open_create(env, ctxt, &cath, NULL, name);
-	if (rc) {
-		CERROR("4a: llog_create with name %s failed: %d\n", name, rc);
-		GOTO(ctxt_release, rc);
-	}
-	rc = llog_init_handle(env, cath, LLOG_F_IS_CAT, &uuid);
-	if (rc) {
-		CERROR("4a: can't init llog handle: %d\n", rc);
-		GOTO(out, rc);
-	}
-
-	num_recs++;
-	cat_logid = cath->lgh_id;
-
-	CWARN("4b: write 1 record into the catalog\n");
-	rc = llog_cat_add(env, cath, &lmr.lmr_hdr, &cookie, NULL);
-	if (rc != 1) {
-		CERROR("4b: write 1 catalog record failed at: %d\n", rc);
-		GOTO(out, rc);
-	}
-	num_recs++;
-	rc = verify_handle("4b", cath, 2);
-	if (rc)
-		GOTO(out, rc);
-
-	rc = verify_handle("4b", cath->u.chd.chd_current_log, num_recs);
-	if (rc)
-		GOTO(out, rc);
-
-	CWARN("4c: cancel 1 log record\n");
-	rc = llog_cat_cancel_records(env, cath, 1, &cookie);
-	if (rc) {
-		CERROR("4c: cancel 1 catalog based record failed: %d\n", rc);
-		GOTO(out, rc);
-	}
-	num_recs--;
-
-	rc = verify_handle("4c", cath->u.chd.chd_current_log, num_recs);
-	if (rc)
-		GOTO(out, rc);
-
-	CWARN("4d: write %d more log records\n", LLOG_TEST_RECNUM);
-	for (i = 0; i < LLOG_TEST_RECNUM; i++) {
-		rc = llog_cat_add(env, cath, &lmr.lmr_hdr, NULL, NULL);
-		if (rc) {
-			CERROR("4d: write %d records failed at #%d: %d\n",
-			       LLOG_TEST_RECNUM, i + 1, rc);
-			GOTO(out, rc);
-		}
-		num_recs++;
-	}
-
-	/* make sure new plain llog appears */
-	rc = verify_handle("4d", cath, 3);
-	if (rc)
-		GOTO(out, rc);
-
-	CWARN("4e: add 5 large records, one record per block\n");
-	buflen = LLOG_CHUNK_SIZE - sizeof(struct llog_rec_hdr) -
-		 sizeof(struct llog_rec_tail);
-	OBD_ALLOC(buf, buflen);
-	if (buf == NULL)
-		GOTO(out, rc = -ENOMEM);
-	for (i = 0; i < 5; i++) {
-		rec.lrh_len = buflen;
-		rec.lrh_type = OBD_CFG_REC;
-		rc = llog_cat_add(env, cath, &rec, NULL, buf);
-		if (rc) {
-			CERROR("4e: write 5 records failed at #%d: %d\n",
-			       i + 1, rc);
-			GOTO(out_free, rc);
-		}
-		num_recs++;
-	}
-out_free:
-	OBD_FREE(buf, buflen);
-out:
-	CWARN("4f: put newly-created catalog\n");
-	rc2 = llog_cat_close(env, cath);
-	if (rc2) {
-		CERROR("4: close log %s failed: %d\n", name, rc2);
-		if (rc == 0)
-			rc = rc2;
-	}
-ctxt_release:
-	llog_ctxt_put(ctxt);
-	return rc;
-}
-
-static int cat_counter;
-
-static int cat_print_cb(const struct lu_env *env, struct llog_handle *llh,
-			struct llog_rec_hdr *rec, void *data)
-{
-	struct llog_logid_rec	*lir = (struct llog_logid_rec *)rec;
-	struct lu_fid		 fid = {0};
-
-	if (rec->lrh_type != LLOG_LOGID_MAGIC) {
-		CERROR("invalid record in catalog\n");
-		return -EINVAL;
-	}
-
-	logid_to_fid(&lir->lid_id, &fid);
-
-	CWARN("seeing record at index %d - "DFID" in log "DFID"\n",
-	      rec->lrh_index, PFID(&fid),
-	      PFID(lu_object_fid(&llh->lgh_obj->do_lu)));
-
-	cat_counter++;
-
-	return 0;
-}
-
-static int plain_counter;
-
-static int plain_print_cb(const struct lu_env *env, struct llog_handle *llh,
-			  struct llog_rec_hdr *rec, void *data)
-{
-	struct lu_fid fid = {0};
-
-	if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) {
-		CERROR("log is not plain\n");
-		return -EINVAL;
-	}
-
-	logid_to_fid(&llh->lgh_id, &fid);
-
-	CDEBUG(D_INFO, "seeing record at index %d in log "DFID"\n",
-	       rec->lrh_index, PFID(&fid));
-
-	plain_counter++;
-
-	return 0;
-}
-
-static int cancel_count;
-
-static int llog_cancel_rec_cb(const struct lu_env *env,
-			      struct llog_handle *llh,
-			      struct llog_rec_hdr *rec, void *data)
-{
-	struct llog_cookie cookie;
-
-	if (!(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN)) {
-		CERROR("log is not plain\n");
-		return -EINVAL;
-	}
-
-	cookie.lgc_lgl = llh->lgh_id;
-	cookie.lgc_index = rec->lrh_index;
-
-	llog_cat_cancel_records(env, llh->u.phd.phd_cat_handle, 1, &cookie);
-	cancel_count++;
-	if (cancel_count == LLOG_TEST_RECNUM)
-		return -LLOG_EEMPTY;
-	return 0;
-}
-
-/* Test log and catalogue processing */
-static int llog_test_5(const struct lu_env *env, struct obd_device *obd)
-{
-	struct llog_handle	*llh = NULL;
-	char			 name[10];
-	int			 rc, rc2;
-	struct llog_mini_rec	 lmr;
-	struct llog_ctxt	*ctxt;
-
-	ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
-	LASSERT(ctxt);
-
-	lmr.lmr_hdr.lrh_len = lmr.lmr_tail.lrt_len = LLOG_MIN_REC_SIZE;
-	lmr.lmr_hdr.lrh_type = 0xf00f00;
-
-	CWARN("5a: re-open catalog by id\n");
-	rc = llog_open(env, ctxt, &llh, &cat_logid, NULL, LLOG_OPEN_EXISTS);
-	if (rc) {
-		CERROR("5a: llog_create with logid failed: %d\n", rc);
-		GOTO(out_put, rc);
-	}
-
-	rc = llog_init_handle(env, llh, LLOG_F_IS_CAT, &uuid);
-	if (rc) {
-		CERROR("5a: can't init llog handle: %d\n", rc);
-		GOTO(out, rc);
-	}
-
-	CWARN("5b: print the catalog entries.. we expect 2\n");
-	cat_counter = 0;
-	rc = llog_process(env, llh, cat_print_cb, "test 5", NULL);
-	if (rc) {
-		CERROR("5b: process with cat_print_cb failed: %d\n", rc);
-		GOTO(out, rc);
-	}
-	if (cat_counter != 2) {
-		CERROR("5b: %d entries in catalog\n", cat_counter);
-		GOTO(out, rc = -EINVAL);
-	}
-
-	CWARN("5c: Cancel %d records, see one log zapped\n", LLOG_TEST_RECNUM);
-	cancel_count = 0;
-	rc = llog_cat_process(env, llh, llog_cancel_rec_cb, "foobar", 0, 0);
-	if (rc != -LLOG_EEMPTY) {
-		CERROR("5c: process with cat_cancel_cb failed: %d\n", rc);
-		GOTO(out, rc);
-	}
-
-	CWARN("5c: print the catalog entries.. we expect 1\n");
-	cat_counter = 0;
-	rc = llog_process(env, llh, cat_print_cb, "test 5", NULL);
-	if (rc) {
-		CERROR("5c: process with cat_print_cb failed: %d\n", rc);
-		GOTO(out, rc);
-	}
-	if (cat_counter != 1) {
-		CERROR("5c: %d entries in catalog\n", cat_counter);
-		GOTO(out, rc = -EINVAL);
-	}
-
-	CWARN("5d: add 1 record to the log with many canceled empty pages\n");
-	rc = llog_cat_add(env, llh, &lmr.lmr_hdr, NULL, NULL);
-	if (rc) {
-		CERROR("5d: add record to the log with many canceled empty "
-		       "pages failed\n");
-		GOTO(out, rc);
-	}
-
-	CWARN("5e: print plain log entries.. expect 6\n");
-	plain_counter = 0;
-	rc = llog_cat_process(env, llh, plain_print_cb, "foobar", 0, 0);
-	if (rc) {
-		CERROR("5e: process with plain_print_cb failed: %d\n", rc);
-		GOTO(out, rc);
-	}
-	if (plain_counter != 6) {
-		CERROR("5e: found %d records\n", plain_counter);
-		GOTO(out, rc = -EINVAL);
-	}
-
-	CWARN("5f: print plain log entries reversely.. expect 6\n");
-	plain_counter = 0;
-	rc = llog_cat_reverse_process(env, llh, plain_print_cb, "foobar");
-	if (rc) {
-		CERROR("5f: reversely process with plain_print_cb failed:"
-		       "%d\n", rc);
-		GOTO(out, rc);
-	}
-	if (plain_counter != 6) {
-		CERROR("5f: found %d records\n", plain_counter);
-		GOTO(out, rc = -EINVAL);
-	}
-
-out:
-	CWARN("5g: close re-opened catalog\n");
-	rc2 = llog_cat_close(env, llh);
-	if (rc2) {
-		CERROR("5g: close log %s failed: %d\n", name, rc2);
-		if (rc == 0)
-			rc = rc2;
-	}
-out_put:
-	llog_ctxt_put(ctxt);
-
-	return rc;
-}
-
-/* Test client api; open log by name and process */
-static int llog_test_6(const struct lu_env *env, struct obd_device *obd,
-		       char *name)
-{
-	struct obd_device	*mgc_obd;
-	struct llog_ctxt	*ctxt;
-	struct obd_uuid		*mgs_uuid;
-	struct obd_export	*exp;
-	struct obd_uuid		 uuid = { "LLOG_TEST6_UUID" };
-	struct llog_handle	*llh = NULL;
-	struct llog_ctxt	*nctxt;
-	int			 rc, rc2;
-
-	ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
-	LASSERT(ctxt);
-	mgs_uuid = &ctxt->loc_exp->exp_obd->obd_uuid;
-
-	CWARN("6a: re-open log %s using client API\n", name);
-	mgc_obd = class_find_client_obd(mgs_uuid, LUSTRE_MGC_NAME, NULL);
-	if (mgc_obd == NULL) {
-		CERROR("6a: no MGC devices connected to %s found.\n",
-		       mgs_uuid->uuid);
-		GOTO(ctxt_release, rc = -ENOENT);
-	}
-
-	rc = obd_connect(NULL, &exp, mgc_obd, &uuid,
-			 NULL /* obd_connect_data */, NULL);
-	if (rc != -EALREADY) {
-		CERROR("6a: connect on connected MGC (%s) failed to return"
-		       " -EALREADY", mgc_obd->obd_name);
-		if (rc == 0)
-			obd_disconnect(exp);
-		GOTO(ctxt_release, rc = -EINVAL);
-	}
-
-	nctxt = llog_get_context(mgc_obd, LLOG_CONFIG_REPL_CTXT);
-	rc = llog_open(env, nctxt, &llh, NULL, name, LLOG_OPEN_EXISTS);
-	if (rc) {
-		CERROR("6a: llog_open failed %d\n", rc);
-		GOTO(nctxt_put, rc);
-	}
-
-	rc = llog_init_handle(env, llh, LLOG_F_IS_PLAIN, NULL);
-	if (rc) {
-		CERROR("6a: llog_init_handle failed %d\n", rc);
-		GOTO(parse_out, rc);
-	}
-
-	plain_counter = 1; /* llog header is first record */
-	CWARN("6b: process log %s using client API\n", name);
-	rc = llog_process(env, llh, plain_print_cb, NULL, NULL);
-	if (rc)
-		CERROR("6b: llog_process failed %d\n", rc);
-	CWARN("6b: processed %d records\n", plain_counter);
-
-	rc = verify_handle("6b", llh, plain_counter);
-	if (rc)
-		GOTO(parse_out, rc);
-
-	plain_counter = 1; /* llog header is first record */
-	CWARN("6c: process log %s reversely using client API\n", name);
-	rc = llog_reverse_process(env, llh, plain_print_cb, NULL, NULL);
-	if (rc)
-		CERROR("6c: llog_reverse_process failed %d\n", rc);
-	CWARN("6c: processed %d records\n", plain_counter);
-
-	rc = verify_handle("6c", llh, plain_counter);
-	if (rc)
-		GOTO(parse_out, rc);
-
-parse_out:
-	rc2 = llog_close(env, llh);
-	if (rc2) {
-		CERROR("6: llog_close failed: rc = %d\n", rc2);
-		if (rc == 0)
-			rc = rc2;
-	}
-nctxt_put:
-	llog_ctxt_put(nctxt);
-ctxt_release:
-	llog_ctxt_put(ctxt);
-	return rc;
-}
-
-static union {
-	struct llog_rec_hdr		lrh;   /* common header */
-	struct llog_logid_rec		llr;   /* LLOG_LOGID_MAGIC */
-	struct llog_unlink64_rec	lur;   /* MDS_UNLINK64_REC */
-	struct llog_setattr64_rec	lsr64; /* MDS_SETATTR64_REC */
-	struct llog_size_change_rec	lscr;  /* OST_SZ_REC */
-	struct llog_changelog_rec	lcr;   /* CHANGELOG_REC */
-	struct llog_changelog_user_rec	lcur;  /* CHANGELOG_USER_REC */
-	struct llog_gen_rec		lgr;   /* LLOG_GEN_REC */
-} llog_records;
-
-static int test_7_print_cb(const struct lu_env *env, struct llog_handle *llh,
-			   struct llog_rec_hdr *rec, void *data)
-{
-	struct lu_fid fid = {0};
-
-	logid_to_fid(&llh->lgh_id, &fid);
-
-	CDEBUG(D_OTHER, "record type %#x at index %d in log "DFID"\n",
-	       rec->lrh_type, rec->lrh_index, PFID(&fid));
-
-	plain_counter++;
-	return 0;
-}
-
-static int test_7_cancel_cb(const struct lu_env *env, struct llog_handle *llh,
-			    struct llog_rec_hdr *rec, void *data)
-{
-	plain_counter++;
-	/* test LLOG_DEL_RECORD is working */
-	return LLOG_DEL_RECORD;
-}
-
-static int llog_test_7_sub(const struct lu_env *env, struct llog_ctxt *ctxt)
-{
-	struct llog_handle	*llh;
-	int			 rc = 0, i, process_count;
-	int			 num_recs = 0;
-
-	rc = llog_open_create(env, ctxt, &llh, NULL, NULL);
-	if (rc) {
-		CERROR("7_sub: create log failed\n");
-		return rc;
-	}
-
-	rc = llog_init_handle(env, llh,
-			      LLOG_F_IS_PLAIN | LLOG_F_ZAP_WHEN_EMPTY,
-			      &uuid);
-	if (rc) {
-		CERROR("7_sub: can't init llog handle: %d\n", rc);
-		GOTO(out_close, rc);
-	}
-	for (i = 0; i < LLOG_BITMAP_SIZE(llh->lgh_hdr); i++) {
-		rc = llog_write(env, llh, &llog_records.lrh, NULL, 0,
-				NULL, -1);
-		if (rc == -ENOSPC) {
-			break;
-		} else if (rc < 0) {
-			CERROR("7_sub: write recs failed at #%d: %d\n",
-			       i + 1, rc);
-			GOTO(out_close, rc);
-		}
-		num_recs++;
-	}
-	if (rc != -ENOSPC) {
-		CWARN("7_sub: write record more than BITMAP size!\n");
-		GOTO(out_close, rc = -EINVAL);
-	}
-
-	rc = verify_handle("7_sub", llh, num_recs + 1);
-	if (rc) {
-		CERROR("7_sub: verify handle failed: %d\n", rc);
-		GOTO(out_close, rc);
-	}
-	if (num_recs < LLOG_BITMAP_SIZE(llh->lgh_hdr) - 1)
-		CWARN("7_sub: records are not aligned, written %d from %u\n",
-		      num_recs, LLOG_BITMAP_SIZE(llh->lgh_hdr) - 1);
-
-	plain_counter = 0;
-	rc = llog_process(env, llh, test_7_print_cb, "test 7", NULL);
-	if (rc) {
-		CERROR("7_sub: llog process failed: %d\n", rc);
-		GOTO(out_close, rc);
-	}
-	process_count = plain_counter;
-	if (process_count != num_recs) {
-		CERROR("7_sub: processed %d records from %d total\n",
-		       process_count, num_recs);
-		GOTO(out_close, rc = -EINVAL);
-	}
-
-	plain_counter = 0;
-	rc = llog_reverse_process(env, llh, test_7_cancel_cb, "test 7", NULL);
-	if (rc) {
-		CERROR("7_sub: reverse llog process failed: %d\n", rc);
-		GOTO(out_close, rc);
-	}
-	if (process_count != plain_counter) {
-		CERROR("7_sub: Reverse/direct processing found different"
-		       "number of records: %d/%d\n",
-		       plain_counter, process_count);
-		GOTO(out_close, rc = -EINVAL);
-	}
-	if (llog_exist(llh)) {
-		CERROR("7_sub: llog exists but should be zapped\n");
-		GOTO(out_close, rc = -EEXIST);
-	}
-
-	rc = verify_handle("7_sub", llh, 1);
-out_close:
-	if (rc)
-		llog_destroy(env, llh);
-	llog_close(env, llh);
-	return rc;
-}
-
-/* Test all llog records writing and processing */
-static int llog_test_7(const struct lu_env *env, struct obd_device *obd)
-{
-	struct llog_ctxt	*ctxt;
-	int			 rc;
-
-	ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
-
-	CWARN("7a: test llog_logid_rec\n");
-	llog_records.llr.lid_hdr.lrh_len = sizeof(llog_records.llr);
-	llog_records.llr.lid_tail.lrt_len = sizeof(llog_records.llr);
-	llog_records.llr.lid_hdr.lrh_type = LLOG_LOGID_MAGIC;
-
-	rc = llog_test_7_sub(env, ctxt);
-	if (rc) {
-		CERROR("7a: llog_logid_rec test failed\n");
-		GOTO(out, rc);
-	}
-
-	CWARN("7b: test llog_unlink64_rec\n");
-	llog_records.lur.lur_hdr.lrh_len = sizeof(llog_records.lur);
-	llog_records.lur.lur_tail.lrt_len = sizeof(llog_records.lur);
-	llog_records.lur.lur_hdr.lrh_type = MDS_UNLINK64_REC;
-
-	rc = llog_test_7_sub(env, ctxt);
-	if (rc) {
-		CERROR("7b: llog_unlink_rec test failed\n");
-		GOTO(out, rc);
-	}
-
-	CWARN("7c: test llog_setattr64_rec\n");
-	llog_records.lsr64.lsr_hdr.lrh_len = sizeof(llog_records.lsr64);
-	llog_records.lsr64.lsr_tail.lrt_len = sizeof(llog_records.lsr64);
-	llog_records.lsr64.lsr_hdr.lrh_type = MDS_SETATTR64_REC;
-
-	rc = llog_test_7_sub(env, ctxt);
-	if (rc) {
-		CERROR("7c: llog_setattr64_rec test failed\n");
-		GOTO(out, rc);
-	}
-
-	CWARN("7d: test llog_size_change_rec\n");
-	llog_records.lscr.lsc_hdr.lrh_len = sizeof(llog_records.lscr);
-	llog_records.lscr.lsc_tail.lrt_len = sizeof(llog_records.lscr);
-	llog_records.lscr.lsc_hdr.lrh_type = OST_SZ_REC;
-
-	rc = llog_test_7_sub(env, ctxt);
-	if (rc) {
-		CERROR("7d: llog_size_change_rec test failed\n");
-		GOTO(out, rc);
-	}
-
-	CWARN("7e: test llog_changelog_rec\n");
-	llog_records.lcr.cr_hdr.lrh_len = sizeof(llog_records.lcr);
-	llog_records.lcr.cr_tail.lrt_len = sizeof(llog_records.lcr);
-	llog_records.lcr.cr_hdr.lrh_type = CHANGELOG_REC;
-
-	rc = llog_test_7_sub(env, ctxt);
-	if (rc) {
-		CERROR("7e: llog_changelog_rec test failed\n");
-		GOTO(out, rc);
-	}
-
-	CWARN("7f: test llog_changelog_user_rec\n");
-	llog_records.lcur.cur_hdr.lrh_len = sizeof(llog_records.lcur);
-	llog_records.lcur.cur_tail.lrt_len = sizeof(llog_records.lcur);
-	llog_records.lcur.cur_hdr.lrh_type = CHANGELOG_USER_REC;
-
-	rc = llog_test_7_sub(env, ctxt);
-	if (rc) {
-		CERROR("7f: llog_changelog_user_rec test failed\n");
-		GOTO(out, rc);
-	}
-
-	CWARN("7g: test llog_gen_rec\n");
-	llog_records.lgr.lgr_hdr.lrh_len = sizeof(llog_records.lgr);
-	llog_records.lgr.lgr_tail.lrt_len = sizeof(llog_records.lgr);
-	llog_records.lgr.lgr_hdr.lrh_type = LLOG_GEN_REC;
-
-	rc = llog_test_7_sub(env, ctxt);
-	if (rc) {
-		CERROR("7g: llog_size_change_rec test failed\n");
-		GOTO(out, rc);
-	}
-out:
-	llog_ctxt_put(ctxt);
-	return rc;
-}
-
-/* -------------------------------------------------------------------------
- * Tests above, boring obd functions below
- * ------------------------------------------------------------------------- */
-static int llog_run_tests(const struct lu_env *env, struct obd_device *obd)
-{
-	struct llog_handle	*llh = NULL;
-	struct llog_ctxt	*ctxt;
-	int			 rc, err;
-	char			 name[10];
-
-	ctxt = llog_get_context(obd, LLOG_TEST_ORIG_CTXT);
-	LASSERT(ctxt);
-
-	sprintf(name, "%x", llog_test_rand);
-
-	rc = llog_test_1(env, obd, name);
-	if (rc)
-		GOTO(cleanup_ctxt, rc);
-
-	rc = llog_test_2(env, obd, name, &llh);
-	if (rc)
-		GOTO(cleanup_ctxt, rc);
-
-	rc = llog_test_3(env, obd, llh);
-	if (rc)
-		GOTO(cleanup, rc);
-
-	rc = llog_test_4(env, obd);
-	if (rc)
-		GOTO(cleanup, rc);
-
-	rc = llog_test_5(env, obd);
-	if (rc)
-		GOTO(cleanup, rc);
-
-	rc = llog_test_6(env, obd, name);
-	if (rc)
-		GOTO(cleanup, rc);
-
-	rc = llog_test_7(env, obd);
-	if (rc)
-		GOTO(cleanup, rc);
-
-cleanup:
-	err = llog_destroy(env, llh);
-	if (err)
-		CERROR("cleanup: llog_destroy failed: %d\n", err);
-	llog_close(env, llh);
-	if (rc == 0)
-		rc = err;
-cleanup_ctxt:
-	llog_ctxt_put(ctxt);
-	return rc;
-}
-
-#if defined (CONFIG_PROC_FS)
-static struct lprocfs_vars lprocfs_llog_test_obd_vars[] = { { NULL } };
-static struct lprocfs_vars lprocfs_llog_test_module_vars[] = { { NULL } };
-static void lprocfs_llog_test_init_vars(struct lprocfs_static_vars *lvars)
-{
-    lvars->module_vars  = lprocfs_llog_test_module_vars;
-    lvars->obd_vars     = lprocfs_llog_test_obd_vars;
-}
-#else
-static void lprocfs_llog_test_init_vars(struct lprocfs_static_vars *lvars)
-{
-}
-#endif
-
-static int llog_test_cleanup(struct obd_device *obd)
-{
-	struct obd_device	*tgt;
-	struct lu_env		 env;
-	int			 rc;
-
-	rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD);
-	if (rc)
-		return rc;
-
-	tgt = obd->obd_lvfs_ctxt.dt->dd_lu_dev.ld_obd;
-	rc = llog_cleanup(&env, llog_get_context(tgt, LLOG_TEST_ORIG_CTXT));
-	if (rc)
-		CERROR("failed to llog_test_llog_finish: %d\n", rc);
-	lu_env_fini(&env);
-	return rc;
-}
-
-static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
-{
-	struct obd_device	*tgt;
-	struct llog_ctxt	*ctxt;
-	struct dt_object	*o;
-	struct lu_env		 env;
-	struct lu_context	 test_session;
-	int			 rc;
-
-	if (lcfg->lcfg_bufcount < 2) {
-		CERROR("requires a TARGET OBD name\n");
-		return -EINVAL;
-	}
-
-	if (lcfg->lcfg_buflens[1] < 1) {
-		CERROR("requires a TARGET OBD name\n");
-		return -EINVAL;
-	}
-
-	/* disk obd */
-	tgt = class_name2obd(lustre_cfg_string(lcfg, 1));
-	if (!tgt || !tgt->obd_attached || !tgt->obd_set_up) {
-		CERROR("target device not attached or not set up (%s)\n",
-		       lustre_cfg_string(lcfg, 1));
-		return -EINVAL;
-	}
-
-	rc = lu_env_init(&env, LCT_LOCAL | LCT_MG_THREAD);
-	if (rc)
-		return rc;
-
-	rc = lu_context_init(&test_session, LCT_SESSION);
-	if (rc)
-		GOTO(cleanup_env, rc);
-	test_session.lc_thread = (struct ptlrpc_thread *)current;
-	lu_context_enter(&test_session);
-	env.le_ses = &test_session;
-
-	CWARN("Setup llog-test device over %s device\n",
-	      lustre_cfg_string(lcfg, 1));
-
-	OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
-	obd->obd_lvfs_ctxt.dt = lu2dt_dev(tgt->obd_lu_dev);
-
-	rc = llog_setup(&env, tgt, &tgt->obd_olg, LLOG_TEST_ORIG_CTXT, tgt,
-			&llog_osd_ops);
-	if (rc)
-		GOTO(cleanup_session, rc);
-
-	/* use MGS llog dir for tests */
-	ctxt = llog_get_context(tgt, LLOG_CONFIG_ORIG_CTXT);
-	LASSERT(ctxt);
-	o = ctxt->loc_dir;
-	llog_ctxt_put(ctxt);
-
-	ctxt = llog_get_context(tgt, LLOG_TEST_ORIG_CTXT);
-	LASSERT(ctxt);
-	ctxt->loc_dir = o;
-	llog_ctxt_put(ctxt);
-
-	llog_test_rand = cfs_rand();
-
-	rc = llog_run_tests(&env, tgt);
-	if (rc)
-		llog_test_cleanup(obd);
-cleanup_session:
-	lu_context_exit(&test_session);
-	lu_context_fini(&test_session);
-cleanup_env:
-	lu_env_fini(&env);
-	return rc;
-}
-
-static struct obd_ops llog_obd_ops = {
-	.o_owner       = THIS_MODULE,
-	.o_setup       = llog_test_setup,
-	.o_cleanup     = llog_test_cleanup,
-};
-
-static int __init llog_test_init(void)
-{
-	struct lprocfs_static_vars uninitialized_var(lvars);
-
-	lprocfs_llog_test_init_vars(&lvars);
-	return class_register_type(&llog_obd_ops, NULL,
-				   lvars.module_vars, "llog_test", NULL);
-}
-
-static void __exit llog_test_exit(void)
-{
-	class_unregister_type("llog_test");
-}
-
-MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("llog test module");
-MODULE_LICENSE("GPL");
-
-module_init(llog_test_init);
-module_exit(llog_test_exit);
-- 
1.9.3


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

* [PATCH 10/12] staging/lustre/obdclass: remove llog_osd.c
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (8 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 09/12] staging/lustre/obdclass: remove llog_test.ko Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 11/12] staging/lustre/mdc: remove obsolete llog ioctl handlers Oleg Drokin
  2014-08-30 21:12 ` [PATCH 12/12] staging/lustre: remove unused som_attrs and hsm_attrs structures Oleg Drokin
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger; +Cc: John L. Hammond

From: "John L. Hammond" <john.hammond@intel.com>

llog_osd_ops is not used so remove it and its supporting methods.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
---
 drivers/staging/lustre/lustre/include/lustre_log.h |    9 -
 drivers/staging/lustre/lustre/obdclass/Makefile    |    2 +-
 drivers/staging/lustre/lustre/obdclass/llog_osd.c  | 1290 --------------------
 3 files changed, 1 insertion(+), 1300 deletions(-)
 delete mode 100644 drivers/staging/lustre/lustre/obdclass/llog_osd.c

diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h
index 3944c6d..ed97887 100644
--- a/drivers/staging/lustre/lustre/include/lustre_log.h
+++ b/drivers/staging/lustre/lustre/include/lustre_log.h
@@ -313,15 +313,6 @@ struct llog_handle {
 	atomic_t		 lgh_refcount;
 };
 
-/* llog_osd.c */
-extern struct llog_operations llog_osd_ops;
-int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d,
-			  int idx, int count,
-			  struct llog_catid *idarray);
-int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d,
-			  int idx, int count,
-			  struct llog_catid *idarray);
-
 #define LLOG_CTXT_FLAG_UNINITIALIZED     0x00000001
 #define LLOG_CTXT_FLAG_STOP		 0x00000002
 
diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index 9a2b83f..c8c95e1 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -3,7 +3,7 @@ obj-$(CONFIG_LUSTRE_FS) += obdclass.o
 obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
 	      llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \
 	      genops.o uuid.o llog_ioctl.o lprocfs_status.o		   \
-	      lustre_handles.o lustre_peer.o llog_osd.o \
+	      lustre_handles.o lustre_peer.o \
 	      local_storage.o statfs_pack.o obdo.o obd_config.o obd_mount.o\
 	      lu_object.o dt_object.o capa.o cl_object.o   \
 	      cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_osd.c b/drivers/staging/lustre/lustre/obdclass/llog_osd.c
deleted file mode 100644
index 2c6a51e..0000000
--- a/drivers/staging/lustre/lustre/obdclass/llog_osd.c
+++ /dev/null
@@ -1,1290 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2012, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/obdclass/llog_osd.c - low level llog routines on top of OSD API
- *
- * Author: Alexey Zhuravlev <alexey.zhuravlev@intel.com>
- * Author: Mikhail Pershin <mike.pershin@intel.com>
- */
-
-#define DEBUG_SUBSYSTEM S_LOG
-
-#include "../include/obd.h"
-#include "../include/obd_class.h"
-#include "../include/lustre_fid.h"
-#include "../include/dt_object.h"
-
-#include "llog_internal.h"
-#include "local_storage.h"
-
-/*
- * - multi-chunks or big-declaration approach
- * - use unique sequence instead of llog sb tracking unique ids
- * - re-use existing environment
- * - named llog support (can be used for testing only at the present)
- * - llog_origin_connect() work with OSD API
- */
-
-static int llog_osd_declare_new_object(const struct lu_env *env,
-				       struct local_oid_storage *los,
-				       struct dt_object *o,
-				       struct thandle *th)
-{
-	struct llog_thread_info *lgi = llog_info(env);
-
-	lgi->lgi_attr.la_valid = LA_MODE;
-	lgi->lgi_attr.la_mode = S_IFREG | S_IRUGO | S_IWUSR;
-	lgi->lgi_dof.dof_type = dt_mode_to_dft(S_IFREG);
-
-	return local_object_declare_create(env, los, o, &lgi->lgi_attr,
-					   &lgi->lgi_dof, th);
-}
-
-static int llog_osd_create_new_object(const struct lu_env *env,
-				      struct local_oid_storage *los,
-				      struct dt_object *o,
-				      struct thandle *th)
-{
-	struct llog_thread_info *lgi = llog_info(env);
-
-	lgi->lgi_attr.la_valid = LA_MODE;
-	lgi->lgi_attr.la_mode = S_IFREG | S_IRUGO | S_IWUSR;
-	lgi->lgi_dof.dof_type = dt_mode_to_dft(S_IFREG);
-
-	return local_object_create(env, los, o, &lgi->lgi_attr,
-				   &lgi->lgi_dof, th);
-}
-
-static int llog_osd_pad(const struct lu_env *env, struct dt_object *o,
-			loff_t *off, int len, int index, struct thandle *th)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	int			 rc;
-
-	LASSERT(th);
-	LASSERT(off);
-	LASSERT(len >= LLOG_MIN_REC_SIZE && (len & 0x7) == 0);
-
-	lgi->lgi_tail.lrt_len = lgi->lgi_lrh.lrh_len = len;
-	lgi->lgi_tail.lrt_index = lgi->lgi_lrh.lrh_index = index;
-	lgi->lgi_lrh.lrh_type = LLOG_PAD_MAGIC;
-
-	lgi->lgi_buf.lb_buf = &lgi->lgi_lrh;
-	lgi->lgi_buf.lb_len = sizeof(lgi->lgi_lrh);
-	dt_write_lock(env, o, 0);
-	rc = dt_record_write(env, o, &lgi->lgi_buf, off, th);
-	if (rc) {
-		CERROR("%s: error writing padding record: rc = %d\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name, rc);
-		GOTO(out, rc);
-	}
-
-	lgi->lgi_buf.lb_buf = &lgi->lgi_tail;
-	lgi->lgi_buf.lb_len = sizeof(lgi->lgi_tail);
-	*off += len - sizeof(lgi->lgi_lrh) - sizeof(lgi->lgi_tail);
-	rc = dt_record_write(env, o, &lgi->lgi_buf, off, th);
-	if (rc)
-		CERROR("%s: error writing padding record: rc = %d\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name, rc);
-out:
-	dt_write_unlock(env, o);
-	return rc;
-}
-
-static int llog_osd_write_blob(const struct lu_env *env, struct dt_object *o,
-			       struct llog_rec_hdr *rec, void *buf,
-			       loff_t *off, struct thandle *th)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	int			 buflen = rec->lrh_len;
-	int			 rc;
-
-	LASSERT(env);
-	LASSERT(o);
-
-	if (buflen == 0)
-		CWARN("0-length record\n");
-
-	CDEBUG(D_OTHER, "write blob with type %x, buf %p/%u at off %llu\n",
-	       rec->lrh_type, buf, buflen, *off);
-
-	lgi->lgi_attr.la_valid = LA_SIZE;
-	lgi->lgi_attr.la_size = *off;
-
-	if (!buf) {
-		lgi->lgi_buf.lb_len = buflen;
-		lgi->lgi_buf.lb_buf = rec;
-		rc = dt_record_write(env, o, &lgi->lgi_buf, off, th);
-		if (rc)
-			CERROR("%s: error writing log record: rc = %d\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name, rc);
-		GOTO(out, rc);
-	}
-
-	/* the buf case */
-	/* protect the following 3 writes from concurrent read */
-	dt_write_lock(env, o, 0);
-	rec->lrh_len = sizeof(*rec) + buflen + sizeof(lgi->lgi_tail);
-	lgi->lgi_buf.lb_len = sizeof(*rec);
-	lgi->lgi_buf.lb_buf = rec;
-	rc = dt_record_write(env, o, &lgi->lgi_buf, off, th);
-	if (rc) {
-		CERROR("%s: error writing log hdr: rc = %d\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name, rc);
-		GOTO(out_unlock, rc);
-	}
-
-	lgi->lgi_buf.lb_len = buflen;
-	lgi->lgi_buf.lb_buf = buf;
-	rc = dt_record_write(env, o, &lgi->lgi_buf, off, th);
-	if (rc) {
-		CERROR("%s: error writing log buffer: rc = %d\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name,  rc);
-		GOTO(out_unlock, rc);
-	}
-
-	lgi->lgi_tail.lrt_len = rec->lrh_len;
-	lgi->lgi_tail.lrt_index = rec->lrh_index;
-	lgi->lgi_buf.lb_len = sizeof(lgi->lgi_tail);
-	lgi->lgi_buf.lb_buf = &lgi->lgi_tail;
-	rc = dt_record_write(env, o, &lgi->lgi_buf, off, th);
-	if (rc)
-		CERROR("%s: error writing log tail: rc = %d\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name, rc);
-
-out_unlock:
-	dt_write_unlock(env, o);
-
-out:
-	/* cleanup the content written above */
-	if (rc) {
-		dt_punch(env, o, lgi->lgi_attr.la_size, OBD_OBJECT_EOF, th,
-			 BYPASS_CAPA);
-		dt_attr_set(env, o, &lgi->lgi_attr, th, BYPASS_CAPA);
-	}
-
-	return rc;
-}
-
-static int llog_osd_read_header(const struct lu_env *env,
-				struct llog_handle *handle)
-{
-	struct llog_rec_hdr	*llh_hdr;
-	struct dt_object	*o;
-	struct llog_thread_info	*lgi;
-	int			 rc;
-
-	LASSERT(sizeof(*handle->lgh_hdr) == LLOG_CHUNK_SIZE);
-
-	o = handle->lgh_obj;
-	LASSERT(o);
-
-	lgi = llog_info(env);
-
-	rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL);
-	if (rc)
-		return rc;
-
-	LASSERT(lgi->lgi_attr.la_valid & LA_SIZE);
-
-	if (lgi->lgi_attr.la_size == 0) {
-		CDEBUG(D_HA, "not reading header from 0-byte log\n");
-		return LLOG_EEMPTY;
-	}
-
-	lgi->lgi_off = 0;
-	lgi->lgi_buf.lb_buf = handle->lgh_hdr;
-	lgi->lgi_buf.lb_len = LLOG_CHUNK_SIZE;
-
-	rc = dt_record_read(env, o, &lgi->lgi_buf, &lgi->lgi_off);
-	if (rc) {
-		CERROR("%s: error reading log header from "DFID": rc = %d\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name,
-		       PFID(lu_object_fid(&o->do_lu)), rc);
-		return rc;
-	}
-
-	llh_hdr = &handle->lgh_hdr->llh_hdr;
-	if (LLOG_REC_HDR_NEEDS_SWABBING(llh_hdr))
-		lustre_swab_llog_hdr(handle->lgh_hdr);
-
-	if (llh_hdr->lrh_type != LLOG_HDR_MAGIC) {
-		CERROR("%s: bad log %s "DFID" header magic: %#x "
-		       "(expected %#x)\n", o->do_lu.lo_dev->ld_obd->obd_name,
-		       handle->lgh_name ? handle->lgh_name : "",
-		       PFID(lu_object_fid(&o->do_lu)),
-		       llh_hdr->lrh_type, LLOG_HDR_MAGIC);
-		return -EIO;
-	} else if (llh_hdr->lrh_len != LLOG_CHUNK_SIZE) {
-		CERROR("%s: incorrectly sized log %s "DFID" header: "
-		       "%#x (expected %#x)\n"
-		       "you may need to re-run lconf --write_conf.\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name,
-		       handle->lgh_name ? handle->lgh_name : "",
-		       PFID(lu_object_fid(&o->do_lu)),
-		       llh_hdr->lrh_len, LLOG_CHUNK_SIZE);
-		return -EIO;
-	}
-
-	handle->lgh_last_idx = handle->lgh_hdr->llh_tail.lrt_index;
-
-	return 0;
-}
-
-static int llog_osd_declare_write_rec(const struct lu_env *env,
-				      struct llog_handle *loghandle,
-				      struct llog_rec_hdr *rec,
-				      int idx, struct thandle *th)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	struct dt_object	*o;
-	int			 rc;
-
-	LASSERT(env);
-	LASSERT(th);
-	LASSERT(loghandle);
-
-	o = loghandle->lgh_obj;
-	LASSERT(o);
-
-	/* each time we update header */
-	rc = dt_declare_record_write(env, o, sizeof(struct llog_log_hdr), 0,
-				     th);
-	if (rc || idx == 0) /* if error or just header */
-		return rc;
-
-	if (dt_object_exists(o)) {
-		rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA);
-		lgi->lgi_off = lgi->lgi_attr.la_size;
-		LASSERT(ergo(rc == 0, lgi->lgi_attr.la_valid & LA_SIZE));
-		if (rc)
-			return rc;
-
-		rc = dt_declare_punch(env, o, lgi->lgi_off, OBD_OBJECT_EOF, th);
-		if (rc)
-			return rc;
-	} else {
-		lgi->lgi_off = 0;
-	}
-
-	/* XXX: implement declared window or multi-chunks approach */
-	rc = dt_declare_record_write(env, o, 32 * 1024, lgi->lgi_off, th);
-
-	return rc;
-}
-
-/* returns negative in on error; 0 if success && reccookie == 0; 1 otherwise */
-/* appends if idx == -1, otherwise overwrites record idx. */
-static int llog_osd_write_rec(const struct lu_env *env,
-			      struct llog_handle *loghandle,
-			      struct llog_rec_hdr *rec,
-			      struct llog_cookie *reccookie, int cookiecount,
-			      void *buf, int idx, struct thandle *th)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	struct llog_log_hdr	*llh;
-	int			 reclen = rec->lrh_len;
-	int			 index, rc, old_tail_idx;
-	struct llog_rec_tail	*lrt;
-	struct dt_object	*o;
-	size_t			 left;
-
-	LASSERT(env);
-	llh = loghandle->lgh_hdr;
-	LASSERT(llh);
-	o = loghandle->lgh_obj;
-	LASSERT(o);
-	LASSERT(th);
-
-	CDEBUG(D_OTHER, "new record %x to "DFID"\n",
-	       rec->lrh_type, PFID(lu_object_fid(&o->do_lu)));
-
-	/* record length should not bigger than LLOG_CHUNK_SIZE */
-	if (buf)
-		rc = (reclen > LLOG_CHUNK_SIZE - sizeof(struct llog_rec_hdr) -
-		      sizeof(struct llog_rec_tail)) ? -E2BIG : 0;
-	else
-		rc = (reclen > LLOG_CHUNK_SIZE) ? -E2BIG : 0;
-	if (rc)
-		return rc;
-
-	rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL);
-	if (rc)
-		return rc;
-
-	if (buf)
-		/* write_blob adds header and tail to lrh_len. */
-		reclen = sizeof(*rec) + rec->lrh_len +
-			 sizeof(struct llog_rec_tail);
-
-	if (idx != -1) {
-		/* no header: only allowed to insert record 1 */
-		if (idx != 1 && lgi->lgi_attr.la_size == 0)
-			LBUG();
-
-		if (idx && llh->llh_size && llh->llh_size != rec->lrh_len)
-			return -EINVAL;
-
-		if (!ext2_test_bit(idx, llh->llh_bitmap))
-			CERROR("%s: modify unset record %u\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name, idx);
-		if (idx != rec->lrh_index)
-			CERROR("%s: index mismatch %d %u\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name, idx,
-			       rec->lrh_index);
-
-		lgi->lgi_off = 0;
-		rc = llog_osd_write_blob(env, o, &llh->llh_hdr, NULL,
-					 &lgi->lgi_off, th);
-		/* we are done if we only write the header or on error */
-		if (rc || idx == 0)
-			return rc;
-
-		if (buf) {
-			/* We assume that caller has set lgh_cur_* */
-			lgi->lgi_off = loghandle->lgh_cur_offset;
-			CDEBUG(D_OTHER,
-			       "modify record "DOSTID": idx:%d/%u/%d, len:%u "
-			       "offset %llu\n",
-			       POSTID(&loghandle->lgh_id.lgl_oi), idx,
-			       rec->lrh_index,
-			       loghandle->lgh_cur_idx, rec->lrh_len,
-			       (long long)(lgi->lgi_off - sizeof(*llh)));
-			if (rec->lrh_index != loghandle->lgh_cur_idx) {
-				CERROR("%s: modify idx mismatch %u/%d\n",
-				       o->do_lu.lo_dev->ld_obd->obd_name, idx,
-				       loghandle->lgh_cur_idx);
-				return -EFAULT;
-			}
-		} else {
-			/* Assumes constant lrh_len */
-			lgi->lgi_off = sizeof(*llh) + (idx - 1) * reclen;
-		}
-
-		rc = llog_osd_write_blob(env, o, rec, buf, &lgi->lgi_off, th);
-		if (rc == 0 && reccookie) {
-			reccookie->lgc_lgl = loghandle->lgh_id;
-			reccookie->lgc_index = idx;
-			rc = 1;
-		}
-		return rc;
-	}
-
-	/* Make sure that records don't cross a chunk boundary, so we can
-	 * process them page-at-a-time if needed.  If it will cross a chunk
-	 * boundary, write in a fake (but referenced) entry to pad the chunk.
-	 *
-	 * We know that llog_current_log() will return a loghandle that is
-	 * big enough to hold reclen, so all we care about is padding here.
-	 */
-	LASSERT(lgi->lgi_attr.la_valid & LA_SIZE);
-	lgi->lgi_off = lgi->lgi_attr.la_size;
-	left = LLOG_CHUNK_SIZE - (lgi->lgi_off & (LLOG_CHUNK_SIZE - 1));
-	/* NOTE: padding is a record, but no bit is set */
-	if (left != 0 && left != reclen &&
-	    left < (reclen + LLOG_MIN_REC_SIZE)) {
-		index = loghandle->lgh_last_idx + 1;
-		rc = llog_osd_pad(env, o, &lgi->lgi_off, left, index, th);
-		if (rc)
-			return rc;
-		loghandle->lgh_last_idx++; /*for pad rec*/
-	}
-	/* if it's the last idx in log file, then return -ENOSPC */
-	if (loghandle->lgh_last_idx >= LLOG_BITMAP_SIZE(llh) - 1)
-		return -ENOSPC;
-
-	loghandle->lgh_last_idx++;
-	index = loghandle->lgh_last_idx;
-	LASSERT(index < LLOG_BITMAP_SIZE(llh));
-	rec->lrh_index = index;
-	if (buf == NULL) {
-		lrt = (struct llog_rec_tail *)((char *)rec + rec->lrh_len -
-					       sizeof(*lrt));
-		lrt->lrt_len = rec->lrh_len;
-		lrt->lrt_index = rec->lrh_index;
-	}
-	/* The caller should make sure only 1 process access the lgh_last_idx,
-	 * Otherwise it might hit the assert.*/
-	LASSERT(index < LLOG_BITMAP_SIZE(llh));
-	spin_lock(&loghandle->lgh_hdr_lock);
-	if (ext2_set_bit(index, llh->llh_bitmap)) {
-		CERROR("%s: index %u already set in log bitmap\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name, index);
-		spin_unlock(&loghandle->lgh_hdr_lock);
-		LBUG(); /* should never happen */
-	}
-	llh->llh_count++;
-	spin_unlock(&loghandle->lgh_hdr_lock);
-	old_tail_idx = llh->llh_tail.lrt_index;
-	llh->llh_tail.lrt_index = index;
-
-	lgi->lgi_off = 0;
-	rc = llog_osd_write_blob(env, o, &llh->llh_hdr, NULL, &lgi->lgi_off,
-				 th);
-	if (rc)
-		GOTO(out, rc);
-
-	rc = dt_attr_get(env, o, &lgi->lgi_attr, NULL);
-	if (rc)
-		GOTO(out, rc);
-
-	LASSERT(lgi->lgi_attr.la_valid & LA_SIZE);
-	lgi->lgi_off = lgi->lgi_attr.la_size;
-
-	rc = llog_osd_write_blob(env, o, rec, buf, &lgi->lgi_off, th);
-
-out:
-	/* cleanup llog for error case */
-	if (rc) {
-		spin_lock(&loghandle->lgh_hdr_lock);
-		ext2_clear_bit(index, llh->llh_bitmap);
-		llh->llh_count--;
-		spin_unlock(&loghandle->lgh_hdr_lock);
-
-		/* restore the header */
-		loghandle->lgh_last_idx--;
-		llh->llh_tail.lrt_index = old_tail_idx;
-		lgi->lgi_off = 0;
-		llog_osd_write_blob(env, o, &llh->llh_hdr, NULL,
-				    &lgi->lgi_off, th);
-	}
-
-	CDEBUG(D_RPCTRACE, "added record "DOSTID": idx: %u, %u\n",
-	       POSTID(&loghandle->lgh_id.lgl_oi), index, rec->lrh_len);
-	if (rc == 0 && reccookie) {
-		reccookie->lgc_lgl = loghandle->lgh_id;
-		reccookie->lgc_index = index;
-		if ((rec->lrh_type == MDS_UNLINK_REC) ||
-		    (rec->lrh_type == MDS_SETATTR64_REC))
-			reccookie->lgc_subsys = LLOG_MDS_OST_ORIG_CTXT;
-		else if (rec->lrh_type == OST_SZ_REC)
-			reccookie->lgc_subsys = LLOG_SIZE_ORIG_CTXT;
-		else
-			reccookie->lgc_subsys = -1;
-		rc = 1;
-	}
-	return rc;
-}
-
-/* We can skip reading at least as many log blocks as the number of
- * minimum sized log records we are skipping.  If it turns out
- * that we are not far enough along the log (because the
- * actual records are larger than minimum size) we just skip
- * some more records.
- */
-static void llog_skip_over(__u64 *off, int curr, int goal)
-{
-	if (goal <= curr)
-		return;
-	*off = (*off + (goal - curr - 1) * LLOG_MIN_REC_SIZE) &
-		~(LLOG_CHUNK_SIZE - 1);
-}
-
-/* sets:
- *  - cur_offset to the furthest point read in the log file
- *  - cur_idx to the log index preceding cur_offset
- * returns -EIO/-EINVAL on error
- */
-static int llog_osd_next_block(const struct lu_env *env,
-			       struct llog_handle *loghandle, int *cur_idx,
-			       int next_idx, __u64 *cur_offset, void *buf,
-			       int len)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	struct dt_object	*o;
-	struct dt_device	*dt;
-	int			 rc;
-
-	LASSERT(env);
-	LASSERT(lgi);
-
-	if (len == 0 || len & (LLOG_CHUNK_SIZE - 1))
-		return -EINVAL;
-
-	CDEBUG(D_OTHER, "looking for log index %u (cur idx %u off %llu)\n",
-	       next_idx, *cur_idx, *cur_offset);
-
-	LASSERT(loghandle);
-	LASSERT(loghandle->lgh_ctxt);
-
-	o = loghandle->lgh_obj;
-	LASSERT(o);
-	LASSERT(dt_object_exists(o));
-	dt = lu2dt_dev(o->do_lu.lo_dev);
-	LASSERT(dt);
-
-	rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA);
-	if (rc)
-		GOTO(out, rc);
-
-	while (*cur_offset < lgi->lgi_attr.la_size) {
-		struct llog_rec_hdr	*rec, *last_rec;
-		struct llog_rec_tail	*tail;
-
-		llog_skip_over(cur_offset, *cur_idx, next_idx);
-
-		/* read up to next LLOG_CHUNK_SIZE block */
-		lgi->lgi_buf.lb_len = LLOG_CHUNK_SIZE -
-				      (*cur_offset & (LLOG_CHUNK_SIZE - 1));
-		lgi->lgi_buf.lb_buf = buf;
-
-		/* Note: read lock is not needed around la_size get above at
-		 * the time of dt_attr_get(). There are only two cases that
-		 * matter. Either la_size == cur_offset, in which case the
-		 * entire read is skipped, or la_size > cur_offset and the loop
-		 * is entered and this thread is blocked at dt_read_lock()
-		 * until the write is completed. When the write completes, then
-		 * the dt_read() will be done with the full length, and will
-		 * get the full data.
-		 */
-		dt_read_lock(env, o, 0);
-		rc = dt_read(env, o, &lgi->lgi_buf, cur_offset);
-		dt_read_unlock(env, o);
-		if (rc < 0) {
-			CERROR("%s: can't read llog block from log "DFID
-			       " offset %llu: rc = %d\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       PFID(lu_object_fid(&o->do_lu)), *cur_offset,
-			       rc);
-			GOTO(out, rc);
-		}
-
-		if (rc < len) {
-			/* signal the end of the valid buffer to
-			 * llog_process */
-			memset(buf + rc, 0, len - rc);
-		}
-
-		if (rc == 0) /* end of file, nothing to do */
-			GOTO(out, rc);
-
-		if (rc < sizeof(*tail)) {
-			CERROR("%s: invalid llog block at log id "DOSTID"/%u "
-			       "offset %llu\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       POSTID(&loghandle->lgh_id.lgl_oi),
-			       loghandle->lgh_id.lgl_ogen, *cur_offset);
-			GOTO(out, rc = -EINVAL);
-		}
-
-		rec = buf;
-		if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
-			lustre_swab_llog_rec(rec);
-
-		tail = (struct llog_rec_tail *)((char *)buf + rc -
-						sizeof(struct llog_rec_tail));
-		/* get the last record in block */
-		last_rec = (struct llog_rec_hdr *)((char *)buf + rc -
-						   le32_to_cpu(tail->lrt_len));
-
-		if (LLOG_REC_HDR_NEEDS_SWABBING(last_rec))
-			lustre_swab_llog_rec(last_rec);
-		LASSERT(last_rec->lrh_index == tail->lrt_index);
-
-		*cur_idx = tail->lrt_index;
-
-		/* this shouldn't happen */
-		if (tail->lrt_index == 0) {
-			CERROR("%s: invalid llog tail at log id "DOSTID"/%u "
-			       "offset %llu\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       POSTID(&loghandle->lgh_id.lgl_oi),
-			       loghandle->lgh_id.lgl_ogen, *cur_offset);
-			GOTO(out, rc = -EINVAL);
-		}
-		if (tail->lrt_index < next_idx)
-			continue;
-
-		/* sanity check that the start of the new buffer is no farther
-		 * than the record that we wanted.  This shouldn't happen. */
-		if (rec->lrh_index > next_idx) {
-			CERROR("%s: missed desired record? %u > %u\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       rec->lrh_index, next_idx);
-			GOTO(out, rc = -ENOENT);
-		}
-		GOTO(out, rc = 0);
-	}
-	GOTO(out, rc = -EIO);
-out:
-	return rc;
-}
-
-static int llog_osd_prev_block(const struct lu_env *env,
-			       struct llog_handle *loghandle,
-			       int prev_idx, void *buf, int len)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	struct dt_object	*o;
-	struct dt_device	*dt;
-	loff_t			 cur_offset;
-	int			 rc;
-
-	if (len == 0 || len & (LLOG_CHUNK_SIZE - 1))
-		return -EINVAL;
-
-	CDEBUG(D_OTHER, "looking for log index %u\n", prev_idx);
-
-	LASSERT(loghandle);
-	LASSERT(loghandle->lgh_ctxt);
-
-	o = loghandle->lgh_obj;
-	LASSERT(o);
-	LASSERT(dt_object_exists(o));
-	dt = lu2dt_dev(o->do_lu.lo_dev);
-	LASSERT(dt);
-
-	cur_offset = LLOG_CHUNK_SIZE;
-	llog_skip_over(&cur_offset, 0, prev_idx);
-
-	rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA);
-	if (rc)
-		GOTO(out, rc);
-
-	while (cur_offset < lgi->lgi_attr.la_size) {
-		struct llog_rec_hdr	*rec, *last_rec;
-		struct llog_rec_tail	*tail;
-
-		lgi->lgi_buf.lb_len = len;
-		lgi->lgi_buf.lb_buf = buf;
-		/* It is OK to have locking around dt_read() only, see
-		 * comment in llog_osd_next_block for details
-		 */
-		dt_read_lock(env, o, 0);
-		rc = dt_read(env, o, &lgi->lgi_buf, &cur_offset);
-		dt_read_unlock(env, o);
-		if (rc < 0) {
-			CERROR("%s: can't read llog block from log "DFID
-			       " offset %llu: rc = %d\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       PFID(lu_object_fid(&o->do_lu)), cur_offset, rc);
-			GOTO(out, rc);
-		}
-
-		if (rc == 0) /* end of file, nothing to do */
-			GOTO(out, rc);
-
-		if (rc < sizeof(*tail)) {
-			CERROR("%s: invalid llog block at log id "DOSTID"/%u "
-			       "offset %llu\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       POSTID(&loghandle->lgh_id.lgl_oi),
-			       loghandle->lgh_id.lgl_ogen, cur_offset);
-			GOTO(out, rc = -EINVAL);
-		}
-
-		rec = buf;
-		if (LLOG_REC_HDR_NEEDS_SWABBING(rec))
-			lustre_swab_llog_rec(rec);
-
-		tail = (struct llog_rec_tail *)((char *)buf + rc -
-						sizeof(struct llog_rec_tail));
-		/* get the last record in block */
-		last_rec = (struct llog_rec_hdr *)((char *)buf + rc -
-						   le32_to_cpu(tail->lrt_len));
-
-		if (LLOG_REC_HDR_NEEDS_SWABBING(last_rec))
-			lustre_swab_llog_rec(last_rec);
-		LASSERT(last_rec->lrh_index == tail->lrt_index);
-
-		/* this shouldn't happen */
-		if (tail->lrt_index == 0) {
-			CERROR("%s: invalid llog tail at log id "DOSTID"/%u "
-			       "offset %llu\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       POSTID(&loghandle->lgh_id.lgl_oi),
-			       loghandle->lgh_id.lgl_ogen, cur_offset);
-			GOTO(out, rc = -EINVAL);
-		}
-		if (tail->lrt_index < prev_idx)
-			continue;
-
-		/* sanity check that the start of the new buffer is no farther
-		 * than the record that we wanted.  This shouldn't happen. */
-		if (rec->lrh_index > prev_idx) {
-			CERROR("%s: missed desired record? %u > %u\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       rec->lrh_index, prev_idx);
-			GOTO(out, rc = -ENOENT);
-		}
-		GOTO(out, rc = 0);
-	}
-	GOTO(out, rc = -EIO);
-out:
-	return rc;
-}
-
-struct dt_object *llog_osd_dir_get(const struct lu_env *env,
-				   struct llog_ctxt *ctxt)
-{
-	struct dt_device	*dt;
-	struct dt_thread_info	*dti = dt_info(env);
-	struct dt_object	*dir;
-	int			 rc;
-
-	dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt;
-	if (ctxt->loc_dir == NULL) {
-		rc = dt_root_get(env, dt, &dti->dti_fid);
-		if (rc)
-			return ERR_PTR(rc);
-		dir = dt_locate(env, dt, &dti->dti_fid);
-	} else {
-		lu_object_get(&ctxt->loc_dir->do_lu);
-		dir = ctxt->loc_dir;
-	}
-
-	return dir;
-}
-
-static int llog_osd_open(const struct lu_env *env, struct llog_handle *handle,
-			 struct llog_logid *logid, char *name,
-			 enum llog_open_param open_param)
-{
-	struct llog_thread_info		*lgi = llog_info(env);
-	struct llog_ctxt		*ctxt = handle->lgh_ctxt;
-	struct dt_object		*o;
-	struct dt_device		*dt;
-	struct ls_device		*ls;
-	struct local_oid_storage	*los;
-	int				 rc = 0;
-
-	LASSERT(env);
-	LASSERT(ctxt);
-	LASSERT(ctxt->loc_exp);
-	LASSERT(ctxt->loc_exp->exp_obd);
-	dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt;
-	LASSERT(dt);
-
-	ls = ls_device_get(dt);
-	if (IS_ERR(ls))
-		return PTR_ERR(ls);
-
-	mutex_lock(&ls->ls_los_mutex);
-	los = dt_los_find(ls, name != NULL ? FID_SEQ_LLOG_NAME : FID_SEQ_LLOG);
-	mutex_unlock(&ls->ls_los_mutex);
-	LASSERT(los);
-	ls_device_put(env, ls);
-
-	LASSERT(handle);
-
-	if (logid != NULL) {
-		logid_to_fid(logid, &lgi->lgi_fid);
-	} else if (name) {
-		struct dt_object *llog_dir;
-
-		llog_dir = llog_osd_dir_get(env, ctxt);
-		if (IS_ERR(llog_dir))
-			GOTO(out, rc = PTR_ERR(llog_dir));
-		dt_read_lock(env, llog_dir, 0);
-		rc = dt_lookup_dir(env, llog_dir, name, &lgi->lgi_fid);
-		dt_read_unlock(env, llog_dir);
-		lu_object_put(env, &llog_dir->do_lu);
-		if (rc == -ENOENT && open_param == LLOG_OPEN_NEW) {
-			/* generate fid for new llog */
-			rc = local_object_fid_generate(env, los,
-						       &lgi->lgi_fid);
-		}
-		if (rc < 0)
-			GOTO(out, rc);
-		OBD_ALLOC(handle->lgh_name, strlen(name) + 1);
-		if (handle->lgh_name)
-			strcpy(handle->lgh_name, name);
-		else
-			GOTO(out, rc = -ENOMEM);
-	} else {
-		LASSERTF(open_param & LLOG_OPEN_NEW, "%#x\n", open_param);
-		/* generate fid for new llog */
-		rc = local_object_fid_generate(env, los, &lgi->lgi_fid);
-		if (rc < 0)
-			GOTO(out, rc);
-	}
-
-	o = ls_locate(env, ls, &lgi->lgi_fid);
-	if (IS_ERR(o))
-		GOTO(out_name, rc = PTR_ERR(o));
-
-	/* No new llog is expected but doesn't exist */
-	if (open_param != LLOG_OPEN_NEW && !dt_object_exists(o))
-		GOTO(out_put, rc = -ENOENT);
-
-	fid_to_logid(&lgi->lgi_fid, &handle->lgh_id);
-	handle->lgh_obj = o;
-	handle->private_data = los;
-	LASSERT(handle->lgh_ctxt);
-
-	return rc;
-
-out_put:
-	lu_object_put(env, &o->do_lu);
-out_name:
-	if (handle->lgh_name != NULL)
-		OBD_FREE(handle->lgh_name, strlen(name) + 1);
-out:
-	dt_los_put(los);
-	return rc;
-}
-
-static int llog_osd_exist(struct llog_handle *handle)
-{
-	LASSERT(handle->lgh_obj);
-	return (dt_object_exists(handle->lgh_obj) &&
-		!lu_object_is_dying(handle->lgh_obj->do_lu.lo_header));
-}
-
-static int llog_osd_declare_create(const struct lu_env *env,
-				   struct llog_handle *res, struct thandle *th)
-{
-	struct llog_thread_info		*lgi = llog_info(env);
-	struct local_oid_storage	*los;
-	struct dt_object		*o;
-	int				 rc;
-
-	LASSERT(res->lgh_obj);
-	LASSERT(th);
-
-	/* object can be created by another thread */
-	o = res->lgh_obj;
-	if (dt_object_exists(o))
-		return 0;
-
-	los = res->private_data;
-	LASSERT(los);
-
-	rc = llog_osd_declare_new_object(env, los, o, th);
-	if (rc)
-		return rc;
-
-	rc = dt_declare_record_write(env, o, LLOG_CHUNK_SIZE, 0, th);
-	if (rc)
-		return rc;
-
-	if (res->lgh_name) {
-		struct dt_object *llog_dir;
-
-		llog_dir = llog_osd_dir_get(env, res->lgh_ctxt);
-		if (IS_ERR(llog_dir))
-			return PTR_ERR(llog_dir);
-		logid_to_fid(&res->lgh_id, &lgi->lgi_fid);
-		rc = dt_declare_insert(env, llog_dir,
-				       (struct dt_rec *)&lgi->lgi_fid,
-				       (struct dt_key *)res->lgh_name, th);
-		lu_object_put(env, &llog_dir->do_lu);
-		if (rc)
-			CERROR("%s: can't declare named llog %s: rc = %d\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       res->lgh_name, rc);
-	}
-	return rc;
-}
-
-/* This is a callback from the llog_* functions.
- * Assumes caller has already pushed us into the kernel context. */
-static int llog_osd_create(const struct lu_env *env, struct llog_handle *res,
-			   struct thandle *th)
-{
-	struct llog_thread_info *lgi = llog_info(env);
-	struct local_oid_storage *los;
-	struct dt_object	*o;
-	int		      rc = 0;
-
-	LASSERT(env);
-	o = res->lgh_obj;
-	LASSERT(o);
-
-	/* llog can be already created */
-	if (dt_object_exists(o))
-		return -EEXIST;
-
-	los = res->private_data;
-	LASSERT(los);
-
-	dt_write_lock(env, o, 0);
-	if (!dt_object_exists(o))
-		rc = llog_osd_create_new_object(env, los, o, th);
-	else
-		rc = -EEXIST;
-
-	dt_write_unlock(env, o);
-	if (rc)
-		return rc;
-
-	if (res->lgh_name) {
-		struct dt_object *llog_dir;
-
-		llog_dir = llog_osd_dir_get(env, res->lgh_ctxt);
-		if (IS_ERR(llog_dir))
-			return PTR_ERR(llog_dir);
-
-		logid_to_fid(&res->lgh_id, &lgi->lgi_fid);
-		dt_read_lock(env, llog_dir, 0);
-		rc = dt_insert(env, llog_dir,
-			       (struct dt_rec *)&lgi->lgi_fid,
-			       (struct dt_key *)res->lgh_name,
-			       th, BYPASS_CAPA, 1);
-		dt_read_unlock(env, llog_dir);
-		lu_object_put(env, &llog_dir->do_lu);
-		if (rc)
-			CERROR("%s: can't create named llog %s: rc = %d\n",
-			       o->do_lu.lo_dev->ld_obd->obd_name,
-			       res->lgh_name, rc);
-	}
-	return rc;
-}
-
-static int llog_osd_close(const struct lu_env *env, struct llog_handle *handle)
-{
-	struct local_oid_storage	*los;
-	int				 rc = 0;
-
-	LASSERT(handle->lgh_obj);
-
-	lu_object_put(env, &handle->lgh_obj->do_lu);
-
-	los = handle->private_data;
-	LASSERT(los);
-	dt_los_put(los);
-
-	if (handle->lgh_name)
-		OBD_FREE(handle->lgh_name, strlen(handle->lgh_name) + 1);
-
-	return rc;
-}
-
-static int llog_osd_destroy(const struct lu_env *env,
-			    struct llog_handle *loghandle)
-{
-	struct llog_ctxt	*ctxt;
-	struct dt_object	*o, *llog_dir = NULL;
-	struct dt_device	*d;
-	struct thandle		*th;
-	char			*name = NULL;
-	int			 rc;
-
-	ctxt = loghandle->lgh_ctxt;
-	LASSERT(ctxt);
-
-	o = loghandle->lgh_obj;
-	LASSERT(o);
-
-	d = lu2dt_dev(o->do_lu.lo_dev);
-	LASSERT(d);
-	LASSERT(d == ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt);
-
-	th = dt_trans_create(env, d);
-	if (IS_ERR(th))
-		return PTR_ERR(th);
-
-	if (loghandle->lgh_name) {
-		llog_dir = llog_osd_dir_get(env, ctxt);
-		if (IS_ERR(llog_dir))
-			GOTO(out_trans, rc = PTR_ERR(llog_dir));
-
-		name = loghandle->lgh_name;
-		rc = dt_declare_delete(env, llog_dir,
-				       (struct dt_key *)name, th);
-		if (rc)
-			GOTO(out_trans, rc);
-	}
-
-	dt_declare_ref_del(env, o, th);
-
-	rc = dt_declare_destroy(env, o, th);
-	if (rc)
-		GOTO(out_trans, rc);
-
-	rc = dt_trans_start_local(env, d, th);
-	if (rc)
-		GOTO(out_trans, rc);
-
-	dt_write_lock(env, o, 0);
-	if (dt_object_exists(o)) {
-		if (name) {
-			dt_read_lock(env, llog_dir, 0);
-			rc = dt_delete(env, llog_dir,
-				       (struct dt_key *) name,
-				       th, BYPASS_CAPA);
-			dt_read_unlock(env, llog_dir);
-			if (rc) {
-				CERROR("%s: can't remove llog %s: rc = %d\n",
-				       o->do_lu.lo_dev->ld_obd->obd_name,
-				       name, rc);
-				GOTO(out_unlock, rc);
-			}
-		}
-		dt_ref_del(env, o, th);
-		rc = dt_destroy(env, o, th);
-		if (rc)
-			GOTO(out_unlock, rc);
-	}
-out_unlock:
-	dt_write_unlock(env, o);
-out_trans:
-	dt_trans_stop(env, d, th);
-	if (llog_dir != NULL)
-		lu_object_put(env, &llog_dir->do_lu);
-	return rc;
-}
-
-static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd,
-			  struct obd_llog_group *olg, int ctxt_idx,
-			  struct obd_device *disk_obd)
-{
-	struct local_oid_storage	*los;
-	struct llog_thread_info		*lgi = llog_info(env);
-	struct llog_ctxt		*ctxt;
-	int				 rc = 0;
-
-	LASSERT(obd);
-	LASSERT(olg->olg_ctxts[ctxt_idx]);
-
-	ctxt = llog_ctxt_get(olg->olg_ctxts[ctxt_idx]);
-	LASSERT(ctxt);
-
-	/* initialize data allowing to generate new fids,
-	 * literally we need a sequence */
-	lgi->lgi_fid.f_seq = FID_SEQ_LLOG;
-	lgi->lgi_fid.f_oid = 1;
-	lgi->lgi_fid.f_ver = 0;
-	rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
-				    &lgi->lgi_fid, &los);
-	if (rc < 0)
-		return rc;
-
-	lgi->lgi_fid.f_seq = FID_SEQ_LLOG_NAME;
-	lgi->lgi_fid.f_oid = 1;
-	lgi->lgi_fid.f_ver = 0;
-	rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
-				    &lgi->lgi_fid, &los);
-	llog_ctxt_put(ctxt);
-	return rc;
-}
-
-static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
-{
-	struct dt_device		*dt;
-	struct ls_device		*ls;
-	struct local_oid_storage	*los, *nlos;
-
-	LASSERT(ctxt->loc_exp->exp_obd);
-	dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt;
-	ls = ls_device_get(dt);
-	if (IS_ERR(ls))
-		return PTR_ERR(ls);
-
-	mutex_lock(&ls->ls_los_mutex);
-	los = dt_los_find(ls, FID_SEQ_LLOG);
-	nlos = dt_los_find(ls, FID_SEQ_LLOG_NAME);
-	mutex_unlock(&ls->ls_los_mutex);
-	if (los != NULL) {
-		dt_los_put(los);
-		local_oid_storage_fini(env, los);
-	}
-	if (nlos != NULL) {
-		dt_los_put(nlos);
-		local_oid_storage_fini(env, nlos);
-	}
-	ls_device_put(env, ls);
-	return 0;
-}
-
-struct llog_operations llog_osd_ops = {
-	.lop_next_block		= llog_osd_next_block,
-	.lop_prev_block		= llog_osd_prev_block,
-	.lop_read_header	= llog_osd_read_header,
-	.lop_destroy		= llog_osd_destroy,
-	.lop_setup		= llog_osd_setup,
-	.lop_cleanup		= llog_osd_cleanup,
-	.lop_open		= llog_osd_open,
-	.lop_exist		= llog_osd_exist,
-	.lop_declare_create	= llog_osd_declare_create,
-	.lop_create		= llog_osd_create,
-	.lop_declare_write_rec	= llog_osd_declare_write_rec,
-	.lop_write_rec		= llog_osd_write_rec,
-	.lop_close		= llog_osd_close,
-};
-EXPORT_SYMBOL(llog_osd_ops);
-
-/* reads the catalog list */
-int llog_osd_get_cat_list(const struct lu_env *env, struct dt_device *d,
-			  int idx, int count, struct llog_catid *idarray)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	struct dt_object	*o = NULL;
-	struct thandle		*th;
-	int			 rc, size;
-
-	LASSERT(d);
-
-	size = sizeof(*idarray) * count;
-	lgi->lgi_off = idx *  sizeof(*idarray);
-
-	lu_local_obj_fid(&lgi->lgi_fid, LLOG_CATALOGS_OID);
-
-	o = dt_locate(env, d, &lgi->lgi_fid);
-	if (IS_ERR(o))
-		return PTR_ERR(o);
-
-	if (!dt_object_exists(o)) {
-		th = dt_trans_create(env, d);
-		if (IS_ERR(th))
-			GOTO(out, rc = PTR_ERR(th));
-
-		lgi->lgi_attr.la_valid = LA_MODE;
-		lgi->lgi_attr.la_mode = S_IFREG | S_IRUGO | S_IWUSR;
-		lgi->lgi_dof.dof_type = dt_mode_to_dft(S_IFREG);
-
-		rc = dt_declare_create(env, o, &lgi->lgi_attr, NULL,
-				       &lgi->lgi_dof, th);
-		if (rc)
-			GOTO(out_trans, rc);
-
-		rc = dt_trans_start_local(env, d, th);
-		if (rc)
-			GOTO(out_trans, rc);
-
-		dt_write_lock(env, o, 0);
-		if (!dt_object_exists(o))
-			rc = dt_create(env, o, &lgi->lgi_attr, NULL,
-				       &lgi->lgi_dof, th);
-		dt_write_unlock(env, o);
-out_trans:
-		dt_trans_stop(env, d, th);
-		if (rc)
-			GOTO(out, rc);
-	}
-
-	rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA);
-	if (rc)
-		GOTO(out, rc);
-
-	if (!S_ISREG(lgi->lgi_attr.la_mode)) {
-		CERROR("%s: CATALOGS is not a regular file!: mode = %o\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name,
-		       lgi->lgi_attr.la_mode);
-		GOTO(out, rc = -ENOENT);
-	}
-
-	CDEBUG(D_CONFIG, "cat list: disk size=%d, read=%d\n",
-	       (int)lgi->lgi_attr.la_size, size);
-
-	/* return just number of llogs */
-	if (idarray == NULL) {
-		rc = lgi->lgi_attr.la_size / sizeof(*idarray);
-		GOTO(out, rc);
-	}
-
-	/* read for new ost index or for empty file */
-	memset(idarray, 0, size);
-	if (lgi->lgi_attr.la_size < lgi->lgi_off + size)
-		GOTO(out, rc = 0);
-	if (lgi->lgi_attr.la_size < lgi->lgi_off + size)
-		size = lgi->lgi_attr.la_size - lgi->lgi_off;
-
-	lgi->lgi_buf.lb_buf = idarray;
-	lgi->lgi_buf.lb_len = size;
-	rc = dt_record_read(env, o, &lgi->lgi_buf, &lgi->lgi_off);
-	if (rc) {
-		CERROR("%s: error reading CATALOGS: rc = %d\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name,  rc);
-		GOTO(out, rc);
-	}
-
-out:
-	lu_object_put(env, &o->do_lu);
-	return rc;
-}
-EXPORT_SYMBOL(llog_osd_get_cat_list);
-
-/* writes the cat list */
-int llog_osd_put_cat_list(const struct lu_env *env, struct dt_device *d,
-			  int idx, int count, struct llog_catid *idarray)
-{
-	struct llog_thread_info	*lgi = llog_info(env);
-	struct dt_object	*o = NULL;
-	struct thandle		*th;
-	int			 rc, size;
-
-	if (!count)
-		return 0;
-
-	LASSERT(d);
-
-	size = sizeof(*idarray) * count;
-	lgi->lgi_off = idx * sizeof(*idarray);
-
-	lu_local_obj_fid(&lgi->lgi_fid, LLOG_CATALOGS_OID);
-
-	o = dt_locate(env, d, &lgi->lgi_fid);
-	if (IS_ERR(o))
-		return PTR_ERR(o);
-
-	if (!dt_object_exists(o))
-		GOTO(out, rc = -ENOENT);
-
-	rc = dt_attr_get(env, o, &lgi->lgi_attr, BYPASS_CAPA);
-	if (rc)
-		GOTO(out, rc);
-
-	if (!S_ISREG(lgi->lgi_attr.la_mode)) {
-		CERROR("%s: CATALOGS is not a regular file!: mode = %o\n",
-		       o->do_lu.lo_dev->ld_obd->obd_name,
-		       lgi->lgi_attr.la_mode);
-		GOTO(out, rc = -ENOENT);
-	}
-
-	th = dt_trans_create(env, d);
-	if (IS_ERR(th))
-		GOTO(out, rc = PTR_ERR(th));
-
-	rc = dt_declare_record_write(env, o, size, lgi->lgi_off, th);
-	if (rc)
-		GOTO(out, rc);
-
-	rc = dt_trans_start_local(env, d, th);
-	if (rc)
-		GOTO(out_trans, rc);
-
-	lgi->lgi_buf.lb_buf = idarray;
-	lgi->lgi_buf.lb_len = size;
-	rc = dt_record_write(env, o, &lgi->lgi_buf, &lgi->lgi_off, th);
-	if (rc)
-		CDEBUG(D_INODE, "error writing CATALOGS: rc = %d\n", rc);
-out_trans:
-	dt_trans_stop(env, d, th);
-out:
-	lu_object_put(env, &o->do_lu);
-	return rc;
-}
-EXPORT_SYMBOL(llog_osd_put_cat_list);
-- 
1.9.3


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

* [PATCH 11/12] staging/lustre/mdc: remove obsolete llog ioctl handlers
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (9 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 10/12] staging/lustre/obdclass: remove llog_osd.c Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  2014-08-30 21:12 ` [PATCH 12/12] staging/lustre: remove unused som_attrs and hsm_attrs structures Oleg Drokin
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Oleg Drokin

From: "John L. Hammond" <john.hammond@intel.com>

In mdc_iocontrol() remove the handlers for the obsolete llog ioctls
OBD_IOC_PARSE, OBD_IOC_LLOG_INFO, and OBD_IOC_LLOG_PRINT.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/mdc/mdc_request.c | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index a2a6334..e6e2515 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1830,7 +1830,6 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 	struct obd_device *obd = exp->exp_obd;
 	struct obd_ioctl_data *data = karg;
 	struct obd_import *imp = obd->u.cli.cl_import;
-	struct llog_ctxt *ctxt;
 	int rc;
 
 	if (!try_module_get(THIS_MODULE)) {
@@ -1886,20 +1885,6 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 	case IOC_OSC_SET_ACTIVE:
 		rc = ptlrpc_set_import_active(imp, data->ioc_offset);
 		goto out;
-	case OBD_IOC_PARSE: {
-		ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
-		rc = class_config_parse_llog(NULL, ctxt, data->ioc_inlbuf1,
-					     NULL);
-		llog_ctxt_put(ctxt);
-		goto out;
-	}
-	case OBD_IOC_LLOG_INFO:
-	case OBD_IOC_LLOG_PRINT: {
-		ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);
-		rc = llog_ioctl(NULL, ctxt, cmd, data);
-		llog_ctxt_put(ctxt);
-		goto out;
-	}
 	case OBD_IOC_POLL_QUOTACHECK:
 		rc = mdc_quota_poll_check(exp, (struct if_quotacheck *)karg);
 		goto out;
-- 
1.9.3


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

* [PATCH 12/12] staging/lustre: remove unused som_attrs and hsm_attrs structures
  2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
                   ` (10 preceding siblings ...)
  2014-08-30 21:12 ` [PATCH 11/12] staging/lustre/mdc: remove obsolete llog ioctl handlers Oleg Drokin
@ 2014-08-30 21:12 ` Oleg Drokin
  11 siblings, 0 replies; 13+ messages in thread
From: Oleg Drokin @ 2014-08-30 21:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, devel, Andreas Dilger
  Cc: John L. Hammond, Oleg Drokin

These structures are only used server-side to parse relevant
attributes.

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 .../lustre/lustre/include/lustre/lustre_idl.h      | 37 -----------------
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c    | 48 ----------------------
 2 files changed, 85 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
index 88c3990..e529ad4 100644
--- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
@@ -322,43 +322,6 @@ enum lma_incompat {
 #define LMA_INCOMPAT_SUPP	(LMAI_AGENT | LMAI_REMOTE_PARENT)
 
 /**
- * SOM on-disk attributes stored in a separate xattr.
- */
-struct som_attrs {
-	/** Bitfield for supported data in this structure. For future use. */
-	__u32	som_compat;
-
-	/** Incompat feature list. The supported feature mask is available in
-	 * SOM_INCOMPAT_SUPP */
-	__u32	som_incompat;
-
-	/** IO Epoch SOM attributes belongs to */
-	__u64	som_ioepoch;
-	/** total file size in objects */
-	__u64	som_size;
-	/** total fs blocks in objects */
-	__u64	som_blocks;
-	/** mds mount id the size is valid for */
-	__u64	som_mountid;
-};
-#define SOM_INCOMPAT_SUPP 0x0
-
-/**
- * HSM on-disk attributes stored in a separate xattr.
- */
-struct hsm_attrs {
-	/** Bitfield for supported data in this structure. For future use. */
-	__u32	hsm_compat;
-
-	/** HSM flags, see hsm_flags enum below */
-	__u32	hsm_flags;
-	/** backend archive id associated with the file */
-	__u64	hsm_arch_id;
-	/** version associated with the last archiving, if any */
-	__u64	hsm_arch_ver;
-};
-
-/**
  * fid constants
  */
 enum {
diff --git a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
index 0624420..d6d9204 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/wiretest.c
@@ -460,54 +460,6 @@ void lustre_assert_wire_constants(void)
 	LASSERTF(OBJ_INDEX_DELETE == 11, "found %lld\n",
 		 (long long)OBJ_INDEX_DELETE);
 
-	/* Checks for struct som_attrs */
-	LASSERTF((int)sizeof(struct som_attrs) == 40, "found %lld\n",
-		 (long long)(int)sizeof(struct som_attrs));
-	LASSERTF((int)offsetof(struct som_attrs, som_compat) == 0, "found %lld\n",
-		 (long long)(int)offsetof(struct som_attrs, som_compat));
-	LASSERTF((int)sizeof(((struct som_attrs *)0)->som_compat) == 4, "found %lld\n",
-		 (long long)(int)sizeof(((struct som_attrs *)0)->som_compat));
-	LASSERTF((int)offsetof(struct som_attrs, som_incompat) == 4, "found %lld\n",
-		 (long long)(int)offsetof(struct som_attrs, som_incompat));
-	LASSERTF((int)sizeof(((struct som_attrs *)0)->som_incompat) == 4, "found %lld\n",
-		 (long long)(int)sizeof(((struct som_attrs *)0)->som_incompat));
-	LASSERTF((int)offsetof(struct som_attrs, som_ioepoch) == 8, "found %lld\n",
-		 (long long)(int)offsetof(struct som_attrs, som_ioepoch));
-	LASSERTF((int)sizeof(((struct som_attrs *)0)->som_ioepoch) == 8, "found %lld\n",
-		 (long long)(int)sizeof(((struct som_attrs *)0)->som_ioepoch));
-	LASSERTF((int)offsetof(struct som_attrs, som_size) == 16, "found %lld\n",
-		 (long long)(int)offsetof(struct som_attrs, som_size));
-	LASSERTF((int)sizeof(((struct som_attrs *)0)->som_size) == 8, "found %lld\n",
-		 (long long)(int)sizeof(((struct som_attrs *)0)->som_size));
-	LASSERTF((int)offsetof(struct som_attrs, som_blocks) == 24, "found %lld\n",
-		 (long long)(int)offsetof(struct som_attrs, som_blocks));
-	LASSERTF((int)sizeof(((struct som_attrs *)0)->som_blocks) == 8, "found %lld\n",
-		 (long long)(int)sizeof(((struct som_attrs *)0)->som_blocks));
-	LASSERTF((int)offsetof(struct som_attrs, som_mountid) == 32, "found %lld\n",
-		 (long long)(int)offsetof(struct som_attrs, som_mountid));
-	LASSERTF((int)sizeof(((struct som_attrs *)0)->som_mountid) == 8, "found %lld\n",
-		 (long long)(int)sizeof(((struct som_attrs *)0)->som_mountid));
-
-	/* Checks for struct hsm_attrs */
-	LASSERTF((int)sizeof(struct hsm_attrs) == 24, "found %lld\n",
-		 (long long)(int)sizeof(struct hsm_attrs));
-	LASSERTF((int)offsetof(struct hsm_attrs, hsm_compat) == 0, "found %lld\n",
-		 (long long)(int)offsetof(struct hsm_attrs, hsm_compat));
-	LASSERTF((int)sizeof(((struct hsm_attrs *)0)->hsm_compat) == 4, "found %lld\n",
-		 (long long)(int)sizeof(((struct hsm_attrs *)0)->hsm_compat));
-	LASSERTF((int)offsetof(struct hsm_attrs, hsm_flags) == 4, "found %lld\n",
-		 (long long)(int)offsetof(struct hsm_attrs, hsm_flags));
-	LASSERTF((int)sizeof(((struct hsm_attrs *)0)->hsm_flags) == 4, "found %lld\n",
-		 (long long)(int)sizeof(((struct hsm_attrs *)0)->hsm_flags));
-	LASSERTF((int)offsetof(struct hsm_attrs, hsm_arch_id) == 8, "found %lld\n",
-		 (long long)(int)offsetof(struct hsm_attrs, hsm_arch_id));
-	LASSERTF((int)sizeof(((struct hsm_attrs *)0)->hsm_arch_id) == 8, "found %lld\n",
-		 (long long)(int)sizeof(((struct hsm_attrs *)0)->hsm_arch_id));
-	LASSERTF((int)offsetof(struct hsm_attrs, hsm_arch_ver) == 16, "found %lld\n",
-		 (long long)(int)offsetof(struct hsm_attrs, hsm_arch_ver));
-	LASSERTF((int)sizeof(((struct hsm_attrs *)0)->hsm_arch_ver) == 8, "found %lld\n",
-		 (long long)(int)sizeof(((struct hsm_attrs *)0)->hsm_arch_ver));
-
 	/* Checks for struct ost_id */
 	LASSERTF((int)sizeof(struct ost_id) == 16, "found %lld\n",
 		 (long long)(int)sizeof(struct ost_id));
-- 
1.9.3


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

end of thread, other threads:[~2014-08-30 21:13 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-30 21:12 [PATCH 00/12] lustre: continues dead code removal Oleg Drokin
2014-08-30 21:12 ` [PATCH 01/12] staging/lustre: Remove unused header libcfs_heap.h Oleg Drokin
2014-08-30 21:12 ` [PATCH 02/12] staging/lustre/obdecho: remove metadata echo client Oleg Drokin
2014-08-30 21:12 ` [PATCH 03/12] staging/lustre/obdecho: remove #if 0-ed out regions Oleg Drokin
2014-08-30 21:12 ` [PATCH 04/12] staging/lustre/obdclass: remove idmap.c Oleg Drokin
2014-08-30 21:12 ` [PATCH 05/12] staging/lustre/obdclass: remove lu_ucred.c Oleg Drokin
2014-08-30 21:12 ` [PATCH 06/12] staging/lustre/obdclass: remove mea.c Oleg Drokin
2014-08-30 21:12 ` [PATCH 07/12] staging/lustre: remove md_object.h Oleg Drokin
2014-08-30 21:12 ` [PATCH 08/12] staging/lustre/mgc: remove server specific handlers Oleg Drokin
2014-08-30 21:12 ` [PATCH 09/12] staging/lustre/obdclass: remove llog_test.ko Oleg Drokin
2014-08-30 21:12 ` [PATCH 10/12] staging/lustre/obdclass: remove llog_osd.c Oleg Drokin
2014-08-30 21:12 ` [PATCH 11/12] staging/lustre/mdc: remove obsolete llog ioctl handlers Oleg Drokin
2014-08-30 21:12 ` [PATCH 12/12] staging/lustre: remove unused som_attrs and hsm_attrs structures Oleg Drokin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.