static const char dotdot[] = "..";
static const struct dt_body_operations lod_body_lnk_ops;
+static const struct dt_body_operations lod_body_ops;
/**
* Implementation of dt_index_operations::dio_lookup
if (dof->dof_type == DFT_SYM)
dt->do_body_ops = &lod_body_lnk_ops;
+ else if (dof->dof_type == DFT_REGULAR)
+ dt->do_body_ops = &lod_body_ops;
/*
* it's lod_ah_init() that has decided the object will be striped
return lod_sub_object_write(env, dt_object_child(dt), buf, pos, th, iq);
}
+static int lod_declare_punch(const struct lu_env *env, struct dt_object *dt,
+ __u64 start, __u64 end, struct thandle *th)
+{
+ if (dt_object_remote(dt))
+ return -ENOTSUPP;
+
+ return lod_sub_object_declare_punch(env, dt_object_child(dt), start,
+ end, th);
+}
+
+static int lod_punch(const struct lu_env *env, struct dt_object *dt,
+ __u64 start, __u64 end, struct thandle *th)
+{
+ if (dt_object_remote(dt))
+ return -ENOTSUPP;
+
+ return lod_sub_object_punch(env, dt_object_child(dt), start, end, th);
+}
+
static const struct dt_body_operations lod_body_lnk_ops = {
.dbo_read = lod_read,
.dbo_declare_write = lod_declare_write,
.dbo_write = lod_write
};
+static const struct dt_body_operations lod_body_ops = {
+ .dbo_read = lod_read,
+ .dbo_declare_write = lod_declare_write,
+ .dbo_write = lod_write,
+ .dbo_declare_punch = lod_declare_punch,
+ .dbo_punch = lod_punch,
+};
+
/**
* Implementation of lu_object_operations::loo_object_init.
*
*/
static int lod_object_start(const struct lu_env *env, struct lu_object *o)
{
- if (S_ISLNK(o->lo_header->loh_attr & S_IFMT))
+ if (S_ISLNK(o->lo_header->loh_attr & S_IFMT)) {
lu2lod_obj(o)->ldo_obj.do_body_ops = &lod_body_lnk_ops;
+ } else if (S_ISREG(o->lo_header->loh_attr & S_IFMT) ||
+ fid_is_local_file(lu_object_fid(o))) {
+ /* Note: some local file (like last rcvd) is created
+ * through bottom layer (OSD), so the object initialization
+ * comes to lod, it does not set loh_attr yet, so
+ * set do_body_ops for local file anyway */
+ lu2lod_obj(o)->ldo_obj.do_body_ops = &lod_body_ops;
+ }
return 0;
}