diff options
| author | Chao Yu <yuchao0@huawei.com> | 2016-10-29 18:46:34 +0800 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-13 12:34:22 +0200 |
| commit | 998151782c3f7e9f09e5b5a4fcb3bd3bb4cb2464 (patch) | |
| tree | 68461312a0667b89f2b6e373801971831122f8b0 | |
| parent | b3244e069470597a99be362af7e8b91f8ada4938 (diff) | |
f2fs: report error of f2fs_fill_dentries
Report error of f2fs_fill_dentries to ->iterate_shared, otherwise when
error ocurrs, user may just list part of dirents in target directory
without any hints.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Conflicts:
fs/f2fs/dir.c
fs/f2fs/f2fs.h
fs/f2fs/inline.c
| -rw-r--r-- | fs/f2fs/dir.c | 22 | ||||
| -rw-r--r-- | fs/f2fs/f2fs.h | 2 | ||||
| -rw-r--r-- | fs/f2fs/inline.c | 6 |
3 files changed, 17 insertions, 13 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 8e2fa018c..ee6c99794 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -786,7 +786,7 @@ bool f2fs_empty_dir(struct inode *dir) return true; } -bool f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir, +int f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir, struct f2fs_dentry_ptr *d, unsigned int n, unsigned int bit_pos, struct fscrypt_str *fstr) { @@ -822,7 +822,7 @@ bool f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir, (u32)de->hash_code, 0, &de_name, fstr); if (err) - return true; + return err; de_name = *fstr; fstr->len = save_len; @@ -833,12 +833,12 @@ bool f2fs_fill_dentries(struct file *file, void *dirent, filldir_t filldir, le32_to_cpu(de->ino), d_type); if (over) { file->f_pos += bit_pos - start_bit_pos; - return true; + return 1; } bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); } - return false; + return 0; } static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir) @@ -882,18 +882,21 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir) dentry_page = get_lock_data_page(inode, n, false); if (IS_ERR(dentry_page)) { err = PTR_ERR(dentry_page); - if (err == -ENOENT) + if (err == -ENOENT) { + err = 0; continue; - else + } else { goto out; + } } dentry_blk = kmap(dentry_page); make_dentry_ptr(inode, &d, (void *)dentry_blk, 1); - if (f2fs_fill_dentries(file, dirent, filldir, &d, n, - bit_pos, &fstr)) { + err = f2fs_fill_dentries(file, dirent, filldir, &d, n, + bit_pos, &fstr); + if (err) { kunmap(dentry_page); f2fs_put_page(dentry_page, 1); break; @@ -904,10 +907,9 @@ static int f2fs_readdir(struct file *file, void *dirent, filldir_t filldir) kunmap(dentry_page); f2fs_put_page(dentry_page, 1); } - err = 0; out: fscrypt_fname_free_buffer(&fstr); - return err; + return err < 0 ? err : 0; } static int f2fs_dir_open(struct inode *inode, struct file *filp) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 32df7b1f7..8005d0f23 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2036,7 +2036,7 @@ void set_de_type(struct f2fs_dir_entry *, umode_t); unsigned char get_de_type(struct f2fs_dir_entry *); struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *, f2fs_hash_t, int *, struct f2fs_dentry_ptr *); -bool f2fs_fill_dentries(struct file *, void *, filldir_t, +int f2fs_fill_dentries(struct file *, void *, filldir_t, struct f2fs_dentry_ptr *, unsigned int, unsigned int, struct fscrypt_str *); void do_make_empty_dir(struct inode *, struct inode *, diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index ab88e96e0..f42bfcb50 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -613,6 +613,7 @@ int f2fs_read_inline_dir(struct file *file, void *dirent, filldir_t filldir, struct f2fs_inline_dentry *inline_dentry = NULL; struct page *ipage = NULL; struct f2fs_dentry_ptr d; + int err; if (pos >= NR_INLINE_DENTRY) return 0; @@ -627,11 +628,12 @@ int f2fs_read_inline_dir(struct file *file, void *dirent, filldir_t filldir, make_dentry_ptr(inode, &d, (void *)inline_dentry, 2); - if (!f2fs_fill_dentries(file, dirent, filldir, &d, 0, bit_pos, fstr)) + err = f2fs_fill_dentries(file, dirent, filldir, &d, 0, bit_pos, fstr); + if (!err) file->f_pos = NR_INLINE_DENTRY; f2fs_put_page(ipage, 1); - return 0; + return err < 0 ? err : 0; } int f2fs_inline_data_fiemap(struct inode *inode, |
