*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*/
#define DEBUG_SUBSYSTEM S_ECHO
#include <obd.h>
#include <obd_support.h>
#include <obd_class.h>
-#include <lustre_debug.h>
#include <lprocfs_status.h>
#include <cl_object.h>
#include <lustre_fid.h>
*/
static inline struct echo_device *cl2echo_dev(const struct cl_device *dev)
{
- return container_of0(dev, struct echo_device, ed_cl);
+ return container_of_safe(dev, struct echo_device, ed_cl);
}
static inline struct cl_device *echo_dev2cl(struct echo_device *d)
#ifdef HAVE_SERVER_SUPPORT
static inline struct echo_md_device *lu2emd_dev(struct lu_device *d)
{
- return container_of0(d, struct echo_md_device, emd_md_dev.md_lu_dev);
+ return container_of_safe(d, struct echo_md_device,
+ emd_md_dev.md_lu_dev);
}
static inline struct lu_device *emd2lu_dev(struct echo_md_device *d)
OBD_SLAB_FREE_PTR(ecl, echo_lock_kmem);
}
-static struct cl_lock_operations echo_lock_ops = {
- .clo_fini = echo_lock_fini,
+static const struct cl_lock_operations echo_lock_ops = {
+ .clo_fini = echo_lock_fini,
};
/** @} echo_lock */
RETURN(obj);
}
-static struct lu_device_operations echo_device_lu_ops = {
+static const struct lu_device_operations echo_device_lu_ops = {
.ldo_object_alloc = echo_object_alloc,
};
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);
+ 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);
struct page *vmpage = pvec->pages[i];
struct cl_page *page = (struct cl_page *)vmpage->private;
- cl_page_list_add(&queue->c2_qout, page);
+ cl_page_list_add(&queue->c2_qout, page, true);
}
}
break;
}
- cl_2queue_add(queue, clp);
+ cl_2queue_add(queue, clp, true);
/*
* drop the reference count for cl_page_find, so that the page
static void echo_ucred_init(struct lu_env *env)
{
struct lu_ucred *ucred = lu_ucred(env);
+ kernel_cap_t kcap = current_cap();
ucred->uc_valid = UCRED_INVALID;
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;
+ if (ucred->uc_fsuid) {
+ kcap = cap_drop_nfsd_set(kcap);
+ kcap = cap_drop_fs_set(kcap);
+ }
+ ucred->uc_cap = kcap.cap[0];
ucred->uc_valid = UCRED_NEW;
}
if (rw == OBD_BRW_WRITE)
brw_flags = OBD_BRW_ASYNC;
- OBD_ALLOC(pga, npages * sizeof(*pga));
+ OBD_ALLOC_PTR_ARRAY_LARGE(pga, npages);
if (!pga)
RETURN(-ENOMEM);
- OBD_ALLOC(pages, npages * sizeof(*pages));
+ OBD_ALLOC_PTR_ARRAY_LARGE(pages, npages);
if (!pages) {
- OBD_FREE(pga, npages * sizeof(*pga));
+ OBD_FREE_PTR_ARRAY_LARGE(pga, npages);
RETURN(-ENOMEM);
}
if (!pgp->pg)
goto out;
+ /* set mapping so page is not considered encrypted */
+ pgp->pg->mapping = ECHO_MAPPING_UNENCRYPTED;
pages[i] = pgp->pg;
pgp->count = PAGE_SIZE;
pgp->off = off;
}
__free_page(pgp->pg);
}
- OBD_FREE(pga, npages * sizeof(*pga));
- OBD_FREE(pages, npages * sizeof(*pages));
+ OBD_FREE_PTR_ARRAY_LARGE(pga, npages);
+ OBD_FREE_PTR_ARRAY_LARGE(pages, npages);
RETURN(rc);
}
apc = npages = batch >> PAGE_SHIFT;
tot_pages = count >> PAGE_SHIFT;
- OBD_ALLOC_LARGE(lnb, apc * sizeof(*lnb));
+ OBD_ALLOC_PTR_ARRAY_LARGE(lnb, apc);
if (!lnb)
RETURN(-ENOMEM);
}
out:
- OBD_FREE_LARGE(lnb, apc * sizeof(*lnb));
+ OBD_FREE_PTR_ARRAY_LARGE(lnb, apc);
RETURN(ret);
}
switch (cmd) {
case OBD_IOC_CREATE: /* may create echo object */
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
GOTO(out, rc = -EPERM);
rc = echo_create_object(env, ed, oa);
int dirlen;
__u64 id;
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
GOTO(out, rc = -EPERM);
count = data->ioc_count;
__u64 seq;
int max_count;
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
GOTO(out, rc = -EPERM);
rc = seq_client_get_seq(env, ed->ed_cl_seq, &seq);
}
#endif /* HAVE_SERVER_SUPPORT */
case OBD_IOC_DESTROY:
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
GOTO(out, rc = -EPERM);
rc = echo_get_object(&eco, ed, oa);
GOTO(out, rc);
case OBD_IOC_SETATTR:
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
GOTO(out, rc = -EPERM);
rc = echo_get_object(&eco, ed, oa);
GOTO(out, rc);
case OBD_IOC_BRW_WRITE:
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
GOTO(out, rc = -EPERM);
rw = OBD_BRW_WRITE;
OBD_CONNECT_BRW_SIZE |
OBD_CONNECT_GRANT | OBD_CONNECT_FULL20 |
OBD_CONNECT_64BITHASH | OBD_CONNECT_LVB_TYPE |
- OBD_CONNECT_FID;
+ OBD_CONNECT_FID | OBD_CONNECT_FLAGS2;
+ ocd->ocd_connect_flags2 = OBD_CONNECT2_REP_MBITS;
+
ocd->ocd_brw_size = DT_MAX_BRW_SIZE;
ocd->ocd_version = LUSTRE_VERSION_CODE;
ocd->ocd_group = FID_SEQ_ECHO;
if (rc != 0)
goto failed_0;
- rc = class_register_type(&echo_obd_ops, NULL, true, NULL,
+ rc = class_register_type(&echo_obd_ops, NULL, true,
LUSTRE_ECHO_NAME, &echo_srv_type);
if (rc != 0)
goto failed_1;
rc = lu_kmem_init(echo_caches);
if (rc == 0) {
rc = class_register_type(&echo_client_obd_ops, NULL, false,
- NULL, LUSTRE_ECHO_CLIENT_NAME,
+ LUSTRE_ECHO_CLIENT_NAME,
&echo_device_type);
if (rc)
lu_kmem_fini(echo_caches);