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-13783 libcfs: support __vmalloc with only 2 args.
[fs/lustre-release.git]
/
lustre
/
ofd
/
ofd_objects.c
diff --git
a/lustre/ofd/ofd_objects.c
b/lustre/ofd/ofd_objects.c
index
6d55a99
..
8c1b21a
100644
(file)
--- a/
lustre/ofd/ofd_objects.c
+++ b/
lustre/ofd/ofd_objects.c
@@
-64,8
+64,6
@@
static int ofd_version_get_check(struct ofd_thread_info *info,
{
dt_obj_version_t curr_version;
- LASSERT(ofd_object_exists(fo));
-
if (info->fti_exp == NULL)
RETURN(0);
@@
-742,6
+740,94
@@
out:
}
/**
+ * Fallocate(Preallocate) space for OFD object.
+ *
+ * This function allocates space for the object from the \a start
+ * offset to the \a end offset.
+ *
+ * \param[in] env execution environment
+ * \param[in] fo OFD object
+ * \param[in] start start offset to allocate from
+ * \param[in] end end of allocate
+ * \param[in] mode fallocate mode
+ * \param[in] la object attributes
+ * \param[in] ff filter_fid structure
+ *
+ * \retval 0 if successful
+ * \retval negative value on error
+ */
+int ofd_object_fallocate(const struct lu_env *env, struct ofd_object *fo,
+ __u64 start, __u64 end, int mode, struct lu_attr *la,
+ struct obdo *oa)
+{
+ struct ofd_thread_info *info = ofd_info(env);
+ struct ofd_device *ofd = ofd_obj2dev(fo);
+ struct dt_object *dob = ofd_object_child(fo);
+ struct thandle *th;
+ struct filter_fid *ff = &info->fti_mds_fid;
+ bool ff_needed = false;
+ int rc;
+
+ ENTRY;
+
+ if (!ofd_object_exists(fo))
+ RETURN(-ENOENT);
+
+ /* VBR: version recovery check */
+ rc = ofd_version_get_check(info, fo);
+ if (rc != 0)
+ RETURN(rc);
+
+ if (ff != NULL) {
+ rc = ofd_object_ff_load(env, fo);
+ if (rc == -ENODATA)
+ ff_needed = true;
+ else if (rc < 0)
+ RETURN(rc);
+ }
+
+ th = ofd_trans_create(env, ofd);
+ if (IS_ERR(th))
+ RETURN(PTR_ERR(th));
+
+ rc = dt_declare_attr_set(env, dob, la, th);
+ if (rc)
+ GOTO(stop, rc);
+
+ rc = dt_declare_fallocate(env, dob, start, end, mode, th);
+ if (rc)
+ GOTO(stop, rc);
+
+ rc = ofd_trans_start(env, ofd, fo, th);
+ if (rc)
+ GOTO(stop, rc);
+
+ ofd_write_lock(env, fo);
+ if (!ofd_object_exists(fo))
+ GOTO(unlock, rc = -ENOENT);
+
+ rc = dt_falloc(env, dob, start, end, mode, th);
+ if (rc)
+ GOTO(unlock, rc);
+
+ rc = dt_attr_set(env, dob, la, th);
+ if (rc)
+ GOTO(unlock, rc);
+
+ if (ff_needed) {
+ rc = dt_xattr_set(env, ofd_object_child(fo), &info->fti_buf,
+ XATTR_NAME_FID, 0, th);
+ if (!rc)
+ filter_fid_le_to_cpu(&fo->ofo_ff, ff, sizeof(*ff));
+ }
+unlock:
+ ofd_write_unlock(env, fo);
+stop:
+ ofd_trans_stop(env, ofd, th, rc);
+ RETURN(rc);
+}
+
+/**
* Truncate/punch OFD object.
*
* This function frees all of the allocated object's space from the \a start
@@
-834,6
+920,17
@@
int ofd_object_punch(const struct lu_env *env, struct ofd_object *fo,
oa->o_valid &= ~OBD_MD_LAYOUT_VERSION;
}
+ if (oa->o_valid & OBD_MD_FLFLAGS && oa->o_flags & LUSTRE_ENCRYPT_FL) {
+ /* punch must be aware we are dealing with an encrypted file */
+ struct lu_attr la = {
+ .la_valid = LA_FLAGS,
+ .la_flags = LUSTRE_ENCRYPT_FL,
+ };
+
+ rc = dt_attr_set(env, dob, &la, th);
+ if (rc)
+ GOTO(unlock, rc);
+ }
rc = dt_punch(env, dob, start, OBD_OBJECT_EOF, th);
if (rc)
GOTO(unlock, rc);
@@
-925,14
+1022,14
@@
int ofd_destroy(const struct lu_env *env, struct ofd_object *fo,
ofd_write_lock(env, fo);
if (!ofd_object_exists(fo))
- GOTO(
stop
, rc = -ENOENT);
+ GOTO(
unlock
, rc = -ENOENT);
tgt_fmd_drop(ofd_info(env)->fti_exp, &fo->ofo_header.loh_fid);
dt_ref_del(env, ofd_object_child(fo), th);
dt_destroy(env, ofd_object_child(fo), th);
+unlock:
ofd_write_unlock(env, fo);
-
stop:
rc2 = ofd_trans_stop(env, ofd, th, rc);
if (rc2)