Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
filesystems
lustre_2_12
0012-LU-13430-vfs-add-ll_vfs_getxattr-ll_vfs_se...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0012-LU-13430-vfs-add-ll_vfs_getxattr-ll_vfs_setxattr-com.patch of Package lustre_2_12
From 1f0883a18f94807f1f0824c18d7bd31ab7fe9088 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson <sbuisson@ddn.com> Date: Mon, 6 Apr 2020 09:29:10 +0000 Subject: [PATCH 12/35] LU-13430 vfs: add ll_vfs_getxattr/ll_vfs_setxattr compat macro Instead of checking everywhere in the code whether kernel defines __vfs_getxattr/__vfs_setxattr/__vfs_removexattr, define compat macros to handle this in lustre_compat.h. Signed-off-by: Sebastien Buisson <sbuisson@ddn.com> Change-Id: Iabb54c41e6ccc4b9524f614308a4cd98c5a7ec55 Reviewed-on: https://review.whamcloud.com/38175 Reviewed-by: Andreas Dilger <adilger@whamcloud.com> Tested-by: jenkins <devops@whamcloud.com> Reviewed-by: James Simmons <jsimmons@infradead.org> Tested-by: Maloo <maloo@whamcloud.com> Reviewed-by: Oleg Drokin <green@whamcloud.com> --- lustre/include/lustre_compat.h | 69 ++++++++++++++++++------------- lustre/llite/xattr_security.c | 4 +- lustre/osd-ldiskfs/osd_handler.c | 4 +- lustre/osd-ldiskfs/osd_internal.h | 20 +-------- lustre/osd-ldiskfs/osd_scrub.c | 2 +- 5 files changed, 48 insertions(+), 51 deletions(-) diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index c36f2bf9ce28..6c5630eb708b 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -478,34 +478,6 @@ int ll_removexattr(struct dentry *dentry, const char *name); #endif /* ! HAVE_XATTR_HANDLER_FLAGS */ #endif /* HAVE_IOP_XATTR */ -#ifndef HAVE_VFS_SETXATTR -const struct xattr_handler *get_xattr_type(const char *name); - -static inline int -__vfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, - const void *value, size_t size, int flags) -{ -# ifdef HAVE_XATTR_HANDLER_FLAGS - const struct xattr_handler *handler; - int rc; - - handler = get_xattr_type(name); - if (!handler) - return -EOPNOTSUPP; - -# if defined(HAVE_XATTR_HANDLER_INODE_PARAM) - rc = handler->set(handler, dentry, inode, name, value, size, flags); -# elif defined(HAVE_XATTR_HANDLER_SIMPLIFIED) - rc = handler->set(handler, dentry, name, value, size, flags); -# else - rc = handler->set(dentry, name, value, size, flags, handler->flags); -# endif /* !HAVE_XATTR_HANDLER_INODE_PARAM */ - return rc; -# else /* !HAVE_XATTR_HANDLER_FLAGS */ - return ll_setxattr(dentry, name, value, size, flags); -# endif /* HAVE_XATTR_HANDLER_FLAGS */ -} -#endif /* HAVE_VFS_SETXATTR */ #ifdef HAVE_IOP_SET_ACL #ifdef CONFIG_FS_POSIX_ACL @@ -825,4 +797,45 @@ static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw) #define selinux_is_enabled() 1 #endif +static inline int ll_vfs_getxattr(struct dentry *dentry, struct inode *inode, + const char *name, + void *value, size_t size) +{ +#ifndef HAVE_VFS_SETXATTR + if (!inode->i_op->getxattr) + return -ENODATA; + + return inode->i_op->getxattr(dentry, name, value, size); +#else + return __vfs_getxattr(dentry, inode, name, value, size); +#endif +} + +static inline int ll_vfs_setxattr(struct dentry *dentry, struct inode *inode, + const char *name, + const void *value, size_t size, int flags) +{ +#ifndef HAVE_VFS_SETXATTR + if (!inode->i_op->setxattr) + return -ENOTSUPP; + + return inode->i_op->setxattr(dentry, name, value, size, flags); +#else + return __vfs_setxattr(dentry, inode, name, value, size, flags); +#endif +} + +static inline int ll_vfs_removexattr(struct dentry *dentry, struct inode *inode, + const char *name) +{ +#ifndef HAVE_VFS_SETXATTR + if (!inode->i_op->setxattr) + return -ENOTSUPP; + + return inode->i_op->removexattr(dentry, name); +#else + return __vfs_removexattr(dentry, name); +#endif +} + #endif /* _LUSTRE_COMPAT_H */ diff --git a/lustre/llite/xattr_security.c b/lustre/llite/xattr_security.c index 094266223b3b..83dccf8a52e3 100644 --- a/lustre/llite/xattr_security.c +++ b/lustre/llite/xattr_security.c @@ -124,8 +124,8 @@ ll_initxattrs(struct inode *inode, const struct xattr *xattr_array, break; } - err = __vfs_setxattr(dentry, inode, full_name, xattr->value, - xattr->value_len, XATTR_CREATE); + err = ll_vfs_setxattr(dentry, inode, full_name, xattr->value, + xattr->value_len, XATTR_CREATE); kfree(full_name); if (err < 0) break; diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index f8d9beaa81cb..a37b29e79b2b 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -4549,7 +4549,7 @@ static int osd_xattr_set_pfid(const struct lu_env *env, struct osd_object *obj, /* Remove old PFID EA entry firstly. */ ll_vfs_dq_init(inode); - rc = osd_removexattr(dentry, inode, XATTR_NAME_FID); + rc = ll_vfs_removexattr(dentry, inode, XATTR_NAME_FID); if (rc == -ENODATA) { if ((fl & LU_XATTR_REPLACE) && !(fl & LU_XATTR_CREATE)) RETURN(rc); @@ -4855,7 +4855,7 @@ static int osd_xattr_del(const struct lu_env *env, struct dt_object *dt, ll_vfs_dq_init(inode); dentry->d_inode = inode; dentry->d_sb = inode->i_sb; - rc = osd_removexattr(dentry, inode, name); + rc = ll_vfs_removexattr(dentry, inode, name); } osd_trans_exec_check(env, handle, OSD_OT_XATTR_SET); diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index ed368631a56b..899ba4123ff3 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -679,22 +679,6 @@ struct osd_thread_info { extern int ldiskfs_pdo; -#ifndef HAVE_VFS_SETXATTR -#define osd_setxattr(dentry, inode, name, buf, len, flag) \ - ((inode)->i_op->setxattr(dentry, name, buf, len, flag)) -#define osd_getxattr(dentry, inode, name, buf, len) \ - ((inode)->i_op->getxattr(dentry, name, buf, len)) -#define osd_removexattr(dentry, inode, name) \ - ((inode)->i_op->removexattr(dentry, name)) -#else /* HAVE_VFS_SETXATTR */ -#define osd_setxattr(dentry, inode, name, buf, len, flag) \ - __vfs_setxattr(dentry, inode, name, buf, len, flag) -#define osd_getxattr(dentry, inode, name, buf, len) \ - __vfs_getxattr(dentry, inode, name, buf, len) -#define osd_removexattr(dentry, inode, name) \ - __vfs_removexattr(dentry, name) -#endif /* !HAVE_VFS_SETXATTR */ - static inline int __osd_xattr_get(struct inode *inode, struct dentry *dentry, const char *name, void *buf, int len) { @@ -703,7 +687,7 @@ static inline int __osd_xattr_get(struct inode *inode, struct dentry *dentry, dentry->d_inode = inode; dentry->d_sb = inode->i_sb; - return osd_getxattr(dentry, inode, name, buf, len); + return ll_vfs_getxattr(dentry, inode, name, buf, len); } static inline int __osd_xattr_set(struct osd_thread_info *info, @@ -715,7 +699,7 @@ static inline int __osd_xattr_set(struct osd_thread_info *info, ll_vfs_dq_init(inode); dentry->d_inode = inode; dentry->d_sb = inode->i_sb; - return osd_setxattr(dentry, inode, name, buf, buflen, fl); + return ll_vfs_setxattr(dentry, inode, name, buf, buflen, fl); } #ifdef CONFIG_PROC_FS diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index c5bc79790e24..9e193ee79853 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -208,7 +208,7 @@ osd_scrub_convert_ff(struct osd_thread_info *info, struct osd_device *dev, if (rc == sizeof(*ff)) { /* 2) delete the old XATTR_NAME_FID */ ll_vfs_dq_init(inode); - rc = osd_removexattr(dentry, inode, XATTR_NAME_FID); + rc = ll_vfs_removexattr(dentry, inode, XATTR_NAME_FID); if (rc) GOTO(stop, rc); -- 2.41.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor