op_data->op_xvalid |= OP_XVALID_CTIME_SET;
op_data->op_attr_blocks = inode->i_blocks;
op_data->op_attr_flags = ll_inode_to_ext_flags(inode->i_flags);
- if (ll_file_test_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT))
+ if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags))
op_data->op_attr_flags |= LUSTRE_PROJINHERIT_FL;
op_data->op_open_handle = och->och_open_handle;
if (och->och_flags & FMODE_WRITE &&
- ll_file_test_and_clear_flag(ll_i2info(inode), LLIF_DATA_MODIFIED))
+ test_and_clear_bit(LLIF_DATA_MODIFIED, &ll_i2info(inode)->lli_flags))
/* For HSM: if inode data has been modified, pack it so that
* MDT can set data dirty flag in the archive. */
op_data->op_bias |= MDS_DATA_MODIFIED;
if (S_ISDIR(inode->i_mode) && lli->lli_opendir_key == fd)
ll_deauthorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file_dentry(file)) {
+ if (is_root_inode(inode)) {
file->private_data = NULL;
ll_file_data_put(fd);
GOTO(out, rc = 0);
libcfs_debug_dumplog();
out:
- if (!rc && inode->i_sb->s_root != file_dentry(file))
+ if (!rc && !is_root_inode(inode))
ll_stats_ops_tally(sbi, LPROC_LL_RELEASE,
ktime_us_delta(ktime_get(), kstart));
RETURN(rc);
if (S_ISDIR(inode->i_mode))
ll_authorize_statahead(inode, fd);
- if (inode->i_sb->s_root == file_dentry(file)) {
+ if (is_root_inode(inode)) {
file->private_data = fd;
RETURN(0);
}
* POSIX. Solving this problem needs to send an RPC to MDT for each
* read, this will hurt performance.
*/
- if (ll_file_test_and_clear_flag(lli, LLIF_UPDATE_ATIME) ||
+ if (test_and_clear_bit(LLIF_UPDATE_ATIME, &lli->lli_flags) ||
inode->i_atime.tv_sec < lli->lli_atime)
inode->i_atime.tv_sec = lli->lli_atime;
ll_heat_add(inode, CIT_WRITE, result);
ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_WRITE_BYTES,
result);
- ll_file_set_flag(ll_i2info(inode), LLIF_DATA_MODIFIED);
+ set_bit(LLIF_DATA_MODIFIED, &ll_i2info(inode)->lli_flags);
}
CDEBUG(D_VFSTRACE, "result: %zu, original count %zu\n", result, count);
int rc;
ENTRY;
- if (!cfs_capable(CFS_CAP_SYS_ADMIN))
+ if (!capable(CAP_SYS_ADMIN))
RETURN(-EPERM);
OBD_ALLOC_LARGE(lump, lum_size);
*/
int ll_release_openhandle(struct dentry *dentry, struct lookup_intent *it)
{
- struct inode *inode = dentry->d_inode;
- struct obd_client_handle *och;
- int rc;
- ENTRY;
+ struct inode *inode = dentry->d_inode;
+ struct obd_client_handle *och;
+ int rc;
+ ENTRY;
- LASSERT(inode);
+ LASSERT(inode);
- /* Root ? Do nothing. */
- if (dentry->d_inode->i_sb->s_root == dentry)
- RETURN(0);
+ /* Root ? Do nothing. */
+ if (is_root_inode(inode))
+ RETURN(0);
- /* No open handle to close? Move away */
- if (!it_disposition(it, DISP_OPEN_OPEN))
- RETURN(0);
+ /* No open handle to close? Move away */
+ if (!it_disposition(it, DISP_OPEN_OPEN))
+ RETURN(0);
- LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0);
+ LASSERT(it_open_error(DISP_OPEN_OPEN, it) == 0);
- OBD_ALLOC(och, sizeof(*och));
- if (!och)
- GOTO(out, rc = -ENOMEM);
+ OBD_ALLOC(och, sizeof(*och));
+ if (!och)
+ GOTO(out, rc = -ENOMEM);
rc = ll_och_fill(ll_i2sbi(inode)->ll_md_exp, it, och);
if (rc)
ENTRY;
- if (!cfs_capable(CFS_CAP_DAC_READ_SEARCH) &&
+ if (!capable(CAP_DAC_READ_SEARCH) &&
!(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH))
RETURN(-EPERM);
/* Non-root users are forbidden to set or clear flags which are
* NOT defined in HSM_USER_MASK. */
if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) &&
- !cfs_capable(CFS_CAP_SYS_ADMIN))
+ !capable(CAP_SYS_ADMIN))
RETURN(-EPERM);
if (!exp_connect_archive_id_array(exp)) {
RETURN(-EFAULT);
fsxattr.fsx_xflags = ll_inode_flags_to_xflags(inode->i_flags);
- if (ll_file_test_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT))
+ if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags))
fsxattr.fsx_xflags |= FS_XFLAG_PROJINHERIT;
fsxattr.fsx_projid = ll_i2info(inode)->lli_projid;
if (copy_to_user((struct fsxattr __user *)arg,
if (ll_i2info(inode)->lli_projid != fa->fsx_projid)
return -EINVAL;
- if (ll_file_test_flag(ll_i2info(inode), LLIF_PROJECT_INHERIT)) {
+ if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags)) {
if (!(fa->fsx_xflags & FS_XFLAG_PROJINHERIT))
return -EINVAL;
} else {
int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd,
unsigned long arg)
{
-
struct md_op_data *op_data;
struct ptlrpc_request *req = NULL;
- int rc = 0;
struct fsxattr fsxattr;
struct cl_object *obj;
- struct iattr *attr;
- int flags;
+ unsigned int inode_flags;
+ int rc = 0;
if (copy_from_user(&fsxattr,
(const struct fsxattr __user *)arg,
if (IS_ERR(op_data))
RETURN(PTR_ERR(op_data));
- flags = ll_xflags_to_inode_flags(fsxattr.fsx_xflags);
- op_data->op_attr_flags = ll_inode_to_ext_flags(flags);
+ inode_flags = ll_xflags_to_inode_flags(fsxattr.fsx_xflags);
+ op_data->op_attr_flags = ll_inode_to_ext_flags(inode_flags);
if (fsxattr.fsx_xflags & FS_XFLAG_PROJINHERIT)
op_data->op_attr_flags |= LUSTRE_PROJINHERIT_FL;
op_data->op_projid = fsxattr.fsx_projid;
op_data->op_xvalid |= OP_XVALID_PROJID | OP_XVALID_FLAGS;
- rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL,
- 0, &req);
+ rc = md_setattr(ll_i2sbi(inode)->ll_md_exp, op_data, NULL, 0, &req);
ptlrpc_req_finished(req);
if (rc)
GOTO(out_fsxattr, rc);
ll_update_inode_flags(inode, op_data->op_attr_flags);
- obj = ll_i2info(inode)->lli_clob;
- if (obj == NULL)
- GOTO(out_fsxattr, rc);
- /* Avoiding OST RPC if this is only project ioctl */
+ /* Avoid OST RPC if this is only ioctl setting project inherit flag */
if (fsxattr.fsx_xflags == 0 ||
fsxattr.fsx_xflags == FS_XFLAG_PROJINHERIT)
GOTO(out_fsxattr, rc);
- OBD_ALLOC_PTR(attr);
- if (attr == NULL)
- GOTO(out_fsxattr, rc = -ENOMEM);
+ obj = ll_i2info(inode)->lli_clob;
+ if (obj) {
+ struct iattr attr = { 0 };
+
+ rc = cl_setattr_ost(obj, &attr, OP_XVALID_FLAGS,
+ fsxattr.fsx_xflags);
+ }
- rc = cl_setattr_ost(obj, attr, OP_XVALID_FLAGS,
- fsxattr.fsx_xflags);
- OBD_FREE_PTR(attr);
out_fsxattr:
ll_finish_md_op_data(op_data);
RETURN(rc);
}
}
-loff_t ll_lseek(struct inode *inode, loff_t offset, int whence)
+loff_t ll_lseek(struct file *file, loff_t offset, int whence)
{
+ struct inode *inode = file_inode(file);
struct lu_env *env;
struct cl_io *io;
struct cl_lseek_io *lsio;
io = vvp_env_thread_io(env);
io->ci_obj = ll_i2info(inode)->lli_clob;
+ ll_io_set_mirror(io, file);
lsio = &io->u.ci_lseek;
lsio->ls_start = offset;
do {
rc = cl_io_init(env, io, CIT_LSEEK, io->ci_obj);
- if (!rc)
+ if (!rc) {
+ struct vvp_io *vio = vvp_env_io(env);
+
+ vio->vui_fd = file->private_data;
rc = cl_io_loop(env, io);
- else
+ } else {
rc = io->ci_result;
+ }
retval = rc ? : lsio->ls_result;
cl_io_fini(env, io);
} while (unlikely(io->ci_need_restart));
cl_sync_file_range(inode, offset, OBD_OBJECT_EOF,
CL_FSYNC_LOCAL, 0);
- retval = ll_lseek(inode, offset, origin);
+ retval = ll_lseek(file, offset, origin);
if (retval < 0)
return retval;
retval = vfs_setpos(file, retval, ll_file_maxbytes(inode));
* by checking the migrate FID against the FID of the
* filesystem root.
*/
- if (child_inode == parent->i_sb->s_root->d_inode)
+ if (is_root_inode(child_inode))
GOTO(out_iput, rc = -EINVAL);
+ if (IS_ENCRYPTED(child_inode)) {
+ rc = llcrypt_get_encryption_info(child_inode);
+ if (rc)
+ GOTO(out_iput, rc);
+ if (!llcrypt_has_encryption_key(child_inode)) {
+ CDEBUG(D_SEC, "no enc key for "DFID"\n",
+ PFID(ll_inode2fid(child_inode)));
+ GOTO(out_iput, rc = -ENOKEY);
+ }
+ }
+
op_data = ll_prep_md_op_data(NULL, parent, NULL, name, namelen,
child_inode->i_mode, LUSTRE_OPC_ANY, NULL);
if (IS_ERR(op_data))
* restore the MDT holds the layout lock so the glimpse will
* block up to the end of restore (getattr will block)
*/
- if (!ll_file_test_flag(lli, LLIF_FILE_RESTORING)) {
+ if (!test_bit(LLIF_FILE_RESTORING, &lli->lli_flags)) {
rc = ll_glimpse_size(inode);
if (rc < 0)
RETURN(rc);
return rc;
}
-struct posix_acl *ll_get_acl(struct inode *inode, int type)
-{
- struct ll_inode_info *lli = ll_i2info(inode);
- struct posix_acl *acl = NULL;
- ENTRY;
-
- spin_lock(&lli->lli_lock);
- /* VFS' acl_permission_check->check_acl will release the refcount */
- acl = posix_acl_dup(lli->lli_posix_acl);
- spin_unlock(&lli->lli_lock);
-
- RETURN(acl);
-}
-
-#ifdef HAVE_IOP_SET_ACL
-#ifdef CONFIG_LUSTRE_FS_POSIX_ACL
-int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
-{
- struct ll_sb_info *sbi = ll_i2sbi(inode);
- struct ptlrpc_request *req = NULL;
- const char *name = NULL;
- char *value = NULL;
- size_t value_size = 0;
- int rc = 0;
- ENTRY;
-
- switch (type) {
- case ACL_TYPE_ACCESS:
- name = XATTR_NAME_POSIX_ACL_ACCESS;
- if (acl)
- rc = posix_acl_update_mode(inode, &inode->i_mode, &acl);
- break;
-
- case ACL_TYPE_DEFAULT:
- name = XATTR_NAME_POSIX_ACL_DEFAULT;
- if (!S_ISDIR(inode->i_mode))
- rc = acl ? -EACCES : 0;
- break;
-
- default:
- rc = -EINVAL;
- break;
- }
- if (rc)
- return rc;
-
- if (acl) {
- value_size = posix_acl_xattr_size(acl->a_count);
- value = kmalloc(value_size, GFP_NOFS);
- if (value == NULL)
- GOTO(out, rc = -ENOMEM);
-
- rc = posix_acl_to_xattr(&init_user_ns, acl, value, value_size);
- if (rc < 0)
- GOTO(out_value, rc);
- }
-
- rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
- value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
- name, value, value_size, 0, 0, &req);
-
- ptlrpc_req_finished(req);
-out_value:
- kfree(value);
-out:
- if (rc)
- forget_cached_acl(inode, type);
- else
- set_cached_acl(inode, type, acl);
- RETURN(rc);
-}
-#endif /* CONFIG_LUSTRE_FS_POSIX_ACL */
-#endif /* HAVE_IOP_SET_ACL */
-
int ll_inode_permission(struct inode *inode, int mask)
{
int rc = 0;
* need to do it before permission check.
*/
- if (inode == inode->i_sb->s_root->d_inode) {
+ if (is_root_inode(inode)) {
rc = ll_inode_revalidate(inode->i_sb->s_root, IT_LOOKUP);
if (rc)
RETURN(rc);
}
/* -o localflock - only provides locally consistent flock locks */
-struct file_operations ll_file_operations = {
+static const struct file_operations ll_file_operations = {
#ifdef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
# ifdef HAVE_SYNC_READ_WRITE
.read = new_sync_read,
.fallocate = ll_fallocate,
};
-struct file_operations ll_file_operations_flock = {
+static const struct file_operations ll_file_operations_flock = {
#ifdef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
# ifdef HAVE_SYNC_READ_WRITE
.read = new_sync_read,
};
/* These are for -o noflock - to return ENOSYS on flock calls */
-struct file_operations ll_file_operations_noflock = {
+static const struct file_operations ll_file_operations_noflock = {
#ifdef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
# ifdef HAVE_SYNC_READ_WRITE
.read = new_sync_read,
.fallocate = ll_fallocate,
};
-struct inode_operations ll_file_inode_operations = {
+const struct inode_operations ll_file_inode_operations = {
.setattr = ll_setattr,
.getattr = ll_getattr,
.permission = ll_inode_permission,
#endif
};
+const struct file_operations *ll_select_file_operations(struct ll_sb_info *sbi)
+{
+ const struct file_operations *fops = &ll_file_operations_noflock;
+
+ if (sbi->ll_flags & LL_SBI_FLOCK)
+ fops = &ll_file_operations_flock;
+ else if (sbi->ll_flags & LL_SBI_LOCALFLOCK)
+ fops = &ll_file_operations;
+
+ return fops;
+}
+
int ll_layout_conf(struct inode *inode, const struct cl_object_conf *conf)
{
struct ll_inode_info *lli = ll_i2info(inode);