* \retval - number of bytes have been read, or error code if error occurred.
*/
static ssize_t
-ll_do_fast_read(const struct lu_env *env, struct kiocb *iocb,
- struct iov_iter *iter)
+ll_do_fast_read(struct kiocb *iocb, struct iov_iter *iter)
{
ssize_t result;
if (iocb->ki_filp->f_flags & O_DIRECT)
return 0;
- ll_cl_add(iocb->ki_filp, env, NULL, LCC_RW);
result = generic_file_read_iter(iocb, iter);
- ll_cl_remove(iocb->ki_filp, env);
/* If the first page is not in cache, generic_file_aio_read() will be
* returned with -ENODATA.
ssize_t rc2;
__u16 refcheck;
+ result = ll_do_fast_read(iocb, to);
+ if (result < 0 || iov_iter_count(to) == 0)
+ GOTO(out, result);
+
env = cl_env_get(&refcheck);
if (IS_ERR(env))
return PTR_ERR(env);
- result = ll_do_fast_read(env, iocb, to);
- if (result < 0 || iov_iter_count(to) == 0)
- GOTO(out, result);
-
args = ll_env_args(env, IO_NORMAL);
args->u.normal.via_iter = to;
args->u.normal.via_iocb = iocb;
else if (result == 0)
result = rc2;
-out:
cl_env_put(env, &refcheck);
+out:
return result;
}
static ssize_t ll_file_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos)
{
- struct lu_env *env;
struct iovec iov = { .iov_base = buf, .iov_len = count };
- struct kiocb *kiocb;
+ struct kiocb kiocb;
ssize_t result;
- __u16 refcheck;
ENTRY;
- env = cl_env_get(&refcheck);
- if (IS_ERR(env))
- RETURN(PTR_ERR(env));
-
- kiocb = &ll_env_info(env)->lti_kiocb;
- init_sync_kiocb(kiocb, file);
- kiocb->ki_pos = *ppos;
+ init_sync_kiocb(&kiocb, file);
+ kiocb.ki_pos = *ppos;
#ifdef HAVE_KIOCB_KI_LEFT
- kiocb->ki_left = count;
+ kiocb.ki_left = count;
#elif defined(HAVE_KI_NBYTES)
- kiocb->ki_nbytes = count;
+ kiocb.i_nbytes = count;
#endif
- result = ll_file_aio_read(kiocb, &iov, 1, kiocb->ki_pos);
- *ppos = kiocb->ki_pos;
+ result = ll_file_aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
+ *ppos = kiocb.ki_pos;
- cl_env_put(env, &refcheck);
RETURN(result);
}
RETURN(acl);
}
+#ifdef HAVE_IOP_SET_ACL
+#ifdef CONFIG_FS_POSIX_ACL
+int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+ const char *name = NULL;
+ char *value = NULL;
+ size_t size = 0;
+ int rc = 0;
+ ENTRY;
+
+ switch (type) {
+ case ACL_TYPE_ACCESS:
+ if (acl) {
+ rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
+ if (rc)
+ GOTO(out, rc);
+ }
+ name = XATTR_NAME_POSIX_ACL_ACCESS;
+ break;
+ case ACL_TYPE_DEFAULT:
+ if (!S_ISDIR(inode->i_mode))
+ GOTO(out, rc = acl ? -EACCES : 0);
+ name = XATTR_NAME_POSIX_ACL_DEFAULT;
+ break;
+ default:
+ GOTO(out, rc = -EINVAL);
+ }
+
+ if (acl) {
+ size = posix_acl_xattr_size(acl->a_count);
+ value = kmalloc(size, GFP_NOFS);
+ if (value == NULL)
+ GOTO(out, rc = -ENOMEM);
+
+ rc = posix_acl_to_xattr(&init_user_ns, acl, value, size);
+ if (rc < 0)
+ GOTO(out_free, rc);
+ }
+
+ /* dentry is only used for *.lov attributes so it's safe to be NULL */
+ rc = __vfs_setxattr(NULL, inode, name, value, size, XATTR_CREATE);
+out_free:
+ kfree(value);
+out:
+ if (!rc)
+ set_cached_acl(inode, type, acl);
+ else
+ forget_cached_acl(inode, type);
+ RETURN(rc);
+}
+#endif /* CONFIG_FS_POSIX_ACL */
+#endif /* HAVE_IOP_SET_ACL */
+
#ifndef HAVE_GENERIC_PERMISSION_2ARGS
static int
# ifdef HAVE_GENERIC_PERMISSION_4ARGS
#ifdef HAVE_IOP_GET_ACL
.get_acl = ll_get_acl,
#endif
+#ifdef HAVE_IOP_SET_ACL
+ .set_acl = ll_set_acl,
+#endif
};
/* dynamic ioctl number support routins */