]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/f2fs/namei.c
ocfs2: return non-zero st_blocks for inline data
[karo-tx-linux.git] / fs / f2fs / namei.c
index 6c4a94310b541c89081f227faa7d9706251499c7..6f944e5eb76eb71ab89d56e1cab7c6526ea443a5 100644 (file)
@@ -140,7 +140,7 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        inode->i_mapping->a_ops = &f2fs_dblock_aops;
        ino = inode->i_ino;
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
        err = f2fs_add_link(dentry, inode);
@@ -172,7 +172,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
                !f2fs_is_child_context_consistent_with_parent(dir, inode))
                return -EPERM;
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        inode->i_ctime = CURRENT_TIME;
        ihold(inode);
@@ -214,7 +214,14 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino)
        struct page *page;
        int err = 0;
 
-       f2fs_balance_fs(sbi);
+       if (f2fs_readonly(sbi->sb)) {
+               f2fs_msg(sbi->sb, KERN_INFO,
+                       "skip recovering inline_dots inode (ino:%lu, pino:%u) "
+                       "in readonly mountpoint", dir->i_ino, pino);
+               return 0;
+       }
+
+       f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
 
@@ -295,7 +302,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
        if (!de)
                goto fail;
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
        err = acquire_orphan_inode(sbi);
@@ -318,12 +325,15 @@ fail:
        return err;
 }
 
-static const char *f2fs_follow_link(struct dentry *dentry, void **cookie)
+static const char *f2fs_get_link(struct dentry *dentry,
+                                struct inode *inode,
+                                struct delayed_call *done)
 {
-       const char *link = page_follow_link_light(dentry, cookie);
+       const char *link = page_get_link(dentry, inode, done);
        if (!IS_ERR(link) && !*link) {
                /* this is broken symlink case */
-               page_put_link(NULL, *cookie);
+               do_delayed_call(done);
+               clear_delayed_call(done);
                link = ERR_PTR(-ENOENT);
        }
        return link;
@@ -352,9 +362,10 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
                inode->i_op = &f2fs_encrypted_symlink_inode_operations;
        else
                inode->i_op = &f2fs_symlink_inode_operations;
+       inode_nohighmem(inode);
        inode->i_mapping->a_ops = &f2fs_dblock_aops;
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
        err = f2fs_add_link(dentry, inode);
@@ -445,7 +456,7 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
        inode->i_mapping->a_ops = &f2fs_dblock_aops;
        mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_HIGH_ZERO);
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        set_inode_flag(F2FS_I(inode), FI_INC_LINK);
        f2fs_lock_op(sbi);
@@ -491,7 +502,7 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
        init_special_inode(inode, inode->i_mode, rdev);
        inode->i_op = &f2fs_special_inode_operations;
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
        err = f2fs_add_link(dentry, inode);
@@ -532,7 +543,7 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
                inode->i_mapping->a_ops = &f2fs_dblock_aops;
        }
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
        err = acquire_orphan_inode(sbi);
@@ -635,7 +646,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                if (!new_entry)
                        goto out_whiteout;
 
-               f2fs_balance_fs(sbi);
+               f2fs_balance_fs(sbi, true);
 
                f2fs_lock_op(sbi);
 
@@ -668,7 +679,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                update_inode_page(old_inode);
                update_inode_page(new_inode);
        } else {
-               f2fs_balance_fs(sbi);
+               f2fs_balance_fs(sbi, true);
 
                f2fs_lock_op(sbi);
 
@@ -809,7 +820,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
                        goto out_new_dir;
        }
 
-       f2fs_balance_fs(sbi);
+       f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
 
@@ -927,18 +938,22 @@ static int f2fs_rename2(struct inode *old_dir, struct dentry *old_dentry,
 }
 
 #ifdef CONFIG_F2FS_FS_ENCRYPTION
-static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cookie)
+static const char *f2fs_encrypted_get_link(struct dentry *dentry,
+                                          struct inode *inode,
+                                          struct delayed_call *done)
 {
        struct page *cpage = NULL;
        char *caddr, *paddr = NULL;
        struct f2fs_str cstr = FSTR_INIT(NULL, 0);
        struct f2fs_str pstr = FSTR_INIT(NULL, 0);
-       struct inode *inode = d_inode(dentry);
        struct f2fs_encrypted_symlink_data *sd;
        loff_t size = min_t(loff_t, i_size_read(inode), PAGE_SIZE - 1);
        u32 max_size = inode->i_sb->s_blocksize;
        int res;
 
+       if (!dentry)
+               return ERR_PTR(-ECHILD);
+
        res = f2fs_get_encryption_info(inode);
        if (res)
                return ERR_PTR(res);
@@ -946,7 +961,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook
        cpage = read_mapping_page(inode->i_mapping, 0, NULL);
        if (IS_ERR(cpage))
                return ERR_CAST(cpage);
-       caddr = kmap(cpage);
+       caddr = page_address(cpage);
        caddr[size] = 0;
 
        /* Symlink is encrypted */
@@ -992,27 +1007,27 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook
        /* Null-terminate the name */
        paddr[res] = '\0';
 
-       kunmap(cpage);
        page_cache_release(cpage);
-       return *cookie = paddr;
+       set_delayed_call(done, kfree_link, paddr);
+       return paddr;
 errout:
        kfree(cstr.name);
        f2fs_fname_crypto_free_buffer(&pstr);
-       kunmap(cpage);
        page_cache_release(cpage);
        return ERR_PTR(res);
 }
 
 const struct inode_operations f2fs_encrypted_symlink_inode_operations = {
        .readlink       = generic_readlink,
-       .follow_link    = f2fs_encrypted_follow_link,
-       .put_link       = kfree_put_link,
+       .get_link       = f2fs_encrypted_get_link,
        .getattr        = f2fs_getattr,
        .setattr        = f2fs_setattr,
+#ifdef CONFIG_F2FS_FS_XATTR
        .setxattr       = generic_setxattr,
        .getxattr       = generic_getxattr,
        .listxattr      = f2fs_listxattr,
        .removexattr    = generic_removexattr,
+#endif
 };
 #endif
 
@@ -1041,8 +1056,7 @@ const struct inode_operations f2fs_dir_inode_operations = {
 
 const struct inode_operations f2fs_symlink_inode_operations = {
        .readlink       = generic_readlink,
-       .follow_link    = f2fs_follow_link,
-       .put_link       = page_put_link,
+       .get_link       = f2fs_get_link,
        .getattr        = f2fs_getattr,
        .setattr        = f2fs_setattr,
 #ifdef CONFIG_F2FS_FS_XATTR