Merge branch 'xarray' of git://git.infradead.org/users/willy/linux-dax
[platform/kernel/linux-starfive.git] / fs / f2fs / dir.c
index 0100608..bacc667 100644 (file)
@@ -1,12 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * fs/f2fs/dir.c
  *
  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
  *             http://www.samsung.com/
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
  */
 #include <linux/fs.h>
 #include <linux/f2fs_fs.h>
@@ -658,9 +655,9 @@ int f2fs_do_tmpfile(struct inode *inode, struct inode *dir)
        f2fs_put_page(page, 1);
 
        clear_inode_flag(inode, FI_NEW_INODE);
+       f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
 fail:
        up_write(&F2FS_I(inode)->i_sem);
-       f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
        return err;
 }
 
@@ -733,6 +730,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
                clear_page_dirty_for_io(page);
                ClearPagePrivate(page);
                ClearPageUptodate(page);
+               clear_cold_data(page);
                inode_dec_dirty_pages(dir);
                f2fs_remove_dirty_inode(dir);
        }
@@ -784,9 +782,15 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
        struct f2fs_dir_entry *de = NULL;
        struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
        struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
+       struct blk_plug plug;
+       bool readdir_ra = sbi->readdir_ra == 1;
+       int err = 0;
 
        bit_pos = ((unsigned long)ctx->pos % d->max);
 
+       if (readdir_ra)
+               blk_start_plug(&plug);
+
        while (bit_pos < d->max) {
                bit_pos = find_next_bit_le(d->bitmap, d->max, bit_pos);
                if (bit_pos >= d->max)
@@ -806,29 +810,33 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
 
                if (f2fs_encrypted_inode(d->inode)) {
                        int save_len = fstr->len;
-                       int err;
 
                        err = fscrypt_fname_disk_to_usr(d->inode,
                                                (u32)de->hash_code, 0,
                                                &de_name, fstr);
                        if (err)
-                               return err;
+                               goto out;
 
                        de_name = *fstr;
                        fstr->len = save_len;
                }
 
                if (!dir_emit(ctx, de_name.name, de_name.len,
-                                       le32_to_cpu(de->ino), d_type))
-                       return 1;
+                                       le32_to_cpu(de->ino), d_type)) {
+                       err = 1;
+                       goto out;
+               }
 
-               if (sbi->readdir_ra == 1)
+               if (readdir_ra)
                        f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
 
                bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
                ctx->pos = start_pos + bit_pos;
        }
-       return 0;
+out:
+       if (readdir_ra)
+               blk_finish_plug(&plug);
+       return err;
 }
 
 static int f2fs_readdir(struct file *file, struct dir_context *ctx)