return attr;
}
+static inline struct cl_io *ccc_env_thread_io(const struct lu_env *env)
+{
+ struct cl_io *io = &ccc_env_info(env)->cti_io;
+ memset(io, 0, sizeof(*io));
+ return io;
+}
+
struct ccc_session {
struct ccc_io cs_ios;
};
struct ccc_grouplock {
struct lu_env *cg_env;
+ struct cl_io *cg_io;
struct cl_lock *cg_lock;
unsigned long cg_gid;
};
static int cl_io_get(struct inode *inode, struct lu_env **envout,
struct cl_io **ioout, int *refcheck)
{
- struct ccc_thread_info *info;
struct lu_env *env;
struct cl_io *io;
struct cl_inode_info *lli = cl_i2info(inode);
if (S_ISREG(cl_inode_mode(inode))) {
env = cl_env_get(refcheck);
if (!IS_ERR(env)) {
- info = ccc_env_info(env);
- io = &info->cti_io;
+ io = ccc_env_thread_io(env);
io->ci_obj = clob;
*envout = env;
*ioout = io;
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
io->ci_obj = cl_i2info(inode)->lli_clob;
io->u.ci_setattr.sa_attr.lvb_atime = LTIME_S(attr->ia_atime);
if (IS_ERR(env))
return PTR_ERR(env);
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
io->ci_obj = obj;
rc = cl_io_init(env, io, CIT_MISC, io->ci_obj);
return PTR_ERR(lock);
}
- cg->cg_env = cl_env_get(&refcheck);
+ cg->cg_env = cl_env_get(&refcheck);
+ cg->cg_io = io;
cg->cg_lock = lock;
- cg->cg_gid = gid;
+ cg->cg_gid = gid;
LASSERT(cg->cg_env == env);
cl_env_unplant(env, &refcheck);
void cl_put_grouplock(struct ccc_grouplock *cg)
{
- struct lu_env *env = cg->cg_env;
- struct cl_lock *lock = cg->cg_lock;
- int refcheck;
+ struct lu_env *env = cg->cg_env;
+ struct cl_io *io = cg->cg_io;
+ struct cl_lock *lock = cg->cg_lock;
+ int refcheck;
LASSERT(cg->cg_env);
LASSERT(cg->cg_gid);
cl_unuse(env, lock);
cl_lock_release(env, lock, GROUPLOCK_SCOPE, cfs_current());
- cl_io_fini(env, &ccc_env_info(env)->cti_io);
+ cl_io_fini(env, io);
cl_env_put(env, NULL);
}
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- io = &ccc_env_info(env)->cti_io;
-
+ io = ccc_env_thread_io(env);
if (cl_io_rw_init(env, io, session->lis_cmd == OBD_BRW_WRITE?CIT_WRITE:
CIT_READ,
pos, len) == 0) {
{
struct llu_inode_info *lli = llu_i2info(inode);
- memset(io, 0, sizeof *io);
-
io->u.ci_rw.crw_nonblock = lli->lli_open_flags & O_NONBLOCK;
if (write)
io->u.ci_wr.wr_append = lli->lli_open_flags & O_APPEND;
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
llu_io_init(io, ino, 0);
ret = llu_file_rwx(ino, ioctx, 1);
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
llu_io_init(io, ino, 1);
ret = llu_file_rwx(ino, ioctx, 0);
{
struct inode *inode = file->f_dentry->d_inode;
- memset(io, 0, sizeof *io);
io->u.ci_rw.crw_nonblock = file->f_flags & O_NONBLOCK;
if (write)
io->u.ci_wr.wr_append = !!(file->f_flags & O_APPEND);
ssize_t result;
ENTRY;
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
ll_io_init(io, file, iot == CIT_WRITE);
if (cl_io_rw_init(env, io, iot, *ppos, count) == 0) {
* \retval EINVAL if env can't allocated
* \return other error codes from cl_io_init.
*/
-int ll_fault_io_init(struct vm_area_struct *vma, struct lu_env **env_ret,
- struct cl_env_nest *nest, pgoff_t index, unsigned long *ra_flags)
+struct cl_io *ll_fault_io_init(struct vm_area_struct *vma,
+ struct lu_env **env_ret,
+ struct cl_env_nest *nest,
+ pgoff_t index, unsigned long *ra_flags)
{
struct file *file = vma->vm_file;
struct inode *inode = file->f_dentry->d_inode;
struct lu_env *env;
ENTRY;
+ *env_ret = NULL;
if (ll_file_nolock(file))
- RETURN(-EOPNOTSUPP);
+ RETURN(ERR_PTR(-EOPNOTSUPP));
/*
* page fault can be called when lustre IO is
* one.
*/
env = cl_env_nested_get(nest);
- if (IS_ERR(env)) {
- *env_ret = NULL;
- RETURN(-EINVAL);
- }
+ if (IS_ERR(env))
+ RETURN(ERR_PTR(-EINVAL));
*env_ret = env;
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
io->ci_obj = ll_i2info(inode)->lli_clob;
LASSERT(io->ci_obj != NULL);
cio->cui_fd = fd;
}
- return io->ci_result;
+ return io;
}
#ifndef HAVE_VM_OP_FAULT
ENTRY;
pg_offset = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
- result = ll_fault_io_init(vma, &env, &nest, pg_offset, &ra_flags);
- if (env == NULL)
+ io = ll_fault_io_init(vma, &env, &nest, pg_offset, &ra_flags);
+ if (IS_ERR(io))
return NOPAGE_SIGBUS;
- io = &ccc_env_info(env)->cti_io;
+ result = io->ci_result;
if (result < 0)
goto out_err;
vio = vvp_env_io(env);
-
vio->u.fault.ft_vma = vma;
vio->u.fault.nopage.ft_address = address;
vio->u.fault.nopage.ft_type = type;
int fault_ret = 0;
ENTRY;
- result = ll_fault_io_init(vma, &env, &nest, vmf->pgoff, &ra_flags);
- if (env == NULL)
+ io = ll_fault_io_init(vma, &env, &nest, vmf->pgoff, &ra_flags);
+ if (IS_ERR(io))
RETURN(VM_FAULT_ERROR);
- io = &ccc_env_info(env)->cti_io;
+ result = io->ci_result;
if (result < 0)
goto out_err;
* so cl_io has to be created here.
*/
- io = &ccc_env_info(env)->cti_io;
+ io = ccc_env_thread_io(env);
vio = vvp_env_io(env);
ll_io_init(io, file, 1);
if (IS_ERR(env))
RETURN(PTR_ERR(env));
- io = &ccc_env_info(env)->cti_io;
queue = &vvp_env_info(env)->vti_queue;
clob = ll_i2info(inode)->lli_clob;
LASSERT(clob != NULL);
+ io = ccc_env_thread_io(env);
io->ci_obj = clob;
result = cl_io_init(env, io, CIT_MISC, clob);
if (result == 0) {