#include <md_object.h>
#include <lustre_fid.h>
#include <lustre_acl.h>
+#include <lustre_ioctl.h>
#include <lustre_net.h>
-#include <obd_lov.h>
#include "echo_internal.h"
struct cl_object_header eo_hdr;
struct echo_device *eo_dev;
- cfs_list_t eo_obj_chain;
+ struct list_head eo_obj_chain;
struct lov_stripe_md *eo_lsm;
- cfs_atomic_t eo_npages;
+ atomic_t eo_npages;
int eo_deleted;
};
};
struct echo_page {
- struct cl_page_slice ep_cl;
+ struct cl_page_slice ep_cl;
struct mutex ep_lock;
- struct page *ep_vmpage;
};
struct echo_lock {
- struct cl_lock_slice el_cl;
- cfs_list_t el_chain;
- struct echo_object *el_object;
- __u64 el_cookie;
- cfs_atomic_t el_refcount;
+ struct cl_lock_slice el_cl;
+ struct list_head el_chain;
+ struct echo_object *el_object;
+ __u64 el_cookie;
+ 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);
static struct echo_object *cl_echo_object_find(struct echo_device *d,
struct lov_stripe_md **lsm);
static int cl_echo_object_put(struct echo_object *eco);
-static int cl_echo_enqueue (struct echo_object *eco, obd_off start,
- obd_off end, int mode, __u64 *cookie);
-static int cl_echo_cancel (struct echo_device *d, __u64 cookie);
static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset,
struct page **pages, int npages, int async);
-static struct echo_thread_info *echo_env_info(const struct lu_env *env);
-
struct echo_thread_info {
- struct echo_object_conf eti_conf;
- struct lustre_md eti_md;
+ struct echo_object_conf eti_conf;
+ struct lustre_md eti_md;
- struct cl_2queue eti_queue;
- struct cl_io eti_io;
- struct cl_lock_descr eti_descr;
- struct lu_fid eti_fid;
+ struct cl_2queue eti_queue;
+ struct cl_io eti_io;
+ 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;
+#ifdef HAVE_SERVER_SUPPORT
+ 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];
+ char eti_name[20];
+ struct lu_buf eti_buf;
+ char eti_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
+#endif
};
/* No session used right now */
.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
}
*
* @{
*/
-static struct page *echo_page_vmpage(const struct lu_env *env,
- const struct cl_page_slice *slice)
-{
- return cl2echo_page(slice)->ep_vmpage;
-}
-
static int echo_page_own(const struct lu_env *env,
const struct cl_page_slice *slice,
struct cl_io *io, int nonblock)
struct echo_object *eco = cl2echo_obj(slice->cpl_obj);
ENTRY;
- cfs_atomic_dec(&eco->eo_npages);
- page_cache_release(cl2echo_page(slice)->ep_vmpage);
+ atomic_dec(&eco->eo_npages);
+ page_cache_release(slice->cpl_page->cp_vmpage);
EXIT;
}
const struct cl_page_slice *slice,
void *cookie, lu_printer_t printer)
{
- struct echo_page *ep = cl2echo_page(slice);
+ struct echo_page *ep = cl2echo_page(slice);
- (*printer)(env, cookie, LUSTRE_ECHO_CLIENT_NAME"-page@%p %d vm@%p\n",
- ep, mutex_is_locked(&ep->ep_lock), ep->ep_vmpage);
- return 0;
+ (*printer)(env, cookie, LUSTRE_ECHO_CLIENT_NAME"-page@%p %d vm@%p\n",
+ ep, mutex_is_locked(&ep->ep_lock),
+ slice->cpl_page->cp_vmpage);
+ return 0;
}
static const struct cl_page_operations echo_page_ops = {
.cpo_own = echo_page_own,
.cpo_disown = echo_page_disown,
.cpo_discard = echo_page_discard,
- .cpo_vmpage = echo_page_vmpage,
.cpo_fini = echo_page_fini,
.cpo_print = echo_page_print,
.cpo_is_vmlocked = echo_page_is_vmlocked,
{
struct echo_lock *ecl = cl2echo_lock(slice);
- LASSERT(cfs_list_empty(&ecl->el_chain));
+ LASSERT(list_empty(&ecl->el_chain));
OBD_SLAB_FREE_PTR(ecl, echo_lock_kmem);
}
{
struct echo_lock *ecl = cl2echo_lock(slice);
- LASSERT(cfs_list_empty(&ecl->el_chain));
+ LASSERT(list_empty(&ecl->el_chain));
}
static int echo_lock_fits_into(const struct lu_env *env,
* @{
*/
static int echo_page_init(const struct lu_env *env, struct cl_object *obj,
- struct cl_page *page, struct page *vmpage)
+ struct cl_page *page, pgoff_t index)
{
- struct echo_page *ep = cl_object_page_slice(obj, page);
+ struct echo_page *ep = cl_object_page_slice(obj, page);
struct echo_object *eco = cl2echo_obj(obj);
- ENTRY;
+ ENTRY;
- ep->ep_vmpage = vmpage;
- page_cache_get(vmpage);
+ page_cache_get(page->cp_vmpage);
mutex_init(&ep->ep_lock);
- cl_page_slice_add(page, &ep->ep_cl, obj, &echo_page_ops);
- cfs_atomic_inc(&eco->eo_npages);
- RETURN(0);
+ cl_page_slice_add(page, &ep->ep_cl, obj, index, &echo_page_ops);
+ atomic_inc(&eco->eo_npages);
+ RETURN(0);
}
static int echo_io_init(const struct lu_env *env, struct cl_object *obj,
}
static int echo_lock_init(const struct lu_env *env,
- struct cl_object *obj, struct cl_lock *lock,
- const struct cl_io *unused)
+ struct cl_object *obj, struct cl_lock *lock,
+ const struct cl_io *unused)
{
- struct echo_lock *el;
- ENTRY;
+ struct echo_lock *el;
+ ENTRY;
- OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, __GFP_IO);
- if (el != NULL) {
- cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops);
- el->el_object = cl2echo_obj(obj);
- CFS_INIT_LIST_HEAD(&el->el_chain);
- cfs_atomic_set(&el->el_refcount, 0);
- }
- RETURN(el == NULL ? -ENOMEM : 0);
+ OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, GFP_NOFS);
+ if (el != NULL) {
+ cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops);
+ el->el_object = cl2echo_obj(obj);
+ INIT_LIST_HEAD(&el->el_chain);
+ atomic_set(&el->el_refcount, 0);
+ }
+ RETURN(el == NULL ? -ENOMEM : 0);
}
static int echo_conf_set(const struct lu_env *env, struct cl_object *obj,
}
eco->eo_dev = ed;
- cfs_atomic_set(&eco->eo_npages, 0);
+ atomic_set(&eco->eo_npages, 0);
cl_object_page_init(lu2cl(obj), sizeof(struct echo_page));
spin_lock(&ec->ec_lock);
- cfs_list_add_tail(&eco->eo_obj_chain, &ec->ec_objects);
+ list_add_tail(&eco->eo_obj_chain, &ec->ec_objects);
spin_unlock(&ec->ec_lock);
RETURN(0);
struct echo_client_obd *ec = eco->eo_dev->ed_ec;
ENTRY;
- LASSERT(cfs_atomic_read(&eco->eo_npages) == 0);
+ LASSERT(atomic_read(&eco->eo_npages) == 0);
spin_lock(&ec->ec_lock);
- cfs_list_del_init(&eco->eo_obj_chain);
+ list_del_init(&eco->eo_obj_chain);
spin_unlock(&ec->ec_lock);
lu_object_fini(obj);
* @{
*/
static struct lu_object *echo_object_alloc(const struct lu_env *env,
- const struct lu_object_header *hdr,
- struct lu_device *dev)
+ const struct lu_object_header *hdr,
+ struct lu_device *dev)
{
- struct echo_object *eco;
- struct lu_object *obj = NULL;
- ENTRY;
+ struct echo_object *eco;
+ struct lu_object *obj = NULL;
+ ENTRY;
- /* we're the top dev. */
- LASSERT(hdr == NULL);
- OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, __GFP_IO);
- if (eco != NULL) {
- struct cl_object_header *hdr = &eco->eo_hdr;
+ /* we're the top dev. */
+ LASSERT(hdr == NULL);
+ OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, GFP_NOFS);
+ if (eco != NULL) {
+ struct cl_object_header *hdr = &eco->eo_hdr;
- obj = &echo_obj2cl(eco)->co_lu;
- cl_object_header_init(hdr);
- lu_object_init(obj, &hdr->coh_lu, dev);
- lu_object_add_top(&hdr->coh_lu, obj);
+ obj = &echo_obj2cl(eco)->co_lu;
+ cl_object_header_init(hdr);
+ hdr->coh_page_bufsize = cfs_size_round(sizeof(struct cl_page));
- eco->eo_cl.co_ops = &echo_cl_obj_ops;
- obj->lo_ops = &echo_lu_obj_ops;
- }
- RETURN(obj);
+ lu_object_init(obj, &hdr->coh_lu, dev);
+ lu_object_add_top(&hdr->coh_lu, obj);
+
+ eco->eo_cl.co_ops = &echo_cl_obj_ops;
+ obj->lo_ops = &echo_lu_obj_ops;
+ }
+ RETURN(obj);
}
static struct lu_device_operations echo_device_lu_ops = {
}
static void *echo_thread_key_init(const struct lu_context *ctx,
- struct lu_context_key *key)
+ struct lu_context_key *key)
{
- struct echo_thread_info *info;
+ struct echo_thread_info *info;
- OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, __GFP_IO);
- if (info == NULL)
- info = ERR_PTR(-ENOMEM);
- return info;
+ OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, GFP_NOFS);
+ if (info == NULL)
+ info = ERR_PTR(-ENOMEM);
+ return info;
}
static void echo_thread_key_fini(const struct lu_context *ctx,
};
static void *echo_session_key_init(const struct lu_context *ctx,
- struct lu_context_key *key)
+ struct lu_context_key *key)
{
- struct echo_session_info *session;
+ struct echo_session_info *session;
- OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, __GFP_IO);
- if (session == NULL)
- session = ERR_PTR(-ENOMEM);
- return session;
+ OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, GFP_NOFS);
+ if (session == NULL)
+ session = ERR_PTR(-ENOMEM);
+ return session;
}
static void echo_session_key_fini(const struct lu_context *ctx,
LU_TYPE_INIT_FINI(echo, &echo_thread_key, &echo_session_key);
-#define ECHO_SEQ_WIDTH 0xffffffff
+#ifdef HAVE_SERVER_SUPPORT
+# define ECHO_SEQ_WIDTH 0xffffffff
static int echo_fid_init(struct echo_device *ed, char *obd_name,
struct seq_server_site *ss)
{
RETURN(0);
}
+#endif /* HAVE_SERVER_SUPPORT */
static struct lu_device *echo_device_alloc(const struct lu_env *env,
struct lu_device_type *t,
cleanup = 4;
if (ed->ed_next_ismd) {
+#ifdef HAVE_SERVER_SUPPORT
/* Suppose to connect to some Metadata layer */
struct lu_site *ls;
struct lu_device *ld;
ls = next->ld_site;
spin_lock(&ls->ls_ld_lock);
- cfs_list_for_each_entry(ld, &ls->ls_ld_linkage, ld_linkage) {
+ 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;
CERROR("echo fid init error %d\n", rc);
GOTO(out, rc);
}
+#else /* !HAVE_SERVER_SUPPORT */
+ CERROR("Local operations are NOT supported on client side. "
+ "Only remote operations are supported. Metadata client "
+ "must be run on server side.\n");
+ GOTO(out, rc = -EOPNOTSUPP);
+#endif
} else {
/* if echo client is to be stacked upon ost device, the next is
* NULL since ost is not a clio device so far */
* parallelly accessed.
*/
spin_lock(&ec->ec_lock);
- cfs_list_for_each_entry(eco, &ec->ec_objects, eo_obj_chain)
+ list_for_each_entry(eco, &ec->ec_objects, eo_obj_chain)
eco->eo_deleted = 1;
spin_unlock(&ec->ec_lock);
/* Wait for the last reference to be dropped. */
spin_lock(&ec->ec_lock);
- while (!cfs_list_empty(&ec->ec_objects)) {
+ while (!list_empty(&ec->ec_objects)) {
spin_unlock(&ec->ec_lock);
CERROR("echo_client still has objects at cleanup time, "
"wait for 1 second\n");
}
spin_unlock(&ec->ec_lock);
- LASSERT(cfs_list_empty(&ec->ec_locks));
+ LASSERT(list_empty(&ec->ec_locks));
- CDEBUG(D_INFO, "No object exists, exiting...\n");
+ 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)
- next = next->ld_type->ldt_ops->ldto_device_free(env, next);
+ echo_client_cleanup(d->ld_obd);
+#ifdef HAVE_SERVER_SUPPORT
+ echo_fid_fini(d->ld_obd);
+#endif
+ while (next && !ed->ed_next_ismd)
+ next = next->ld_type->ldt_ops->ldto_device_free(env, next);
LASSERT(ed->ed_site == lu2cl_site(d->ld_site));
echo_site_fini(env, ed);
if (rc == 0) {
el = cl2echo_lock(cl_lock_at(lck, &echo_device_type));
spin_lock(&ec->ec_lock);
- if (cfs_list_empty(&el->el_chain)) {
- cfs_list_add(&el->el_chain, &ec->ec_locks);
+ if (list_empty(&el->el_chain)) {
+ list_add(&el->el_chain, &ec->ec_locks);
el->el_cookie = ++ec->ec_unique;
}
- cfs_atomic_inc(&el->el_refcount);
+ atomic_inc(&el->el_refcount);
*cookie = el->el_cookie;
spin_unlock(&ec->ec_lock);
} else {
RETURN(rc);
}
-static int cl_echo_enqueue(struct echo_object *eco, obd_off start, obd_off end,
- int mode, __u64 *cookie)
-{
- struct echo_thread_info *info;
- struct lu_env *env;
- struct cl_io *io;
- int refcheck;
- int result;
- ENTRY;
-
- env = cl_env_get(&refcheck);
- if (IS_ERR(env))
- RETURN(PTR_ERR(env));
-
- info = echo_env_info(env);
- io = &info->eti_io;
-
- io->ci_ignore_layout = 1;
- result = cl_io_init(env, io, CIT_MISC, echo_obj2cl(eco));
- if (result < 0)
- GOTO(out, result);
- LASSERT(result == 0);
-
- result = cl_echo_enqueue0(env, eco, start, end, mode, cookie, 0);
- cl_io_fini(env, io);
-
- EXIT;
-out:
- cl_env_put(env, &refcheck);
- return result;
-}
-
static int cl_echo_cancel0(struct lu_env *env, struct echo_device *ed,
__u64 cookie)
{
struct echo_client_obd *ec = ed->ed_ec;
struct echo_lock *ecl = NULL;
- cfs_list_t *el;
+ struct list_head *el;
int found = 0, still_used = 0;
ENTRY;
LASSERT(ec != NULL);
spin_lock(&ec->ec_lock);
- cfs_list_for_each (el, &ec->ec_locks) {
- ecl = cfs_list_entry (el, struct echo_lock, el_chain);
+ list_for_each(el, &ec->ec_locks) {
+ ecl = list_entry(el, struct echo_lock, el_chain);
CDEBUG(D_INFO, "ecl: %p, cookie: "LPX64"\n", ecl, ecl->el_cookie);
found = (ecl->el_cookie == cookie);
if (found) {
- if (cfs_atomic_dec_and_test(&ecl->el_refcount))
- cfs_list_del_init(&ecl->el_chain);
+ if (atomic_dec_and_test(&ecl->el_refcount))
+ list_del_init(&ecl->el_chain);
else
still_used = 1;
break;
RETURN(0);
}
-static int cl_echo_cancel(struct echo_device *ed, __u64 cookie)
+static void echo_commit_callback(const struct lu_env *env, struct cl_io *io,
+ struct cl_page *page)
{
- struct lu_env *env;
- int refcheck;
- int rc;
- ENTRY;
-
- env = cl_env_get(&refcheck);
- if (IS_ERR(env))
- RETURN(PTR_ERR(env));
-
- rc = cl_echo_cancel0(env, ed, cookie);
-
- cl_env_put(env, &refcheck);
- RETURN(rc);
-}
+ struct echo_thread_info *info;
+ struct cl_2queue *queue;
-static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io,
- enum cl_req_type unused, struct cl_2queue *queue)
-{
- struct cl_page *clp;
- struct cl_page *temp;
- int result = 0;
- ENTRY;
+ info = echo_env_info(env);
+ LASSERT(io == &info->eti_io);
- cl_page_list_for_each_safe(clp, temp, &queue->c2_qin) {
- int rc;
- rc = cl_page_cache_add(env, io, clp, CRT_WRITE);
- if (rc == 0)
- continue;
- result = result ?: rc;
- }
- RETURN(result);
+ queue = &info->eti_queue;
+ cl_page_list_add(&queue->c2_qout, page);
}
static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset,
async = async && (typ == CRT_WRITE);
if (async)
- rc = cl_echo_async_brw(env, io, typ, queue);
- else
+ rc = cl_io_commit_async(env, io, &queue->c2_qin,
+ 0, PAGE_SIZE,
+ echo_commit_callback);
+ else
rc = cl_io_submit_sync(env, io, typ, queue, 0);
CDEBUG(D_INFO, "echo_client %s write returns %d\n",
async ? "async" : "sync", rc);
static obd_id last_object_id;
static int
-echo_copyout_lsm (struct lov_stripe_md *lsm, void *_ulsm, int ulsm_nob)
-{
- struct lov_stripe_md *ulsm = _ulsm;
- int nob, i;
-
- nob = offsetof (struct lov_stripe_md, lsm_oinfo[lsm->lsm_stripe_count]);
- if (nob > ulsm_nob)
- return (-EINVAL);
-
- if (copy_to_user (ulsm, lsm, sizeof(ulsm)))
- return (-EFAULT);
-
- for (i = 0; i < lsm->lsm_stripe_count; i++) {
- if (copy_to_user (ulsm->lsm_oinfo[i], lsm->lsm_oinfo[i],
- sizeof(lsm->lsm_oinfo[0])))
- return (-EFAULT);
- }
- return 0;
-}
-
-static int
echo_copyin_lsm (struct echo_device *ed, struct lov_stripe_md *lsm,
void *ulsm, int ulsm_nob)
{
return (0);
}
+#ifdef HAVE_SERVER_SUPPORT
static inline void echo_md_build_name(struct lu_name *lname, char *name,
__u64 id)
{
RETURN(0);
}
-int echo_attr_get_complex(const struct lu_env *env, struct md_object *next,
- struct md_attr *ma)
+static 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;
ucred->uc_suppgids[0] = -1;
ucred->uc_suppgids[1] = -1;
- ucred->uc_uid = ucred->uc_o_uid = current_uid();
- ucred->uc_gid = ucred->uc_o_gid = current_gid();
- ucred->uc_fsuid = ucred->uc_o_fsuid = current_fsuid();
- ucred->uc_fsgid = ucred->uc_o_fsgid = current_fsgid();
- ucred->uc_cap = cfs_curproc_cap_pack();
+ 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)
cl_env_put(env, &refcheck);
return rc;
}
+#endif /* HAVE_SERVER_SUPPORT */
static int echo_create_object(const struct lu_env *env, struct echo_device *ed,
int on_target, struct obdo *oa, void *ulsm,
static void echo_put_object(struct echo_object *eco)
{
- if (cl_echo_object_put(eco))
- CERROR("echo client: drop an object failed");
+ int rc;
+
+ rc = cl_echo_object_put(eco);
+ if (rc)
+ CERROR("%s: echo client drop an object failed: rc = %d\n",
+ eco->eo_dev->ed_ec->ec_exp->exp_obd->obd_name, rc);
}
static void
}
ioo.ioo_bufcnt = npages;
- oti->oti_transno = 0;
lpages = npages;
ret = obd_preprw(env, rw, exp, oa, 1, &ioo, rnb, &lpages,
LASSERT(lpages == npages);
for (i = 0; i < lpages; i++) {
- struct page *page = lnb[i].page;
+ struct page *page = lnb[i].lnb_page;
- /* read past eof? */
- if (page == NULL && lnb[i].rc == 0)
- continue;
+ /* read past eof? */
+ if (page == NULL && lnb[i].lnb_rc == 0)
+ continue;
- if (async)
- lnb[i].flags |= OBD_BRW_ASYNC;
+ if (async)
+ lnb[i].lnb_flags |= OBD_BRW_ASYNC;
if (ostid_id(&oa->o_oi) == ECHO_PERSISTENT_OBJID ||
(oa->o_valid & OBD_MD_FLFLAGS) == 0 ||
struct obdo *oa = &data->ioc_obdo1;
struct echo_object *eco;
int rc;
- int async = 1;
+ int async = 0;
long test_mode;
ENTRY;
/* OFD/obdfilter works only via prep/commit */
test_mode = (long)data->ioc_pbuf1;
- if (test_mode == 1)
- async = 0;
-
if (ed->ed_next == NULL && test_mode != 3) {
test_mode = 3;
data->ioc_plen1 = data->ioc_count;
}
+ if (test_mode == 3)
+ async = 1;
+
/* Truncate batch size to maximum */
if (data->ioc_plen1 > PTLRPC_MAX_BRW_SIZE)
data->ioc_plen1 = PTLRPC_MAX_BRW_SIZE;
}
static int
-echo_client_enqueue(struct obd_export *exp, struct obdo *oa,
- int mode, obd_off offset, obd_size nob)
-{
- struct echo_device *ed = obd2echo_dev(exp->exp_obd);
- struct lustre_handle *ulh = &oa->o_handle;
- struct echo_object *eco;
- obd_off end;
- int rc;
- ENTRY;
-
- if (ed->ed_next == NULL)
- RETURN(-EOPNOTSUPP);
-
- if (!(mode == LCK_PR || mode == LCK_PW))
- RETURN(-EINVAL);
-
- if ((offset & (~CFS_PAGE_MASK)) != 0 ||
- (nob & (~CFS_PAGE_MASK)) != 0)
- RETURN(-EINVAL);
-
- rc = echo_get_object (&eco, ed, oa);
- if (rc != 0)
- RETURN(rc);
-
- end = (nob == 0) ? ((obd_off) -1) : (offset + nob - 1);
- rc = cl_echo_enqueue(eco, offset, end, mode, &ulh->cookie);
- if (rc == 0) {
- oa->o_valid |= OBD_MD_FLHANDLE;
- CDEBUG(D_INFO, "Cookie is "LPX64"\n", ulh->cookie);
- }
- echo_put_object(eco);
- RETURN(rc);
-}
-
-static int
-echo_client_cancel(struct obd_export *exp, struct obdo *oa)
-{
- struct echo_device *ed = obd2echo_dev(exp->exp_obd);
- __u64 cookie = oa->o_handle.cookie;
-
- if ((oa->o_valid & OBD_MD_FLHANDLE) == 0)
- return -EINVAL;
-
- CDEBUG(D_INFO, "Cookie is "LPX64"\n", cookie);
- return cl_echo_cancel(ed, cookie);
-}
-
-static int
echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
void *karg, void *uarg)
{
tsi = tgt_ses_info(env);
tsi->tsi_exp = ec->ec_exp;
+ tsi->tsi_jobid = NULL;
#endif
switch (cmd) {
case OBD_IOC_CREATE: /* may create echo object */
data->ioc_plen1, &dummy_oti);
GOTO(out, rc);
+#ifdef HAVE_SERVER_SUPPORT
case OBD_IOC_ECHO_MD: {
int count;
int cmd;
return -EFAULT;
GOTO(out, rc);
}
+#endif /* HAVE_SERVER_SUPPORT */
case OBD_IOC_DESTROY:
if (!cfs_capable(CFS_CAP_SYS_ADMIN))
GOTO (out, rc = -EPERM);
rc = echo_client_brw_ioctl(env, rw, exp, data, &dummy_oti);
GOTO(out, rc);
- case ECHO_IOC_GET_STRIPE:
- rc = echo_get_object(&eco, ed, oa);
- if (rc == 0) {
- rc = echo_copyout_lsm(eco->eo_lsm, data->ioc_pbuf1,
- data->ioc_plen1);
- echo_put_object(eco);
- }
- GOTO(out, rc);
-
- case ECHO_IOC_SET_STRIPE:
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
- GOTO (out, rc = -EPERM);
-
- if (data->ioc_pbuf1 == NULL) { /* unset */
- rc = echo_get_object(&eco, ed, oa);
- if (rc == 0) {
- eco->eo_deleted = 1;
- echo_put_object(eco);
- }
- } else {
- rc = echo_create_object(env, ed, 0, oa,
- data->ioc_pbuf1,
- data->ioc_plen1, &dummy_oti);
- }
- GOTO (out, rc);
-
- case ECHO_IOC_ENQUEUE:
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
- GOTO (out, rc = -EPERM);
-
- rc = echo_client_enqueue(exp, oa,
- data->ioc_conn1, /* lock mode */
- data->ioc_offset,
- data->ioc_count);/*extent*/
- GOTO (out, rc);
-
- case ECHO_IOC_CANCEL:
- rc = echo_client_cancel(exp, oa);
- GOTO (out, rc);
-
default:
CERROR ("echo_ioctl(): unrecognised ioctl %#x\n", cmd);
GOTO (out, rc = -ENOTTY);
}
spin_lock_init(&ec->ec_lock);
- CFS_INIT_LIST_HEAD (&ec->ec_objects);
- CFS_INIT_LIST_HEAD (&ec->ec_locks);
+ INIT_LIST_HEAD(&ec->ec_objects);
+ INIT_LIST_HEAD(&ec->ec_locks);
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);
- }
+ if (!strcmp(tgt->obd_type->typ_name, LUSTRE_MDT_NAME)) {
+#ifdef HAVE_SERVER_SUPPORT
+ lu_context_tags_update(ECHO_MD_CTX_TAG);
+ lu_session_tags_update(ECHO_MD_SES_TAG);
+#else
+ CERROR("Local operations are NOT supported on client side. "
+ "Only remote operations are supported. Metadata client "
+ "must be run on server side.\n");
+#endif
+ RETURN(0);
+ }
OBD_ALLOC(ocd, sizeof(*ocd));
if (ocd == NULL) {
if (rc == 0) {
/* Turn off pinger because it connects to tgt obd directly. */
spin_lock(&tgt->obd_dev_lock);
- cfs_list_del_init(&ec->ec_exp->exp_obd_chain_timed);
+ list_del_init(&ec->ec_exp->exp_obd_chain_timed);
spin_unlock(&tgt->obd_dev_lock);
}
RETURN(0);
if (ed->ed_next_ismd) {
- lu_context_tags_clear(ECHO_MD_CTX_TAG);
- lu_session_tags_clear(ECHO_MD_SES_TAG);
+#ifdef HAVE_SERVER_SUPPORT
+ lu_context_tags_clear(ECHO_MD_CTX_TAG);
+ lu_session_tags_clear(ECHO_MD_SES_TAG);
+#else
+ CERROR("This is client-side only module, does not support "
+ "metadata echo client.\n");
+#endif
RETURN(0);
}
- if (!cfs_list_empty(&obddev->obd_exports)) {
+ if (!list_empty(&obddev->obd_exports)) {
CERROR("still has clients!\n");
RETURN(-EBUSY);
}
- LASSERT(cfs_atomic_read(&ec->ec_exp->exp_refcount) > 0);
+ LASSERT(atomic_read(&ec->ec_exp->exp_refcount) > 0);
rc = obd_disconnect(ec->ec_exp);
if (rc != 0)
CERROR("fail to disconnect device: %d\n", rc);
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;
ENTRY;
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 (!cfs_list_empty (&exp->exp_ec_data.eced_locks)) {
- ecl = cfs_list_entry (exp->exp_ec_data.eced_locks.next,
- struct ec_lock, ecl_exp_chain);
- cfs_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 "LPX64" 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:
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
int echo_client_init(void)
{
- struct lprocfs_static_vars lvars = { 0 };
int rc;
- lprocfs_echo_init_vars(&lvars);
-
- rc = lu_kmem_init(echo_caches);
- if (rc == 0) {
- rc = class_register_type(&echo_client_obd_ops, NULL,
- lvars.module_vars,
- LUSTRE_ECHO_CLIENT_NAME,
- &echo_device_type);
- if (rc)
- lu_kmem_fini(echo_caches);
- }
- return rc;
+ rc = lu_kmem_init(echo_caches);
+ if (rc == 0) {
+ rc = class_register_type(&echo_client_obd_ops, NULL, true, NULL,
+#ifndef HAVE_ONLY_PROCFS_SEQ
+ NULL,
+#endif
+ LUSTRE_ECHO_CLIENT_NAME,
+ &echo_device_type);
+ if (rc)
+ lu_kmem_fini(echo_caches);
+ }
+ return rc;
}
void echo_client_exit(void)
#ifdef __KERNEL__
static int __init obdecho_init(void)
{
- struct lprocfs_static_vars lvars;
int rc;
ENTRY;
LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
- lprocfs_echo_init_vars(&lvars);
-
# ifdef HAVE_SERVER_SUPPORT
rc = echo_persistent_pages_init();
if (rc != 0)
goto failed_0;
- rc = class_register_type(&echo_obd_ops, NULL, lvars.module_vars,
- LUSTRE_ECHO_NAME, NULL);
- if (rc != 0)
- goto failed_1;
+ rc = class_register_type(&echo_obd_ops, NULL, true, NULL,
+#ifndef HAVE_ONLY_PROCFS_SEQ
+ NULL,
+#endif
+ LUSTRE_ECHO_NAME, NULL);
+ if (rc != 0)
+ goto failed_1;
# endif
rc = echo_client_init();