orangefs: convert to fileattr

Use the fileattr API to let the VFS handle locking, permission checking and
conversion.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Cc: Mike Marshall <hubcap@omnibond.com>
This commit is contained in:
Miklos Szeredi 2021-04-07 14:36:43 +02:00
parent 88b631cbfb
commit 1f26b0627b
2 changed files with 50 additions and 79 deletions

View file

@ -11,6 +11,7 @@
*/
#include <linux/bvec.h>
#include <linux/fileattr.h>
#include "protocol.h"
#include "orangefs-kernel.h"
#include "orangefs-bufmap.h"
@ -954,6 +955,53 @@ int orangefs_update_time(struct inode *inode, struct timespec64 *time, int flags
return __orangefs_setattr(inode, &iattr);
}
static int orangefs_fileattr_get(struct dentry *dentry, struct fileattr *fa)
{
u64 val = 0;
int ret;
gossip_debug(GOSSIP_FILE_DEBUG, "%s: called on %pd\n", __func__,
dentry);
ret = orangefs_inode_getxattr(d_inode(dentry),
"user.pvfs2.meta_hint",
&val, sizeof(val));
if (ret < 0 && ret != -ENODATA)
return ret;
gossip_debug(GOSSIP_FILE_DEBUG, "%s: flags=%u\n", __func__, (u32) val);
fileattr_fill_flags(fa, val);
return 0;
}
static int orangefs_fileattr_set(struct user_namespace *mnt_userns,
struct dentry *dentry, struct fileattr *fa)
{
u64 val = 0;
gossip_debug(GOSSIP_FILE_DEBUG, "%s: called on %pd\n", __func__,
dentry);
/*
* ORANGEFS_MIRROR_FL is set internally when the mirroring mode is
* turned on for a file. The user is not allowed to turn on this bit,
* but the bit is present if the user first gets the flags and then
* updates the flags with some new settings. So, we ignore it in the
* following edit. bligon.
*/
if (fileattr_has_fsx(fa) ||
(fa->flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NOATIME_FL | ORANGEFS_MIRROR_FL))) {
gossip_err("%s: only supports setting one of FS_IMMUTABLE_FL|FS_APPEND_FL|FS_NOATIME_FL\n",
__func__);
return -EOPNOTSUPP;
}
val = fa->flags;
gossip_debug(GOSSIP_FILE_DEBUG, "%s: flags=%u\n", __func__, (u32) val);
return orangefs_inode_setxattr(d_inode(dentry),
"user.pvfs2.meta_hint",
&val, sizeof(val), 0);
}
/* ORANGEFS2 implementation of VFS inode operations for files */
static const struct inode_operations orangefs_file_inode_operations = {
.get_acl = orangefs_get_acl,
@ -963,6 +1011,8 @@ static const struct inode_operations orangefs_file_inode_operations = {
.listxattr = orangefs_listxattr,
.permission = orangefs_permission,
.update_time = orangefs_update_time,
.fileattr_get = orangefs_fileattr_get,
.fileattr_set = orangefs_fileattr_set,
};
static int orangefs_init_iops(struct inode *inode)