Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
LU-2783 ofd: Implement OBD_IOC_GET_OBJ_VERSION
[fs/lustre-release.git]
/
lustre
/
ofd
/
ofd_obd.c
diff --git
a/lustre/ofd/ofd_obd.c
b/lustre/ofd/ofd_obd.c
index
c20c071
..
dbb7fc9
100644
(file)
--- a/
lustre/ofd/ofd_obd.c
+++ b/
lustre/ofd/ofd_obd.c
@@
-51,7
+51,7
@@
static int ofd_export_stats_init(struct ofd_device *ofd,
{
struct obd_device *obd = ofd_obd(ofd);
struct nid_stat *stats;
- int num_stats
, i
;
+ int num_stats;
int rc, newnid = 0;
ENTRY;
@@
-75,18
+75,6
@@
static int ofd_export_stats_init(struct ofd_device *ofd,
stats = exp->exp_nid_stats;
LASSERT(stats != NULL);
- OBD_ALLOC(stats->nid_brw_stats, sizeof(struct brw_stats));
- if (stats->nid_brw_stats == NULL)
- GOTO(clean, rc = -ENOMEM);
-
- for (i = 0; i < BRW_LAST; i++)
- spin_lock_init(&stats->nid_brw_stats->hist[i].oh_lock);
-
- rc = lprocfs_seq_create(stats->nid_proc, "brw_stats", 0644,
- &ofd_per_nid_stats_fops, stats);
- if (rc)
- CWARN("Error adding the brw_stats file\n");
-
num_stats = (sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) +
LPROC_OFD_LAST - 1;
@@
-630,36
+618,39
@@
static int ofd_get_info(const struct lu_env *env, struct obd_export *exp,
*((__u32 *) val) = ofd->ofd_sync_lock_cancel;
*vallen = sizeof(__u32);
} else if (KEY_IS(KEY_LAST_FID)) {
- struct lu_env env;
- struct ofd_device *ofd = ofd_exp(exp);
- struct ofd_seq *oseq;
- struct
lu_fid *last_f
id = val;
- int rc;
-
- if (
last_f
id == NULL) {
- *vallen = sizeof(struct
lu_f
id);
+ struct lu_env
env;
+ struct ofd_device
*ofd = ofd_exp(exp);
+ struct ofd_seq
*oseq;
+ struct
ost_id *o
id = val;
+ int
rc;
+
+ if (
o
id == NULL) {
+ *vallen = sizeof(struct
ost_
id);
RETURN(0);
}
- if (*vallen < sizeof(*
last_f
id))
+ if (*vallen < sizeof(*
o
id))
RETURN(-EOVERFLOW);
rc = lu_env_init(&env, LCT_DT_THREAD);
if (rc != 0)
RETURN(rc);
ofd_info_init(&env, exp);
- fid_le_to_cpu(last_fid, last_fid);
- oseq = ofd_seq_load(&env, ofd, fid_seq(last_fid));
+
+ ostid_le_to_cpu(oid, oid);
+ CDEBUG(D_HA, "Get LAST FID for seq "LPX64"\n", oid->oi_seq);
+
+ oseq = ofd_seq_load(&env, ofd, oid->oi_seq);
if (IS_ERR(oseq))
- GOTO(out_fi
d
, rc = PTR_ERR(oseq));
+ GOTO(out_fi
ni
, rc = PTR_ERR(oseq));
- last_fid->f_seq = oseq->os_seq;
- last_fid->f_oid = oseq->os_last_oid;
- fid_cpu_to_le(last_fid, last_fid);
+ CDEBUG(D_HA, "LAST FID is "POSTID"\n", oseq->os_last_oid,
+ oseq->os_seq);
- *vallen = sizeof(*last_fid);
+ *oid = oseq->os_oi;
+ *vallen = sizeof(*oid);
ofd_seq_put(&env, oseq);
-out_fi
d
:
+out_fi
ni
:
lu_env_fini(&env);
} else {
CERROR("Not supported key %s\n", (char*)key);
@@
-1274,9
+1265,9
@@
int ofd_create(const struct lu_env *env, struct obd_export *exp,
ofd_obd(ofd)->obd_self_export,
&diff);
if (rc) {
- CDEBUG(D_HA, "%s: failed to acquire grant
space
"
- "
for precreate (%d)
\n",
- ofd_name(ofd), diff);
+ CDEBUG(D_HA, "%s: failed to acquire grant "
+ "
space for precreate (%d): rc = %d
\n",
+ ofd_name(ofd), diff
, rc
);
diff = 0;
}
}
@@
-1312,7
+1303,8
@@
int ofd_create(const struct lu_env *env, struct obd_export *exp,
* them, even if last creation failed */
rc = 0;
else
- CERROR("unable to precreate: %d\n", rc);
+ CERROR("%s: unable to precreate: rc = %d\n",
+ ofd_name(ofd), rc);
oa->o_id = ofd_seq_last_oid(oseq);
oa->o_valid |= OBD_MD_FLID | OBD_MD_FLGROUP;
@@
-1431,6
+1423,63
@@
out:
return rc;
}
+static int ofd_ioc_get_obj_version(const struct lu_env *env,
+ struct ofd_device *ofd, void *karg)
+{
+ struct obd_ioctl_data *data = karg;
+ struct lu_fid fid;
+ struct ofd_object *fo;
+ dt_obj_version_t version;
+ int rc = 0;
+
+ ENTRY;
+
+ if (data->ioc_inlbuf2 == NULL || data->ioc_inllen2 != sizeof(version))
+ GOTO(out, rc = -EINVAL);
+
+ if (data->ioc_inlbuf1 != NULL && data->ioc_inllen1 == sizeof(fid)) {
+ fid = *(struct lu_fid *)data->ioc_inlbuf1;
+ } else if (data->ioc_inlbuf3 != NULL &&
+ data->ioc_inllen3 == sizeof(__u64) &&
+ data->ioc_inlbuf4 != NULL &&
+ data->ioc_inllen4 == sizeof(__u64)) {
+ struct ost_id ostid;
+
+ ostid.oi_id = *(__u64 *)data->ioc_inlbuf3;
+ ostid.oi_seq = *(__u64 *)data->ioc_inlbuf4;
+ rc = fid_ostid_unpack(&fid, &ostid, 0);
+ if (rc != 0)
+ GOTO(out, rc);
+ } else {
+ GOTO(out, rc = -EINVAL);
+ }
+
+ if (!fid_is_sane(&fid))
+ GOTO(out, rc = -EINVAL);
+
+ fo = ofd_object_find(env, ofd, &fid);
+ if (IS_ERR(fo))
+ GOTO(out, rc = PTR_ERR(fo));
+
+ if (!ofd_object_exists(fo))
+ GOTO(out_fo, rc = -ENOENT);
+
+ if (lu_object_remote(&fo->ofo_obj.do_lu))
+ GOTO(out_fo, rc = -EREMOTE);
+
+ version = dt_version_get(env, ofd_object_child(fo));
+ if (version == 0)
+ GOTO(out_fo, rc = -EIO);
+
+ *(dt_obj_version_t *)data->ioc_inlbuf2 = version;
+
+ EXIT;
+out_fo:
+ ofd_object_put(env, fo);
+out:
+ return rc;
+}
+
int ofd_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
void *karg, void *uarg)
{
@@
-1442,7
+1491,7
@@
int ofd_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
ENTRY;
CDEBUG(D_IOCTL, "handling ioctl cmd %#x\n", cmd);
- rc = lu_env_init(&env, LCT_
LOCAL
);
+ rc = lu_env_init(&env, LCT_
DT_THREAD
);
if (rc)
RETURN(rc);
@@
-1460,6
+1509,9
@@
int ofd_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
if (rc == 0)
rc = dt_ro(&env, ofd->ofd_osd);
break;
+ case OBD_IOC_GET_OBJ_VERSION:
+ rc = ofd_ioc_get_obj_version(&env, ofd, karg);
+ break;
default:
CERROR("%s: not supported cmd = %d\n", obd->obd_name, cmd);
rc = -ENOTTY;