Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-4.19.y' into android-4.19-stable
This series addressed merge conflicts based on pa/c/1664425/15, mainly integrated with a patch "f2fs: Handle casefolding with Encryption" for casefolding support in ACK only. * aosp/upstream-f2fs-stable-linux-4.19.y: f2fs: flush dirty meta pages when flushing them f2fs: fix checkpoint=disable:%u%% f2fs: rework filename handling f2fs: split f2fs_d_compare() from f2fs_match_name() f2fs: don't leak filename in f2fs_try_convert_inline_dir() f2fs: fix missing check for f2fs_unlock_op Conflicts: fs/f2fs/dir.c fs/f2fs/f2fs.h fs/f2fs/hash.c fs/f2fs/inline.c fs/f2fs/namei.c Change-Id: Ib5ceb0f2f076d6c215d4c0c6262f3c1d41cde7c8 Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
|
||||
* http://www.samsung.com/
|
||||
*/
|
||||
#include <asm/unaligned.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/f2fs_fs.h>
|
||||
#include "f2fs.h"
|
||||
@@ -107,13 +108,60 @@ static void del_fsync_inode(struct fsync_inode_entry *entry, int drop)
|
||||
kmem_cache_free(fsync_entry_slab, entry);
|
||||
}
|
||||
|
||||
static int init_recovered_filename(const struct inode *dir,
|
||||
struct f2fs_inode *raw_inode,
|
||||
struct f2fs_filename *fname,
|
||||
struct qstr *usr_fname)
|
||||
{
|
||||
int err;
|
||||
|
||||
memset(fname, 0, sizeof(*fname));
|
||||
fname->disk_name.len = le32_to_cpu(raw_inode->i_namelen);
|
||||
fname->disk_name.name = raw_inode->i_name;
|
||||
|
||||
if (WARN_ON(fname->disk_name.len > F2FS_NAME_LEN))
|
||||
return -ENAMETOOLONG;
|
||||
|
||||
if (!IS_ENCRYPTED(dir)) {
|
||||
usr_fname->name = fname->disk_name.name;
|
||||
usr_fname->len = fname->disk_name.len;
|
||||
fname->usr_fname = usr_fname;
|
||||
}
|
||||
|
||||
/* Compute the hash of the filename */
|
||||
if (IS_ENCRYPTED(dir) && IS_CASEFOLDED(dir)) {
|
||||
/*
|
||||
* In this case the hash isn't computable without the key, so it
|
||||
* was saved on-disk.
|
||||
*/
|
||||
if (fname->disk_name.len + sizeof(f2fs_hash_t) > F2FS_NAME_LEN)
|
||||
return -EINVAL;
|
||||
fname->hash = get_unaligned((f2fs_hash_t *)
|
||||
&raw_inode->i_name[fname->disk_name.len]);
|
||||
} else if (IS_CASEFOLDED(dir)) {
|
||||
err = f2fs_init_casefolded_name(dir, fname);
|
||||
if (err)
|
||||
return err;
|
||||
f2fs_hash_filename(dir, fname);
|
||||
#ifdef CONFIG_UNICODE
|
||||
/* Case-sensitive match is fine for recovery */
|
||||
kfree(fname->cf_name.name);
|
||||
fname->cf_name.name = NULL;
|
||||
#endif
|
||||
} else {
|
||||
f2fs_hash_filename(dir, fname);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int recover_dentry(struct inode *inode, struct page *ipage,
|
||||
struct list_head *dir_list)
|
||||
{
|
||||
struct f2fs_inode *raw_inode = F2FS_INODE(ipage);
|
||||
nid_t pino = le32_to_cpu(raw_inode->i_pino);
|
||||
struct f2fs_dir_entry *de;
|
||||
struct fscrypt_name fname;
|
||||
struct f2fs_filename fname;
|
||||
struct qstr usr_fname;
|
||||
struct page *page;
|
||||
struct inode *dir, *einode;
|
||||
struct fsync_inode_entry *entry;
|
||||
@@ -132,16 +180,9 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
|
||||
}
|
||||
|
||||
dir = entry->inode;
|
||||
|
||||
memset(&fname, 0, sizeof(struct fscrypt_name));
|
||||
fname.disk_name.len = le32_to_cpu(raw_inode->i_namelen);
|
||||
fname.disk_name.name = raw_inode->i_name;
|
||||
|
||||
if (unlikely(fname.disk_name.len > F2FS_NAME_LEN)) {
|
||||
WARN_ON(1);
|
||||
err = -ENAMETOOLONG;
|
||||
err = init_recovered_filename(dir, raw_inode, &fname, &usr_fname);
|
||||
if (err)
|
||||
goto out;
|
||||
}
|
||||
retry:
|
||||
de = __f2fs_find_entry(dir, &fname, &page);
|
||||
if (de && inode->i_ino == le32_to_cpu(de->ino))
|
||||
|
||||
Reference in New Issue
Block a user