]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/f2fs/xattr.c
f2fs: use inode pointer for {set, clear}_inode_flag
[mirror_ubuntu-jammy-kernel.git] / fs / f2fs / xattr.c
index 17fd2b1a6848138bb8d284f56c0ef8f78d39719c..ca12d4b051f7043dfa47fb1a3266393215cdbe3c 100644 (file)
@@ -50,10 +50,11 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
 }
 
 static int f2fs_xattr_generic_set(const struct xattr_handler *handler,
-               struct dentry *dentry, const char *name, const void *value,
+               struct dentry *unused, struct inode *inode,
+               const char *name, const void *value,
                size_t size, int flags)
 {
-       struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
+       struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
 
        switch (handler->flags) {
        case F2FS_XATTR_INDEX_USER:
@@ -69,7 +70,7 @@ static int f2fs_xattr_generic_set(const struct xattr_handler *handler,
        default:
                return -EINVAL;
        }
-       return f2fs_setxattr(d_inode(dentry), handler->flags, name,
+       return f2fs_setxattr(inode, handler->flags, name,
                                        value, size, NULL, flags);
 }
 
@@ -95,11 +96,10 @@ static int f2fs_xattr_advise_get(const struct xattr_handler *handler,
 }
 
 static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
-               struct dentry *dentry, const char *name, const void *value,
+               struct dentry *unused, struct inode *inode,
+               const char *name, const void *value,
                size_t size, int flags)
 {
-       struct inode *inode = d_inode(dentry);
-
        if (!inode_owner_or_capable(inode))
                return -EPERM;
        if (value == NULL)
@@ -441,7 +441,6 @@ static int __f2fs_setxattr(struct inode *inode, int index,
                        const char *name, const void *value, size_t size,
                        struct page *ipage, int flags)
 {
-       struct f2fs_inode_info *fi = F2FS_I(inode);
        struct f2fs_xattr_entry *here, *last;
        void *base_addr;
        int found, newsize;
@@ -498,7 +497,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
                        free = free + ENTRY_SIZE(here);
 
                if (unlikely(free < newsize)) {
-                       error = -ENOSPC;
+                       error = -E2BIG;
                        goto exit;
                }
        }
@@ -526,7 +525,6 @@ static int __f2fs_setxattr(struct inode *inode, int index,
                 * Before we come here, old entry is removed.
                 * We just write new entry.
                 */
-               memset(last, 0, newsize);
                last->e_name_index = index;
                last->e_name_len = len;
                memcpy(last->e_name, name, len);
@@ -540,10 +538,10 @@ static int __f2fs_setxattr(struct inode *inode, int index,
        if (error)
                goto exit;
 
-       if (is_inode_flag_set(fi, FI_ACL_MODE)) {
-               inode->i_mode = fi->i_acl_mode;
+       if (is_inode_flag_set(inode, FI_ACL_MODE)) {
+               inode->i_mode = F2FS_I(inode)->i_acl_mode;
                inode->i_ctime = CURRENT_TIME;
-               clear_inode_flag(fi, FI_ACL_MODE);
+               clear_inode_flag(inode, FI_ACL_MODE);
        }
        if (index == F2FS_XATTR_INDEX_ENCRYPTION &&
                        !strcmp(name, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT))