liblustreapi.h \
ll_fiemap.h \
lustre_errno.h \
- lustre_fid.h \
lustre_idl.h \
lustre_lfsck_user.h \
- lustre_ostid.h \
lustre_user.h \
lustreapi.h \
lustre_barrier_user.h
*/
#include <libcfs/libcfs.h>
-#include <lustre/lustre_fid.h>
+#include <uapi/linux/lustre_fid.h>
#include <lustre/lustre_idl.h>
-#include <lustre/lustre_ostid.h>
+#include <uapi/linux/lustre_ostid.h>
struct lu_env;
struct lu_site;
fid_seq_is_root(seq) || fid_seq_is_dot(seq);
}
+static inline void ost_layout_cpu_to_le(struct ost_layout *dst,
+ const struct ost_layout *src)
+{
+ dst->ol_stripe_size = __cpu_to_le32(src->ol_stripe_size);
+ dst->ol_stripe_count = __cpu_to_le32(src->ol_stripe_count);
+ dst->ol_comp_start = __cpu_to_le64(src->ol_comp_start);
+ dst->ol_comp_end = __cpu_to_le64(src->ol_comp_end);
+ dst->ol_comp_id = __cpu_to_le32(src->ol_comp_id);
+}
+
+static inline void ost_layout_le_to_cpu(struct ost_layout *dst,
+ const struct ost_layout *src)
+{
+ dst->ol_stripe_size = __le32_to_cpu(src->ol_stripe_size);
+ dst->ol_stripe_count = __le32_to_cpu(src->ol_stripe_count);
+ dst->ol_comp_start = __le64_to_cpu(src->ol_comp_start);
+ dst->ol_comp_end = __le64_to_cpu(src->ol_comp_end);
+ dst->ol_comp_id = __le32_to_cpu(src->ol_comp_id);
+}
+
+/* Both filter_fid_*cpu* functions not currently used */
+static inline void filter_fid_cpu_to_le(struct filter_fid *dst,
+ const struct filter_fid *src, int size)
+{
+ fid_cpu_to_le(&dst->ff_parent, &src->ff_parent);
+
+ if (size < sizeof(struct filter_fid))
+ memset(&dst->ff_layout, 0, sizeof(dst->ff_layout));
+ else
+ ost_layout_cpu_to_le(&dst->ff_layout, &src->ff_layout);
+
+ /* XXX: Add more if filter_fid is enlarged in the future. */
+}
+
+static inline void filter_fid_le_to_cpu(struct filter_fid *dst,
+ const struct filter_fid *src, int size)
+{
+ fid_le_to_cpu(&dst->ff_parent, &src->ff_parent);
+
+ if (size < sizeof(struct filter_fid))
+ memset(&dst->ff_layout, 0, sizeof(dst->ff_layout));
+ else
+ ost_layout_le_to_cpu(&dst->ff_layout, &src->ff_layout);
+
+ /* XXX: Add more if filter_fid is enlarged in the future. */
+}
+
static inline void lu_last_id_fid(struct lu_fid *fid, __u64 seq, __u32 ost_idx)
{
if (fid_seq_is_mdt0(seq)) {
}
}
+/**
+ * Note: we need check oi_seq to decide where to set oi_id,
+ * so oi_seq should always be set ahead of oi_id.
+ */
+static inline int ostid_set_id(struct ost_id *oi, __u64 oid)
+{
+ if (fid_seq_is_mdt0(oi->oi.oi_seq)) {
+ if (oid >= IDIF_MAX_OID)
+ return -E2BIG;
+ oi->oi.oi_id = oid;
+ } else if (fid_is_idif(&oi->oi_fid)) {
+ if (oid >= IDIF_MAX_OID)
+ return -E2BIG;
+ oi->oi_fid.f_seq = fid_idif_seq(oid,
+ fid_idif_ost_idx(&oi->oi_fid));
+ oi->oi_fid.f_oid = oid;
+ oi->oi_fid.f_ver = oid >> 48;
+ } else {
+ if (oid >= OBIF_MAX_OID)
+ return -E2BIG;
+ oi->oi_fid.f_oid = oid;
+ }
+ return 0;
+}
+
+/* pack any OST FID into an ostid (id/seq) for the wire/disk */
+static inline int fid_to_ostid(const struct lu_fid *fid, struct ost_id *ostid)
+{
+ int rc = 0;
+
+ if (fid_seq_is_igif(fid->f_seq))
+ return -EBADF;
+
+ if (fid_is_idif(fid)) {
+ ostid_set_seq_mdt0(ostid);
+ rc = ostid_set_id(ostid, fid_idif_id(fid_seq(fid),
+ fid_oid(fid), fid_ver(fid)));
+ } else {
+ ostid->oi_fid = *fid;
+ }
+
+ return rc;
+}
+
/* The same as osc_build_res_name() */
static inline void ost_fid_build_resid(const struct lu_fid *fid,
struct ldlm_res_id *resname)
if (fid_seq_is_mdt0(name->name[LUSTRE_RES_ID_VER_OID_OFF])) {
/* old resid */
struct ost_id oi;
+
ostid_set_seq(&oi, name->name[LUSTRE_RES_ID_VER_OID_OFF]);
- ostid_set_id(&oi, name->name[LUSTRE_RES_ID_SEQ_OFF]);
+ if (ostid_set_id(&oi, name->name[LUSTRE_RES_ID_SEQ_OFF])) {
+ CERROR("Bad %llu to set " DOSTID "\n",
+ name->name[LUSTRE_RES_ID_SEQ_OFF], POSTID(&oi));
+ }
ostid_to_fid(fid, &oi, ost_idx);
} else {
/* new resid */
#ifndef _LUSTRE_LOG_USER_H
#define _LUSTRE_LOG_USER_H
-#include <lustre/lustre_fid.h>
+#include <uapi/linux/lustre_fid.h>
/* Lustre logs use FIDs constructed from oi_id and oi_seq directly,
* without attempting to use the IGIF and IDIF ranges as is done
EXTRA_DIST = \
lustre_disk.h \
- lustre_ioctl.h
+ lustre_fid.h \
+ lustre_ioctl.h \
+ lustre_ostid.h
* of three parts: sequence, Object ID, and version.
*
*/
-#ifndef _LUSTRE_LUSTRE_FID_H_
-#define _LUSTRE_LUSTRE_FID_H_
+#ifndef _UAPI_LUSTRE_FID_H_
+#define _UAPI_LUSTRE_FID_H_
#include <lustre/lustre_idl.h>
dst->f_ver = __be32_to_cpu(fid_ver(src));
}
-static inline void ost_layout_cpu_to_le(struct ost_layout *dst,
- const struct ost_layout *src)
-{
- dst->ol_stripe_size = __cpu_to_le32(src->ol_stripe_size);
- dst->ol_stripe_count = __cpu_to_le32(src->ol_stripe_count);
- dst->ol_comp_start = __cpu_to_le64(src->ol_comp_start);
- dst->ol_comp_end = __cpu_to_le64(src->ol_comp_end);
- dst->ol_comp_id = __cpu_to_le32(src->ol_comp_id);
-}
-
-static inline void ost_layout_le_to_cpu(struct ost_layout *dst,
- const struct ost_layout *src)
-{
- dst->ol_stripe_size = __le32_to_cpu(src->ol_stripe_size);
- dst->ol_stripe_count = __le32_to_cpu(src->ol_stripe_count);
- dst->ol_comp_start = __le64_to_cpu(src->ol_comp_start);
- dst->ol_comp_end = __le64_to_cpu(src->ol_comp_end);
- dst->ol_comp_id = __le32_to_cpu(src->ol_comp_id);
-}
-
-static inline void filter_fid_cpu_to_le(struct filter_fid *dst,
- const struct filter_fid *src, int size)
-{
- fid_cpu_to_le(&dst->ff_parent, &src->ff_parent);
-
- if (size < sizeof(struct filter_fid))
- memset(&dst->ff_layout, 0, sizeof(dst->ff_layout));
- else
- ost_layout_cpu_to_le(&dst->ff_layout, &src->ff_layout);
-
- /* XXX: Add more if filter_fid is enlarged in the future. */
-}
-
-static inline void filter_fid_le_to_cpu(struct filter_fid *dst,
- const struct filter_fid *src, int size)
-{
- fid_le_to_cpu(&dst->ff_parent, &src->ff_parent);
-
- if (size < sizeof(struct filter_fid))
- memset(&dst->ff_layout, 0, sizeof(dst->ff_layout));
- else
- ost_layout_le_to_cpu(&dst->ff_layout, &src->ff_layout);
-
- /* XXX: Add more if filter_fid is enlarged in the future. */
-}
-
static inline bool fid_is_sane(const struct lu_fid *fid)
{
return fid && ((fid_seq(fid) >= FID_SEQ_START && !fid_ver(fid)) ||
* Define ost_id associated functions
*/
-#ifndef _LUSTRE_OSTID_H_
-#define _LUSTRE_OSTID_H_
+#ifndef _UAPI_LUSTRE_OSTID_H_
+#define _UAPI_LUSTRE_OSTID_H_
-#include <libcfs/libcfs.h>
-#include <lustre/lustre_fid.h>
+/*
+ * This is due to us being out of kernel and the way the OpenSFS branch
+ * handles CFLAGS. Upstream will just have linux/lustre_fid.h
+ */
+#ifdef __KERNEL__
+#include <uapi/linux/lustre_fid.h>
+#else
+#include <linux/lustre_fid.h>
+#endif
static inline __u64 lmm_oi_id(const struct ost_id *oi)
{
ostid_set_seq(oi, FID_SEQ_LLOG);
}
-/**
- * Note: we need check oi_seq to decide where to set oi_id,
- * so oi_seq should always be set ahead of oi_id.
- */
-static inline void ostid_set_id(struct ost_id *oi, __u64 oid)
-{
- if (fid_seq_is_mdt0(oi->oi.oi_seq)) {
- if (oid >= IDIF_MAX_OID) {
- CERROR("Bad %llu to set "DOSTID"\n",
- (unsigned long long)oid, POSTID(oi));
- return;
- }
- oi->oi.oi_id = oid;
- } else if (fid_is_idif(&oi->oi_fid)) {
- if (oid >= IDIF_MAX_OID) {
- CERROR("Bad %llu to set "DOSTID"\n",
- (unsigned long long)oid, POSTID(oi));
- return;
- }
- oi->oi_fid.f_seq = fid_idif_seq(oid,
- fid_idif_ost_idx(&oi->oi_fid));
- oi->oi_fid.f_oid = oid;
- oi->oi_fid.f_ver = oid >> 48;
- } else {
- if (oid > OBIF_MAX_OID) {
- CERROR("Bad %llu to set "DOSTID"\n",
- (unsigned long long)oid, POSTID(oi));
- return;
- }
- oi->oi_fid.f_oid = oid;
- }
-}
-
static inline void ostid_cpu_to_le(const struct ost_id *src_oi,
struct ost_id *dst_oi)
{
}
}
-/* pack any OST FID into an ostid (id/seq) for the wire/disk */
-static inline int fid_to_ostid(const struct lu_fid *fid, struct ost_id *ostid)
-{
- if (fid_seq_is_igif(fid->f_seq)) {
- CERROR("bad IGIF, "DFID"\n", PFID(fid));
- return -EBADF;
- }
-
- if (fid_is_idif(fid)) {
- ostid_set_seq_mdt0(ostid);
- ostid_set_id(ostid, fid_idif_id(fid_seq(fid), fid_oid(fid),
- fid_ver(fid)));
- } else {
- ostid->oi_fid = *fid;
- }
-
- return 0;
-}
-
/**
* Sigh, because pre-2.4 uses
* struct lov_mds_md_v1 {
{
__u64 seq = ostid_seq(ostid);
- if (ost_idx > 0xffff) {
- CERROR("bad ost_idx, "DOSTID" ost_idx:%u\n", POSTID(ostid),
- ost_idx);
+ if (ost_idx > 0xffff)
return -EBADF;
- }
if (fid_seq_is_mdt0(seq)) {
__u64 oid = ostid_id(ostid);
* been in production for years. This can handle create rates
* of 1M objects/s/OST for 9 years, or combinations thereof.
*/
- if (oid >= IDIF_MAX_OID) {
- CERROR("bad MDT0 id(1), "DOSTID" ost_idx:%u\n",
- POSTID(ostid), ost_idx);
+ if (oid >= IDIF_MAX_OID)
return -EBADF;
- }
+
fid->f_seq = fid_idif_seq(oid, ost_idx);
/* truncate to 32 bits by assignment */
fid->f_oid = oid;
* maps legacy OST objects into the FID namespace. In both
* cases, we just pass the FID through, no conversion needed.
*/
- if (ostid->oi_fid.f_ver) {
- CERROR("bad MDT0 id(2), "DOSTID" ost_idx:%u\n",
- POSTID(ostid), ost_idx);
+ if (ostid->oi_fid.f_ver)
return -EBADF;
- }
+
*fid = ostid->oi_fid;
}
return 0;
}
-#endif
+#endif /* _UAPI_LUSTRE_OSTID_H_ */
}
ostid_set_seq(oi, FID_SEQ_IDIF);
- ostid_set_id(oi, 0);
+ rc = ostid_set_id(oi, 0);
+ if (rc)
+ GOTO(log, rc);
+
rc = ostid_to_fid(fid, oi, ltd->ltd_index);
if (rc != 0)
GOTO(log, rc);
return lgi;
}
-static inline void
-lustre_build_llog_lvfs_oid(struct llog_logid *logid, __u64 ino, __u32 gen)
-{
- ostid_set_seq_llog(&logid->lgl_oi);
- ostid_set_id(&logid->lgl_oi, ino);
- logid->lgl_ogen = gen;
-}
-
int llog_info_init(void);
void llog_info_fini(void);
RETURN(-EINVAL);
ostid_set_seq(&logid->lgl_oi, seq);
- ostid_set_id(&logid->lgl_oi, id);
+ if (ostid_set_id(&logid->lgl_oi, id))
+ RETURN(-EINVAL);
start = ++end;
if (start - str >= len - 1)
}
ostid_set_seq_echo(&oa->o_oi);
- ostid_set_id(&oa->o_oi, echo_next_id(obd));
+ if (ostid_set_id(&oa->o_oi, echo_next_id(obd))) {
+ CERROR("Bad %llu to set " DOSTID "\n",
+ echo_next_id(obd), POSTID(&oa->o_oi));
+ return -EINVAL;
+ }
oa->o_valid = OBD_MD_FLID;
return 0;
obdo_cpy_md(oa, &obd->u.echo.eo_oa, oa->o_valid);
ostid_set_seq_echo(&oa->o_oi);
- ostid_set_id(&oa->o_oi, id);
+ if (ostid_set_id(&oa->o_oi, id)) {
+ CERROR("Bad %llu to set " DOSTID "\n",
+ id, POSTID(&oa->o_oi));
+ RETURN(-EINVAL);
+ }
RETURN(0);
}
RETURN(-EINVAL);
}
- if (ostid_id(&oa->o_oi) == 0)
- ostid_set_id(&oa->o_oi, ++last_object_id);
+ if (ostid_id(&oa->o_oi) == 0) {
+ rc = ostid_set_id(&oa->o_oi, ++last_object_id);
+ if (rc)
+ GOTO(failed, rc);
+ }
rc = obd_create(env, ec->ec_exp, oa);
if (rc != 0) {
rc = ofd_seq_last_oid_write(env, ofd, oseq);
} else {
/* don't reuse orphan object, return last used objid */
- ostid_set_id(oi, last);
- rc = 0;
+ rc = ostid_set_id(oi, last);
}
GOTO(out_put, rc);
if (!oseq->os_destroys_in_progress) {
CERROR("%s:[%llu] destroys_in_progress already"
" cleared\n", ofd_name(ofd), seq);
- ostid_set_id(&rep_oa->o_oi, ofd_seq_last_oid(oseq));
- GOTO(out, rc = 0);
+ rc = ostid_set_id(&rep_oa->o_oi,
+ ofd_seq_last_oid(oseq));
+ GOTO(out, rc);
}
diff = oid - ofd_seq_last_oid(oseq);
CDEBUG(D_HA, "ofd_last_id() = %llu -> diff = %d\n",
ofd_seq_last_oid(oseq), diff);
if (-diff > OST_MAX_PRECREATE) {
/* Let MDS know that we are so far ahead. */
- ostid_set_id(&rep_oa->o_oi, ofd_seq_last_oid(oseq) + 1);
- rc = 0;
+ rc = ostid_set_id(&rep_oa->o_oi,
+ ofd_seq_last_oid(oseq) + 1);
} else if (diff < 0) {
rc = ofd_orphans_destroy(tsi->tsi_env, exp,
ofd, rep_oa);
granted = 0;
}
- ostid_set_id(&rep_oa->o_oi, ofd_seq_last_oid(oseq));
+ rc = ostid_set_id(&rep_oa->o_oi, ofd_seq_last_oid(oseq));
}
EXIT;
ofd_counter_incr(exp, LPROC_OFD_STATS_CREATE,
void ofd_seq_last_oid_set(struct ofd_seq *oseq, u64 id)
{
spin_lock(&oseq->os_last_oid_lock);
- if (likely(ostid_id(&oseq->os_oi) < id))
- ostid_set_id(&oseq->os_oi, id);
+ if (likely(ostid_id(&oseq->os_oi) < id)) {
+ if (ostid_set_id(&oseq->os_oi, id)) {
+ CERROR("Bad %llu to set " DOSTID "\n",
+ (unsigned long long)id, POSTID(&oseq->os_oi));
+ }
+ }
spin_unlock(&oseq->os_last_oid_lock);
}
CERROR("%s: unable to precreate: rc = %d\n",
ofd_name(ofd), rc);
} else {
- ostid_set_id(&oa->o_oi, ofd_seq_last_oid(oseq));
+ rc = ostid_set_id(&oa->o_oi, ofd_seq_last_oid(oseq));
+ if (rc) {
+ CERROR("%s: Bad %llu to set " DOSTID " : rc %d\n",
+ ofd_name(ofd),
+ (unsigned long long)ofd_seq_last_oid(oseq),
+ POSTID(&oa->o_oi), rc);
+ }
oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
- rc = 0;
}
tgt_grant_commit(ofd_obd(ofd)->obd_self_export, granted, rc);
struct ost_id ostid;
ostid_set_seq(&ostid, *(__u64 *)data->ioc_inlbuf4);
- ostid_set_id(&ostid, *(__u64 *)data->ioc_inlbuf3);
+ rc = ostid_set_id(&ostid, *(__u64 *)data->ioc_inlbuf3);
+ if (rc)
+ GOTO(out, rc);
rc = ostid_to_fid(&fid, &ostid,
ofd->ofd_lut.lut_lsd.lsd_osd_index);
if (rc != 0)
oa->o_valid |= OBD_MD_FLGROUP;
}
if (flags & OBD_MD_FLID) {
- ostid_set_id(&oa->o_oi, ostid_id(&oinfo->loi_oi));
+ int rc;
+
+ rc = ostid_set_id(&oa->o_oi, ostid_id(&oinfo->loi_oi));
+ if (rc) {
+ CERROR("Bad %llu to set " DOSTID " : rc %d\n",
+ (unsigned long long)ostid_id(&oinfo->loi_oi),
+ POSTID(&oa->o_oi), rc);
+ }
oa->o_valid |= OBD_MD_FLID;
}
if (flags & OBD_MD_FLHANDLE) {
if (rc == sizeof(*ff)) {
rc = 0;
ostid_set_seq(ostid, le64_to_cpu(ff->ff_seq));
- ostid_set_id(ostid, le64_to_cpu(ff->ff_objid));
- /* XXX: use 0 as the index for compatibility, the caller will
- * handle index related issues when necessarry. */
- ostid_to_fid(fid, ostid, 0);
+ rc = ostid_set_id(ostid, le64_to_cpu(ff->ff_objid));
+ /*
+ * XXX: use 0 as the index for compatibility, the caller will
+ * handle index related issues when necessary.
+ */
+ if (!rc)
+ ostid_to_fid(fid, ostid, 0);
} else if (rc == sizeof(struct filter_fid)) {
rc = 1;
} else if (rc >= 0) {
if (d->opd_gap_count > 0) {
int count = d->opd_gap_count;
- ostid_set_id(&osi->osi_oi,
- fid_oid(&d->opd_gap_start_fid));
+ rc = ostid_set_id(&osi->osi_oi,
+ fid_oid(&d->opd_gap_start_fid));
+ if (rc) {
+ spin_unlock(&d->opd_pre_lock);
+ RETURN(rc);
+ }
d->opd_gap_count = 0;
spin_unlock(&d->opd_pre_lock);
if (fid_is_idif(fid)) {
struct lu_fid *last_fid;
struct ost_id *oi = &osi->osi_oi;
+ int rc;
spin_lock(&osp->opd_pre_lock);
last_fid = &osp->opd_pre_last_created_fid;
fid_to_ostid(last_fid, oi);
end = min(ostid_id(oi) + *grow, IDIF_MAX_OID);
*grow = end - ostid_id(oi);
- ostid_set_id(oi, ostid_id(oi) + *grow);
+ rc = ostid_set_id(oi, ostid_id(oi) + *grow);
spin_unlock(&osp->opd_pre_lock);
- if (*grow == 0)
+ if (*grow == 0 || rc)
return 1;
ostid_to_fid(fid, oi, osp->opd_index);
memset(&ostid, 0, sizeof(ostid));
switch (h->lrh_type) {
- case MDS_UNLINK_REC:
- ostid_set_seq(&ostid, ((struct llog_unlink_rec *)h)->lur_oseq);
- ostid_set_id(&ostid, ((struct llog_unlink_rec *)h)->lur_oid);
+ case MDS_UNLINK_REC: {
+ struct llog_unlink_rec *unlink = (struct llog_unlink_rec *)h;
+
+ ostid_set_seq(&ostid, unlink->lur_oseq);
+ if (ostid_set_id(&ostid, unlink->lur_oid)) {
+ CERROR("Bad %llu to set " DOSTID "\n",
+ (unsigned long long)(unlink->lur_oid),
+ POSTID(&ostid));
+ return 1;
+ }
+ }
break;
case MDS_UNLINK64_REC:
fid_to_ostid(&((struct llog_unlink64_rec *)h)->lur_fid, &ostid);
struct llog_unlink_rec *rec = (struct llog_unlink_rec *)h;
struct ptlrpc_request *req;
struct ost_body *body;
+ int rc;
ENTRY;
LASSERT(h->lrh_type == MDS_UNLINK_REC);
body = req_capsule_client_get(&req->rq_pill, &RMF_OST_BODY);
LASSERT(body);
ostid_set_seq(&body->oa.o_oi, rec->lur_oseq);
- ostid_set_id(&body->oa.o_oi, rec->lur_oid);
+ rc = ostid_set_id(&body->oa.o_oi, rec->lur_oid);
+ if (rc)
+ return rc;
body->oa.o_misc = rec->lur_count;
body->oa.o_valid = OBD_MD_FLGROUP | OBD_MD_FLID;
if (rec->lur_count)
#include <sys/types.h>
#include <libcfs/util/string.h>
-#include <lustre/lustre_fid.h>
+#include <linux/lustre_fid.h>
#include <lustre/lustreapi.h>
/* Progress reporting period */
#include <libcfs/util/string.h>
#include <lnet/lnetctl.h>
#include <lustre/lustreapi.h>
-#include <lustre/lustre_ostid.h>
+#include <linux/lustre_ostid.h>
#include <linux/lustre_ioctl.h>
#include "lustreapi_internal.h"
#include <limits.h>
#include <sys/types.h>
#include <sys/xattr.h>
-#include <lustre/lustre_fid.h>
+#include <linux/lustre_fid.h>
#define BUFFER_SIZE 65536
#include <errno.h>
#include <time.h>
#include <lnet/nidstr.h>
-#include <lustre/lustre_fid.h>
-#include <lustre/lustre_ostid.h>
+#include <linux/lustre_fid.h>
+#include <linux/lustre_ostid.h>
#include <lustre/lustreapi.h>
#include <lustre_log_user.h>
#include <lustre_cfg.h>
#include <libcfs/util/string.h>
#include <lnet/nidstr.h>
-#include <lustre/lustre_ostid.h>
+#include <linux/lustre_ostid.h>
#include <lustre_cfg.h>
#include <linux/lustre_ioctl.h>
#include <lustre_ver.h>
fprintf(stderr, "Allocate fids error %d.\n",rc);
return rc;
}
- fid_to_ostid(&fid, &data.ioc_obdo1.o_oi);
+ data.ioc_obdo1.o_oi.oi_fid = fid;
}
child_base_id += data.ioc_count;
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
+ /*
+ * base_id is 1 so we don't need to worry about it being
+ * greater than OBIF_MAX_OID
+ */
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = base_id;
data.ioc_obdo1.o_mode = mode;
- ostid_set_id(&data.ioc_obdo1.o_oi, base_id);
data.ioc_obdo1.o_uid = 0;
data.ioc_obdo1.o_gid = 0;
data.ioc_obdo1.o_projid = 0;
int jt_obd_setattr(int argc, char **argv)
{
- struct obd_ioctl_data data;
- char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
- char *end;
- int rc;
+ struct obd_ioctl_data data;
+ char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+ __u64 objid;
+ char *end;
+ int mode;
+ int rc;
memset(&data, 0, sizeof(data));
data.ioc_dev = cur_device;
if (argc != 2)
return CMD_HELP;
- ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
- ostid_set_id(&data.ioc_obdo1.o_oi, strtoull(argv[1], &end, 0));
- if (*end) {
+ objid = strtoull(argv[1], &end, 0);
+ if (*end) {
+ fprintf(stderr, "error: %s: objid '%s' is not a number\n",
+ jt_cmdname(argv[0]), argv[1]);
+ return CMD_HELP;
+ }
+
+ if (objid >= OBIF_MAX_OID) {
fprintf(stderr, "error: %s: invalid objid '%s'\n",
jt_cmdname(argv[0]), argv[1]);
return CMD_HELP;
}
- data.ioc_obdo1.o_mode = S_IFREG | strtoul(argv[2], &end, 0);
+
+ mode = strtoul(argv[2], &end, 0);
if (*end) {
fprintf(stderr, "error: %s: invalid mode '%s'\n",
jt_cmdname(argv[0]), argv[2]);
return CMD_HELP;
}
- data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
+
+ ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
+ data.ioc_obdo1.o_mode = S_IFREG | mode;
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
+ data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
memset(buf, 0, sizeof(rawbuf));
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
- ostid_set_id(&data.ioc_obdo1.o_oi, objid);
+ if (objid >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), objid);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
data.ioc_obdo1.o_mode = S_IFREG;
data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE;
memset(buf, 0, sizeof(rawbuf));
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++, id++) {
- ostid_set_id(&data.ioc_obdo1.o_oi, id);
+ if (id >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), id);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = id;
data.ioc_obdo1.o_mode = S_IFREG | 0644;
data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLMODE;
{
struct obd_ioctl_data data;
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
+ __u64 objid;
char *end;
int rc;
if (argc != 2)
return CMD_HELP;
- memset(&data, 0, sizeof(data));
- data.ioc_dev = cur_device;
- ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
- ostid_set_id(&data.ioc_obdo1.o_oi, strtoull(argv[1], &end, 0));
+ objid = strtoull(argv[1], &end, 0);
if (*end) {
+ fprintf(stderr, "error: %s: objid '%s' is not a number\n",
+ jt_cmdname(argv[0]), argv[1]);
+ return CMD_HELP;
+ }
+
+ if (objid >= OBIF_MAX_OID) {
fprintf(stderr, "error: %s: invalid objid '%s'\n",
jt_cmdname(argv[0]), argv[1]);
return CMD_HELP;
}
+
+ memset(&data, 0, sizeof(data));
+ data.ioc_dev = cur_device;
+ ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
/* to help obd filter */
data.ioc_obdo1.o_mode = 0100644;
data.ioc_obdo1.o_valid = 0xffffffff;
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
for (i = 1, next_count = verbose; i <= count && shmem_running(); i++) {
- ostid_set_id(&data.ioc_obdo1.o_oi, objid);
+ if (objid >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), objid);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
data.ioc_obdo1.o_mode = S_IFREG;
data.ioc_obdo1.o_valid = 0xffffffff;
memset(buf, 0, sizeof(rawbuf));
#endif
ostid_set_seq_echo(&data.ioc_obdo1.o_oi);
- ostid_set_id(&data.ioc_obdo1.o_oi, objid);
+ if (objid >= OBIF_MAX_OID) {
+ fprintf(stderr, "errr: %s: invalid objid '%llu'\n",
+ jt_cmdname(argv[0]), objid);
+ return -E2BIG;
+ }
+
+ data.ioc_obdo1.o_oi.oi_fid.f_oid = objid;
data.ioc_obdo1.o_mode = S_IFREG;
data.ioc_obdo1.o_valid = OBD_MD_FLID | OBD_MD_FLTYPE | OBD_MD_FLMODE |
OBD_MD_FLFLAGS | OBD_MD_FLGROUP;