Merge git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile
[deliverable/linux.git] / fs / f2fs / xattr.c
index 06a72dc0191a022049bbf48ad26e127bb6211c02..c8898b5148eb62134db2467d579d5401f8efdcfd 100644 (file)
 #include "xattr.h"
 
 static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
-               struct dentry *dentry, const char *name, void *buffer,
-               size_t size)
+               struct dentry *unused, struct inode *inode,
+               const char *name, void *buffer, size_t size)
 {
-       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:
@@ -45,15 +45,16 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
        default:
                return -EINVAL;
        }
-       return f2fs_getxattr(d_inode(dentry), handler->flags, name,
+       return f2fs_getxattr(inode, handler->flags, name,
                             buffer, size, NULL);
 }
 
 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);
 }
 
@@ -86,29 +87,26 @@ static bool f2fs_xattr_trusted_list(struct dentry *dentry)
 }
 
 static int f2fs_xattr_advise_get(const struct xattr_handler *handler,
-               struct dentry *dentry, const char *name, void *buffer,
-               size_t size)
+               struct dentry *unused, struct inode *inode,
+               const char *name, void *buffer, size_t size)
 {
-       struct inode *inode = d_inode(dentry);
-
        if (buffer)
                *((char *)buffer) = F2FS_I(inode)->i_advise;
        return sizeof(char);
 }
 
 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)
                return -EINVAL;
 
        F2FS_I(inode)->i_advise |= *(char *)value;
-       mark_inode_dirty(inode);
+       f2fs_mark_inode_dirty_sync(inode);
        return 0;
 }
 
@@ -301,6 +299,7 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
                if (ipage) {
                        inline_addr = inline_xattr_addr(ipage);
                        f2fs_wait_on_page_writeback(ipage, NODE, true);
+                       set_page_dirty(ipage);
                } else {
                        page = get_node_page(sbi, inode->i_ino);
                        if (IS_ERR(page)) {
@@ -443,13 +442,12 @@ 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;
        size_t len;
        __u32 new_hsize;
-       int error = -ENOMEM;
+       int error = 0;
 
        if (name == NULL)
                return -EINVAL;
@@ -467,7 +465,7 @@ static int __f2fs_setxattr(struct inode *inode, int index,
 
        base_addr = read_all_xattrs(inode, ipage);
        if (!base_addr)
-               goto exit;
+               return -ENOMEM;
 
        /* find entry with wanted name. */
        here = __find_xattr(base_addr, index, len, name);
@@ -500,7 +498,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;
                }
        }
@@ -528,7 +526,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);
@@ -542,19 +539,15 @@ 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))
                f2fs_set_encrypted_inode(inode);
-
-       if (ipage)
-               update_inode(inode, ipage);
-       else
-               update_inode_page(inode);
+       f2fs_mark_inode_dirty_sync(inode);
 exit:
        kzfree(base_addr);
        return error;
This page took 0.058478 seconds and 5 git commands to generate.