int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr,
enum op_xvalid xvalid, unsigned int attr_flags)
{
- struct lu_env *env;
- struct cl_io *io;
- int result;
- __u16 refcheck;
+ struct lu_env *env;
+ struct cl_io *io;
+ int result;
+ __u16 refcheck;
- ENTRY;
+ ENTRY;
- env = cl_env_get(&refcheck);
- if (IS_ERR(env))
- RETURN(PTR_ERR(env));
+ env = cl_env_get(&refcheck);
+ if (IS_ERR(env))
+ RETURN(PTR_ERR(env));
io = vvp_env_thread_io(env);
io->ci_obj = obj;
io->u.ci_setattr.sa_avalid = attr->ia_valid;
io->u.ci_setattr.sa_xvalid = xvalid;
io->u.ci_setattr.sa_parent_fid = lu_object_fid(&obj->co_lu);
-
+ if (attr->ia_valid & ATTR_SIZE)
+ io->u.ci_setattr.sa_subtype = CL_SETATTR_TRUNC;
again:
if (attr->ia_valid & ATTR_FILE)
ll_io_set_mirror(io, attr->ia_file);
- if (cl_io_init(env, io, CIT_SETATTR, io->ci_obj) == 0) {
+ if (cl_io_init(env, io, CIT_SETATTR, io->ci_obj) == 0) {
struct vvp_io *vio = vvp_env_io(env);
if (attr->ia_valid & ATTR_FILE)
- /* populate the file descriptor for ftruncate to honor
- * group lock - see LU-787 */
- vio->vui_fd = LUSTRE_FPRIVATE(attr->ia_file);
-
- result = cl_io_loop(env, io);
- } else {
- result = io->ci_result;
- }
- cl_io_fini(env, io);
+ /*
+ * populate the file descriptor for ftruncate to honor
+ * group lock - see LU-787
+ */
+ vio->vui_fd = attr->ia_file->private_data;
+
+ result = cl_io_loop(env, io);
+ } else {
+ result = io->ci_result;
+ }
+ cl_io_fini(env, io);
if (unlikely(io->ci_need_restart))
goto again;
static void cl_object_put_last(struct lu_env *env, struct cl_object *obj)
{
struct lu_object_header *header = obj->co_lu.lo_header;
- wait_queue_entry_t waiter;
if (unlikely(atomic_read(&header->loh_ref) != 1)) {
struct lu_site *site = obj->co_lu.lo_dev->ld_site;
wq = lu_site_wq_from_fid(site, &header->loh_fid);
- init_waitqueue_entry(&waiter, current);
- add_wait_queue(wq, &waiter);
-
- while (1) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- if (atomic_read(&header->loh_ref) == 1)
- break;
- schedule();
- }
-
- set_current_state(TASK_RUNNING);
- remove_wait_queue(wq, &waiter);
+ wait_event(*wq, atomic_read(&header->loh_ref) == 1);
}
cl_object_put(env, obj);